Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://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":



  • 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 imbibing at the Monastery: (3)
As of 2024-04-19 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found