Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found