#!/usr/bin/perl # # http://clanlib.org/~mbn/webcomments.cgi/modules.html # use English; use CGI; $query = new CGI; if ($ENV{REQUEST_URI} =~ /$ENV{SCRIPT_NAME}\/(.*)$/) { $filename = $1; $filename .= "index.html" if ($filename =~ /\/$/); } else { exit; } print "Content-type: text/html\n\n"; if ($filename =~ /^(.*)\?(.*)$/) { $filename = $1; $params = $2; } if ($params eq "add_submit") { $from = $query->param('from'); $text = $query->param('text'); if ($text ne "") { $date = `date`; chop $date; open (MAIL, "|/var/qmail/bin/qmail-inject clanlib-cvs") || die; print MAIL "To: ClanLib CVS Commit list \n"; print MAIL "From: ClanLib Web Comment script \n"; print MAIL "Subject: Comment added on $filename\n"; print MAIL "\n\n"; print MAIL "$from changed the following page:\n"; print MAIL "\n"; print MAIL "\thttp://clanlib.org/documentation/ClanLib-0.7.cgi/$filename\n"; print MAIL "\n"; print MAIL "User comment added:\n\n"; print MAIL $text; close (MAIL); $text =~ s/&/&/gs; $text =~ s//>/gs; $text =~ s/\n\n+/<\/p>

;/gs; $text =~ s/\r\n(\r\n)+/<\/p>

/gs; $text =~ s/\r\n/
/gs; $text =~ s/\n/
/gs; open (SILLY_FILE, ">>comments.db") || die; print SILLY_FILE "--SILLY_BEGIN FROM=$from DATE=$date FILE=$filename\n"; print SILLY_FILE $text."\n"; print SILLY_FILE "--SILLY_END $filename\n"; close (SILLY_FILE); } } $fullname = "ClanLib-0.7/$filename"; open(FILE, $fullname) || die; while ($line = ) { if ($line =~ //) { if ($params eq "add") { print "

\n"; print "\n"; print "
"; print "

Please enter your comment and press submit:

"; print "

Name:

\n"; print "

Comment:

\n"; print "

\n"; print "
\n"; print "

The comment is posted as plain text, as seen in the text area. Newlines translate into <br>'s, double newlines become a new paragraph and everything is written in a fixed pitch font.

\n"; print "


\n"; } } if ($line =~ //) { print "

User comments:

"; open (SILLY_FILE, "comments.db") || die; $include_line = 0; while ($silly_line = ) { if ($silly_line =~ /^--SILLY_BEGIN FROM=(.*) DATE=(.*) FILE=$filename$/) { $from = $1; $date = $2; $include_line = 1; print ""; print "\n"; print ""; } else { while ($silly_line =~ s/^(\s*)\t/$1    /s || $silly_line =~ s/^(\s*) /$1 /s) { } print $silly_line if ($include_line); } } print "

"; print "$from

$date

"; } elsif ($silly_line =~ /^--SILLY_END $filename$/) { $include_line = 0; print "

 

Add a comment

"; } print $line; } close(FILE);