#!/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 (<TFILE>); 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 "[<font color=\"#ff0000\" size=\"-1\">$ENV{ +'REMOTE_ADDR'} - $date</font>]\n", br, "<font size=\"-1\">$_</font>", br; } close (SERVER_NOTES); } ## Start HTML ## print header; print start_html(-title=>"$project_name notes", -BGCOLOR=>"#cccc99" ), "\n"; print "<tt><center>\n"; print h3("project $project_name notes"),"\n"; print "</center>\n"; print hr,"\n"; print "\n\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" wid +th=\"70%\" align=\"center\">\n\n"; print "<tr align=\"center\" bgcolor=\"#999966\">\n <th>notes</th>\n </tr>\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=<FH>; print "<td>@notes</td>\n"; } print "</table>\n"; print br,br,br; print "\n\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" wid +th=\"70%\" align=\"center\">\n\n"; print "<tr align=\"center\" bgcolor=\"#999966\">\n <th>change $file </th>\n </tr>\n"; print "</table>\n",br; print start_form; print "<center>\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 "</center>\n",br; if ( -s $archive ) { print "\n\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" + width=\"70%\" align=\"center\">\n\n"; print "<tr align=\"center\" bgcolor=\"#999966\">\n <th>Archives</th>\n </tr>\n"; open ( FH2, "$archive" ) or die "Unable to open $archive: $!\n"; my @archives=<FH2>; print "<td>@archives</td>\n"; print "</table>\n"; } print "\n\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" hei +ght=\"20\" width=\"70%\" align=\"center\">\n\n"; print "<tr align=\"center\" bgcolor=\"#999966\">\n <td> </td>\n </tr>\n"; print "</table>\n",br; print end_html; __END__ =head1 NAME notes.cgi - Leave notes for other users, logs IP address & date =head1 AUTHOR Ted Fiedler<fiedlert@gmail.com>

In reply to notes.cgi by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.