Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I made a script that should act as a bulletin board, but doesn't seem to work right. Could somebody check my script for any problems, I'd really appreciate it. Here's the script:
#!/usr/bin/perl require "cgi-lib.pl"; require "subroutines.pl"; &ReadParse; print &PrintHeader; $url="http://soccermb.netfirms.com/board/bb.htm"; $bbfile1 = "$ENV{'DOCUMENT_ROOT'}/www/board/box1.htm"; $bbfile2 = "$ENV{'DOCUMENT_ROOT'}/www/board/box2.htm"; $bbfile3 = "$ENV{'DOCUMENT_ROOT'}/www/board/box3.htm"; $bbfile4 = "$ENV{'DOCUMENT_ROOT'}/www/board/box4.htm"; unless (-e $bbfile1) { print <<"PrintTag"; <html><body> <h2>$bbfile1 not present.</h2> <p>Did you upload the file? If so, the server path to your box1.htm file is incorrect in your CGI program. Check with your hosting service to find the server path to your HTML files.</p> </body></html> PrintTag exit(0); } unless (-e $bbfile2) { print <<"PrintTag"; <html><body> <h2>$bbfile2 not present.</h2> <p>Did you upload the file? If so, the server path to your box1.htm file is incorrect in your CGI program. Check with your hosting service to find the server path to your HTML files.</p> </body></html> PrintTag exit(0); } unless (-e $bbfile3) { print <<"PrintTag"; <html><body> <h2>$bbfile3 not present.</h2> <p>Did you upload the file? If so, the server path to your box1.htm file is incorrect in your CGI program. Check with your hosting service to find the server path to your HTML files.</p> </body></html> PrintTag exit(0); } unless (-e $bbfile4) { print <<"PrintTag"; <html><body> <h2>$bbfile4 not present.</h2> <p>Did you upload the file? If so, the server path to your box1.htm file is incorrect in your CGI program. Check with your hosting service to find the server path to your HTML files.</p> </body></html> PrintTag exit(0); } $tempfile1="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp1.htm"; $tempfile2="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp2.htm"; $tempfile3="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp3.htm"; $tempfile4="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp4.htm"; if (($in{'visitor_name'} eq "") || ($in{'visitor_email_address'} eq "" +) || ($in{'radioset'} eq "") || ($in{'Comment'} eq "")) { print <<"PrintTag"; <html><body> <h2>Data Incomplete</h2> <p>Your request to send comments to the board has been rejected due to insufficient information. To properly send your comments, please fill out:</p> <ul> PrintTag if ($in{'visitor_name'} eq "") { print "\n<li> Your Name\n"; } if ($in{'visitor_email_address'} eq "") { print "\n<li> Your Email Address\n"; } if ($in{'radioset'} eq "") { print "\n<li> Your county\n"; } if ($in{'Comment'} eq "") { print "\n<li> Your comments\n"; } print "</ul>\n</p>\n</body>\n</html>\n"; exit(0); } #STOP HERE FOR NOW if (($in{'Comments'} =~ /damn/) || ($in{'Comments'} =~ /darn/) || ($in{'Comments'} =~ /dang/) || ($in{'Comments'} =~ /shit/) || ($in{'Comments'} =~ /basterd/) || ($in{'Comments'} =~ /fuck/) || ($in{'Comments'} =~ /fuckin'/) || ($in{'Comments'} =~ /fucking/) || ($in{'Comments'} =~ /freak/) || ($in{'Comments'} =~ /freakin'/) || ($in{'Comments'} =~ /freaking/) || ($in{'Comments'} =~ /bitch/) || ($in{'Comments'} =~ /bitchin'/) || ($in{'Comments'} =~ /bitching/)) { print<<"PrintTag"; <html><body> <h2>Request denied-improper language.</h2> </body></html> PrintTag exit(0); } $in{'visitor_name'} =~ s/\</&lt;/g; $in{'visitor_name'} =~ s/\>/&gt;/g; $in{'visitor_email_address'} =~ s/\</&lt;/g; $in{'visitor_email_address'} =~ s/\>/&gt;/g; $in{'Comment'} =~ s/\</&lt;/g; $in{'Comment'} =~ s/\>/&gt;/g; if (-e "lock.fil") { print <<"PrintTag"; <HTML> <BODY> <H2>Try again!</H2> <p> The bulletin board is in use. Please try again later. </p> </BODY> </HTML> PrintTag exit(0); } open(LOCKFILE, ">lock.fil"); #Start subroutines if ($in{'radioset'} eq "Kern" || "San Luis Obispo" || "Santa Barbara") { &box1 } if ($in{'radioset'} eq "Riverside" || "San Diego" || "Imperial") { &box4 } if ($in{'radioset'} eq "Orange" || "San Bernadino") { &box3 } if ($in{'radioset'} eq "Ventura" || "Los Angeles") { &box2 } #open(BBFILE,"$bbfile") || die "Can't find bulletin board.\n"; #@indata = <BBFILE>; #close(BBFILE); #open(TEMPFILE,">$tempfile") || die "Can't find temp file.\n"; #foreach $i (@indata) #{ #chop($i); #print TEMPFILE "$i\n"; #if ($i =~ /<!-- BEGINNING -->/i) #{ #print TEMPFILE "<p><a href=\"mailto:$in{'email'}\">"; #print TEMPFILE "$in{'name'}"; #print TEMPFILE "</a>"; #print TEMPFILE "<br>"; #print TEMPFILE "$in{'comments'}</p><hr>\n\n"; #} #} #refresh bulletin board #close(TEMPFILE); #rename("$bbfile", "$bbfile.old"); #rename("$tempfile", "$bbfile"); #close(LOCKFILE); #unlink("lock.fil"); #Thank you page #print <<"PrintTag"; #<html><body> #<h2>Bulletin Board Entry Accepted</h2> #<p>View <A HREF="$url">Bulletin Board</A></p> #</body></html> #PrintTag
And here's the subroutine script:
sub box1 { $url="http://soccermb.netfirms.com/board/box1.htm"; $bbfile1 = "$ENV{'DOCUMENT_ROOT'}/www/board/box1.htm"; $tempfile1="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp1.htm"; open(BBFILE,"$bbfile1") || die "Can't find bulletin board.\n"; @indata = <BBFILE>; close(BBFILE); open(TEMPFILE,">$tempfile1") || die "Can't find temp file.\n"; foreach $i (@indata) { chop($i); print TEMPFILE "$i\n"; if ($in{'radioset'} eq "Kern") { if ($i =~ /<!-- BEGINNING -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile1", "$bbfile.old"); rename("$tempfile1", "$bbfile1"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } } if ($in{'radioset'} eq "San Luis Obispo") { if ($i =~ /<!-- BEGINNING1 -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile1", "$bbfile.old"); rename("$tempfile1", "$bbfile1"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } if ($in{'radioset'} eq "Santa Barbara") { if ($i =~ /<!-- BEGINNING3 -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile1", "$bbfile.old"); rename("$tempfile1", "$bbfile1"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } } } #refresh bulletin board #close(TEMPFILE); #rename("$bbfile", "$bbfile.old"); #rename("$tempfile", "$bbfile"); #close(LOCKFILE); #unlink("lock.fil"); #Thank you page #print <<"PrintTag"; #<html><body> #<h2>Bulletin Board Entry Accepted</h2> #<p>View <A HREF="$url">Bulletin Board</A></p> #</body></html> #PrintTag sub box2 { $url2 = "http://soccermb.netfirms.com/board/box2.htm"; $bbfile2 = "$ENV{'DOCUMENT_ROOT'}/www/board/box2.htm"; $tempfile2="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp2.htm"; open(BBFILE,"$bbfile2") || die "Can't find bulletin board.\n"; @indata = <BBFILE>; close(BBFILE); open(TEMPFILE,">$tempfile2") || die "Can't find temp file.\n"; foreach $i (@indata) { chop($i); print TEMPFILE "$i\n"; if ($in{'radioset'} eq "Ventura") { if ($i =~ /<!-- BEGINNING -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile2", "$bbfile.old"); rename("$tempfile2", "$bbfile2"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } if ($in{'radioset'} eq "Los Angeles") { if ($i =~ /<!-- BEGINNING1 -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile2", "$bbfile.old"); rename("$tempfile2", "$bbfile2"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } } } sub box3 { $url3 = "http://soccermb.netfirms.com/board/box1.htm"; $bbfile3 = "$ENV{'DOCUMENT_ROOT'}/www/board/box3.htm"; $tempfile3="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp3.htm"; open(BBFILE,"$bbfile3") || die "Can't find bulletin board.\n"; @indata = <BBFILE>; close(BBFILE); open(TEMPFILE,">$tempfile3") || die "Can't find temp file.\n"; foreach $i (@indata) { chop($i); print TEMPFILE "$i\n"; if ($in{'radioset'} eq "Orange") { if ($i =~ /<!-- BEGINNING -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile3", "$bbfile.old"); rename("$tempfile3", "$bbfile3"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } if ($in{'radioset'} eq "San Bernadino") { if ($i =~ /<!-- BEGINNING1 -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile3", "$bbfile.old"); rename("$tempfile3", "$bbfile3"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } } } sub box4 { $url4 = "http://soccermb.netfirms.com/board/box4.htm" $bbfile4 = "$ENV{'DOCUMENT_ROOT'}/www/board/box4.htm"; $tempfile4="$ENV{'DOCUMENT_ROOT'}/www/board/bbtemp4.htm"; open(BBFILE,"$bbfile4") || die "Can't find bulletin board.\n"; @indata = <BBFILE>; close(BBFILE); open(TEMPFILE,">$tempfile4") || die "Can't find temp file.\n"; foreach $i (@indata) { chop($i); print TEMPFILE "$i\n"; if ($in{'radioset'} eq "Riverside") { if ($i =~ /<!-- BEGINNING -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile4", "$bbfile.old"); rename("$tempfile4", "$bbfile4"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } if ($in{'radioset'} eq "San Diego") { if ($i =~ /<!-- BEGINNING1 -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile4", "$bbfile.old"); rename("$tempfile4", "$bbfile4"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } if ($in{'radioset'} eq "Imperial") { if ($i =~ /<!-- BEGINNING3 -->/i) { print TEMPFILE "<p><a href=\"mailto:$in{'visitor_email_address'}\"> +"; print TEMPFILE "$in{'visitor_name'}"; print TEMPFILE "</a>"; print TEMPFILE "<br>"; print TEMPFILE "$in{'Comment'}</p><hr>\n\n"; close(TEMPFILE); rename("$bbfile4", "$bbfile.old"); rename("$tempfile4", "$bbfile4"); close(LOCKFILE); unlink("lock.fil"); #Thank you page print <<"PrintTag"; <html><body> <h2>Bulletin Board Entry Accepted</h2> <p>View <A HREF="$url">Bulletin Board</A></p> </body></html> PrintTag } } } } 1;

In reply to bulletin board by Anonymous Monk

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [tye]: because s/// doesn't support an 'r' option?
    [tye]: (in your version of Perl?)
    [tye]: no, thankfully (at least my version of Perl) has a different error for that.
    [tye]: could be an unclosed m//, qr//, s///, or even q// (etc.) from earlier

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (9)
    As of 2016-12-07 18:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      On a regular basis, I'm most likely to spy upon:













      Results (131 votes). Check out past polls.