#!/usr/bin/perl -T # notes.cgi # Ted Fiedler use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use warnings; #use Data::Dumper; $CGI::POST_MAX=1024 * 100; # max 100K posts $CGI::DISABLE_UPLOADS = 1; # no uploads # Clean up our UNIX environment # for more infor read perldoc perlsec $ENV{'PATH'} = '/home/tfiedler/stuff/scripts/web/cgi-bin'; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Flush the output buffer $|++; # define our vars my $date = scalar(localtime); my @text; my $file="/home/tfiedler/stuff/scripts/web/cgi-bin/notes.tcf"; my $archive="/home/tfiedler/stuff/scripts/web/cgi-bin/archives.tcf"; my $project_name="webtop"; if (param('Archive')) { open (TFILE, "$file") or die "unable to open $file for reading: $!\n"; #( -s "${file}_arc" ) ? open (TFILE2, ">>${file}_arc") or die($!) # : open (TFILE2, ">${file}_arc") or die($!); open (TFILE2, ">>$archive") or die "Unable to open $archive\n"; print TFILE2 "$_" for (); close(TFILE); close(TFILE2); unlink($file); } if ( param('delete') ) { unlink($file); } if ( ! -e $file ) { open (TOUCH, ">$file") or die("Unable to create $file: $!\n"); close (TOUCH); } if ( defined (param('NOTES')) and param('NOTES') =~ m/\S/ ) { @text=param('NOTES'); open (SERVER_NOTES, ">>$file") or die("Unable to open $file: $!\n"); for $_(@text) { # remove HTML tags <> s/<(?:[^>'"]*|(['"]).*?\1)*>//gs unless param('HTML'); # print the rest to file... print SERVER_NOTES "[$ENV{'REMOTE_ADDR'} - $date]\n", br, "$_", br; } close (SERVER_NOTES); } ## Start HTML ## print header; print start_html(-title=>"$project_name notes", -BGCOLOR=>"#cccc99" ), "\n"; print "
\n"; print h3("project $project_name notes"),"\n"; print "
\n"; print hr,"\n"; print "\n\n\n\n"; print "\n \n \n"; print br,br; print Delete_all() if ( param('delete') or param('Archive') or param('HTML') ); if ( -s $file ) { print Delete_all(); open ( FH, $file ) or die("unable to open notes: $!\n"); my @notes=; print "\n"; } print "
notes
@notes
\n"; print br,br,br; print "\n\n\n\n"; print "\n \n \n"; print "
change $file
\n",br; print start_form; print "
\n"; print textarea('NOTES',"", 15, 80), "\n",br; print checkbox(-name=> 'HTML', -value=> 'off'), " ", checkbox(-name=> 'delete', -value=> 'off'), " ", checkbox(-name=> 'Archive', -value=> 'off'), " ", submit('Submit'); print "
\n",br; if ( -s $archive ) { print "\n\n\n\n"; print "\n \n \n"; open ( FH2, "$archive" ) or die "Unable to open $archive: $!\n"; my @archives=; print "\n"; print "
Archives
@archives
\n"; } print "\n\n\n\n"; print "\n \n \n"; print "
\n",br; print end_html; __END__ =head1 NAME notes.cgi - Leave notes for other users, logs IP address & date =head1 AUTHOR Ted Fiedler