############################################################################### # ModifyMessage.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 # ############################################################################### $modifymessageplver="1 Gold - Release"; sub ModifyMessage { if($username eq 'Guest') { &fatal_error($txt{'223'}); } if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } my( $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, @messages, $curmessage, $msubject, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb, $lastmodification, $nosmiley, ); my $threadid = $INFO{'thread'}; my $postid = int( $INFO{'message'} ); ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/,$yyThreadLine); if( $mstate == 1 ) { &fatal_error($txt{'90'}); } $yytitle = "$txt{'66'}"; fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("$txt{'23'} $threadid.txt"); @messages = ; fclose(FILE); $curmessage = $messages[$postid]; chomp $curmessage; ($msubject, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb) = split(/\|/,$messages[$postid]); if($musername ne $username && (!exists $moderators{$username}) && $settings[7] ne 'Administrator' ) { &fatal_error($txt{'67'}); } $lastmodification = $mlm ? &timeformat($mlm) : '-'; $nosmiley = $mns ? ' checked' : ''; $mmessage =~ s/
/\n/ig; &header; print <<"EOT";
$txt{'66'}
EOT if($enable_ubbc && $showyabbcbutt) { print << "EOT"; EOT } print << "EOT";
$txt{'68'}: $mname
$txt{'69'}: $memail
$txt{'70'}:
$txt{'71'}:
$txt{'252'}:
$txt{'297'}:
$txt{'72'}:
$txt{'211'}: $lastmodification
$txt{'276'}:

$txt{'277'}

EOT &footer; exit; } sub ModifyMessage2 { if($username eq 'Guest') { &fatal_error($txt{'223'}); } if( $FORM{'waction'} eq 'previewmodify' ) { require "$sourcedir/Post.pl"; &Preview; } my( $deletepost, $threadid, $postid, @messages, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, @threads, $tmpa, $tmpb, $tnum2, $tdate2, $newlastposttime, $newlastposter, $lastpostid, $views, $name, $email, $subject, $message, $ns, $postkilled, $threadkilled ); $deletepost = $INFO{'d'} eq '1' || $FORM{'waction'} eq 'deletemodify'; if( $deletepost ) { if( $FORM{'waction'} eq 'deletemodify' ) { $INFO{'id'} = $FORM{'postid'}; $INFO{'thread'} = $FORM{'threadid'}; } elsif( $INFO{'d'} eq 1 && $settings[7] ne 'Administrator' && ! exists $moderators{$username} ) { &fatal_error($txt{'73'}); } $threadid = $INFO{'thread'}; $postid = $INFO{'id'}; } else { $threadid = $FORM{'threadid'}; $postid = $FORM{'postid'}; } fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("$txt{'23'} $threadid.txt"); @messages = ; fclose(FILE); # Make sure the user is allowed to edit this post. if( $postid >= 0 && $postid < @messages ) { chomp $messages[$postid]; ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb) = split( /\|/, $messages[$postid]); unless( $musername eq $username || exists $moderators{$username} || $settings[7] eq 'Administrator' ) { &fatal_error($txt{'67'}); } } else { &fatal_error("$txt{'580'} $postid"); } # Look for the current thread in the current board. fopen(FILE, "$boardsdir/$currentboard.txt"); @threads = ; fclose(FILE); ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split( /\|/, $yyThreadLine ); $threadnum = $yyThreadPosition; if( $tstate == 1 ) { &fatal_error($txt{'90'}); } if( $deletepost ) { if( $musername ne 'Guest' ) { fopen(FILE, "$memberdir/$musername.dat"); @userprofile = ; fclose(FILE); chomp $userprofile[6]; --$userprofile[6]; $userprofile[6] .= "\n"; fopen(FILE, ">$memberdir/$musername.dat", 1); print FILE @userprofile; fclose(FILE); } # If the post is to be deleted. --$treplies; $postkilled = 1; if( $treplies < 0 ) { # If the post is the only one in the thread, # then delete the thread as well. $threads[$threadnum] = ''; $threadkilled = 1; unlink("$datadir/$tnum.txt"); unlink("$datadir/$tnum.mail"); unlink("$datadir/$tnum.data"); if( $threadnum == 0 ) { ($tnum2, $tmpa, $tmpa, $tmpa, $tdate2) = split( /\|/, $threads[1] ); if( $tnum2 ) { $newlastposttime = $tdate2; fopen(FILE, "$datadir/$tnum2.data"); $tmpa = ; fclose(FILE); ($views,$newlastposter) = split(/\|/, $tmpa); } else { $newlastposttime = 'N/A'; $newlastposter = 'N/A'; } } } else { # If the post is not the only one in the thread... if( $postid == $#messages ) { ($tmpa,$tmpa,$tmpa,$tdate) = split( /\|/, $messages[$postid-1] ); } elsif( $postid == 0 ) { $_ = $messages[1]; chomp; ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb) = split( /\|/, $_ ); $tsub = $msub; $ticon = $micon; } $threads[$threadnum] = qq~$tnum|$tsub|$tname|$temail|$tdate|$treplies|$tusername|$ticon|$tstate\n~; if( $postid == $#messages ) { # If the post is the last one in the thread, then make sure # all the lastposter/lastposttime stuff is correct for the thread. $lastpostid = $postid - 1; $_ = $messages[$lastpostid]; chomp; ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb) = split( /\|/, $_ ); if( $threadnum == 0 ) { $newlastposttime = $mdate; $newlastposter = $mname } fopen(FILE, "$datadir/$tnum.data"); $tmpa = ; fclose(FILE); ($views,$tmpa) = split(/\|/, $tmpa); fopen(FILE, "+>$datadir/$tnum.data"); print FILE qq~$views|$mname~; fclose(FILE); } $messages[$postid] = ''; # Save thread without the deleted post. fopen(FILE, ">$datadir/$threadid.txt", 1) || &fatal_error("$txt{'23'} $threadid.txt"); print FILE @messages; fclose(FILE); } } else { # If the post is to be modified... $name = $FORM{'name'}; $email = $FORM{'email'}; $subject = $FORM{'subject'}; $message = $FORM{'message'}; $icon = $FORM{'icon'}; $ns = $FORM{'ns'}; &CheckIcon; &fatal_error($txt{'78'}) unless($message); if (length($message)>$MaxMessLen) { &fatal_error($txt{'499'}); } $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; $subject =~ s/\&/\&/g; $subject =~ s/"/\"/g; $subject =~ s/ / \ /g; $subject =~ s//>/g; $subject =~ s/\|/\|/g; &fatal_error($txt{'77'}) unless($subject && $subject !~ m~\A[\s_.,]+\Z~ ); $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; #$message =~ s~(\S{80})(?=\S)~$1\n~g; $message =~ s/\&/\&/g; $message =~ s/"/\"/g; $message =~ s/ / \ /g; $message =~ s//>/g; $message =~ s/\t/ \  \  \ /g; $message =~ s/\n/
/g; $message =~ s/\|/\|/g; if( $postid == 0 ) { $tsub = $subject; $ticon = $icon; } $threads[$threadnum] = qq~$tnum|$tsub|$tname|$temail|$tdate|$treplies|$tusername|$ticon|$tstate\n~; $messages[$postid] = qq~$subject|$mname|$memail|$mdate|$musername|$icon|0|$ENV{'REMOTE_ADDR'}|$message|$ns|$date|$username\n~; fopen(FILE, ">$datadir/$threadid.txt", 1) || &fatal_error("$txt{'23'} $threadid.txt"); print FILE @messages; fclose(FILE); } # Save the current board. fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("$txt{'23'} $currentboard.txt"); print FILE @threads; fclose(FILE); if( $postkilled ) { # If post was killed, update the current board. my( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($currentboard); --$messagecount; if( $threadkilled ) { --$threadcount; } &BoardCountSet( $currentboard, $threadcount, $messagecount, $newlastposttime || $lastposttime, $newlastposter || $lastposter ); } &dumplog($currentboard); if( $threadkilled ) { $yySetLocation = qq~$cgi~; &redirectexit; } else { # Let's figure out what page number to show my $pageindex = int($postid / $maxmessagedisplay); my $start = $pageindex * $maxmessagedisplay; $yySetLocation = qq~$cgi&action=display&num=$threadid&start=$start~; &redirectexit; } } 1;