Guest_imported
New member
- Jan 1, 1970
- 0
This CGI previews changes from another edit page and is suppose to write an identical text file. The CGI previews fine, but is pretty useless without writing to the text file.
What is the correct way to do this?
Thanks for any help.
Tim
------------------------------------------------------------
#!/usr/local/bin/perl
require ('cgi-lib.pl');
$| = 1;
# Print HTML compliant header
print "Content-type: text/html \n\n";
print <<End_of_Intro;
<HTML>
<HEAD><TITLE>St Martins Staff</TITLE>
<BODY BGcolor="#FFFFFF">
<!--#exec cgi="/cgi-local/axis/ax.pl" -->
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="60">
<tr>
<td width="100%" align="center" height="60"><img border="0" src="../../gifs/smdir.gif" width="315" height="31">
<p><font size="1"><a href=" face="Trajan">HOME</font></a><font face="Trajan,Arial,Helvetica,Geneva"> |
<a href=" | <a href=" | <a href=" | <a href=" | <a href="| <a href="
</td>
</tr>
</table>
<hr>
<p align="center">
<br>
</p>
<CENTER>
<table border='0' align='center' width='645'>
<tr>
<td width="375">
<table width="628" height="599">
<tr align="left" vAlign="top">
<td height="1" width="796"><hr size="1">
End_of_Intro
$db ="staff.dbf";
# Open Database file and read all the staff
open (FILE, "<" . $db) || die "Cannot read votes database (staff.dbf)";
flock (FILE, 2);
for ($loop = 0; $loop <15; $loop++) {
$line[$loop] = <FILE>;
$line[$loop] =~ s/\n$//;
@data = split ("::", $line[$loop]);
$KEY[$loop] = $data[0];
$NAME[$loop] = $data[1];
$PAGER[$loop] = $data[2];
$POSITION[$loop] = $data[3];
$EMAIL[$loop] = $data[4];
$TELEPHONE [$loop] = $data[5];
}
flock (FILE, 8 );
close (FILE);
# Sort all the lines in the database by vote
@sortline = @line;
foreach (@sortline) {
push (@datakeys, (split(/::/))[6]);
}
sub bydatakeys { $datakeys[$b] <=> $datakeys[$a]; }
@sortdata = @sortline[sort bydatakeys $[..$#sortline];
# Present new table showing staff
print <<End_of_Table;
End_of_Table
$level = 0;
foreach (@sortdata) {
$level ++;
@data = split ("::", $_);
$KEY = $data[0];
$NAME = $data[1];
$PAGER = $data[2];
$POSITION = $data[3];
$EMAIL = $data[4];
if ($EMAIL eq ""
{
$AHREF = "$NAME";
}else{
$AHREF = "<a href=\"mailto:$EMAIL\">$NAME</a>";
}
$TELEPHONE = $data[5];
print <<End_of_stuff;
<table border="0" width="100%" bordercolor="#FFFFFF" cellspacing="0" cellpadding="0" height="20">
<tr>
<td width="38%" height="20">
<font color="#800080" face="Arial">$POSITION</font></td>
<td width="62%" height="20">
<font face="Helvetica,Arial" size="-1"> $AHREF </font></td>
</tr>
<tr>
<td width="38%" height="22"><b><font face="Helvetica,Arial" size="-1">$TELEPHONE</font></b></td>
<td width="62%" height="22">$PAGER </td>
</tr>
</table>
<hr size="1">
</td>
</tr>
<tr>
<td height="20" width="796">
End_of_stuff
}
print " </table></table></CENTER><br></body></html> \n";
exit(0);
What is the correct way to do this?
Thanks for any help.
Tim
------------------------------------------------------------
#!/usr/local/bin/perl
require ('cgi-lib.pl');
$| = 1;
# Print HTML compliant header
print "Content-type: text/html \n\n";
print <<End_of_Intro;
<HTML>
<HEAD><TITLE>St Martins Staff</TITLE>
<BODY BGcolor="#FFFFFF">
<!--#exec cgi="/cgi-local/axis/ax.pl" -->
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="60">
<tr>
<td width="100%" align="center" height="60"><img border="0" src="../../gifs/smdir.gif" width="315" height="31">
<p><font size="1"><a href=" face="Trajan">HOME</font></a><font face="Trajan,Arial,Helvetica,Geneva"> |
<a href=" | <a href=" | <a href=" | <a href=" | <a href="| <a href="
</td>
</tr>
</table>
<hr>
<p align="center">
<br>
</p>
<CENTER>
<table border='0' align='center' width='645'>
<tr>
<td width="375">
<table width="628" height="599">
<tr align="left" vAlign="top">
<td height="1" width="796"><hr size="1">
End_of_Intro
$db ="staff.dbf";
# Open Database file and read all the staff
open (FILE, "<" . $db) || die "Cannot read votes database (staff.dbf)";
flock (FILE, 2);
for ($loop = 0; $loop <15; $loop++) {
$line[$loop] = <FILE>;
$line[$loop] =~ s/\n$//;
@data = split ("::", $line[$loop]);
$KEY[$loop] = $data[0];
$NAME[$loop] = $data[1];
$PAGER[$loop] = $data[2];
$POSITION[$loop] = $data[3];
$EMAIL[$loop] = $data[4];
$TELEPHONE [$loop] = $data[5];
}
flock (FILE, 8 );
close (FILE);
# Sort all the lines in the database by vote
@sortline = @line;
foreach (@sortline) {
push (@datakeys, (split(/::/))[6]);
}
sub bydatakeys { $datakeys[$b] <=> $datakeys[$a]; }
@sortdata = @sortline[sort bydatakeys $[..$#sortline];
# Present new table showing staff
print <<End_of_Table;
End_of_Table
$level = 0;
foreach (@sortdata) {
$level ++;
@data = split ("::", $_);
$KEY = $data[0];
$NAME = $data[1];
$PAGER = $data[2];
$POSITION = $data[3];
$EMAIL = $data[4];
if ($EMAIL eq ""
$AHREF = "$NAME";
}else{
$AHREF = "<a href=\"mailto:$EMAIL\">$NAME</a>";
}
$TELEPHONE = $data[5];
print <<End_of_stuff;
<table border="0" width="100%" bordercolor="#FFFFFF" cellspacing="0" cellpadding="0" height="20">
<tr>
<td width="38%" height="20">
<font color="#800080" face="Arial">$POSITION</font></td>
<td width="62%" height="20">
<font face="Helvetica,Arial" size="-1"> $AHREF </font></td>
</tr>
<tr>
<td width="38%" height="22"><b><font face="Helvetica,Arial" size="-1">$TELEPHONE</font></b></td>
<td width="62%" height="22">$PAGER </td>
</tr>
</table>
<hr size="1">
</td>
</tr>
<tr>
<td height="20" width="796">
End_of_stuff
}
print " </table></table></CENTER><br></body></html> \n";
exit(0);