############################################################################### # Post.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Project started by Zef Hemel (zef@zefnet.com) # # Software Version: YaBB 1 Gold - Release # # =========================================================================== # # Software Distributed by: http://yabb.xnull.com # # Support, News, Updates at: http://yabb.xnull.com/community/ # # =========================================================================== # # Copyright (c) 2000-2001 X-Null - All Rights Reserved # # Software by: The YaBB Development Team # ############################################################################### $postplver="1 Gold - Release"; sub Post { if($username eq 'Guest' && $enable_guestposting == 0) { &fatal_error($txt{'165'}); } if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } my( $notification, $x, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $msubject, $mattach, $mip, $mmessage, $mns, $name_field, $email_field, $form_message, $quotestart, $form_subject ); my $threadid = $INFO{'num'}; my $quotemsg = $INFO{'quote'}; ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/,$yyThreadLine); if( $mstate == 1 ) { &fatal_error($txt{'90'}); } # Determine what category we are in. fopen(FILE, "$boardsdir/$currentboard.ctb") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.ctb"); $cat = ; fclose(FILE); $curcat = $cat; fopen(FILE, "$boardsdir/$cat.cat") || &fatal_error("300 $txt{'106'}: $txt{'23'} $cat.cat"); $cat = ; fclose(FILE); $notification = ! $enable_notification || $username eq 'Guest' ? '' : <<"EOT"; $txt{'131'}: EOT $yytitle=$INFO{'title'}; &header; $name_field = $realname eq '' ? qq~~ : qq~$realname~; $email_field = $realemail eq '' ? qq~~ : qq~$realemail~; if( $threadid ne '' ) { fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("201 $txt{'106'}: $txt{'23'} $threadid.txt"); @messages = ; fclose(FILE); if($quotemsg ne '') { ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns) = split(/\|/,$messages[$quotemsg]); $form_message=$mmessage; $form_message =~ s~
~\n~g; $form_message =~ s~\n{0,1}\[quote([^\]]*)\](.*?)\[/quote\]\n{0,1}~\n~isg; $form_message =~ s~\n*\[/*quote([^\]]*)\]\n*~~ig; $mname ||= $musername || $txt{'470'}; $quotestart = int( $quotemsg / $maxmessagedisplay ) * $maxmessagedisplay; $form_message = qq~\n\n\[quote author=$mname link=board=$currentboard&num=$threadid&start=$quotestart#$quotemsg date=$mdate\]\n$form_message\n\[/quote\]~; $msubject =~ s/\bre:\s+//ig; $form_subject = "Re: $msubject"; } else { ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattache, $mip, $mmessage, $mns) = split(/\|/,$messages[0]); $msubject =~ s/\bre:\s+//ig; $form_subject = "Re: $msubject"; } } if(!$form_subject) { $sub = "$txt{'33'}"; } else { $sub = "$form_subject"; } print <<"EOT";
   $mbname
   $cat
   $boardname
   $INFO{'title'} ( $sub )
$yytitle
EOT if( $enable_ubbc && $showyabbcbutt) { print << "EOT"; EOT } print << "EOT"; $notification
$txt{'68'}: $name_field
$txt{'69'}: $email_field
$txt{'70'}:
$txt{'71'}:
$txt{'252'}:
$txt{'297'}:
$txt{'72'}:
$txt{'276'}:

$txt{'277'}

EOT &doshowthread; &footer; exit; } sub Preview { $name = $FORM{'name'}; $email = $FORM{'email'}; $subject = $FORM{'subject'}; $message = $FORM{'message'}; $icon = $FORM{'icon'}; $ns = $FORM{'ns'}; $threadid = $FORM{'threadid'}; $notify = $FORM{'notify'}; if (length($subject) > 50) { $subject = substr($subject,0,50); } $subject =~ s/\&/\&/g; $subject =~ s/"/\"/g; $subject =~ s/ / \ /g; $subject =~ s//>/g; $subject =~ s/\|/\|/g; $message =~ s/\cM//g; $message =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $message =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $message =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1$2~g; $message =~ s/\&/\&/g; $message =~ s/"/\"/g; $message =~ s/ / \ /g; $message =~ s//>/g; $message =~ s/\t/ \  \  \ /g; $message =~ s/\n/
/g; $message =~ s/\|/\|/g; &CheckIcon; if ($username eq 'Guest') { fopen(FILE, "$memberdir/memberlist.txt") || &fatal_error("202 $txt{'106'}: $txt{'23'} memberlist.txt"); @memberlist = ; fclose(FILE); $testname = lc $name; for ($a = 0; $a < @memberlist; $a++) { chomp $memberlist[$a]; $membername = lc $memberlist[$a]; if( fopen(FILE2, "$memberdir/$memberlist[$a].dat") ) { $tmpa = ; $realname = ; fclose(FILE2); chomp $realname; $realname = lc $realname; if ($realname eq $testname || $membername eq $testname) { &fatal_error($txt{'100'}); } } elsif( $testname eq $membername ) { &fatal_error($txt{'100'}); } } fopen(FILE, "$vardir/reserve.txt") || &fatal_error("203 $txt{'106'}: $txt{'23'} reserve.txt"); @reserve = ; fclose(FILE); fopen(FILE, "$vardir/reservecfg.txt") || &fatal_error("204 $txt{'106'}: $txt{'23'} reservecfg.txt"); @reservecfg = ; fclose(FILE); for( $a = 0; $a < @reservecfg; $a++ ) { chomp $reservecfg[$a]; } $matchword = $reservecfg[0] eq 'checked'; $matchcase = $reservecfg[1] eq 'checked'; $matchuser = $reservecfg[2] eq 'checked'; $matchname = $reservecfg[3] eq 'checked'; $namecheck = $matchcase eq 'checked' ? $name : lc $name; foreach $reserved (@reserve) { chomp $reserved; $reservecheck = $matchcase ? $reserved : lc $reserved; if ($matchname) { if ($matchword) { if ($namecheck eq $reservecheck) { &fatal_error("$txt{'244'} $reserved"); } } else { if ($namecheck =~ $reservecheck) { &fatal_error("$txt{'244'} $reserved"); } } } } } if($enable_ubbc) { &DoUBBC; } $message =~ s~(\S{80})(?=\S)~$1\n~g; if( $FORM{'waction'} eq 'previewmodify' ) { $destination = 'modify2'; $submittxt = $txt{'10'}; } elsif( $FORM{'waction'} eq 'previewim' ) { $destination = 'imsend2'; $submittxt = $txt{'148'}; } else { $destination = 'post2'; $submittxt = $txt{'105'}; } $csubject = $subject; # Load Censor List &LoadCensorList; $csubject =~ s/\Q$tmpa\E/$tmpb/gi; $message =~ s/\Q$tmpa\E/$tmpb/gi; $yytitle = "$txt{'507'} - $csubject"; &header; print<<"EOT";
$csubject
$message
EOT $FORM{'message'} =~ s/\&/\&/g; $FORM{'message'} =~ s/"/\"/g; $FORM{'message'} =~ s/ / \ /g; $FORM{'message'} =~ s//>/g; $FORM{'message'} =~ s/\t/ \  \  \ /g; $FORM{'message'} =~ s/\cM//g; $FORM{'message'} =~ s~(\S{80})(?=\S)~$1\n~g; $FORM{'message'} =~ s/\|/\|/g; print<<"EOT";

$txt{'250'}
EOT &footer; exit; } sub Post2 { if($username eq 'Guest' && $enable_guestposting == 0) { &fatal_error($txt{'165'}); } my( $email, $subject, $icon, $ns, $threadid, $notify, @memberlist, $a, $realname, $membername, $testname, @reserve, @reservecfg, $matchword, $matchcase, $matchuser, $matchname, $namecheck, $reserved, $reservecheck, $newthreadid, @messages, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $start, $pageindex, $tempname ); # If poster is a Guest then evaluate the legality of name and email if(!$settings[2]) { $FORM{'name'} =~ s/\A\s+//; $FORM{'name'} =~ s/\s+\Z//; &fatal_error($txt{'75'}) unless ($FORM{'name'} ne '' && $FORM{'name'} ne '_' && $FORM{'name'} ne ' '); &fatal_error($txt{'568'}) if(length($FORM{'name'}) > 25); &fatal_error("$txt{'76'}") if($FORM{'email'} eq ''); &fatal_error($txt{'243'}) if($FORM{'email'} !~ /^[0-9A-Za-z@\._\-]+$/); &fatal_error("$txt{'500'}") if(($FORM{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($FORM{'email'} !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/)); } # Get the form values $name = $FORM{'name'}; $email = $FORM{'email'}; $subject = $FORM{'subject'}; $message = $FORM{'message'}; $icon = $FORM{'icon'}; $ns = $FORM{'ns'}; $threadid = $FORM{'threadid'}; if( $threadid =~ /\D/ ) { &fatal_error($txt{'337'}); } $notify = $FORM{'notify'}; if($name && $email) { $name =~ s/\&/\&/g; $name =~ s/"/\"/g; $name =~ s/ / \ /g; $name =~ s//>/g; $name =~ s/\|/\|/g; $email =~ s/\&/\&/g; $email =~ s/"/\"/g; $email =~ s/ / \ /g; $email =~ s//>/g; $email =~ s/\|//g; # let's hold it temporarily so we can put the _'s back later $tempname = $name; $name =~ s/\_/ /g; } &fatal_error($txt{'75'}) unless($username || $name); &fatal_error($txt{'76'}) unless($settings[2] || $email); &fatal_error($txt{'77'}) unless($subject && $subject !~ m~\A[\s_.,]+\Z~ ); &fatal_error($txt{'78'}) unless($message); if (length($message)>$MaxMessLen) { &fatal_error($txt{'499'}); } if( $FORM{'waction'} eq 'preview' ) { &Preview; } &spam_protection; if (length($subject) > 50) { $subject = substr($subject,0,50); } $message =~ s/\cM//g; #$message =~ s~(\S{80})(?=\S)~$1\n~g; $message =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $message =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $message =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g; $subject =~ s/\&/\&/g; $subject =~ s/"/\"/g; $subject =~ s/ / \ /g; $subject =~ s//>/g; $subject =~ s/\|/\|/g; $message =~ s/\&/\&/g; $message =~ s/"/\"/g; $message =~ s/ / \ /g; $message =~ s//>/g; $message =~ s/\t/ \  \  \ /g; $message =~ s/\n/
/g; $message =~ s/\|/\|/g; &CheckIcon; if(-e("$datadir/.txt")) { unlink("$datadir/.txt"); } if ($username ne 'Guest') { # If not guest, get name and email. $name = $settings[1]; $email = $settings[2]; } else { # If user is Guest, then make sure the chosen name # is not reserved or used by a member. # fopen(FILE, "$memberdir/memberlist.txt") || &fatal_error("206 $txt{'106'}: $txt{'23'} $memberlist.txt"); @memberlist = ; fclose(FILE); $testname = lc $name; for ($a = 0; $a < @memberlist; $a++) { chomp $memberlist[$a]; $membername = lc $memberlist[$a]; if( fopen(FILE2, "$memberdir/$memberlist[$a].dat") ) { $tmpa = ; $realname = ; fclose(FILE2); chomp $realname; $realname = lc $realname; if ($realname eq $testname || $membername eq $testname) { &fatal_error($txt{'473'}); } } elsif( $testname eq $membername ) { &fatal_error($txt{'473'}); } } fopen(FILE, "$vardir/reserve.txt") || &fatal_error("207 $txt{'106'}: $txt{'23'} reserve.txt"); @reserve = ; fclose(FILE); fopen(FILE, "$vardir/reservecfg.txt") || &fatal_error("208 $txt{'106'}: $txt{'23'} reservecfg.txt"); @reservecfg = ; fclose(FILE); for( $a = 0; $a < @reservecfg; $a++ ) { chomp $reservecfg[$a]; } $matchword = $reservecfg[0] eq 'checked'; $matchcase = $reservecfg[1] eq 'checked'; $matchuser = $reservecfg[2] eq 'checked'; $matchname = $reservecfg[3] eq 'checked'; $namecheck = $matchcase eq 'checked' ? $name : lc $name; foreach $reserved (@reserve) { chomp $reserved; $reservecheck = $matchcase ? $reserved : lc $reserved; if ($matchname) { if ($matchword) { if ($namecheck eq $reservecheck) { &fatal_error("$txt{'244'} $reserved"); } } else { if ($namecheck =~ $reservecheck) { &fatal_error("$txt{'244'} $reserved"); } } } } $name = $tempname; # put the name back (with any _'s) now that we've checked it } # If no thread specified, this is a new thread. # Find a valid random ID for it. if($threadid eq '') { $newthreadid = time; $i=0; if (-e "$datadir/$newthreadid.txt") { while (-e "$datadir/$newthreadid$i.txt") { ++$i; } $newthreadid="$newthreadid$i"; } } else { $newthreadid = ''; } fopen(FILE, "$boardsdir/$currentboard.txt") || &fatal_error("209 $txt{'106'}: $txt{'23'} $boardsdir/$currentboard.txt"); @messages = ; fclose(FILE); if($newthreadid) { # This is a new thread. Save it. fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("210 $txt{'106'}: $txt{'23'} $currentboard.txt"); print FILE qq~$newthreadid|$subject|$name|$email|$date|0|$username|$icon|0\n~; print FILE @messages; fclose(FILE); fopen(FILE, ">$datadir/$newthreadid.txt") || &fatal_error("$txt{'23'} $newthreadid.txt"); print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$ENV{REMOTE_ADDR}|$message|$ns|\n~; fclose(FILE); $mreplies = 0; } else { # This is an old thread. Save it. ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/,$yyThreadLine); if( $mstate == 1 ) { &fatal_error($txt{'90'}); } ++$mreplies; $messages[$yyThreadPosition] = ''; fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("211 $txt{'106'}: $txt{'23'} $currentboard.txt"); print FILE qq~$mnum|$msub|$mname|$memail|$date|$mreplies|$musername|$micon|$mstate\n~; print FILE @messages; fclose(FILE); fopen(FILE, ">>$datadir/$threadid.txt") || &fatal_error("212 $txt{'106'}: $txt{'23'} $threadid.txt"); print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$ENV{REMOTE_ADDR}|$message|$ns|\n~; fclose(FILE); } if($username ne 'Guest') { # Increment post count for the member. $settings[6] =~ s/[\n\r]//g; ++$settings[6]; fopen(FILE, ">$memberdir/$username.dat") || &fatal_error("213 $txt{'106'}: $txt{'23'} $username.dat"); foreach (@settings) { print FILE qq~$_\n~; } fclose(FILE); } # The thread ID, regardless of whether it's a new thread or not. $thread = $newthreadid || $threadid; # Update totals for this board. &doaddition; # Notify any members who have notification turned on for this thread. if(-e("$datadir/$thread.mail")) { &NotifyUsers; } # Mark thread as read for the member. &dumplog($currentboard,$date); # Let's figure out what page number to show $start = 0; $pageindex = int($mreplies / $maxmessagedisplay); $start = $pageindex * $maxmessagedisplay; if( $notify ) { $INFO{'thread'} = $thread; $INFO{'start'} = $start; require "$sourcedir/Notify.pl"; Notify2(); } $yySetLocation = qq~$cgi&action=display&num=$thread&start=$start~; &redirectexit; } sub NotifyUsers { $subject = $FORM{'subject'}; fopen(FILE, "$datadir/$thread.mail") || return 0; @mails = ; fclose(FILE); foreach $curmail (@mails) { chomp $curmail; if ($curmail ne $settings[2]) { &sendmail($curmail,"$txt{'127'}\: $subject","$txt{'128'}, $subject, $txt{'129'} $cgi&action=display&num=$thread\n\n$txt{'130'}"); } } return 1; } sub doshowthread { my( $line, $trash, $tempname, $tempdate, $temppost ); # Load Censor List &LoadCensorList; if (@messages) { print qq~

~; foreach $line (@messages) { #start for each ($trash, $tempname, $trash, $tempdate, $trash, $trash, $trash, $trash, $message, $ns) = split(/\|/,$line); $tempdate = &timeformat($tempdate); foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; } if($enable_ubbc) { &DoUBBC; } print qq~ ~; } print "
$txt{'468'}
$txt{'279'}: $tempname $txt{'280'}: $tempdate
$message
\n"; } else { print ""; } } sub doaddition { fopen(FILE, "+>$boardsdir/$currentboard.poster"); print FILE $name; fclose(FILE); fopen(FILE2, "$datadir/$thread.data"); $tempinfo = ; fclose(FILE2); ($views, $lastposter) = split(/\|/,$tempinfo); my( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($currentboard); ++$messagecount; unless( $FORM{'threadid'} ) { ++$threadcount; } $myname = $username eq 'Guest' ? qq~Guest-$name~ : $username; &BoardCountSet( $currentboard, $threadcount, $messagecount, $date, $myname ); fopen(FILE2, "+>$datadir/$thread.data"); print FILE2 "$views|$myname"; fclose(FILE2); } 1;