sub RemoveThread { my( $threadcount, $messagecount, $lastposttime, $lastposter, $tmpa, $tmpb, $dummy, $checknum, $a, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mattach, $thread, @threads, $mnum2 ); $thread = $INFO{'thread'}; if ($thread =~ m~/~){ &fatal_error($txt{'224'}); } if ($thread =~ m~\\~){ &fatal_error($txt{'225'}); } if((!exists $moderators{$username}) && $settings[7] ne "Administrator" && $settings[7] ne "Global Moderator") { &fatal_error("$txt{'73'}"); } fopen(FILE, "$boardsdir/$currentboard.txt") || &fatal_error("7542 $txt{'23'} $currentboard.txt"); @threads = ; fclose(FILE); ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $msummary) = split(/\|/,$yyThreadLine); $tmp_posts = $mreplies + 1; ( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($currentboard); --$threadcount; $messagecount -= $tmp_posts; if( $yyThreadPosition == 0 ) { ($mnum2, $dummy, $dummy, $dummy, $lastposttime) = split(/\|/, $threads[1]); if( $mnum2 ) { fopen(FILE, "$datadir/$mnum2.data"); $tmpa = ; fclose(FILE); ($tmpa, $lastposter) = split(/\|/, $tmpa); } else { $lastposttime = 'N/A'; $lastposter = 'N/A'; } } if (-e "$boardsdir/Recycle_Bin.txt" && $currentboard ne "Recycle_Bin") { # Copy thread to Recycle Bin $newthreadid = time; $i=0; if (-e "$datadir/$newthreadid.txt") { while (-e "$datadir/$newthreadid$i.txt") { ++$i; } $newthreadid="$newthreadid$i"; } fopen(FILE, "$boardsdir/Recycle_Bin.txt"); @Recycle_Bin = ; fclose(FILE); chomp $threads[$yyThreadPosition]; @newthreadinfo = split(/\|/, $threads[$yyThreadPosition]); $newthreadinfo[0] = "$newthreadid"; $threads[$yyThreadPosition] = join("|", @newthreadinfo)."\n"; fopen(FILE, ">$boardsdir/Recycle_Bin.txt", 1); print FILE qq~$threads[$yyThreadPosition]~; print FILE @Recycle_Bin; fclose(FILE); opendir (MMD,$datadir); @files = readdir(MMD); closedir(MMD); foreach $files(@files) { if ($files =~ /\A$thread\.(.+)/ig) { fopen(FILE, "$datadir/$thread.$1"); @fileinfo = ; fclose(FILE); fopen(FILE, ">$datadir/$newthreadid.$1"); print FILE @fileinfo; fclose(FILE); } } my ($tmp_num, $tmp_threadcount, $tmp_messagecount, $tmp_lastposttime, $tmp_lastposter); ( $tmp_threadcount, $tmp_messagecount, $tmp_lastposttime, $tmp_lastposter ) = &BoardCountGet("Recycle_Bin"); ++$tmp_threadcount; $tmp_messagecount += $tmp_posts; ($tmp_num, $dummy, $dummy, $dummy, $tmp_lastposttime) = split(/\|/, $threads[$yyThreadPosition]); fopen(FILE, "$datadir/$tmp_num.data"); $tmpa = ; fclose(FILE); ($dummy, $tmp_lastposter) = split(/\|/, $tmpa); &BoardCountSet( "Recycle_Bin", $tmp_threadcount, $tmp_messagecount, $tmp_lastposttime, $tmp_lastposter ); } # Delete old thread $threads[$yyThreadPosition] = ''; fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("7543 $txt{'23'} $currentboard.txt"); print FILE @threads; fclose(FILE); &BoardCountSet( $currentboard, $threadcount, $messagecount, $lastposttime, $lastposter ); fopen(AMV, "$vardir/attachments.txt"); my @attachments = ; fclose(AMV); fopen(AMV, ">$vardir/attachments.txt"); foreach $row(@attachments) { chomp $row; my ($amthreadid, $amreplies, $amthreadsub, $amposter, $amcurrentboard, $amkb, $amdate, $amfn) = split(/\|/,$row); if($amthreadid ne $thread) { print AMV qq~$amthreadid|$amreplies|$amthreadsub|$amposter|$amcurrentboard|$amkb|$amdate|$amfn\n~; } elsif ($currentboard ne "Recycle_Bin") { print AMV qq~$newthreadid|$amreplies|$amthreadsub|$amposter|Recycle_Bin|$amkb|$amdate|$amfn\n~; } elsif (-e("$upload_dir/$amfn") && $amfn ne "deleted") { unlink("$upload_dir/$amfn"); } } fclose(AMV); unlink("$datadir/$thread.txt"); unlink("$datadir/$thread.mail"); unlink("$datadir/$thread.data"); unlink("$datadir/$thread.poll"); unlink("$datadir/$thread.polled"); unlink("$datadir/$thread.polll"); &Sticky_remove($thread); &dumplog($currentboard); if($INFO{'moveit'} != 1) { $yySetLocation = qq~$cgi~; &redirectexit; } }