############################################################################### # Post.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.1 # # Released: December 2001; Updated March 22, 2002 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2002 Xnull (www.xnull.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $postplver = "1 Gold - SP 1.1"; sub Post { if($username eq 'Guest' && $enable_guestposting == 0) { &fatal_error($txt{'165'}); } if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } my($filetype_info, $filesize_info); 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); $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; ### hide mod if( $message =~ /\[hide\]/) { $message =~ s/\[hide\](.+?)\[\/hide\]/\[HIDDEN - YOU MUST REPLY TO SEE THIS TEXT!]/g; } ### hide mod $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(!$sub) { $subtitle = "$txt{'33'}"; } else { $subtitle = "$sub"; } $yymain .= qq~
   $mbname
   $cat
   $boardname
   $INFO{'title'} ( $subtitle )
~; $submittxt = "$txt{'105'}"; $destination = "post2"; $icon = "xx"; $waction = "post"; $post = "post"; $preview = "preview"; $yytitle = "$INFO{'title'}"; &Postpage; &doshowthread; &template; exit; } sub Postpage { my $extra; my($filetype_info, $filesize_info); $filetype_info = $checkext == 1 ? qq~$fatxt{'2'} @ext~ : qq~$fatxt{'2'} $fatxt{'4'}~; $filesize_info = $limit != 0 ? qq~$fatxt{'3'} $limit KB~ : qq~$fatxt{'3'} $fatxt{'5'}~; if ($FORM{'waction'} =~ /preview/) {$txt{'507'}=$txt{'771'};} if($waction eq "imsend") { if(!$INFO{'to'}) { $INFO{'to'} = $FORM{'to'};} if($INFO{'to'}) {$settofield="message";} else {$settofield="to";} $idinfo = "$INFO{'id'}"; $extra = qq~ $txt{'150'} $txt{'748'} ~; } else { $extra = qq~ $txt{'71'}: ~; if ($realname eq '' && $threadid ne '') {$settofield="name";} } $yymain .= qq~ ~; if($enable_ubbc && $showyabbcbutt) { $yymain .= qq~ ~ : qq~~; $email_field = $realemail eq '' ? qq~ ~ : 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"); } } } } } &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; if( $FORM{'waction'} eq 'previewmodify' ) { $submittxt = "$txt{'10'}"; $waction = "postmodify"; $post = "postmodify"; $preview = "previewmodify"; $destination = 'modify2'; $submittxt = $txt{'10'}; } elsif( $FORM{'waction'} eq 'previewim' ) { $submittxt = "$txt{'148'}"; $destination = "imsend2"; $waction = "imsend"; $post = "imsend"; $preview = "previewim"; $submittxt = $txt{'148'}; } else { $notification = ! $enable_notification || $username eq 'Guest' ? '' : <<"~;"; ~; $destination = 'post2'; $submittxt = $txt{'105'}; $waction = "post"; $post = "post"; $preview = "preview"; } $csubject = $sub; &LoadCensorList; # Load Censor List $csubject =~ s/\Q$tmpa\E/$tmpb/gi; $message =~ s/\Q$tmpa\E/$tmpb/gi; $yymain .= qq~
$yytitle
$name_field $email_field $extra
$txt{'70'}:
~; } else { $yymain .= qq~
$txt{'252'}:
~; } $yymain .= qq~ ~; $messagextra = ""; if (-e("$boardsdir/$currentboard.xtra")) {&ToHTML($xtraheading);require "$boardsdir/$currentboard.xtra";} if ($usextra eq "1" && ($action eq 'post' || $action eq 'post2')) { if ($xtrareply eq "1" || ($xtrareply eq "0" && $threadid eq '')) { if ($xtraopt ne "") { @xoptions = split(/\|/, $xtraopt); $messagextra .= qq~\n~; $messagextra .= qq~\n~; $messagextra .= qq~\n~; } if ($xtrafield ne "") { @xfields = split(/\|/, $xtrafield); $i = 0; foreach $xtmp (@xfields) { $messagextra .= qq~\n~; $messagextra .= qq~\n~; $messagextra .= qq~\n~; $messagextra .= qq~\n~; $i++; } } } } $yymain .= qq~ $messagextra ~; # File Attachment's Browse Box Code if ($allowattach == 1 && ($action eq 'post' || $action eq 'post2') && (($allowguestattach == 0 && $username ne 'Guest') || $allowguestattach == 1)) { $yymain .= qq~ ~; if( ($FORM{'waction'} =~ 'preview') && ($FORM{'file'}) ) { $yymain .= qq~ ~; } } # /File Attachment's Browse Box Code $yymain .= qq~
$txt{'297'}: ~; if ($detach == 1){ $yymain .= qq~ More smilies ~; } $yymain .= qq~
$xtraheading:
$xtmp:
$txt{'72'}:
$fatxt{'6'}
$filetype_info
$filesize_info
$fatxt{'7'}
$notification $lastmod
$txt{'276'}:

$txt{'277'}

$txt{'329'}
~; unless ($FORM{'waction'} =~ /preview/){$yymain .= qq~ ~;} $yymain.=qq~
~; } sub Preview { $xmessage = ""; if (-e("$boardsdir/$currentboard.xtra")) { require "$boardsdir/$currentboard.xtra"; &FromHTML($xtraheading); $i = 0; @xoptions = split(/\|/, $xtraopt); foreach $xtmp (@xoptions) { &FromHTML($xtmp); $xtraoption = $FORM{'xtraoption'}; if ($xtraopt ne "" && $xtraoption eq "option$i") { if ($xtraformat eq "1") {$xmessage .= qq~\[center\]\[b\]\[size=3\]$xtmp\[\/size\]\[\/b\]\[\/center\]\n~;} else {$xmessage .= qq~$xtraheading: $xtmp\n~;} } $i++; } if ($xtrafield ne "") { $i = 0; @xfields = split(/\|/, $xtrafield); if ($xtraformat eq "1") {$xmessage .= qq~\[table\]~;} foreach $xtmp (@xfields) { &FromHTML($xtmp); $field[$i] = $FORM{"field$i"}; if ($xtrahide eq "0" || $xtrahide eq "1" && $field[$i] ne "") { if ($xtraformat eq "1") {$xmessage .= qq~\[tr\]\[td\]\[size=2\]$xtmp: \[\/size\]\[\/td\]\[td\]\[b\]\[size=2\]$field[$i] \[\/size\]\[\/b\]\[\/td\]\[\/tr\]~;} else {$xmessage .= qq~$xtmp: $field[$i]\n~;} } $i++; } if ($xtraformat eq "1") {$xmessage .= qq~\[\/table\]\n~;} } $xmessage .= qq~\n\n~; } &clear_temp; $name = $FORM{'name'}; $email = $FORM{'email'}; $sub = $FORM{'subject'}; $mess = $FORM{'message'}; $message = $xmessage.$FORM{'message'}; $icon = $FORM{'icon'}; $ns = $FORM{'ns'}; $threadid = $FORM{'threadid'}; $notify = $FORM{'notify'}; $postid = $FORM{'postid'}; if (length($subject) > 50) { $sub = substr($subject,0,50); } &ToHTML($sub); $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'}:
$txt{'69'}:
$txt{'131'}: $txt{'750'}
$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'} !~ /^[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'}; $xmessage = ""; $xblock = ""; $xsimple = ""; $xheader = ""; if (-e("$boardsdir/$currentboard.xtra")) {require "$boardsdir/$currentboard.xtra";} if ($usextra eq "1") { my ($xmessage, $xheader, $xblock, $xsimple); &FromHTML($xtraheading); @xoptions = split(/\|/, $xtraopt); $xtraoption = $FORM{'xtraoption'}; $xtmp = $xoptions[$xtraoption] &FromHTML($xtmp); if ($xtraopt ne "") { $xtmp = $xoptions[$xtraoption]; &FromHTML($xtmp); if ($xtraformat eq "0") {$xheader .= qq~$xtraheading: $xtmp~;} else {$xheader .= qq~\[center\] \[b\]\[size=3\] $xtmp \[\/size\]\[\/b\] \[\/center\]~;} } if ($xtrafield ne "") { $i = 0; @xfields = split(/\|/, $xtrafield); foreach $xtmp (@xfields) { &FromHTML($xtmp); $field[$i] = $FORM{"field$i"}; if ($xtrahide eq "0" || $xtrahide eq "1" && $field[$i] ne "") { $xblock .= qq~\[tr\]\[td\]\[size=2\] $xtmp: \[\/size\]\[\/td\]\[td\]\[b\]\[size=2\] $field[$i] \[\/size\]\[\/b\]\[\/td\]\[\/tr\]~; if ($xsimple ne "") {$xsimple .= qq~\n~;} $xsimple .= qq~$xtmp: $field[$i]~; } $i++; } if ($xblock ne "") {$xblock = qq~\[table\] $xblock \[tr\]\[td\] \[\/td\]\[td\] \[\/td\]\[\/tr\] [\/table\]~;} } if ($xtraformat eq "1") { # Advanced format if ($xheader ne "") {$xheader .= qq~\n~;} $xmessage = qq~$xheader$xblock~; } elsif ($xtraformat eq "2" && $xtratemplate ne "") { # Custom Format $xmessage = qq~$xtratemplate~; $xmessage =~ s/\|/\n/g; &FromHTML($xmessage); if ($xtrafield ne "") { $xtmp = $xoptions[$xtraoption]; &FromHTML($xtmp); $xmessage =~ s/\[caption0\]/$xtraheading/gi; $xmessage =~ s/\[field0\]/$xtmp/gi; $i = 0; @xfields = split(/\|/, $xtrafield); foreach $xtmp (@xfields) { &FromHTML($xtmp); $j = $i + 1; if ($xtrahide eq "0" || $xtrahide eq "1" && $field[$i] ne "") { $xmessage =~ s/\[caption$j\]/$xtmp/gi; $xmessage =~ s/\[field$j\]/$field[$i]/gi; } else { $xmessage =~ s/\[caption$j\]//gi; $xmessage =~ s/\[field$j\]//gi; } $i++; } $xmessage =~ s/\[block\]/$xblock/gi; $xmessage =~ s/\[simple\]/$xsimple/gi; $xmessage =~ s/\[header\]/$xheader/gi; } } else { # Simple format if ($xheader ne "") {$xheader .= qq~\n~;} $xmessage = qq~$xheader$xsimple~; } if ($xmessage ne "") {$xmessage .= qq~\n\n~;} $message = $xmessage.$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); &fatal_error($txt{'77'}) unless($subject && $subject !~ m~\A[\s_.,]+\Z~); $xmessage = ""; $xblock = ""; $xsimple = ""; $xheader = ""; if (-e("$boardsdir/$currentboard.xtra")) {require "$boardsdir/$currentboard.xtra";} if ($usextra eq "1") { my ($xmessage, $xheader, $xblock, $xsimple); &FromHTML($xtraheading); @xoptions = split(/\|/, $xtraopt); $xtraoption = $FORM{'xtraoption'}; $xtmp = $xoptions[$xtraoption] &FromHTML($xtmp); if ($xtraopt ne "") { $xtmp = $xoptions[$xtraoption]; &FromHTML($xtmp); if ($xtraformat eq "0") {$xheader .= qq~$xtraheading: $xtmp~;} else {$xheader .= qq~\[center\] \[b\]\[size=3\] $xtmp \[\/size\]\[\/b\] \[\/center\]~;} } if ($xtrafield ne "") { $i = 0; @xfields = split(/\|/, $xtrafield); foreach $xtmp (@xfields) { &FromHTML($xtmp); $field[$i] = $FORM{"field$i"}; if ($xtrahide eq "0" || $xtrahide eq "1" && $field[$i] ne "") { $xblock .= qq~\[tr\]\[td\]\[size=2\] $xtmp: \[\/size\]\[\/td\]\[td\]\[b\]\[size=2\] $field[$i] \[\/size\]\[\/b\]\[\/td\]\[\/tr\]~; if ($xsimple ne "") {$xsimple .= qq~\n~;} $xsimple .= qq~$xtmp: $field[$i]~; } $i++; } if ($xblock ne "") {$xblock = qq~\[table\] $xblock \[tr\]\[td\] \[\/td\]\[td\] \[\/td\]\[\/tr\] [\/table\]~;} } if ($xtraformat eq "1") { # Advanced format if ($xheader ne "") {$xheader .= qq~\n~;} $xmessage = qq~$xheader$xblock~; } elsif ($xtraformat eq "2" && $xtratemplate ne "") { # Custom Format $xmessage = qq~$xtratemplate~; $xmessage =~ s/\|/\n/g; &FromHTML($xmessage); if ($xtrafield ne "") { $xtmp = $xoptions[$xtraoption]; &FromHTML($xtmp); $xmessage =~ s/\[caption0\]/$xtraheading/gi; $xmessage =~ s/\[field0\]/$xtmp/gi; $i = 0; @xfields = split(/\|/, $xtrafield); foreach $xtmp (@xfields) { &FromHTML($xtmp); $j = $i + 1; if ($xtrahide eq "0" || $xtrahide eq "1" && $field[$i] ne "") { $xmessage =~ s/\[caption$j\]/$xtmp/gi; $xmessage =~ s/\[field$j\]/$field[$i]/gi; } else { $xmessage =~ s/\[caption$j\]//gi; $xmessage =~ s/\[field$j\]//gi; } $i++; } $xmessage =~ s/\[block\]/$xblock/gi; $xmessage =~ s/\[simple\]/$xsimple/gi; $xmessage =~ s/\[header\]/$xheader/gi; } } else { # Simple format if ($xheader ne "") {$xheader .= qq~\n~;} $xmessage = qq~$xheader$xsimple~; } if ($xmessage ne "") {$xmessage .= qq~\n\n~;} $message = $xmessage.$message; } if (length($message)>$MaxMessLen) { &fatal_error($txt{'499'}); } if( $FORM{'waction'} =~ '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($subject); &ToHTML($message); $message =~ s~\t~ \  \  \ ~g; $message =~ s~\n~
~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 } ###################################### ## DaveB's File Attachment Mod v2.3 ## ###################################### if ($FORM{'file'}) { if ($FORM{'waction'} ne 'post') { &write_error("$fatxt{'49'}"); } $mylimit = 1024 * $limit; $mydirlimit = 1024 * $dirlimit; $file = $filename; $file =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/; $file =~ s/[#%+,\/:?"<>'|@^]//g; #edit in between [ ] to include characters you dont want to allow in filenames (dont put a . there or you wont be able to get any file extensions). $file =~ s/ /_/g; #replaces spaces in filenames with a "_" character. opendir(AMD, $upload_dir) || &write_error("$fatxt{'19'} $upload_dir."); @dirlist = readdir(AMD); closedir(AMD); foreach $dirlist(@dirlist) { if ($dirlist eq $file) { &write_error("$fatxt{'8'}"); } } if ($checkext == 0) { $match = 1; } else { foreach $ext (@ext){ chomp ($ext); if (grep /$ext$/i,$file){$match=1; last;} } } if ($match) { if ($allowattach == 1 && (($allowguestattach == 0 && $username ne 'Guest') || $allowguestattach == 1)) { $upload_okay = 1; } } else { &write_error("$fatxt{'20'} @ext"); } if ($mydirlimit > 0) { &dirstats; } $filesize = $ENV{'CONTENT_LENGTH'} - $postsize; $filesizekb = int ($filesize/1024); if ($filesize > $mylimit && $mylimit != 0) { $filesizediff = $filesizekb - $limit; if ($filesizediff == 1) { $sizevar = "kilobyte"; } else { $sizevar = "kilobytes"; } &write_error("$fatxt{'21'} $filesizediff $sizevar $fatxt{'21b'}"); } elsif ($filesize > $spaceleft && $mydirlimit != 0) { $filesizediff = $filesizekb - $kbspaceleft; if ($filesizediff == 1) { $sizevar = "kilobyte"; } else { $sizevar = "kilobytes"; } &write_error("$fatxt{'22'} $filesizediff $sizevar $fatxt{'22b'}"); } $write_file = "$upload_dir/$file"; $save_file = "$http_dir/$file"; } ####################################### ## /DaveB's File Attachment Mod v2.3 ## ####################################### # 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.txt") || &write_error("210 $txt{'106'}: $txt{'23'} $currentboard.txt"); seek FILE, 0, 0; fopen(TEMP, "+>$boardsdir/$currentboard.txt.temp") || &fatal_error("209 $txt{'106'}: $txt{'23'} $boardsdir/$currentboard.txt.temp"); while( read(FILE,$buffer,1024) ) { print TEMP $buffer; } seek TEMP, 0, 0; truncate FILE, 0; seek FILE, 0, 0; print FILE qq~$newthreadid|$subject|$name|$email|$date|0|$username|$icon|0\n~; while( read(TEMP,$buffer,1024) ) { print FILE $buffer; } fclose(TEMP); if (-e "$boardsdir/$currentboard.txt.temp") { unlink("$boardsdir/$currentboard.txt.temp"); } fclose(FILE); fopen(FILE, ">$datadir/$newthreadid.txt") || &write_error("$txt{'23'} $newthreadid.txt"); print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$save_file|$file\n~; fclose(FILE); $mreplies = 0; if ($file) { fopen(AMP, ">>$vardir/attachments.txt") || &write_error("209 $txt{'106'}: $txt{'23'} $vardir/attachments.txt"); print AMP qq~$newthreadid|$mreplies|$subject|$name|$currentboard|$filesizekb|$date|$file\n~; fclose(AMP); } } 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; fopen(FILE, "+<$boardsdir/$currentboard.txt") || &write_error("211 $txt{'106'}: $txt{'23'} $currentboard.txt"); seek FILE, 0, 0; fopen(TEMP, "+>$boardsdir/$currentboard.txt.temp") || &fatal_error("209 $txt{'106'}: $txt{'23'} $boardsdir/$currentboard.txt.temp"); seek TEMP, 0, 0; while( read(FILE,$buffer,1024) ) { print TEMP $buffer; } truncate FILE, 0; seek FILE, 0, 0; print FILE qq~$mnum|$msub|$mname|$memail|$date|$mreplies|$musername|$micon|$mstate\n~; seek TEMP, 0, 0; my $new_count = 0; while( $line = ) { unless($new_count == $yyThreadPosition) { print FILE $line; } $new_count++; } fclose(TEMP); if (-e "$boardsdir/$currentboard.txt.temp") { unlink("$boardsdir/$currentboard.txt.temp"); } fclose(FILE); fopen(FILE, ">>$datadir/$threadid.txt") || &write_error("212 $txt{'106'}: $txt{'23'} $threadid.txt"); print FILE qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$save_file|$file\n~; fclose(FILE); if ($file) { fopen(AMP, ">>$vardir/attachments.txt") || &write_error("209 $txt{'106'}: $txt{'23'} $vardir/attachments.txt"); print AMP qq~$mnum|$mreplies|$subject|$name|$currentboard|$filesizekb|$date|$file\n~; fclose(AMP); } } 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); ###################################### ## DaveB's File Attachment Mod v2.3 ## ###################################### if ($upload_okay == 1) { if($servertype == 0) { fopen(AMT, ">$write_file")||&write_error("$fatxt{'19'} $write_file. $!"); binmode AMT; # binmode is for windows only. Ignored by unix while ($bytesread=read($filename,$buffer,1024)) { print AMT $buffer; } fclose(AMT); chmod (0666, "$write_file"); close($filename); 1; } elsif ($servertype == 1) { close($filename); rename $tmpfile, $write_file || &write_error("Error renaming '$tmpfile' to '$write_file'!"); 1; } &clear_temp; } ####################################### ## /DaveB's File Attachment Mod v2.3 ## ####################################### # 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;#$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 ); &LoadCensorList; # Load Censor List if (@messages) { $yymain .= 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; } ### hide mod if( $message =~ /\[hide\]/) { $message =~ s/\[hide\](.+?)\[\/hide\]/\[HIDDEN\]/g; } ### hide mod my @words = split(/\s/,$message); &wrap; $displayname = $tempname; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $yymain .= qq~ ~; } $yymain .= "
$txt{'468'}
$txt{'279'}: $tempname $txt{'280'}: $tempdate
$message
\n"; } else { $yymain .= ""; } } sub doaddition { fopen(FILE, "+>$boardsdir/$currentboard.poster"); print FILE $name; fclose(FILE); fopen(FILE2, "$datadir/$thread.data"); $tempinfo = ; fclose(FILE2); ($views, $lastposter, $data, $data2) = 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|$data|$data2"; fclose(FILE2); } 1;