############################################################################### #Post.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.3 # # Released: December 2001; Updated April 6, 2003 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2003 YaBB (www.yabbforum.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # # Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com # ############################################################################### $postplver = "1 Gold - SP 1.3"; sub Post { if($username eq 'Guest' && $enable_guestposting == 0) { &fatal_error($txt{'165'}); } if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } my( $subtitle, $x, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $msubject, $mattach, $mip, $mmessage, $mns, $quotestart); my $quotemsg = $INFO{'quote'}; $threadid = $INFO{'num'}; ($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); $pollthread = 0; $polltxt{'1a'} =~ tr/+/ /; $polltxt{'2a'} =~ tr/+/ /; if ($INFO{'title'} eq $polltxt{'1a'}) { $pollthread = 1; } elsif ($INFO{'title'} eq $polltxt{'2a'}) { $pollthread = 2; } if ($pollthread == 2 && $useraddpoll == 0) { &fatal_error($txt{'1'}); } $notification = ! $enable_notification || $username eq 'Guest' ? '' : <<"~;"; $txt{'131'}: $txt{'750'} ~; $name_field = $realname eq '' ? qq~ $txt{'44'}: ~ : qq~~; $email_field = $realemail eq '' ? qq~ $txt{'69'}: ~ : qq~~; $sub = ""; $settofield="subject"; 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]); $message=$mmessage; $message =~ s~
~\n~g; $message =~ s~\n{0,1}\[quote([^\]]*)\](.*?)\[/quote\]\n{0,1}~\n~isg; $message =~ s~\n*\[/*quote([^\]]*)\]\n*~~ig; $mname ||= $musername || $txt{'470'}; $quotestart = int( $quotemsg / $maxmessagedisplay ) * $maxmessagedisplay; $message = qq~[quote author=$mname link=board=$currentboard;num=$threadid;start=$quotestart#$quotemsg date=$mdate\]$message\[/quote\]\n~; $msubject =~ s/\bre:\s+//ig; if ($mns eq "NS") {$nscheck="checked";} } else { ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattache, $mip, $mmessage, $mns) = split(/\|/,$messages[0]); $msubject =~ s/\bre:\s+//ig; } $sub = "Re: $msubject"; $settofield="message"; } if ($pollthread && $username eq "Guest") {$guest_vote = 1;} if ($pollthread == 2) { $settofield="question"; $sub = "$msubject"; } else { if (!$enable_notification || $username eq 'Guest') {$notification = ""} else { $notification = qq~ $txt{'131'}: $txt{'750'} ~;} } if(!$sub) { $subtitle = "$txt{'33'}"; } else { $subtitle = "$sub"; } $yymain .= qq~
   $mbname
   $cat
   $boardname
   $INFO{'title'} ( $subtitle )
~; $submittxt = "$txt{'105'}"; $destination = "post2"; $icon = "xx"; $is_preview = 0; $post = "post"; $preview = "preview"; $yytitle = "$INFO{'title'}"; &Postpage; if ($pollthread != 2) { &doshowthread; } &template; exit; } sub Postpage { my $extra; if ($is_preview) {$txt{'507'}=$txt{'771'};} $message =~ s~<\/~\<\;/~isg; if($post eq "imsend") { if(!$INFO{'to'}) { $INFO{'to'} = $FORM{'to'};} if($INFO{'to'}) {$settofield="message";} else {$settofield="to";} $idinfo = "$INFO{'id'}"; if($action = "imsend") { $write_outbox = qq~$imtxt{'84'} $imtxt{'85'}~; } if(!$INFO{'adminim'}) { $extra = qq~ $txt{'150'} $txt{'748'} ~; } else { $extra = qq~$adminim~; } } else { $extra = qq~ $txt{'71'}: ~; if ($realname eq '' && $threadid ne '') {$settofield="name";} } if($INFO{'adminim'} || $INFO{'action'} eq "imgroups") { $destination = "imgroups"; } $yymain .= qq~ ~; if ($pollthread != 2 || ($pollthread == 2 && $username eq 'Guest')) { $yymain .= qq~ ~; } ## [Poll Mod Options] ## if ($pollthread) { $maxpq ||= 60; $maxpo ||= 50; $maxpc ||= 0; $numpolloptions ||= 8; if ($guest_vote) {$gvchecked = " checked";} if ($hide_results) {$hrchecked = " checked";} if ($multi_choice) {$mcchecked = " checked";} $yymain .= qq~ ~; } if ($pollthread != 2) { # if not adding a poll to an existing thread, display standard post page inputs ## [/Poll Mod Options] ## ### Begin Enable HTML Mod if ($post eq "post" || $post eq "postmodify" || $post eq "imsend") { $message_backup = $message; # since $message is no local variable, it often gets overwritten accidently somehwere (couldn't find out where) $enable_html = HTML_allow($username); $message = $message_backup; if ($enable_html == 1) { if ($message =~ /\#enable_html/isg || $FORM{enable_html} eq "1") { $enable_html_check = ' checked'; $message =~ s/\#enable_html//isg; } else { $enable_html_check = '' } $enable_html_checkbox = qq~~; } else { $enable_html_checkbox = ''; } } ### End Enable HTML Mod if($enable_ubbc && $showyabbcbutt) { $yymain .= qq~ ~; } $yymain .= qq~
$yytitle
~; if ($pollthread == 2 ) {$extra = "";} else { $yymain .= qq~ ~; } $yymain .= qq~ $name_field $email_field $extra
$txt{'70'}:
~; if ($maxpc > 0) { $yymain .= qq~ ~; } $yymain .= qq~
$polltxt{'6'}:
  ~; for(my $i = 1; $i <= $numpolloptions; $i++) { $yymain .= qq~ ~; } $yymain .= qq~
  $polltxt{'7'} $i:  
$polltxt{'59'}:
$polltxt{'32'} $polltxt{'54'}
$polltxt{'26'} $polltxt{'55'}
$polltxt{'58'} $polltxt{'56'}
$txt_allow_html_mod{'1'}: $txt_allow_html_mod{'5'}
~; } else { $yymain .= qq~
$txt{'252'}:
 
~; } ### Add More Smilies 3.0 - Smiley List ### if ($SmilieURL[0] eq "") {&LoadSmilies;} $showmore = ""; $smilie_list = ""; $smilie_more = ""; $smilie_block = ""; $smilie_url_array = ""; for( my $i = 0; $i < @SmilieURL; $i++ ) { if ($SmilieURL[$i] =~ /\//i) {$tmpurl = $SmilieURL[$i];} else {$tmpurl = qq~$smiliesurl/$SmilieURL[$i]~;} ($tmpCode, $dummy) = split (/\s+/, $SmilieCode[$i]); $tmpCode =~ s/'/'/g; if ($SmilieOption[$i] % 2 == 1) { $smilie_list .= qq~ document.write("$SmilieDescription[$i] ");~; } if (($SmilieOption[$i] / 2) % 2 == 1) {$smilie_block .= qq~ document.write("");~; $smilie_url_array .= qq~"$tmpurl", ~; } if (($SmilieOption[$i] / 4) % 2 == 1) {$showmore = 1;} } $smilie_url_array .= qq~""~; if ($showmore == 1 && ($show_smilie_block != 1 || $smilie_block eq "")) {$smilie_more = qq~ document.write('$smi_txt{'8'}');~; } if ($smilie_list ne "" || $smilie_more ne "" ) {$yymain .= qq~ ~; } ### Add More Smilies 3.0 - Smiley List ### $yymain .= qq~ ~; $offset++; } if (($counter % $wincolumn + $offset) % 2 == 0) {$smiliescolor = qq~class="windowbg2" bgcolor="$color{'windowbg2'}"~;} else {$smiliescolor = qq~class="windowbg" bgcolor="$color{'windowbg'}"~;} if ($SmilieURL[$i]=~ /\//i) {$tmpurl = $SmilieURL[$i];} else {$tmpurl = qq~$smiliesurl/$SmilieURL[$i]~;} ($tmpCode, $dummy) = split (/\s+/, $SmilieCode[$i]); $tmpCode =~ s/'/'/g; if (($SmilieOption[$i] / 2) % 2 == 1) { $smilieslist .= qq~ ~; $counter++; } $i++; } while ($counter % $wincolumn != 0) { if (($counter % $wincolumn + $offset) % 2 == 0) {$smiliescolor = qq~class="windowbg2" bgcolor="$color{'windowbg2'}"~;} else {$smiliescolor = qq~class="windowbg" bgcolor="$color{'windowbg'}"~;} $smilieslist .= qq~ \n~; $counter++; } $yymain .= qq~
$txt{'297'}:
~; ### BEGIN Add More Smilies 3.0 - Side table add in by Flicker ### if ($show_smilie_sidetable == 1 && $show_smilie_block == 0) { $wincolumn = "3"; # Number of columns in More Smilies pop-up window. if ($SmilieURL[0] eq "") {&LoadSmilies;} $i = 0; $offset = 0; $counter = 0; $smilieslist = ""; $colwidth = int(100 / $wincolumn); while($SmilieURL[$i]) { if ($counter % $wincolumn == 0 && $counter !=0) { $counter = 0; $smilieslist .= qq~
 
$smilieslist
~; } ### END Add More Smilies 3.0 - Side table add in by Flicker ### ### Add More Smilies 3.0 - Smiley Block ### if ($show_smilie_block == 1 && $smilie_block ne "" && $show_smilie_sidetable ==0) {$yymain .= qq~


~; } ### Add More Smilies 3.0 - Smiley Block ### $yymain .= qq~

$enable_html_checkbox $notification $lastmod $write_outbox
$txt{'276'}:
$txt{'277'}
$txt{'329'}
~; unless ($pollthread == 2) {$yymain .= qq~ ~;} unless ($is_preview){$yymain .= qq~ ~;} $yymain.=qq~
~; } sub Preview { $poll_question = $FORM{'question'}; $numpolloptions ||= 8; for(my $i = 1; $i <= $numpolloptions; $i++) {$options[$i] = $FORM{"option$i"};} $guest_vote = $FORM{'guest_vote'}; $hide_results = $FORM{'hide_results'}; $multi_choice = $FORM{'multi_choice'}; $poll_comment = $FORM{'poll_comment'}; $pollthread = $FORM{'pollthread'} || 0; $name = $FORM{'name'}; $email = $FORM{'email'}; $sub = $FORM{'subject'}; $FORM{'message'} =~ s~\r~~g; $mess = $FORM{'message'}; $message = $FORM{'message'}; $icon = $FORM{'icon'}; $ns = $FORM{'ns'}; $threadid = $FORM{'threadid'}; $notify = $FORM{'notify'}; $postid = $FORM{'postid'}; if (length($sub) > 50) { $sub = substr($sub,0,50); } $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; &ToHTML($message); $message =~ s/\t/ \  \  \ /g; $message =~ s/\n/
/g; &CheckIcon; if($icon eq "xx") { $ic1 = " selected"; } elsif($icon eq "thumbup") { $ic2 = " selected"; } elsif($icon eq "thumbdown") { $ic3 = " selected"; } elsif($icon eq "exclamation") { $ic4 = " selected"; } elsif($icon eq "question") { $ic5 = " selected"; } elsif($icon eq "lamp") { $ic6 = " selected"; } elsif($icon eq "smiley") { $ic7 = " selected"; } elsif($icon eq "angry") { $ic8 = " selected"; } elsif($icon eq "cheesy") { $ic9 = " selected"; } elsif($icon eq "laugh") { $ic10 = " selected"; } elsif($icon eq "sad") { $ic11 = " selected"; } elsif($icon eq "wink") { $ic12 = " selected"; } $name_field = $realname eq '' ? qq~ $txt{'44'}: ~ : qq~~; $email_field = $realemail eq '' ? qq~ $txt{'69'}: ~ : qq~~; if ($FORM{'notify'} eq "x") {$notify = " checked";} if ($FORM{'ns'} eq 'NS') {$nscheck = " checked";} 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"); } } } } } ### Begin Enable HTML Mod $html_username = $username; if($FORM{enable_html} eq "1") { $message .= qq~#enable_html~; } if ($message =~ /\#enable_html/isg) { $message_backup = $message; # since $message is no local variable, it often gets overwritten accidently somehwere (couldn't find out where) $enable_html = HTML_allow($html_username); $message = $message_backup; if ($enable_html == 1) { $message =~ s/\#enable_html//isg; $message =~ s/
/\n/ig; &FromHTML($message); } } else { $enable_html = 0; } if ($enable_html != 1) { ################ Media Player mod if ($username ne 'Guest') { $mediausername = $settings[1]; } else{ $mediausername = $FORM{'name'}; } ################ Media Player mod end &wrap; $displayname = $settings[1]; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; } ### End Enable HTML Mod if( $FORM{'previewmodify'} ) { $submittxt = "$txt{'10'}"; $is_preview = 1; $post = "postmodify"; $preview = "previewmodify"; $destination = 'modify2'; $submittxt = $txt{'10'}; } elsif( $FORM{'previewim'} ) { $submittxt = "$txt{'148'}"; $destination = "imsend2"; $is_preview = 1; $post = "imsend"; $preview = "previewim"; $submittxt = $txt{'148'}; } else { $notification = ! $enable_notification || $username eq 'Guest' ? '' : <<"~;"; $txt{'131'}: $txt{'750'} ~; $destination = 'post2'; $submittxt = $txt{'105'}; $is_preview = 1; $post = "post"; $preview = "preview"; } if($INFO{'action'} eq "imgroups") { $destination = "imgroups"; } $csubject = $sub; &LoadCensorList; # Load Censor List $csubject =~ s/\Q$tmpa\E/$tmpb/gi; $message =~ s/\Q$tmpa\E/$tmpb/gi; $yymain .= qq~
$csubject

$message


~; $message = $mess; $yytitle = "$txt{'507'} - $csubject"; $settofield="message"; &Postpage; &template; exit; } sub Post2 { if($username eq 'Guest' && $enable_guestposting == 0) { &fatal_error($txt{'165'}); } my( $email, $subject, $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{'240'} $txt{'69'} $txt{'241'}") if($FORM{'email'} !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/); &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) { &ToHTML($name); $email =~ s/\|//g; &ToHTML($email); $tempname = $name; # hold it temporarily so we can put the _'s back later $name =~ s/\_/ /g; } &fatal_error($txt{'75'}) unless($username || $name); &fatal_error($txt{'76'}) unless($settings[2] || $email); $pollthread = $FORM{'pollthread'} || 0; if ($pollthread != 2) { # If user is NOT adding a Poll to an existing thread &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{'preview'} ) { &Preview; } &spam_protection; if (length($subject) > 50) { $subject = substr($subject,0,50); } $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\n$2~g; &ToHTML($message); $message =~ s~\t~ \  \  \ ~g; $message =~ s~\n~
~g; &CheckIcon; ### Begin Enable HTML Mod $message =~ s/\#enable_html//isg; if($FORM{enable_html} eq "1") { $message_backup = $message; # since $message is no local variable, it often gets overwritten accidently somehwere (couldn't find out where) $enable_html = HTML_allow($username); $message = $message_backup; if ($enable_html == 1) { $message .= qq~#enable_html~; } } ### End Enable HTML Mod if(-e("$datadir/.txt")) { unlink("$datadir/.txt"); } } # end if 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 } ## [Poll Mod] ## my @poll_data; if ($pollthread) { $maxpq ||= 60; $maxpo ||= 50; $maxpc ||= 0; $numpolloptions ||= 8; $numcount = 0; if ( length($FORM{"question"} ) > $maxpq) { &fatal_error("$polltxt{'40'} $polltxt{'34a'} $maxpq $polltxt{'34b'} $polltxt{'36'}"); } &ToHTML($FORM{"question"}); $guest_vote = $FORM{'guest_vote'} || 0; $hide_results = $FORM{'hide_results'} || 0; $multi_choice = $FORM{'multi_choice'} || 0; $poll_comment = $FORM{'poll_comment'} || ""; if ( length($poll_comment ) > $maxpc) { &fatal_error("$polltxt{'57'} $polltxt{'34a'} $maxpc $polltxt{'34b'} $polltxt{'36'}"); } &ToHTML($poll_comment); $poll_comment =~ s~\n~
~g; $poll_comment =~ s~\r~~g; push @poll_data, qq~$FORM{"question"}|0|$username|$name|$email|$date|$guest_vote|$hide_results|$multi_choice|||$poll_comment\n~; for ($i = 1; $i <= $numpolloptions; $i++){ if ($FORM{"option$i"}) { if (length($FORM{"option$i"}) > $maxpo) { &fatal_error("$polltxt{'7'} $i $polltxt{'34a'} $maxpo $polltxt{'34b'} $polltxt{'36'}"); } &ToHTML($FORM{"option$i"}); $numcount++; push @poll_data, qq~0|$FORM{"option$i"}\n~; } } unless ($FORM{"question"}) { &fatal_error("$polltxt{'37'}"); } if ($numcount < 2) { &fatal_error("$polltxt{'38'}"); } } ## [/Poll Mod] ## # 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 = ''; } if($newthreadid) { # This is a new thread. Save it. fopen(FILE, "$boardsdir/$currentboard.dat") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.dat"); @postcheck = ; fclose(FILE); chomp($postcheck[5]); if ($postcheck[5] ne "1") { # 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); } fopen(FILE, "+<$boardsdir/$currentboard.txt", 1) || &fatal_error("210 $txt{'106'}: $txt{'23'} $currentboard.txt"); seek FILE, 0, 0; my @buffer = ; truncate FILE, 0; seek FILE, 0, 0; print FILE qq~$newthreadid|$subject|$name|$email|$date|0|$username|$icon|0\n~; print FILE @buffer; fclose(FILE); fopen(FILE, ">$datadir/$newthreadid.txt") || &fatal_error("$txt{'23'} $newthreadid.txt"); print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|\n~; fclose(FILE); $mreplies = 0; if ($pollthread) { # Save Poll data for new thread fopen (POLL, ">$datadir/$newthreadid.poll"); print POLL @poll_data; fclose (POLL); } } else { # This is an old thread. Save it. fopen(FILE, "$boardsdir/$currentboard.dat") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.dat"); @postcheck = ; fclose(FILE); chomp($postcheck[4]); if ($postcheck[4] ne "1") { # 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); } if ($pollthread) { # Save new Poll data fopen (POLL, ">$datadir/$threadid.poll"); print POLL @poll_data; fclose (POLL); $yySetLocation = qq~$cgi;action=display;num=$threadid~; &redirectexit; } else { # or save new reply data ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/,$yyThreadLine); if( $mstate == 1 ) { &fatal_error($txt{'90'}); } ++$mreplies; fopen(FILE, "+<$boardsdir/$currentboard.txt", 1) || &fatal_error("211 $txt{'106'}: $txt{'23'} $currentboard.txt"); seek FILE, 0, 0; my @buffer = ; truncate FILE, 0; for ($a = 0; $a < @buffer; $a++) { if ( $buffer[$a] =~ m~\A$mnum\|~o ) { $buffer[$a] = ""; last; } } seek FILE, 0, 0; print FILE qq~$mnum|$msub|$mname|$memail|$date|$mreplies|$musername|$micon|$mstate\n~; print FILE @buffer; 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|$user_ip|$message|$ns|\n~; fclose(FILE); } # end else } if($username ne 'Guest') { # Outtaken because 0 counter mod by dOCda S! &WriteLastOnline($username, "x", $date, "x"); } # The thread ID, regardless of whether it's a new thread or not. $thread = $newthreadid || $threadid; # Update totals for this board. &doaddition; # 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; # Notify any members who have notification turned on for this thread. if(-e("$datadir/$thread.mail")) { &NotifyUsers; } if($notify) { $INFO{'thread'} = $thread; $INFO{'start'} = $start; require "$sourcedir/Notify.pl"; &Notify2; } $yySetLocation = qq~$cgi;action=display;num=$thread;start=$start#$mreplies~; &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 ); my( $html_username, $lastmoduser, $enable_html ); &LoadCensorList; # Load Censor List if (@messages) { $yymain .= qq~

~; foreach $line (@messages) { #start for each ($trash, $tempname, $trash, $tempdate, $html_username, $trash, $trash, $trash, $message, $ns, $trash, $lastmoduser) = split(/\|/,$line); $tempdate = &timeformat($tempdate); foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; } my @words = split(/\s/,$message); ################ Media Player mod $mediausername = $tempname; ################ Media Player mod end ### Begin Enable HTML Mod if ($message =~ /\#enable_html/isg) { $lastmoduser =~ s~\n~~g; if ($lastmoduser ne $html_username && $lastmoduser ne '') { $html_username = $lastmoduser; } $message_backup = $message; # since $message is no local variable, it often gets overwritten accidently somehwere (couldn't find out where) $enable_html = HTML_allow($html_username); $message = $message_backup; if ($enable_html == 1) { $message =~ s/\#enable_html//isg; $message =~ s/
/\n/ig; &FromHTML($message); } } else { $enable_html = 0; } if ($enable_html != 1) { &wrap; $displayname = $tempname; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; } ### End Enable HTML Mod $yymain .= qq~ ~; } $yymain .= "
$txt{'468'}
$txt{'279'}: $tempname $txt{'280'}: $tempdate
$message
\n"; } else { $yymain .= ""; } } sub doaddition { 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;