flock.cgi
#!/usr/bin/perl if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); if ($ENV{'QUERY_STRING'}) { @getpairs =split(/&/, $ENV{'QUERY_STRING'}); push(@pairs,@getpairs); } } else { print "Content-type: text/html\n\n"; print "<P>Use Post or Get"; } $comments = $formdata{'comments'}; open (LOG, ">>../../logs/logfile.txt") || &ErrorMessage; flock (LOG, 2); print LOG "$comments\n"; flock (LOG, 8); 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.setgetweb.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; }
Last updated: 05/25/2025 14:37:56