############################################ ## ## ## WebBBS ## ## by Darryl Burgdorf ## ## (e-mail burgdorf@awsd.com) ## ## ## ## version: 3.21 ## ## last modified: 4/28/99 ## ## copyright (c) 1999 ## ## ## ## latest version is available from ## ## http://awsd.com/scripts/ ## ## ## ############################################ # COPYRIGHT NOTICE: # # Copyright 1999 Darryl C. Burgdorf. All Rights Reserved. # # This program is being distributed as shareware. It may be used and # modified by anyone, so long as this copyright notice and the header # above remain intact, but any usage should be registered. (See the # program documentation for registration information.) Selling the # code for this program without prior written consent is expressly # forbidden. Obtain permission before redistributing this program # over the Internet or in any other medium. In all cases copyright # and header must remain intact. # # This program is distributed "as is" and without warranty of any # kind, either express or implied. (Some states do not allow the # limitation or exclusion of liability for incidental or consequential # damages, so this notice may not apply to you.) In no event shall # the liability of Darryl C. Burgdorf and/or Affordable Web Space # Design for any damages, losses and/or causes of action exceed the # total amount paid by the user for this software. sub WebBBS { &Parse_Form; &Initialize_Data; if ((!($UseFrames) && ($ENV{'QUERY_STRING'} =~ /review=(\d+)/i)) || ($ENV{'QUERY_STRING'} =~ /read=(\d+)/i)) { $messagenumber = $1; if ($FORM{'ListType'} =~ /Guestbook-Style, Thread/) { &DisplayThread; } else { &DisplayMessage; } } elsif ($ENV{'QUERY_STRING'} =~ /posterstats/i) { &PosterStats; } elsif ($ENV{'QUERY_STRING'} =~ /form=(\d+)/i) { $messagenumber = $1; &PostForm; } elsif ($ENV{'QUERY_STRING'} =~ /post/i) { &PostMessage; } elsif ($ENV{'QUERY_STRING'} =~ /addresslist/i) { &UpdateAddressList; } elsif ($ENV{'QUERY_STRING'} =~ /subscribe/i) { &Subscribe; } elsif ($ENV{'QUERY_STRING'} =~ /search/i) { &Search; } elsif ($ENV{'QUERY_STRING'} =~ /reconfigure/i) { &Reconfigure; } elsif ($ENV{'QUERY_STRING'} =~ /delete/i) { &Delete; } elsif ($ENV{'QUERY_STRING'} =~ /blank/i) { &BlankPage; } elsif ($UseFrames && ($ENV{'QUERY_STRING'} !~ /index/i)) { if ($ENV{'QUERY_STRING'} =~ /review=(\d+)/i) { $message = $1; } &SetupFrames; } else { &DisplayIndex; } } sub Parse_Form { if ($NaughtyWords) { @naughtywords = split(/ /,$NaughtyWords); } read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($val1, $val2) = split(/=/, $pair); $val1 =~ tr/+/ /; $val1 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $val2 =~ tr/+/ /; $val2 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; unless (($AllowHTML > 1) && ($val1 eq "body")) { $val2 =~ s// /g; } if (($AllowHTML < 1) || ($val1 ne "body")) { $val2 =~ s/<([^>]|\n)*>/ /g; } unless (($AllowHTML eq "1") && ($val1 eq "body")) { $val2 =~ s/\&/\&\;/g; $val2 =~ s/"/\"\;/g; $val2 =~ s//\>\;/g; } if ($val1 eq "body") { if ($AutoHotlink) { $val2 =~ s/\&\;/\&/g; $val2 =~ s/([\w]+:\/\/[\w-?&;#~=\.\/]+[\w])/$1<\/A>/g; } $val2 =~ s/\cM\n*/\n/g; $val2 =~ s/\n/
/g; $val2 =~ s/
\s\s\s+/

/g; $val2 =~ s/
\t/

/g; $val2 =~ s/\s+/ /g; $val2 =~ s/
\s/
/g; $val2 =~ s/\s
/
/g; $val2 =~ s/

/

/g; $val2 =~ s/


/

/g; unless ($SingleLineBreaks) { $val2 =~ s/
$AutoQuoteChar//g; $val2 =~ s/
>//g; $val2 =~ s/
/ /g; $val2 =~ s//
$AutoQuoteChar/g; } } else { $val2 =~ s/\|/ /g; } $val2 =~ s/\s+/ /g; $val2 =~ s/^\s+//g; $val2 =~ s/\s+$//g; $val2 =~ s/

/\n

/g; $val2 =~ s/
/\n
/g; $val2 =~ s/

\n//g; $val2 =~ s/
\n//g; if ($NaughtyWords) { if ($CensorPosts) { foreach $naughtyword (@naughtywords) { $val2 =~ s/$naughtyword/#####/ig; } } else { foreach $naughtyword (@naughtywords) { if ($val2 =~ /$naughtyword/) { $NaughtyFlag = 1; } } } } if ($FORM{$val1}) { $FORM{$val1} = "$FORM{$val1} $val2"; } else { $FORM{$val1} = $val2; } } } sub Initialize_Data { $version = "3.21"; $time = time; $todaydate = $time; $rebuildflag = 0; unless ($InputColumns) { $InputColumns = 80; } if ($InputColumns < 25) { $InputColumns = 25; } unless ($InputRows) { $InputRows = 15; } if ($InputRows < 5) { $InputRows = 5; } $InputLength = int($InputColumns/2); $TotalMessages = 0; $DisplayedMessages = 0; @sortedmessages = (); @keywordmatches = (); $navbar = ""; if ($ENV{'QUERY_STRING'} =~ /noframes/i) { $UseFrames = ""; $BBSquery = "?noframes&"; } else { $BBSquery = "?"; } if ($UseFrames) { $BBStarget = " TARGET=msgtxt"; $BBStargetidx = " TARGET=msgidx"; $BBStargettop = " TARGET=\"$BBSFrame\""; $SepPostForm = 1; } else { $BBStarget = " TARGET=_self"; $BBStargetidx = " TARGET=_self"; $BBStargettop = " TARGET=_self"; } $maillist_link = "
"; $maillist_link .= "$maillist_address<\/A>"; foreach $key (keys %text) { $text{$key} =~ s//$boardname/g; $text{$key} =~ s//$cgiurl/g; $text{$key} =~ s//$maillist_address/g; $text{$key} =~ s//$maillist_link/g; $text{$key} =~ s///g; } if (($ENV{'QUERY_STRING'} =~ /blank/i) || ($UseFrames && !($ENV{'QUERY_STRING'}))) { print "Content-type: text/html\n\n"; return; } unless (-e "$dir/messages.idx") { &Rebuild_Database; } print "Content-type: text/html\n"; open (INDEX,"$dir/messages.idx") || &Error("9100","9101"); while () { chop; if (($message,$timestamp,$sub,$poster,$date,$prev,$next,$count,$admin,$ip) = split(/\|/)) { $TotalMessages ++; push (@sortedmessages,$message); $timestamp{$message} = $timestamp; $age{$message} = (($time-$timestamp)/86400); $subject{$message} = $sub; $poster{$message} = $poster; $date{$message} = $date; $previous{$message} = $prev; $next{$message} = $next; $count{$message} = $count; if ($admin eq "AdminPost") { $admin{$message} = $admin; } $ipaddress{$message} = $ip; unless (($message =~ /^\d*$/) && ($timestamp =~ /^\d*$/) && ($date =~ /^\d*$/)&& ($prev =~ /^[\d|\s]*$/) && ($next =~ /^[\d|\s]*$/) && ($count =~ /^\d*$/)) { $count{$message} = 0; &ResetMessageData; $rebuildflag = 1; } } } close (INDEX); $lastmessage = $message; opendir (MESSAGES,$dir); @messagecount = readdir(MESSAGES); closedir (MESSAGES); foreach $message (@messagecount) { unless (($message =~ /\.tmp$/) || ($message == 0)) { if ($message > $lastmessage) { $rebuildflag = 1; } } } if ($rebuildflag) { &Rebuild_Database; } $FORM{'email'} =~ s/\s//g; unless ($FORM{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|,|;/ || $FORM{'email'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { $email = "$FORM{'email'}"; } if ($FORM{'name'}) { $name = "$FORM{'name'}"; } if ($LockRemoteUser && $ENV{'REMOTE_USER'}) { $name = $ENV{'REMOTE_USER'}; } $name = substr($name,0,$MaxInputLength); $FORM{'url'} =~ s/\&\;/\&/g; $FORM{'url'} =~ s/\s//g; $FORM{'imageurl'} =~ s/\&\;/\&/g; $FORM{'imageurl'} =~ s/\s//g; unless ($FORM{'url'} =~ /\*|(\.\.)|(^\.)|(\/\/\.)/ || $FORM{'url'} !~ /.*\:\/\/.*\..*/ || !($FORM{'url_title'})) { $message_url = "$FORM{'url'}"; $message_url_title = "$FORM{'url_title'}"; } unless ($FORM{'imageurl'} =~ /\*|(\.\.)|(^\.)|(\/\/\.)/ || $FORM{'imageurl'} !~ /.*\:\/\/.*\..*/) { $image_url = "$FORM{'imageurl'}"; } if ($UseCookies) { $Cookie_Exp_Date = "Sun, 10-Oct-2000 00:00:00 GMT"; if ($cgiurl =~ m#^http://([\w-\.]+):?(\d*)/(.+)/#o) { $Cookie_Path = "/$3/"; } &GetCompressedCookies($boardname); if (!($FORM{'ListType'})) { $FORM{'ListType'} = $Cookies{'listtype'}; } if (!($FORM{'ListTime'})) { $FORM{'ListTime'} = $Cookies{'listtime'}; } if ($FORM{'KeySearch'} eq "No") { $listtype = $FORM{'ListType'}; $listtime = $FORM{'ListTime'}; } if ($ENV{'QUERY_STRING'} =~ /post/i) { if (!($FORM{'wantnotice'})) { $Cookies{'wantnotice'} = "no"; } else { $Cookies{'wantnotice'} = "yes"; } } &Send_Cookie; } if (!($FORM{'ListTime'})) { $FORM{'ListTime'} = $DefaultTime; } unless ($FORM{'ListTime'}) { $FORM{'ListTime'} = "Week"; } if ($ArchiveOnly || ($FORM{'ListTime'} eq "Archive")) { $FORM{'ListTime'} = "Several Eons"; } if (!($FORM{'ListType'})) { if ($ENV{'HTTP_USER_AGENT'} =~ /Lynx/i ) { $FORM{'ListType'} = "Compressed"; } else { $FORM{'ListType'} = $DefaultType; } } unless ($FORM{'ListType'}) { $FORM{'ListType'} = "Chronologically"; } if ($FORM{'ListType'} =~ /Alpha/) { foreach $message (@sortedmessages) { $sortsubject{$message} = $subject{$message}; $sortsubject{$message} =~ tr/A-Z/a-z/; $sortsubject{$message} =~ s/^re: //; } } if ((($FORM{'ListType'} =~ /Guestbook/) || ($FORM{'ListType'} =~ /Compress/)) && ($IndexEntryLines eq "news")) { $IndexEntryLines = 2; } unless ($DateConfig) { $DateConfig = "%DY%, %dy% %MO% %YR%, at %hr%:%mn% %am%"; } unless ($NewCode) { $NewCode = "NEW: "; } unless ($AutoQuoteChar) { $AutoQuoteChar = ":"; } } sub SetupFrames { print "\n$boardname\n"; if ($HeadLinesFile) { open (HEADLN,"$HeadLinesFile"); @headln = ; close (HEADLN); foreach $line (@headln) { print "$line"; } } print "\n"; if ($UseFrames =~ /h/i) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; } elsif ($WelcomePage) { print "SRC=\"$WelcomePage\">\n"; } else { print "SRC=\"$cgiurl?blank\">\n"; } print "\n"; print "

Make your own free website on Tripod.com
\n"; if ($HeaderFile) { open (HEADER,"$HeaderFile"); @header =
; close (HEADER); foreach $line (@header) { print "$line"; } } if ($printboardname) { print "

"; print "$boardname

\n"; } print "$text{'0100'}\n"; print "

$boardname "; print "is maintained by "; print "$admin_name with "; print ""; print "WebBBS $version.

\n"; if ($FooterFile) { open (FOOTER,"$FooterFile"); @footer =