#!/usr/bin/perl
use CGI;
$query = new CGI;
$act = $query->param('act');
$student = $query->param('student');
if ( $act eq "List courses" ) {
# Print HTML.
print ( "Content-type: text/html\n\n" );
# Use "here-doc" syntax.
print <<EndofHTML;
<html>
<body>
<table width="100%" height="80%">
<tr>
<td align="center">
<font size="+1"><b>
EndofHTML
# Remove leading and trailing spacing.
$student =~ s/^\s*(\S*)\s*$/$1/;
# For security, remove some Unix metacharacters.
$student =~ s/;|>|>>|<|\*|\?|\&|\|//g;
# Compose a Java command.
$cmd = "/usr/bin/java -Djava.security.egd=file:/dev/./urandom ListCourses ";
if ( ( $query->param('all') ) ||
( !$query->param('Poke Mon') && !$query->param('Sponge Bob') &&
( $student eq "" ) ) ) { $cmd .= "''"; }
else {
if ( $query->param('Poke Mon') ) { $cmd .= "'POKE MON' "; }
if ( $query->param('Sponge Bob') ) { $cmd .= "'SPONGE BOB' "; }
if ( !( $student eq "" ) ) { $cmd .= "'" . uc($student). "'"; }
}
print( $cmd ); system( $cmd );
print <<EndofHTML;
<form>
<input type="button" value=" Back " onclick="history.go(-1);return false;" />
</form>
</b></font>
</td>
</tr>
</table>
</body>
</html>
EndofHTML
}
elsif ( $act eq "HTML source" ) {
print ( "Content-type: text/plain\n\n" );
$cmd = "/usr/bin/lynx -dump -source " . $ENV{HTTP_REFERER};
$cmd .= "; echo \n\n\n\n";
system( $cmd );
}
elsif ( $act eq "CGI source" ) {
# Print plain text.
print ( "Content-type: text/plain\n\n" );
system( "/bin/cat ListCourses.cgi; echo \n\n\n\n" );
}
elsif ( $act eq "Perl source" ) {
print ( "Content-type: text/plain\n\n" );
system( "/bin/cat ListCourses.pl; echo \n\n\n\n" );
}
elsif ( $act eq "Java source" ) {
print ( "Content-type: text/plain\n\n" );
system( "/bin/cat ListCourses.java; echo \n\n\n\n" );
}
elsif ( $act eq "SQL source" ) {
print ( "Content-type: text/plain\n\n" );
system( "/bin/cat ListCourses.sql; echo \n\n\n\n" );
}
elsif ( $act eq "Help" ) {
print ( "Content-type: text/html\n\n" );
system( "/bin/cat Help.html" );
}
else {
print( "Content-type: text/html\n\n" );
print( "No such option: <em>$act</em>" );
}
|