writetolog.cgi
#!/usr/bin/perl @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $key =~ tr/+/ /; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~s/<!--(.|\n)*-->//g; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } $comments = $formdata{'comments'}; open (LOG, ">>/news/wendyfile.txt") || &ErrorMessage; print LOG "$comments\n"; close (LOG); print "Content-type: text/html\n\n"; print "<P>You commented thusly: <BLOCKQUOTE><P><I>$comments</I></BLOCKQUOTE>\n"; print "<HR>Would you like to see all the messages? <A HREF=\"http://www.lawsonhelp.com/cgi-bin/readfromlog.cgi\">Yes</A>"; sub ErrorMessage { print "Content-type: text/html\n\n"; print "The server can't open the file. It either doesn't exist or the permissions are wrong. \n"; exit; }