#!/usr/local/bin/perl ######################################################################## # Graphical Message Board # Version 4.0 # Copyright 1998 Techno Trade Online Solutions http://www.technotrade.com # Written By : Sammy Afifi sammy@technotrade.com # Date Last Modified : Sep 1, 1998 ######################################################################## ### These Variables hold the location of the .gif images, default is the same directory ### as the cgi script. Change these values if your cgi-bin will not accept .gif's ### example : $post1 = "http://www.myserver.com/images/post1.gif" ### $post1 = "post1.gif"; $post2 = "post2.gif"; $post3 = "post3.gif"; $post4 = "post4.gif"; $exit = "exit.gif"; $left1 = "left1.gif"; $left2 = "left2.gif"; $right1 = "right1.gif"; $right2 = "right2.gif"; $admin = "admin.gif"; $key = "key.gif"; ##### You need to change the following 2 variables ##### $formaction = "http://www.technotrade.com/board4/board4.cgi"; # Where the CGI script is $basedir = "/u/web/tech12/board4/"; # base directory where data files go (/usr/www/joe/data/) $editorpassword = "1111"; # your password for deleting $badwords = "shit|prick|fuck|bitch|cunt|suck|tits"; #### Did your mother teach you to say that ? &parse_form; ############################################################ # # *** do not change these variables *** # $numdatafields = 6; $messagenumber = $input{'messagenumber'}; # which message number to start at $direction = $input{'direction'}; # which way to go (right, left or list) $boardname = $input{'boardname'}; # text file for the messages # get rid of dangerous characters $boardname =~ s/\>//g; $boardname =~ s/\

Missing Parameters


\n"; print "If you're reading this, then you didn't call the script properly, you need to pass some variables such as boardname, direction, formaction etc. Please refer to the instructions at the CGI Archive on how to call this script.\n"; for ($x = 0; $x <= $numselected; $x++) { print "$sortedposts[$x]
\n"; } &print_footer; exit; ############################### sub hidden_fields { print "\n"; print "\n"; print "\n"; print "\n"; } ############################### # # # ############################### sub fetchmessage { &print_content; &print_header; &readmessage; print "
\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print " \n"; print " \n"; print "\n"; print "
\n"; print " \n"; print "  $boardtitle\n"; print " \n"; print "
\n"; print " \n"; print "  $msgtitles[$gotorecord]
\n"; print "
\n"; print "
\n"; print "
\n"; print "  " . $msgdates[$gotorecord] . "\n"; print "\n"; print "\  \  \  \  \  \n"; print "By : " . $msgnames[$gotorecord] . "\n"; print "\ \ \ \ \ \n"; if ($msgemails[$gotorecord] ne "") { print "E-Mail\n"; } if ($msgurls[$gotorecord] ne "") { print "\ \ \ \ \ \n"; print "Homepage\n"; } print "\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; # post new print "\n"; #post a reply to print "\n"; # list postings print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; if ($gotorecord == 1) { print "\n"; } else { print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; print "
\n"; } print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; # $msgsource = $rpostedbyname . " (" . $rpostedbyemail . ") " . $rmessagedate; # $msgsource =~ s/\"/\'/g; # replace double quotes with single quotes # print "\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; # $msgsource = $rpostedbyname . " (" . $rpostedbyemail . ") " . $rmessagedate; # $msgsource =~ s/\"/\'/g; # replace double quotes with single quotes # print "\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; # print "\n"; print "
\n"; print "
\n"; if ($gotorecord == $numpostings) { print "\n"; } else { print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; # print "\n"; print "
\n"; } print "
\n"; print "       \n"; print "\n"; print "
\n"; print "
\n"; print "Message Board By Techno Trade Online Solutions\n"; print "
\n"; &print_footer; exit; } ###################################### # # # ###################################### sub postmessage { &print_content; &print_header; print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print " \n"; print " \n"; print "\n"; print "
\n"; print " \n"; print "  $boardtitle\n"; print " \n"; print "
\n"; print " \n"; print "  Post a Message
\n"; print "
\n"; print "
\n"; $messagetitle =~ s/\"/\'/g; if ($messagetitle ne "") { $firstthree = substr($messagetitle,0,3); # get the first three chars to see if it = RE: if ($firstthree ne "RE:") { $messagetitle = "RE: " . $messagetitle; } } print "  Title: "; &hidden_fields; print "
\n"; print "
  Name   : \n";
    print  "  E-Mail : 
"; # print "  URL : "; print "
\n"; print ""; print "
"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; # list postings print ""; print "
\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; # print "\n"; print "
\n"; print "
"; print "
\n"; print "
\n"; &print_footer; exit; } ################################## # # # ################################## sub postmessagetofile { $ct = time; $timedifference = 10800; local($sec,$min,$hour,$mday,$mon,$yday,$wday,$isdst) = localtime($ct - $timedifference); $min = "0" . $min if ($min < 10); $hour = "0" . $hour if ($hour < 10); $mon++; $sec = "0" . $sec if ($sec < 10); $mon = "0" . $mon if ($mon < 10); $mday = "0" . $mday if ($mday < 10); $yday = "0" . $yday if ($yday < 10); $yday = 1900 + $yday; $msgdate = "$mon/$mday/$yday $hour:$min"; open(FILE1,">>$basedir$boardname"); $messagebody =~ s/\cM//g; $messagebody =~ s/\n/\<\*R\*\>/g; $messagebody = &clean_string($messagebody); $msgname = &clean_string($msgname); $msgtitle = &clean_string($msgtitle); $msgemail = &clean_string($msgemail); print FILE1 "$messagetitle|$msgdate|$msgname|$msgemail|$msgurl|$messagebody\n"; close(FILE1); } ################################## # # deletes badwords from a string # sub clean_string { local($st) = @_; $st =~ s/\b$badwords\b//gi; return($st); } ##################################### # # # ##################################### sub readmessage { $gotorecord = 0 if ($gotorecord < 1); $prevposting = $gotorecord - 1; $nextposting = $gotorecord + 1; $nextposting = $numpostings if ($nextposting > $numpostings); return(1); } ##################################################### # display a drop down window of all the Subjects of all postings ##################################################### sub displaysubjects { $position = 0; &print_content; &print_header; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print " \n"; print " \n"; print "\n"; print "
\n"; print " \n"; print "  $boardtitle\n"; print " \n"; print "
\n"; print " \n"; print " Subject Listing
\n"; print "
\n"; print "
\n"; print "\n"; &hidden_fields; print "\n"; print ""; print "
"; print "
"; print "Click and drag with your mouse to select multiple messages"; print "
\n"; print "
"; print "
"; #print "Administrator-only\n"; print "
"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; # post new print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; # print "\n"; print "
\n"; print "
\n"; print "       \n"; print "\n"; print "
\n"; print "
\n"; print "Message Board By Techno Trade Online Solutions\n"; print "
\n"; &print_footer; exit; } ##################################################### # ##################################################### sub displayselected { &print_content; &print_header; print "
\n"; print "\n"; print "\n"; $sp++; } } print "\n"; print "\n"; print "
\n"; print " \n"; print " \n"; print "\n"; print "
\n"; print " \n"; print "  $boardtitle\n"; print " \n"; print "
\n"; print " \n"; print "  Group Listing
\n"; print "
\n"; $position = 1; $sp = 0; for ($gc = 1; $gc <= $numpostings; $gc++) { if ($gc == $sortedposts[$sp]) { print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; $msgsource = $msgnames[$gc] . " (" . $msgemails[$gc] . ") " . $msgdates[$gc]; $msgsource =~ s/\"/\'/g; # replace double quotes with single quotes # print "\n"; print "
\n"; print "Subject : $msgtitles[$gc]
\n"; print "Date     : $msgdates[$gc]
\n"; print "By         : $msgnames[$gc] \n"; print "   E-mail    \n" if ($msgemails[$gc] ne ""); print "URL\n" if ($msgurls[$gc] ne ""); print "

\n"; $msgbodys[$gc] =~ s/\n/\/g; print "$msgbodys[$gc]"; print "
\n"; print "\n"; print "\n"; print "\n"; # post new print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; # print "\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; &hidden_fields; print "\n"; print "
\n"; print "
\n"; print "       \n"; print "\n"; print "
\n"; print "
\n"; print "
\n"; &print_footer; exit; } ##################################################### # ##################################################### sub delete_messages { open(BF,">$basedir$boardname"); flock(BF,2); for ($gc = 1; $gc <= $numpostings; $gc++) { if (&inselected($gc) == 0) { print BF "$boardlines[$gc-1]\n"; } } close(BF); } ################################# # returns true or false if a given number exists in the selected array (sortedposts) sub inselected { local($check) = @_; foreach $sel (@sortedposts) { return(1) if ($sel == $check); } return(0); } ##################### # ##################### sub readfile { open(FILE1,"$basedir$boardname"); @boardlines = ; close(FILE1); # number of lines in the file $numpostings = @boardlines; # get rid of new line chars and control Z's # and count how many Postings there are for($xc = 1; $xc <= $numpostings;$xc++) { $boardlines[$xc - 1] =~ s/\cM//g; $boardlines[$xc - 1] =~ s/\n//g; ($msgtitles[$xc],$msgdates[$xc],$msgnames[$xc],$msgemails[$xc],$msgurls[$xc],$msgbodys[$xc]) = split(/\s*\|\s*/,$boardlines[$xc - 1],$numdatafields); $msgbodys[$xc] =~ s/<\*R\*\>/\n/g; } } # This subroutine is called when the user has selected a message to goto from the drop down menu # it returns the message number which is located in the first part of the string (before the period) sub getrecordnum { $gotorecord = $gotomessage; @selectedposts = split(/\s*\ \s*/,$gotomessage); $numselected = @selectedposts; $gotorecord = 1 if ( ($numselected == 1) && ($gotorecord eq "") ); @sortedposts = sort {$a <=> $b} @selectedposts; shift(@sortedposts) if ($sortedposts[0] == 0); $numsortedposts = @sortedposts; } ######################################################### sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); if (length($buffer) < 5) { $buffer = $ENV{QUERY_STRING}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($input{$name} eq "") { $input{$name} = $value; } else { $input{$name} = $input{$name} . " " . $value; } } } ######################################################### sub print_content { # Check to see if we're running on one of those cough cough NT machines print "HTTP/1.0 200 OK\r\n" if $ENV{PERLXS} eq "PerlIS"; print "Content-type: text/html\n\n"; } sub print_header { print< $boardtitle HEAD } sub print_footer { print< FOOT }