jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser /; my $q = CGI->new(); #declare some vars my $mail ='menu@uranus.com'; my $path_to_text="/home/mysite/www/myfolder/my.txt" # Parse Form Search Information # if it's a single form value, map the value as a scalar, otherwise, t +he value is # an arrayref my %FORM = map { $_, @{[ param($_) ]} > 1 ? [ param($_) ] : param($_) } param(); my $words = $q->param('words'); if ($words eq ""){ $words = "no specials today"; } my $user = $ENV{'REMOTE_ADDR'}; my $pass = $q->param('pass'); if ($pass ne "whatever"){ open (TEXTFILE,"$path_to_text") || die "where's the damn file? + : $!"; $words = <TEXTFILE>; close (TEXTFILE) || die "close damn you : $!"; print "Content-type: text/html\n\n"; print "<HTML> \n"; print "<body bgcolor=000000 text=99CCCC> \n"; print "<CENTER><H1><font face=Arial>!Unauthorized Access!\n"; print "<BR>"; print "The menu for tonight remains \n"; print "<font color = blue> $words </font>"; print ". <BR> \n"; print "<font color = red>Hey bub, stop messin' with my menu!\n +"; print "<BR>You are at IP address $user !"; print "</H1></CENTER></font></body>"; open MAIL,"|mail $mail" or die "mail problem : $!"; print MAIL "$user tried to get in using $pass for a password.\ +n"; close MAIL; exit 0; }else{ open (TEXTFILE,"$path_to_text") || die "where's the damn file? : $ +!"; print TEXTFILE $words; close (TEXTFILE) || die "close damn you : $!"; print "Content-type: text/html\n\n"; print "<HTML><body bgcolor=000000 text=99CCCC><CENTER><H1> <font f +ace=Arial> \n"; print "The menu has been updated for you. <BR> \n"; print "The menu for tonight is \n"; print "<font color = blue> $words </font>.</CENTER></H1></font></b +ody>"; open MAIL,"|mail $mail" or die "mail problem : $!"; print MAIL "$user changed the menu $words.\n"; close MAIL; }
|
|---|