For some reason, .txt files are no longer displayed just as text, but are parsed. I'll try posting the changes here.
Delete the changes you made.
Code:
html.pl
sub html_footer
after
print qq!| <A HREF="$db_script_link_url&admin_display=1">Admin</A> ! if ($per_admin);
add
print qq!| <A HREF="$db_script_link_url&transform=1">Process file</A> ! if ($per_admin);
Code:
html.pl
new subroutine
add it anywhere, as long as it's not within another subroutine
sub &html_transform_success {
# --------------------------------------------------------
# This page let's the user know that the records were successfully
# transformed.
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Record(s) Transformed.</title>
</head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Record(s) Transformed.</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Record(s) Transformed
</b></font></center><br>
<$font>
The records were successfully transformed.
</font></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}
Code:
db.cgi
sub main
after
elsif ($in{'modify_record'}) { if ($per_mod) { &modify_record; } else { &html_unauth; } }
add
elsif ($in{'transform'}) { if ($per_admin) { &transform_records; } else { &html_unauth; } }
Code:
db.cgi
new subroutine
add it anywhere, as long as it's not within another subroutine
sub transform_records {
# --------------------------------------------------------
# This routine does the actual modification of a record. It expects
# to find in %in a record that is already in the database, and will
# rewrite the database with the new entry. First it checks to make
# sure that the modified record is ok with validate record.
# It then goes through the database looking for the right record to
# modify, if found, it prints out the modified record, and returns
# the user to a success page. Otherwise the user is returned to an error
# page with a reason why.
my ($status, $line, @lines, @data, $output, $found, $restricted);
open (DB, "<$db_file_name") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; } # Skip and Remove blank lines
if ($line =~ /^#/) { $output .= $line; next LINE; } # Comment Line
chomp ($line);
@data = &split_decode($line);
$data[0] = $data[2] + $data[3];
$in{$db_cols[0]} = $data[0];
$in{$db_cols[1]} = $data[1];
$in{$db_cols[2]} = $data[2];
$in{$db_cols[3]} = $data[3];
$output .= &join_encode(%in);;
}
open (DB, ">$db_file_name") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
&auth_logging("modified record: $in{$db_key}") if ($auth_logging);
&html_transform_success;
}
}
JPD
----------------------------------------------------
JPDeni's DBMan-ual How to
ask questions the smart way.