D:\my docs\My Received Files\Yabb\Yabb\YaBB_2.5_AEB\cgi-bin\yabb2_old\Sources\MoveSplitSplice.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Sources\MoveSplitSplice.pl
############################################################################### ###############################################################################
# MoveSplitSplice.pl                                                          # # MoveSplitSplice.pl                                                          #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5 Anniversary Edition                                # # Version:        YaBB 2.5.2                                                  #
# Packaged:       July 04, 2010                                               # # Packaged:       September 30, 2012                                          #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #    
#               Your source for web hosting, web design, and domains.         #    
############################################################################### ###############################################################################
   
$movesplitspliceplver = 'YaBB 2.5 AE $Revision: 1.4 $'; $movesplitspliceplver = 'YaBB 2.5.2 $Revision: 1.0 $';
if ($action eq 'detailedversion') { return 1; } if ($action eq 'detailedversion') { return 1; }
   
&LoadLanguage('MoveSplitSplice'); &LoadLanguage('MoveSplitSplice');
   
sub Split_Splice { sub Split_Splice {
   if (!$staff) { &fatal_error("split_splice_not_allowed"); }    if (!$staff) { &fatal_error("split_splice_not_allowed"); }
   &Split_Splice_2 if $FORM{'ss_submit'} || $INFO{'ss_submit'};    &Split_Splice_2 if $FORM{'ss_submit'} || $INFO{'ss_submit'};
   
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>$sstxt{'1'}</title> <title>$sstxt{'1'}</title>
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />
<link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" /> <link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" />
   
</head> </head>
<body> <body>
<a name="pagetop">&nbsp;</a><br /> <a name="pagetop">&nbsp;</a><br />
<div id="maincontainer"> <div id="maincontainer">
<div id="container"> <div id="container">
<br /> <br />
<br />~; <br />~;
   
   my $curboard  = $INFO{'board'};    my $curboard  = $INFO{'board'};
   my $curthread = $INFO{'thread'};    my $curthread = $INFO{'thread'};
   unless (exists $FORM{'oldposts'}) { $FORM{'oldposts'} = $INFO{'oldposts'}; }    unless (exists $FORM{'oldposts'}) { $FORM{'oldposts'} = $INFO{'oldposts'}; }
   unless (exists $FORM{'leave'})    { $FORM{'leave'} = $INFO{'leave'}; }    unless (exists $FORM{'leave'})    { $FORM{'leave'} = $INFO{'leave'}; }
   if     (exists $INFO{'newinfo'})  { $FORM{'newinfo'} = $INFO{'newinfo'}; }    if     (exists $INFO{'newinfo'})  { $FORM{'newinfo'} = $INFO{'newinfo'}; }
   my $newcat    = $FORM{'newcat'} || $INFO{'newcat'};    my $newcat    = $FORM{'newcat'} || $INFO{'newcat'};
   my $newboard  = $FORM{'newboard'} || $INFO{'newboard'};    my $newboard  = $FORM{'newboard'} || $INFO{'newboard'};
   unless (exists $FORM{'newthread'}) { $FORM{'newthread'} = $INFO{'newthread'}; }    unless (exists $FORM{'newthread'}) { $FORM{'newthread'} = $INFO{'newthread'}; }
   my $newthread = $FORM{'newthread'} || "new";    my $newthread = $FORM{'newthread'} || "new";
   unless (exists $FORM{'newthread_subject'}) { $FORM{'newthread_subject'} = $INFO{'newthread_subject'}; }    unless (exists $FORM{'newthread_subject'}) { $FORM{'newthread_subject'} = $INFO{'newthread_subject'}; }
   unless (exists $FORM{'position'})          { $FORM{'position'} = $INFO{'position'}; }    unless (exists $FORM{'position'})          { $FORM{'position'} = $INFO{'position'}; }
   
   require "$sourcedir/YaBBC.pl";    require "$sourcedir/YaBBC.pl";
   &LoadCensorList;    &LoadCensorList;
   
   # Get posts of current thread    # Get posts of current thread
   unless (ref($thread_arrayref{$curthread})) {    unless (ref($thread_arrayref{$curthread})) {
       fopen(FILE, "$datadir/$curthread.txt");        fopen(FILE, "$datadir/$curthread.txt");
       @{$thread_arrayref{$curthread}} = <FILE>;        @{$thread_arrayref{$curthread}} = <FILE>;
       fclose(FILE);        fclose(FILE);
   }    }
   my @messages = @{$thread_arrayref{$curthread}};    my @messages = @{$thread_arrayref{$curthread}};
   
   my ($counter,$size1);    my ($counter,$size1);
   for ($counter = 0; $counter < @messages; $counter++) {    for ($counter = 0; $counter < @messages; $counter++) {
       $message = (split(/\|/, $messages[$counter], 10))[8];        $message = (split(/\|/, $messages[$counter], 10))[8];
       ($message, undef) = &Split_Splice_Move($message,1);        ($message, undef) = &Split_Splice_Move($message,1);
       &DoUBBC;        &DoUBBC;
   
       $convertstr = $message;        $convertstr = $message;
       $convertcut = 50;        $convertcut = 50;
       &CountChars;        &CountChars;
       $message = $convertstr;        $message = $convertstr;
       $message .= " ..." if $cliped;        $message .= " ..." if $cliped;
   
       &ToChars($message);        &ToChars($message);
       $message =~ s/<(p|br|div).*?>/ /g;        $message =~ s/<(p|br|div).*?>/ /g;
       $message =~ s/<.*?>//g; # remove HTML-tags        $message =~ s/<.*?>//g; # remove HTML-tags
       $message = &Censor($message);        $message = &Censor($message);
   
       $messages[$counter] = qq~<option value="$counter" ~ . ($FORM{'oldposts'} =~ /\b$counter\b/ ? q~selected="selected"~ : '') . qq~>~ . ($counter ? "$sstxt{'40'} $counter" : $sstxt{'41'}) . qq~: $message</option>\n~;        $messages[$counter] = qq~<option value="$counter" ~ . ($FORM{'oldposts'} =~ /\b$counter\b/ ? q~selected="selected"~ : '') . qq~>~ . ($counter ? "$sstxt{'40'} $counter" : $sstxt{'41'}) . qq~: $message</option>\n~;
   }    }
   @messages = reverse(@messages) if ($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse;    @messages = reverse(@messages) if ($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse;
   my $postlist = ($FORM{'oldposts'} eq "all" ? qq~<option value="all" selected="selected">$sstxt{'26'}</option>\n~ : qq~<option value="all">$sstxt{'26'}</option>\n~) . join('', @messages);    my $postlist = ($FORM{'oldposts'} eq "all" ? qq~<option value="all" selected="selected">$sstxt{'26'}</option>\n~ : qq~<option value="all">$sstxt{'26'}</option>\n~) . join('', @messages);
   $size1 = @messages + 1;    $size1 = @messages + 1;
   $size1 = $size1 > 10 ? 10 : $size1; # maximum size of multiselect field    $size1 = $size1 > 10 ? 10 : $size1; # maximum size of multiselect field
   
   # List of options of what, if anything, to leave in place of the posts moved    # List of options of what, if anything, to leave in place of the posts moved
   my @leaveopts = ($sstxt{'11'}, $sstxt{'12'}, $sstxt{'13'});    my @leaveopts = ($sstxt{'11'}, $sstxt{'12'}, $sstxt{'13'});
   for ($counter = 0; $counter < @leaveopts; $counter++) {    for ($counter = 0; $counter < @leaveopts; $counter++) {
       $leavelist .= qq~<option value="$counter" ~ . ($FORM{'leave'} == $counter ? q~selected="selected"~ : '') . qq~>$leaveopts[$counter]</option>\n~;        $leavelist .= qq~<option value="$counter" ~ . ($FORM{'leave'} == $counter ? q~selected="selected"~ : '') . qq~>$leaveopts[$counter]</option>\n~;
   }    }
   
   # Get categories and make the current one the default selection    # Get categories and make the current one the default selection
   my $catlist = qq~<option value="cats" >$sstxt{'28'}</option>\n~;    my $catlist = qq~<option value="cats" >$sstxt{'28'}</option>\n~;
   foreach (@categoryorder) {    foreach (@categoryorder) {
       my ($catname, $catperms) = split(/\|/, $catinfo{$_}, 3);        my ($catname, $catperms) = split(/\|/, $catinfo{$_}, 3);
       next if !&CatAccess($catperms);        next if !&CatAccess($catperms);
       $catlist .= qq~<option value="$_" ~ . ($newcat eq $_ ? q~selected="selected"~ : '') . qq~>$catname</option>\n~;        $catlist .= qq~<option value="$_" ~ . ($newcat eq $_ ? q~selected="selected"~ : '') . qq~>$catname</option>\n~;
   }    }
   
   # Get boards and make the current one the default selection    # Get boards and make the current one the default selection
   $boardlist = qq~<option value="boards" >$sstxt{'29'}</option>\n~;    $boardlist = qq~<option value="boards" >$sstxt{'29'}</option>\n~;
   foreach (split (/,/, $cat{$newcat})) {    foreach (split (/,/, $cat{$newcat})) {
       my ($boardname, $boardperms) = split(/\|/, $board{$_}, 3);        my ($boardname, $boardperms) = split(/\|/, $board{$_}, 3);
       my $access = &AccessCheck($_, '', $boardperms);        my $access = &AccessCheck($_, '', $boardperms);
       next if !$iamadmin && $access ne "granted" && $boardview != 1;        next if !$iamadmin && $access ne "granted" && $boardview != 1;
       $boardlist .= qq~<option value="$_" ~ . ($newboard eq $_ ? q~selected="selected"~ : '') . qq~>$boardname</option>\n~;        $boardlist .= qq~<option value="$_" ~ . ($newboard eq $_ ? q~selected="selected"~ : '') . qq~>$boardname</option>\n~;
   }    }
   
   # Get threads and make the current one the default selection    # Get threads and make the current one the default selection
   my ($threadlist,$threadids,$positionlist);    my ($threadlist,$threadids,$positionlist);
   if ($cat{$newcat} =~ /\b$newboard\b/) {    if ($cat{$newcat} =~ /\b$newboard\b/) {
       fopen(FILE, "$boardsdir/$newboard.txt");        fopen(FILE, "$boardsdir/$newboard.txt");
       my @threads = <FILE>;        my @threads = <FILE>;
       fclose(FILE);        fclose(FILE);
   
       $threadlist = qq~<option value="new">$sstxt{'30'}</option>\n~;        $threadlist = qq~<option value="new">$sstxt{'30'}</option>\n~;
       my $threadid;        my $threadid;
       foreach (@threads) {        foreach (@threads) {
           ($threadid, $message, undef) = split(/\|/, $_, 3);            ($threadid, $message, undef) = split(/\|/, $_, 3);
           next if $curthread eq $threadid;            next if $curthread eq $threadid;
           $threadids .= "$threadid,";            $threadids .= "$threadid,";
   
           ($message, undef) = &Split_Splice_Move($message,$threadid);            ($message, undef) = &Split_Splice_Move($message,$threadid);
           &DoUBBC;            &DoUBBC;
   
           $convertstr = $message;            $convertstr = $message;
           $convertcut = 50;            $convertcut = 50;
           &CountChars;            &CountChars;
           $message = $convertstr;            $message = $convertstr;
           $message .= " ..." if $cliped;            $message .= " ..." if $cliped;
   
           &ToChars($message);            &ToChars($message);
           $message =~ s/<(p|br|div).*?>/ /g;            $message =~ s/<(p|br|div).*?>/ /g;
           $message =~ s/<.*?>//g; # remove HTML-tags            $message =~ s/<.*?>//g; # remove HTML-tags
           $message = &Censor($message);            $message = &Censor($message);
   
           $threadlist .= qq~<option value="$threadid" ~ . ($newthread eq $threadid ? q~selected="selected"~ : '') . qq~>$message</option>\n~;            $threadlist .= qq~<option value="$threadid" ~ . ($newthread eq $threadid ? q~selected="selected"~ : '') . qq~>$message</option>\n~;
       }        }
   
       # Get new thread posts to select splice site        # Get new thread posts to select splice site
       if ($FORM{'newthread'} ne "new") {        if ($FORM{'newthread'} ne "new") {
           unless (ref($thread_arrayref{$newthread})) {            unless (ref($thread_arrayref{$newthread})) {
               fopen(FILE, "$datadir/$newthread.txt");                fopen(FILE, "$datadir/$newthread.txt");
               @{$thread_arrayref{$newthread}} = <FILE>;                @{$thread_arrayref{$newthread}} = <FILE>;
               fclose(FILE);                fclose(FILE);
           }            }
           @messages = @{$thread_arrayref{$newthread}};            @messages = @{$thread_arrayref{$newthread}};
   
           for ($counter = 0; $counter < @messages; $counter++) {            for ($counter = 0; $counter < @messages; $counter++) {
               $message = (split(/[\|]/, $messages[$counter], 10))[8];                $message = (split(/[\|]/, $messages[$counter], 10))[8];
               ($message, undef) = &Split_Splice_Move($message,1);                ($message, undef) = &Split_Splice_Move($message,1);
               &DoUBBC;                &DoUBBC;
   
               $convertstr = $message;                $convertstr = $message;
               $convertcut = 50;                $convertcut = 50;
               &CountChars;                &CountChars;
               $message = $convertstr;                $message = $convertstr;
               $message .= " ..." if $cliped;                $message .= " ..." if $cliped;
   
               &ToChars($message);                &ToChars($message);
               $message =~ s/<(p|br|div).*?>/ /g;                $message =~ s/<(p|br|div).*?>/ /g;
               $message =~ s/<.*?>//g; # remove HTML-tags                $message =~ s/<.*?>//g; # remove HTML-tags
               $message = &Censor($message);                $message = &Censor($message);
   
               $messages[$counter] = qq~<option value="$counter">~ . ($counter ? "$sstxt{'40'} $counter" : $sstxt{'41'}) . qq~: $message</option>\n~;                $messages[$counter] = qq~<option value="$counter">~ . ($counter ? "$sstxt{'40'} $counter" : $sstxt{'41'}) . qq~: $message</option>\n~;
           }            }
           @messages = reverse(@messages) if ($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse;            @messages = reverse(@messages) if ($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse;
           $positionlist = qq~<option value="end">$sstxt{'31'}</option>\n~;            $positionlist = qq~<option value="end">$sstxt{'31'}</option>\n~;
           $positionlist .= qq~<option value="begin">$sstxt{'32'}</option>\n~ . join('', @messages);            $positionlist .= qq~<option value="begin">$sstxt{'32'}</option>\n~ . join('', @messages);
           if ($FORM{'position'} && $newthread == $FORM{'old_position_thread'}) {            if ($FORM{'position'} && $newthread == $FORM{'old_position_thread'}) {
               $positionlist =~ s/(value="$FORM{'position'}")/$1 selected="selected"/;                $positionlist =~ s/(value="$FORM{'position'}")/$1 selected="selected"/;
           }            }
       }        }
   }    }
   
   $output .= qq~    $output .= qq~
<script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script> <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>
<form action="$scripturl?action=split_splice;board=$currentboard;thread=$INFO{'thread'}" method="post" name="split_splice" onsubmit="return submitproc()"> <form action="$scripturl?action=split_splice;board=$currentboard;thread=$INFO{'thread'}" method="post" name="split_splice" onsubmit="return submitproc()">
<input type="hidden" name="formsession" value="$formsession" /> <input type="hidden" name="formsession" value="$formsession" />
<table border="0" cellspacing="1" cellpadding="8" class="bordercolor" align="center" width="90%"> <table border="0" cellspacing="1" cellpadding="8" class="bordercolor" align="center" width="90%">
   <tr>    <tr>
       <td class="titlebg"><img src="$defaultimagesdir/admin_move_split_splice.gif" alt="$sstxt{'1'}" /> <b>$sstxt{'1'}</b></td>        <td class="titlebg"><img src="$defaultimagesdir/admin_move_split_splice.gif" alt="$sstxt{'1'}" /> <b>$sstxt{'1'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="catbg"><b>$sstxt{'2'}:</b></td>        <td class="catbg"><b>$sstxt{'2'}:</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg"><b>$sstxt{'3'}</b></td>        <td class="windowbg"><b>$sstxt{'3'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="oldposts">$sstxt{'14'}<br />            <label for="oldposts">$sstxt{'14'}<br />
           <select name="oldposts" id="oldposts" size="$size1" multiple="multiple">$postlist</select><br />            <select name="oldposts" id="oldposts" size="$size1" multiple="multiple">$postlist</select><br />
           <span class="small">$sstxt{'14a'}</span></label>            <span class="small">$sstxt{'14a'}</span></label>
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td class="windowbg"><b>$sstxt{'4'}</b></td>        <td class="windowbg"><b>$sstxt{'4'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="leave">$sstxt{'15'}</label><br />            <label for="leave">$sstxt{'15'}</label><br />
           <select name="leave" id="leave">$leavelist</select>            <select name="leave" id="leave">$leavelist</select>
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td class="catbg"><b>$sstxt{'5'}:</b></td>        <td class="catbg"><b>$sstxt{'5'}:</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg"><b>$sstxt{'6'}</b></td>        <td class="windowbg"><b>$sstxt{'6'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="newcat">$sstxt{'16'}</label><br />            <label for="newcat">$sstxt{'16'}</label><br />
           <select name="newcat" id="newcat" onchange="document.split_splice.submit();">$catlist</select>            <select name="newcat" id="newcat" onchange="document.split_splice.submit();">$catlist</select>
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td class="windowbg"><b>$sstxt{'7'}</b></td>        <td class="windowbg"><b>$sstxt{'7'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="newboard">$sstxt{'17'}</label><br />            <label for="newboard">$sstxt{'17'}</label><br />
           <select name="newboard" id="newboard" onchange="document.split_splice.submit();">$boardlist</select>            <select name="newboard" id="newboard" onchange="document.split_splice.submit();">$boardlist</select>
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td class="windowbg"><b>$sstxt{'8'}</b></td>        <td class="windowbg"><b>$sstxt{'8'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="newthread">$sstxt{'18'}</label><br />            <label for="newthread">$sstxt{'18'}</label><br />
           <select name="newthread" id="newthread" onchange="document.split_splice.submit();">$threadlist</select>            <select name="newthread" id="newthread" onchange="document.split_splice.submit();">$threadlist</select>
       </td>        </td>
   </tr>~;    </tr>~;
   
   if ($newthread eq "new" || !$threadlist || $threadids !~ /\b$newthread\b/){    if ($newthread eq "new" || !$threadlist || $threadids !~ /\b$newthread\b/){
       $output .= qq~<tr>        $output .= qq~<tr>
       <td class="windowbg"><b>$sstxt{'9'}</b></td>        <td class="windowbg"><b>$sstxt{'9'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="newthread_subject">$sstxt{'20'}</label><br />            <label for="newthread_subject">$sstxt{'20'}</label><br />
           <input type="text" name="newthread_subject" id="newthread_subject" size="50" value="$FORM{'newthread_subject'}" />            <input type="text" name="newthread_subject" id="newthread_subject" size="50" value="$FORM{'newthread_subject'}" />
           <input type="hidden" name="position" value="$FORM{'position'}" />            <input type="hidden" name="position" value="$FORM{'position'}" />
           <input type="hidden" name="old_position_thread" value="$FORM{'old_position_thread'}" />            <input type="hidden" name="old_position_thread" value="$FORM{'old_position_thread'}" />
       </td>        </td>
   </tr>~;    </tr>~;
   
   } else {    } else {
       $output .= qq~<tr>        $output .= qq~<tr>
       <td class="windowbg"><b>$sstxt{'10'}</b></td>        <td class="windowbg"><b>$sstxt{'10'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <label for="position">$sstxt{'19'}</label><br />            <label for="position">$sstxt{'19'}</label><br />
           <select name="position" id="position">$positionlist</select>            <select name="position" id="position">$positionlist</select>
           <input type="hidden" name="newthread_subject" value="$FORM{'newthread_subject'}" />            <input type="hidden" name="newthread_subject" value="$FORM{'newthread_subject'}" />
           <input type="hidden" name="old_position_thread" value="$newthread" />            <input type="hidden" name="old_position_thread" value="$newthread" />
       </td>        </td>
   </tr>~;    </tr>~;
   }    }
   
   $output .= qq~<tr>    $output .= qq~<tr>
       <td class="windowbg"><b>$sstxt{'4'}</b></td>        <td class="windowbg"><b>$sstxt{'4'}</b></td>
   </tr><tr>    </tr><tr>
       <td class="windowbg2">        <td class="windowbg2">
           <input type="checkbox" name="newinfo" id="newinfo" value="1"~ . ($FORM{'newinfo'} ? ' checked="checked"' : '') . qq~ /> <label for="newinfo">$sstxt{'15a'}</label>            <input type="checkbox" name="newinfo" id="newinfo" value="1"~ . ($FORM{'newinfo'} ? ' checked="checked"' : '') . qq~ /> <label for="newinfo">$sstxt{'15a'}</label>
       </td>        </td>
   </tr><tr>    </tr><tr>
       <td class="catbg" align="center"><input type="submit" name="ss_submit" value="$sstxt{'24'}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="$sstxt{'25'}" /></td>        <td class="catbg" align="center"><input type="submit" name="ss_submit" value="$sstxt{'24'}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="$sstxt{'25'}" /></td>
   </tr>    </tr>
</table> </table>
</form> </form>
<br /> <br />
<br /> <br />
</div> </div>
</div> </div>
</body> </body>
</html>~; </html>~;
   
   &print_output_header;    &print_output_header;
   &print_HTML_output_and_finish;    &print_HTML_output_and_finish;
} }
   
sub Split_Splice_2 { sub Split_Splice_2 {
   if (!$staff && $INFO{'newboard'} ne $binboard) { &fatal_error("split_splice_not_allowed"); }    if (!$staff && $INFO{'newboard'} ne $binboard) { &fatal_error("split_splice_not_allowed"); }
   
   my $curboard       = $INFO{'board'};    my $curboard       = $INFO{'board'};
   my $curthreadid    = $INFO{'thread'};    my $curthreadid    = $INFO{'thread'};
   my $movingposts    = exists $INFO{'oldposts'} ? $INFO{'oldposts'} : $FORM{'oldposts'};    my $movingposts    = exists $INFO{'oldposts'} ? $INFO{'oldposts'} : $FORM{'oldposts'};
   $FORM{'oldposts'}  = $movingposts;    $FORM{'oldposts'}  = $movingposts;
   my $leavemess      = exists $INFO{'leave'} ? $INFO{'leave'} : $FORM{'leave'};    my $leavemess      = exists $INFO{'leave'} ? $INFO{'leave'} : $FORM{'leave'};
   my $forcenewinfo   = exists $INFO{'newinfo'} ? $INFO{'newinfo'} : $FORM{'newinfo'};    my $forcenewinfo   = exists $INFO{'newinfo'} ? $INFO{'newinfo'} : $FORM{'newinfo'};
   my $newcat         = exists $INFO{'newcat'} ? $INFO{'newcat'} : $FORM{'newcat'};    my $newcat         = exists $INFO{'newcat'} ? $INFO{'newcat'} : $FORM{'newcat'};
   my $newboard       = exists $INFO{'newboard'} ? $INFO{'newboard'} : $FORM{'newboard'};    my $newboard       = exists $INFO{'newboard'} ? $INFO{'newboard'} : $FORM{'newboard'};
   my $newthreadid    = exists $INFO{'newthread'} ? $INFO{'newthread'} : $FORM{'newthread'};    my $newthreadid    = exists $INFO{'newthread'} ? $INFO{'newthread'} : $FORM{'newthread'};
   $FORM{'newthread'} = $newthreadid;    $FORM{'newthread'} = $newthreadid;
   my $newthreadsub   = exists $INFO{'newthread_subject'} ? $INFO{'newthread_subject'} : $FORM{'newthread_subject'};    my $newthreadsub   = exists $INFO{'newthread_subject'} ? $INFO{'newthread_subject'} : $FORM{'newthread_subject'};
   my $newposition    = exists $INFO{'position'} ? $INFO{'position'} : $FORM{'position'};    my $newposition    = exists $INFO{'position'} ? $INFO{'position'} : $FORM{'position'};
   $FORM{'position'}  = $newposition;    $FORM{'position'}  = $newposition;
   
   # Error messages if something is not filled out right    # Error messages if something is not filled out right
   &fatal_error('',"$sstxt{'22b'} $sstxt{'23'} $sstxt{'50'}") if $movingposts eq '';    &fatal_error('',"$sstxt{'22b'} $sstxt{'23'} $sstxt{'50'}") if $movingposts eq '';
   &fatal_error('',"$sstxt{'22'}") if $newcat eq 'cats';    &fatal_error('',"$sstxt{'22'}") if $newcat eq 'cats';
   &fatal_error('',"$sstxt{'22a'}") if $newboard eq 'boards';    &fatal_error('',"$sstxt{'22a'}") if $newboard eq 'boards';
   &fatal_error('',"$sstxt{'51'} $sstxt{'50'}") if -e "$datadir/$curthreadid.poll" && -e "$datadir/$newthreadid.poll";    &fatal_error('',"$sstxt{'51'} $sstxt{'50'}") if -e "$datadir/$curthreadid.poll" && -e "$datadir/$newthreadid.poll";
   
   my (@postnum,@utdcurthread,@utdnewthread,$i);    my (@postnum,@utdcurthread,@utdnewthread,$i);
   my $linkcount = 0;    my $linkcount = 0;
   
   # Get current thread posts    # Get current thread posts
   unless (ref($thread_arrayref{$curthreadid})) {    unless (ref($thread_arrayref{$curthreadid})) {
       fopen(FILE, "$datadir/$curthreadid.txt");        fopen(FILE, "$datadir/$curthreadid.txt");
       @{$thread_arrayref{$curthreadid}} = <FILE>;        @{$thread_arrayref{$curthreadid}} = <FILE>;
       fclose(FILE);        fclose(FILE);
   }    }
   my @curthread = @{$thread_arrayref{$curthreadid}};    my @curthread = @{$thread_arrayref{$curthreadid}};
   &MessageTotals("load", $curthreadid);    &MessageTotals("load", $curthreadid);
   
   # Store post numbers to be moved in array    # Store post numbers to be moved in array
   if ((split(/\, /, $movingposts, 2))[0] eq "all") { @postnum = (0 .. $#curthread); }    if ((split(/\, /, $movingposts, 2))[0] eq "all") { @postnum = (0 .. $#curthread); }
   else { @postnum = sort {$a <=> $b} split(/\, /, $movingposts); } # sort numerically ascending because may be reversed!    else { @postnum = sort {$a <=> $b} split(/\, /, $movingposts); } # sort numerically ascending because may be reversed!
   
   # Check to see if current thread was the latest post for the board and if the last post was selected to change    # Check to see if current thread was the latest post for the board and if the last post was selected to change
   &BoardTotals("load", $curboard);    &BoardTotals("load", $curboard);
   if(${$curthreadid}{'lastpostdate'} == ${$uid.$curboard}{'lastposttime'} && $leavemess == 2 && $postnum[$#postnum] == $#curthread) {    if(${$curthreadid}{'lastpostdate'} == ${$uid.$curboard}{'lastposttime'} && $leavemess == 2 && $postnum[$#postnum] == $#curthread) {
       $newest_post = 1;        $newest_post = 1;
   }    }
   
   # Move selected posts to a brand new thread    # Move selected posts to a brand new thread
   if ($newthreadid eq "new") {    if ($newthreadid eq "new") {
       # Find a valid random ID for new thread.        # Find a valid random ID for new thread.
       $newthreadid = (split(/\|/, $curthread[$postnum[0]], 5))[3] + 1;        $newthreadid = (split(/\|/, $curthread[$postnum[0]], 5))[3] + 1;
       while (-e "$datadir/$newthreadid.txt") { $newthreadid++; }        while (-e "$datadir/$newthreadid.txt") { $newthreadid++; }
   
       foreach (@postnum) {        foreach (@postnum) {
           if ($newthreadsub || $leavemess == 1) { # insert new subject name || add 'no_postcount' into copies            if ($newthreadsub || $leavemess == 1) { # insert new subject name || add 'no_postcount' into copies
               my @x = split(/\|/, $curthread[$_]);                my @x = split(/\|/, $curthread[$_]);
               if ($newthreadsub) { $x[0] = $_ == $postnum[0] ? $newthreadsub : qq~$sstxt{'21'} $newthreadsub~; }                if ($newthreadsub) { $x[0] = $_ == $postnum[0] ? $newthreadsub : qq~$sstxt{'21'} $newthreadsub~; }
               if ($leavemess == 1) { $x[5] = 'no_postcount'; }                if ($leavemess == 1) { $x[5] = 'no_postcount'; }
               push(@utdnewthread, join('|', @x));                push(@utdnewthread, join('|', @x));
           } else {            } else {
               push(@utdnewthread, $curthread[$_]);                push(@utdnewthread, $curthread[$_]);
           }            }
       }        }
   
   # Place selected posts in existing thread at selected position    # Place selected posts in existing thread at selected position
   } else {    } else {
       # Get existing thread posts        # Get existing thread posts
       unless (ref($thread_arrayref{$newthreadid})) {        unless (ref($thread_arrayref{$newthreadid})) {
           fopen(FILE, "$datadir/$newthreadid.txt");            fopen(FILE, "$datadir/$newthreadid.txt");
           @{$thread_arrayref{$newthreadid}} = <FILE>;            @{$thread_arrayref{$newthreadid}} = <FILE>;
           fclose(FILE);            fclose(FILE);
       }        }
       my @newthread = @{$thread_arrayref{$newthreadid}};        my @newthread = @{$thread_arrayref{$newthreadid}};
       &MessageTotals("load", $newthreadid);        &MessageTotals("load", $newthreadid);
   
       if    ($newposition eq "end")   { $newposition = $#newthread; }        if    ($newposition eq "end")   { $newposition = $#newthread; }
       elsif ($newposition eq "begin") {        elsif ($newposition eq "begin") {
           foreach (@postnum) {            foreach (@postnum) {
               if ($leavemess == 1) { # add 'no_postcount' into copies                if ($leavemess == 1) { # add 'no_postcount' into copies
                   my @x = split(/\|/, $curthread[$_]);                    my @x = split(/\|/, $curthread[$_]);
                   $x[5] = 'no_postcount';                    $x[5] = 'no_postcount';
                   push(@utdnewthread, join('|', @x));                    push(@utdnewthread, join('|', @x));
               } else {                } else {
                   push(@utdnewthread, $curthread[$_]);                    push(@utdnewthread, $curthread[$_]);
               }                }
           }            }
           $newposition = -1;            $newposition = -1;
       }        }
       for ($i = 0; $i < @newthread; $i++){        for ($i = 0; $i < @newthread; $i++){
           push (@utdnewthread, $newthread[$i]);            push (@utdnewthread, $newthread[$i]);
           if ($newposition == $i) {            if ($newposition == $i) {
               foreach (@postnum) {                foreach (@postnum) {
                   if ($leavemess == 1) { # add 'no_postcount' into copies                    if ($leavemess == 1) { # add 'no_postcount' into copies
                       my @x = split(/\|/, $curthread[$_]);                        my @x = split(/\|/, $curthread[$_]);
                       $x[5] = 'no_postcount';                        $x[5] = 'no_postcount';
                       push(@utdnewthread, join('|', @x));                        push(@utdnewthread, join('|', @x));
                   } else {                    } else {
                       push(@utdnewthread, $curthread[$_]);                        push(@utdnewthread, $curthread[$_]);
                   }                    }
               }                }
               $linkcount = $i + 1;                $linkcount = $i + 1;
           }            }
       }        }
   }    }
   
   # Remove or copy selected posts from current thread    # Remove or copy selected posts from current thread
   if ($#postnum == $#curthread && $leavemess != 1){    if ($#postnum == $#curthread && $leavemess != 1){
       if ($newboard ne $binboard) {        if ($newboard ne $binboard) {
           my ($tmpsub,$tmpmessage);            my ($tmpsub,$tmpmessage);
           my $hidename = &cloak($username);            my $hidename = &cloak($username);
           ($tmpsub, undef) = split(/\|/, $curthread[0], 2);            ($tmpsub, undef) = split(/\|/, $curthread[0], 2);
           if ($curboard eq $newboard) {            if ($curboard eq $newboard) {
               $tmpmessage = qq~[m by=$hidename dest=$newthreadid/$linkcount#$linkcount]~;                $tmpmessage = qq~[m by=$hidename dest=$newthreadid/$linkcount#$linkcount]~;
               $tmpsub = qq~[m by=$hidename dest=$newthreadid]: '$tmpsub'~;                $tmpsub = qq~[m by=$hidename dest=$newthreadid]: '$tmpsub'~;
           } else {            } else {
               $tmpmessage = qq~[m by=$hidename destboard=$newboard dest=$newthreadid/$linkcount#$linkcount]~;                $tmpmessage = qq~[m by=$hidename destboard=$newboard dest=$newthreadid/$linkcount#$linkcount]~;
               $tmpsub = qq~[m by=$hidename destboard=$newboard dest=$newthreadid]: '$tmpsub'~;                $tmpsub = qq~[m by=$hidename destboard=$newboard dest=$newthreadid]: '$tmpsub'~;
           }            }
           &FromChars($tmpmessage);            &FromChars($tmpmessage);
           $utdcurthread[0] = qq~$tmpsub|${$uid.$username}{'realname'}|${$uid.$username}{'email'}|$date|$username|no_postcount||$user_ip|$tmpmessage||||\n~;            $utdcurthread[0] = qq~$tmpsub|${$uid.$username}{'realname'}|${$uid.$username}{'email'}|$date|$username|no_postcount||$user_ip|$tmpmessage||||\n~;
   
           eval { require "$datadir/movedthreads.cgi" };            eval { require "$datadir/movedthreads.cgi" };
           $moved_file{$curthreadid} = $newthreadid;            $moved_file{$curthreadid} = $newthreadid;
           delete $moved_file{$newthreadid};            delete $moved_file{$newthreadid};
           &save_moved_file;            &save_moved_file;
           $leavemess = 0;            $leavemess = 0;
       } else {        } else {
           $leavemess = 2;            $leavemess = 2;
           $forcenewinfo = 1;            $forcenewinfo = 1;
       }        }
   
   } elsif ($leavemess != 1) {    } elsif ($leavemess != 1) {
       $leavemess = 2 if $newboard eq $binboard;        $leavemess = 2 if $newboard eq $binboard;
       for ($i = 0; $i < @curthread; $i++){        for ($i = 0; $i < @curthread; $i++){
           if ($movingposts =~ /\b$i\b/){            if ($movingposts =~ /\b$i\b/){
               if ($leavemess == 0 && $i == $postnum[$#postnum]){                if ($leavemess == 0 && $i == $postnum[$#postnum]){
                   my $tmpsub;                    my $tmpsub;
                   ($tmpsub, undef) = split(/\|/, $curthread[$i], 2);                    ($tmpsub, undef) = split(/\|/, $curthread[$i], 2);
                   push (@utdcurthread, qq~$tmpsub|${$uid.$username}{'realname'}|${$uid.$username}{'email'}|$date|$username|no_postcount||$user_ip|[split] [link=$scripturl?num=$newthreadid/$linkcount#$linkcount][splithere][/link][splithere_end]||||\n~);                    push (@utdcurthread, qq~$tmpsub|${$uid.$username}{'realname'}|${$uid.$username}{'email'}|$date|$username|no_postcount||$user_ip|[split] [link=$scripturl?num=$newthreadid/$linkcount#$linkcount][splithere][/link][splithere_end]||||\n~);
               }                }
           } else {            } else {
               push (@utdcurthread, $curthread[$i]);                push (@utdcurthread, $curthread[$i]);
           }            }
       }        }
   
   } else { @utdcurthread = @curthread; }    } else { @utdcurthread = @curthread; }
   
   if ($forcenewinfo) {    if ($forcenewinfo) {
       my ($boardtitle,$tmpsub,$tmpmessage);        my ($boardtitle,$tmpsub,$tmpmessage);
       ($boardtitle, undef) = split(/\|/, $board{$curboard}, 2);        ($boardtitle, undef) = split(/\|/, $board{$curboard}, 2);
       $tmpmessage = ($#postnum == $#utdnewthread ? "[b][movedhere]" : "[b][postsmovedhere1] " . @postnum . " [postsmovedhere2]") . " [i]$boardtitle\[/i] [move by] [i]${$uid.$username}{'realname'}\[/i].[/b]";        $tmpmessage = ($#postnum == $#utdnewthread ? "[b][movedhere]" : "[b][postsmovedhere1] " . @postnum . " [postsmovedhere2]") . " [i]$boardtitle\[/i] [move by] [i]${$uid.$username}{'realname'}\[/i].[/b]";
       &FromChars($tmpmessage);        &FromChars($tmpmessage);
       ($tmpsub, undef, undef, undef, undef, undef, undef) = split(/\|/, $utdnewthread[0], 7);        ($tmpsub, undef, undef, undef, undef, undef, undef) = split(/\|/, $utdnewthread[0], 7);
       splice(@utdnewthread, ($linkcount + @postnum), 0,qq~$sstxt{'21'} $tmpsub|${$uid.$username}{'realname'}|${$uid.$username}{'email'}|$date|$username|no_postcount||$user_ip|$tmpmessage||||\n~);        splice(@utdnewthread, ($linkcount + @postnum), 0,qq~$sstxt{'21'} $tmpsub|${$uid.$username}{'realname'}|${$uid.$username}{'email'}|$date|$username|no_postcount||$user_ip|$tmpmessage||||\n~);
   }    }
   
   if (@utdcurthread) {    if (@utdcurthread) {
       for ($i = 0; $i < @utdcurthread; $i++) { # sort post numbers        for ($i = 0; $i < @utdcurthread; $i++) { # sort post numbers
           my @x = split(/\|/, $utdcurthread[$i]);            my @x = split(/\|/, $utdcurthread[$i]);
           $x[6] = $i;            $x[6] = $i;
           $utdcurthread[$i] = join('|', @x);            $utdcurthread[$i] = join('|', @x);
       }        }
       # Update current thread        # Update current thread
       fopen(FILE, ">$datadir/$curthreadid.txt");        fopen(FILE, ">$datadir/$curthreadid.txt");
       print FILE @utdcurthread;        print FILE @utdcurthread;
       fclose(FILE);        fclose(FILE);
   } else {    } else {
       require "$sourcedir/RemoveTopic.pl";        require "$sourcedir/RemoveTopic.pl";
       my $moveit = $INFO{'moveit'};        my $moveit = $INFO{'moveit'};
       $INFO{'moveit'} = 1;        $INFO{'moveit'} = 1;
       &RemoveThread;        &RemoveThread;
       $INFO{'moveit'} = $moveit;        $INFO{'moveit'} = $moveit;
   }    }
   
   for ($i = 0; $i < @utdnewthread; $i++) { # sort post numbers    for ($i = 0; $i < @utdnewthread; $i++) { # sort post numbers
       my @x = split(/\|/, $utdnewthread[$i]);        my @x = split(/\|/, $utdnewthread[$i]);
       $x[6] = $i;        $x[6] = $i;
       $utdnewthread[$i] = join('|', @x);        $utdnewthread[$i] = join('|', @x);
   }    }
   # Update new thread    # Update new thread
   fopen(FILE, ">$datadir/$newthreadid.txt");    fopen(FILE, ">$datadir/$newthreadid.txt");
   print FILE @utdnewthread;    print FILE @utdnewthread;
   fclose(FILE);    fclose(FILE);
   
   # Update the .rlog files of the users    # Update the .rlog files of the users
   my ($reply,$ms,$mn,$md,$mu,$mnp,$mi,%mu,%curthreadusersdate,%curthreaduserscount,%newthreadusersdate,%newthreaduserscount,%BoardTotals);    my ($reply,$ms,$mn,$md,$mu,$mnp,$mi,%mu,%curthreadusersdate,%curthreaduserscount,%newthreadusersdate,%newthreaduserscount,%BoardTotals);
   $reply = 0;    $reply = 0;
   foreach (@utdcurthread) { # $subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile    foreach (@utdcurthread) { # $subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile
       ($ms, $mn, undef, $md, $mu, $mnp, undef, $mi, undef) = split(/\|/, $_, 9);        ($ms, $mn, undef, $md, $mu, $mnp, undef, $mi, undef) = split(/\|/, $_, 9);
       $BoardTotals{$curthreadid} = [$md,$mu,$reply,$ms,$mn,$mi] if ${$BoardTotals{$curthreadid}}[0] <= $md;        $BoardTotals{$curthreadid} = [$md,$mu,$reply,$ms,$mn,$mi] if ${$BoardTotals{$curthreadid}}[0] <= $md;
       $reply++;        $reply++;
       next if $mnp eq 'no_postcount';        next if $mnp eq 'no_postcount';
       $curthreadusersdate{$mu} = $md if $curthreadusersdate{$mu} < $md;        $curthreadusersdate{$mu} = $md if $curthreadusersdate{$mu} < $md;
       $curthreaduserscount{$mu}++;        $curthreaduserscount{$mu}++;
       $mu{$mu} = 1;        $mu{$mu} = 1;
   }    }
   $reply = 0;    $reply = 0;
   foreach (@utdnewthread) {    foreach (@utdnewthread) {
       ($ms, $mn, undef, $md, $mu, $mnp, undef, $mi, undef) = split(/\|/, $_, 9);        ($ms, $mn, undef, $md, $mu, $mnp, undef, $mi, undef) = split(/\|/, $_, 9);
       $BoardTotals{$newthreadid} = [$md,$mu,$reply,$ms,$mn,$mi] if ${$BoardTotals{$newthreadid}}[0] <= $md;        $BoardTotals{$newthreadid} = [$md,$mu,$reply,$ms,$mn,$mi] if ${$BoardTotals{$newthreadid}}[0] <= $md;
       $reply++;        $reply++;
       next if $mnp eq 'no_postcount';        next if $mnp eq 'no_postcount';
       $newthreadusersdate{$mu} = $md if $newthreadusersdate{$mu} < $md;        $newthreadusersdate{$mu} = $md if $newthreadusersdate{$mu} < $md;
       $newthreaduserscount{$mu}++;        $newthreaduserscount{$mu}++;
       $mu{$mu} = 1;        $mu{$mu} = 1;
   }    }
   foreach $mu (keys %mu) {    foreach $mu (keys %mu) {
       &Recent_Load($mu);        &Recent_Load($mu);
       delete $recent{$curthreadid};        delete $recent{$curthreadid};
       delete $recent{$newthreadid};        delete $recent{$newthreadid};
       if ($curthreaduserscount{$mu}) {        if ($curthreaduserscount{$mu}) {
           ${$recent{$curthreadid}}[0] = $curthreaduserscount{$mu};            ${$recent{$curthreadid}}[0] = $curthreaduserscount{$mu};
           ${$recent{$curthreadid}}[1] = $curthreadusersdate{$mu};            ${$recent{$curthreadid}}[1] = $curthreadusersdate{$mu};
       }        }
       if ($newthreaduserscount{$mu}) {        if ($newthreaduserscount{$mu}) {
           ${$recent{$newthreadid}}[0] = $newthreaduserscount{$mu};            ${$recent{$newthreadid}}[0] = $newthreaduserscount{$mu};
           ${$recent{$newthreadid}}[1] = $newthreadusersdate{$mu};            ${$recent{$newthreadid}}[1] = $newthreadusersdate{$mu};
       }        }
       &Recent_Save($mu);        &Recent_Save($mu);
   }    }
   
   # For: Mark threads/boards as read    # For: Mark threads/boards as read
   &getlog;    &getlog;
   my $boardlog = 1;    my $boardlog = 1;
   # Mark new thread as read because you will be directed there at the end    # Mark new thread as read because you will be directed there at the end
   delete $yyuserlog{"$newthreadid--unread"};    delete $yyuserlog{"$newthreadid--unread"};
   $yyuserlog{$newthreadid} = $date;    $yyuserlog{$newthreadid} = $date;
   
   # Update .ctb, tags=>(board replies views lastposter lastpostdate threadstatus repliers)    # Update .ctb, tags=>(board replies views lastposter lastpostdate threadstatus repliers)
   # curthread    # curthread
   ${$curthreadid}{'replies'} = $#utdcurthread;    ${$curthreadid}{'replies'} = $#utdcurthread;
   ${$curthreadid}{'lastpostdate'} = ${$BoardTotals{$curthreadid}}[0];    ${$curthreadid}{'lastpostdate'} = ${$BoardTotals{$curthreadid}}[0];
   ${$curthreadid}{'lastposter'}   = ${$BoardTotals{$curthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$curthreadid}}[4]" : ${$BoardTotals{$curthreadid}}[1];    ${$curthreadid}{'lastposter'}   = ${$BoardTotals{$curthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$curthreadid}}[4]" : ${$BoardTotals{$curthreadid}}[1];
   # newthread    # newthread
   ${$newthreadid}{'replies'} = $#utdnewthread;    ${$newthreadid}{'replies'} = $#utdnewthread;
   ${$newthreadid}{'lastpostdate'} = ${$BoardTotals{$newthreadid}}[0];    ${$newthreadid}{'lastpostdate'} = ${$BoardTotals{$newthreadid}}[0];
   ${$newthreadid}{'lastposter'}   = ${$BoardTotals{$newthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$newthreadid}}[4]" : ${$BoardTotals{$newthreadid}}[1];    ${$newthreadid}{'lastposter'}   = ${$BoardTotals{$newthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$newthreadid}}[4]" : ${$BoardTotals{$newthreadid}}[1];
   if ($FORM{'newthread'} eq 'new') {    if ($FORM{'newthread'} eq 'new') {
       ${$newthreadid}{'board'} = $newboard;        ${$newthreadid}{'board'} = $newboard;
       ${$newthreadid}{'views'} = $#postnum == $#curthread ? ${$curthreadid}{'views'} : ($INFO{'ss_submit'} ? 1 : 0);        ${$newthreadid}{'views'} = $#postnum == $#curthread ? ${$curthreadid}{'views'} : ($INFO{'ss_submit'} ? 1 : 0);
       ${$newthreadid}{'threadstatus'} = ${$curthreadid}{'threadstatus'};        ${$newthreadid}{'threadstatus'} = ${$curthreadid}{'threadstatus'};
       ${$curthreadid}{'views'} = $#postnum == $#curthread && $leavemess != 1 ? 0 : ${$curthreadid}{'views'};        ${$curthreadid}{'views'} = $#postnum == $#curthread && $leavemess != 1 ? 0 : ${$curthreadid}{'views'};
   } else {    } else {
       ${$newthreadid}{'views'} += int(${$curthreadid}{'views'} / @curthread * @postnum);        ${$newthreadid}{'views'} += int(${$curthreadid}{'views'} / @curthread * @postnum);
   }    }
   
   # Update current message index    # Update current message index
   fopen(BOARD, "+<$boardsdir/$curboard.txt", 1);    fopen(BOARD, "+<$boardsdir/$curboard.txt", 1);
   my @curmessindex = <BOARD>;    my @curmessindex = <BOARD>;
   truncate BOARD, 0;    truncate BOARD, 0;
   seek BOARD, 0, 0;    seek BOARD, 0, 0;
   
   my $old_mstate;    my $old_mstate;
   for ($i = 0; $i < @curmessindex; $i++) {    for ($i = 0; $i < @curmessindex; $i++) {
       my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $curmessindex[$i]);        my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $curmessindex[$i]);
       $boardlog = 0 if $mdate > $yyuserlog{$curboard}; # For: Mark boards as read        $boardlog = 0 if $mdate > $yyuserlog{$curboard}; # For: Mark boards as read
       if ($mnum == $curthreadid) {        if ($mnum == $curthreadid) {
           chomp $mstate;            chomp $mstate;
           if ($#postnum == $#curthread && $leavemess != 1) { # thread was moved            if ($#postnum == $#curthread && $leavemess != 1) { # thread was moved
               my $hidename = &cloak($username);                my $hidename = &cloak($username);
               if ($curboard eq $newboard) {                if ($curboard eq $newboard) {
                   $msub = qq~[m by=$hidename dest=$newthreadid]: '$msub'~;                    $msub = qq~[m by=$hidename dest=$newthreadid]: '$msub'~;
               } else {                } else {
                   $msub = qq~[m by=$hidename destboard=$newboard dest=$newthreadid]: '$msub'~;                    $msub = qq~[m by=$hidename destboard=$newboard dest=$newthreadid]: '$msub'~;
               }                }
               $mname = ${$uid.$username}{'realname'};                $mname = ${$uid.$username}{'realname'};
               $memail = ${$uid.$username}{'email'};                $memail = ${$uid.$username}{'email'};
               $mreplies = 0;                $mreplies = 0;
               $musername = $username;                $musername = $username;
               # alter message icon to 'exclamation' to match status 'lm'                # alter message icon to 'exclamation' to match status 'lm'
               $micon = 'exclamation' if $micon ne 'no_postcount';                $micon = 'exclamation' if $micon ne 'no_postcount';
               # thread status - (a)nnoumcement, (h)idden, (l)ocked, (m)oved and (s)ticky                # thread status - (a)nnoumcement, (h)idden, (l)ocked, (m)oved and (s)ticky
               $old_mstate = $mstate;                $old_mstate = $mstate;
               if ($curboard eq $annboard && $mstate !~ /a/i) { $mstate .= "a"; }                if ($curboard eq $annboard && $mstate !~ /a/i) { $mstate .= "a"; }
               if ($mstate !~ /l/i) { $mstate .= "l"; }                if ($mstate !~ /l/i) { $mstate .= "l"; }
               if ($mstate !~ /m/i) { $mstate .= "m"; }                if ($mstate !~ /m/i) { $mstate .= "m"; }
               ${$curthreadid}{'threadstatus'} = $mstate;                ${$curthreadid}{'threadstatus'} = $mstate;
           } else {            } else {
               ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdcurthread[0], 7);                ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdcurthread[0], 7);
               $mreplies = ${$curthreadid}{'replies'};                $mreplies = ${$curthreadid}{'replies'};
           }            }
           $curmessindex[$i] = qq~$mnum|$msub|$mname|$memail|${$curthreadid}{'lastpostdate'}|$mreplies|$musername|$micon|$mstate\n~;            $curmessindex[$i] = qq~$mnum|$msub|$mname|$memail|${$curthreadid}{'lastpostdate'}|$mreplies|$musername|$micon|$mstate\n~;
           ${$BoardTotals{$mnum}}[6] = $mstate;            ${$BoardTotals{$mnum}}[6] = $mstate;
   
       } elsif ($mnum == $newthreadid) {        } elsif ($mnum == $newthreadid) {
           chomp $mstate;            chomp $mstate;
           if ($FORM{'position'} eq 'begin') {            if ($FORM{'position'} eq 'begin') {
               ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);                ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);
           }            }
           $yyThreadLine = $curmessindex[$i] = qq~$mnum|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$mstate\n~;            $yyThreadLine = $curmessindex[$i] = qq~$mnum|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$mstate\n~;
           ${$BoardTotals{$mnum}}[6] = $mstate;            ${$BoardTotals{$mnum}}[6] = $mstate;
           if (($enable_notifications == 1 || $enable_notifications == 3) && (-e "$boardsdir/$curboard.mail" || -e "$datadir/$newthreadid.mail")) {            if (($enable_notifications == 1 || $enable_notifications == 3) && (-e "$boardsdir/$curboard.mail" || -e "$datadir/$newthreadid.mail")) {
               require "$sourcedir/Post.pl";                require "$sourcedir/Post.pl";
               $currentboard = $curboard;                $currentboard = $curboard;
               $msub = &Censor($msub);                $msub = &Censor($msub);
               &ReplyNotify($newthreadid, $msub, ${$newthreadid}{'replies'});                &ReplyNotify($newthreadid, $msub, ${$newthreadid}{'replies'});
           }            }
       }        }
   }    }
   if ($curboard eq $newboard && $FORM{'newthread'} eq 'new') {    if ($curboard eq $newboard && $FORM{'newthread'} eq 'new') {
       my ($msub,$mname,$memail,$musername,$micon);        my ($msub,$mname,$memail,$musername,$micon);
       ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);        ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);
       if ($old_mstate !~ /0/i) { $old_mstate .= "0"; }        if ($old_mstate !~ /0/i) { $old_mstate .= "0"; }
       $yyThreadLine = qq~$newthreadid|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$old_mstate\n~;        $yyThreadLine = qq~$newthreadid|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$old_mstate\n~;
       unshift (@curmessindex, $yyThreadLine);        unshift (@curmessindex, $yyThreadLine);
       ${$BoardTotals{$newthreadid}}[6] = $old_mstate;        ${$BoardTotals{$newthreadid}}[6] = $old_mstate;
       if (($enable_notifications == 1 || $enable_notifications == 3) && -e "$boardsdir/$newboard.mail") {        if (($enable_notifications == 1 || $enable_notifications == 3) && -e "$boardsdir/$newboard.mail") {
           require "$sourcedir/Post.pl";            require "$sourcedir/Post.pl";
           $currentboard = $curboard;            $currentboard = $curboard;
           $msub = &Censor($msub);            $msub = &Censor($msub);
           &NewNotify($newthreadid, $msub);            &NewNotify($newthreadid, $msub);
       }        }
   }    }
   print BOARD sort { (split(/\|/,$b,6))[4] <=> (split(/\|/,$a,6))[4] } @curmessindex;    print BOARD sort { (split(/\|/,$b,6))[4] <=> (split(/\|/,$a,6))[4] } @curmessindex;
   fclose(BOARD);    fclose(BOARD);
   
   $yyuserlog{$curboard} = $date if $boardlog; # For: Mark boards as read    $yyuserlog{$curboard} = $date if $boardlog; # For: Mark boards as read
   
   # Update new message index if needed    # Update new message index if needed
   if ($curboard ne $newboard) {    if ($curboard ne $newboard) {
       $boardlog = 1; # For: Mark boards as read        $boardlog = 1; # For: Mark boards as read
   
       fopen(BOARD, "+<$boardsdir/$newboard.txt", 1);        fopen(BOARD, "+<$boardsdir/$newboard.txt", 1);
       seek BOARD, 0, 0;        seek BOARD, 0, 0;
       my @newmessindex = <BOARD>;        my @newmessindex = <BOARD>;
       truncate BOARD, 0;        truncate BOARD, 0;
       seek BOARD, 0, 0;        seek BOARD, 0, 0;
   
       if ($FORM{'newthread'} eq 'new') {        if ($FORM{'newthread'} eq 'new') {
           # For: Mark boards as read            # For: Mark boards as read
           foreach (@newmessindex) {            foreach (@newmessindex) {
               $boardlog = 0 if (split(/\|/, $_, 6))[4] > $yyuserlog{$newboard};                $boardlog = 0 if (split(/\|/, $_, 6))[4] > $yyuserlog{$newboard};
               last if !$boardlog;                last if !$boardlog;
           }            }
   
           my ($msub,$mname,$memail,$musername,$micon);            my ($msub,$mname,$memail,$musername,$micon);
           ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);            ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);
           if ($old_mstate =~ /a/i) {              if ($old_mstate =~ /a/i) {  
               if ($newboard ne $annboard) { $old_mstate =~ s/a//gi; }                if ($newboard ne $annboard) { $old_mstate =~ s/a//gi; }
           } elsif ($newboard eq $annboard) {            } elsif ($newboard eq $annboard) {
               $old_mstate .= "a";                $old_mstate .= "a";
           }            }
           if ($old_mstate !~ /0/i) { $old_mstate .= "0"; }            if ($old_mstate !~ /0/i) { $old_mstate .= "0"; }
           $yyThreadLine = qq~$newthreadid|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$old_mstate\n~;            $yyThreadLine = qq~$newthreadid|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$old_mstate\n~;
           unshift (@newmessindex, $yyThreadLine);            unshift (@newmessindex, $yyThreadLine);
           ${$BoardTotals{$newthreadid}}[6] = $old_mstate;            ${$BoardTotals{$newthreadid}}[6] = $old_mstate;
           if (($enable_notifications == 1 || $enable_notifications == 3) && -e "$boardsdir/$newboard.mail") {            if (($enable_notifications == 1 || $enable_notifications == 3) && -e "$boardsdir/$newboard.mail") {
               require "$sourcedir/Post.pl";                require "$sourcedir/Post.pl";
               $currentboard = $newboard;                $currentboard = $newboard;
               $msub = &Censor($msub);                $msub = &Censor($msub);
               &NewNotify($newthreadid, $msub);                &NewNotify($newthreadid, $msub);
           }            }
   
       } else {        } else {
           for ($i = 0; $i < @newmessindex; $i++) {            for ($i = 0; $i < @newmessindex; $i++) {
               my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $newmessindex[$i]);                my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $newmessindex[$i]);
               $boardlog = 0 if $mdate > $yyuserlog{$newboard}; # For: Mark boards as read                $boardlog = 0 if $mdate > $yyuserlog{$newboard}; # For: Mark boards as read
               if ($mnum == $newthreadid) {                if ($mnum == $newthreadid) {
                   chomp $mstate;                    chomp $mstate;
                   if ($FORM{'position'} eq 'begin') {                    if ($FORM{'position'} eq 'begin') {
                       ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);                        ($msub, $mname, $memail, undef, $musername, $micon, undef) = split(/\|/, $utdnewthread[0], 7);
                   }                    }
                   $yyThreadLine = $newmessindex[$i] = qq~$mnum|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$mstate\n~;                    $yyThreadLine = $newmessindex[$i] = qq~$mnum|$msub|$mname|$memail|${$newthreadid}{'lastpostdate'}|${$newthreadid}{'replies'}|$musername|$micon|$mstate\n~;
                   ${$BoardTotals{$mnum}}[6] = $mstate;                    ${$BoardTotals{$mnum}}[6] = $mstate;
               }                }
           }            }
           if (($enable_notifications == 1 || $enable_notifications == 3) && (-e "$boardsdir/$newboard.mail" || -e "$datadir/$newthreadid.mail")) {            if (($enable_notifications == 1 || $enable_notifications == 3) && (-e "$boardsdir/$newboard.mail" || -e "$datadir/$newthreadid.mail")) {
               require "$sourcedir/Post.pl";                require "$sourcedir/Post.pl";
               $currentboard = $newboard;                $currentboard = $newboard;
               $msub = &Censor($msub);                $msub = &Censor($msub);
               &ReplyNotify($newthreadid, $msub, ${$newthreadid}{'replies'});                &ReplyNotify($newthreadid, $msub, ${$newthreadid}{'replies'});
           }            }
       }        }
       print BOARD sort { (split /\|/,$b,6)[4] <=> (split /\|/,$a,6)[4] } @newmessindex;        print BOARD sort { (split /\|/,$b,6)[4] <=> (split /\|/,$a,6)[4] } @newmessindex;
       fclose(BOARD);        fclose(BOARD);
   
       $yyuserlog{$newboard} = $date if $boardlog; # For: Mark boards as read        $yyuserlog{$newboard} = $date if $boardlog; # For: Mark boards as read
   }    }
   
   &MessageTotals("update", $curthreadid) if @utdcurthread;    &MessageTotals("update", $curthreadid) if @utdcurthread;
   &MessageTotals("update", $newthreadid);    &MessageTotals("update", $newthreadid);
   
   # update current board totals    # update current board totals
   # BoardTotals- tags => (board threadcount messagecount lastposttime lastposter lastpostid lastreply lastsubject lasticon lasttopicstate)    # BoardTotals- tags => (board threadcount messagecount lastposttime lastposter lastpostid lastreply lastsubject lasticon lasttopicstate)
   #&BoardTotals("load", $curboard); - Load this at top now to detect if newest board post is being moved - Unilat    #&BoardTotals("load", $curboard); - Load this at top now to detect if newest board post is being moved - Unilat
   if (${$BoardTotals{$curthreadid}}[6] =~ /m/) { # Moved-Info thread    if (${$BoardTotals{$curthreadid}}[6] =~ /m/) { # Moved-Info thread
       if ($curboard ne $newboard) {        if ($curboard ne $newboard) {
           ${$uid.$curboard}{'threadcount'}--;            ${$uid.$curboard}{'threadcount'}--;
           ${$uid.$curboard}{'messagecount'} -= @postnum;            ${$uid.$curboard}{'messagecount'} -= @postnum;
       }        }
       &BoardSetLastInfo($curboard,\@curmessindex);        &BoardSetLastInfo($curboard,\@curmessindex);
   } else {    } else {
       if ($FORM{'newthread'} eq 'new' && $curboard eq $newboard) { ${$uid.$curboard}{'threadcount'}++; }        if ($FORM{'newthread'} eq 'new' && $curboard eq $newboard) { ${$uid.$curboard}{'threadcount'}++; }
       if ($leavemess == 0) {        if ($leavemess == 0) {
           if ($curboard ne $newboard) { ${$uid.$curboard}{'messagecount'} -= $#postnum; }            if ($curboard ne $newboard) { ${$uid.$curboard}{'messagecount'} -= $#postnum; }
           else { ${$uid.$curboard}{'messagecount'} += ($forcenewinfo ? 2 : 1); }            else { ${$uid.$curboard}{'messagecount'} += ($forcenewinfo ? 2 : 1); }
       } elsif ($leavemess == 1 && $curboard eq $newboard) {        } elsif ($leavemess == 1 && $curboard eq $newboard) {
           ${$uid.$curboard}{'messagecount'} += $#postnum + ($forcenewinfo ? 1 : 0);            ${$uid.$curboard}{'messagecount'} += $#postnum + ($forcenewinfo ? 1 : 0);
       } elsif ($leavemess == 2 && $curboard ne $newboard && @utdcurthread) {        } elsif ($leavemess == 2 && $curboard ne $newboard && @utdcurthread) {
           ${$uid.$curboard}{'messagecount'} -= @postnum;            ${$uid.$curboard}{'messagecount'} -= @postnum;
       }        }
       if ($newest_post || (((${$uid.$curboard}{'threadcount'} == 1 && @utdcurthread) || ${$BoardTotals{$curthreadid}}[0] >= ${$uid.$curboard}{'lastposttime'}) && ($curboard ne $newboard || ${$BoardTotals{$curthreadid}}[0] >= ${$BoardTotals{$newthreadid}}[0]))) {        if ($newest_post || (((${$uid.$curboard}{'threadcount'} == 1 && @utdcurthread) || ${$BoardTotals{$curthreadid}}[0] >= ${$uid.$curboard}{'lastposttime'}) && ($curboard ne $newboard || ${$BoardTotals{$curthreadid}}[0] >= ${$BoardTotals{$newthreadid}}[0]))) {
           ${$uid.$curboard}{'lastposttime'}   = ${$BoardTotals{$curthreadid}}[0];            ${$uid.$curboard}{'lastposttime'}   = ${$BoardTotals{$curthreadid}}[0];
           ${$uid.$curboard}{'lastposter'}     = ${$BoardTotals{$curthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$curthreadid}}[4]" : ${$BoardTotals{$curthreadid}}[1];            ${$uid.$curboard}{'lastposter'}     = ${$BoardTotals{$curthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$curthreadid}}[4]" : ${$BoardTotals{$curthreadid}}[1];
           ${$uid.$curboard}{'lastpostid'}     = $curthreadid;            ${$uid.$curboard}{'lastpostid'}     = $curthreadid;
           ${$uid.$curboard}{'lastreply'}      = ${$BoardTotals{$curthreadid}}[2]--;            ${$uid.$curboard}{'lastreply'}      = ${$BoardTotals{$curthreadid}}[2]--;
           ${$uid.$curboard}{'lastsubject'}    = ${$BoardTotals{$curthreadid}}[3];            ${$uid.$curboard}{'lastsubject'}    = ${$BoardTotals{$curthreadid}}[3];
           ${$uid.$curboard}{'lasticon'}       = ${$BoardTotals{$curthreadid}}[5];            ${$uid.$curboard}{'lasticon'}       = ${$BoardTotals{$curthreadid}}[5];
           ${$uid.$curboard}{'lasttopicstate'} = ${$BoardTotals{$curthreadid}}[6];            ${$uid.$curboard}{'lasttopicstate'} = ${$BoardTotals{$curthreadid}}[6];
       } elsif (${$BoardTotals{$newthreadid}}[0] >= ${$uid.$curboard}{'lastposttime'} && $curboard eq $newboard) {        } elsif (${$BoardTotals{$newthreadid}}[0] >= ${$uid.$curboard}{'lastposttime'} && $curboard eq $newboard) {
           ${$uid.$curboard}{'lastposttime'}   = ${$BoardTotals{$newthreadid}}[0];            ${$uid.$curboard}{'lastposttime'}   = ${$BoardTotals{$newthreadid}}[0];
           ${$uid.$curboard}{'lastposter'}     = ${$BoardTotals{$newthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$newthreadid}}[4]" : ${$BoardTotals{$newthreadid}}[1];            ${$uid.$curboard}{'lastposter'}     = ${$BoardTotals{$newthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$newthreadid}}[4]" : ${$BoardTotals{$newthreadid}}[1];
           ${$uid.$curboard}{'lastpostid'}     = $newthreadid;            ${$uid.$curboard}{'lastpostid'}     = $newthreadid;
           ${$uid.$curboard}{'lastreply'}      = ${$BoardTotals{$newthreadid}}[2]--;            ${$uid.$curboard}{'lastreply'}      = ${$BoardTotals{$newthreadid}}[2]--;
           ${$uid.$curboard}{'lastsubject'}    = ${$BoardTotals{$newthreadid}}[3];            ${$uid.$curboard}{'lastsubject'}    = ${$BoardTotals{$newthreadid}}[3];
           ${$uid.$curboard}{'lasticon'}       = ${$BoardTotals{$newthreadid}}[5];            ${$uid.$curboard}{'lasticon'}       = ${$BoardTotals{$newthreadid}}[5];
           ${$uid.$curboard}{'lasttopicstate'} = ${$BoardTotals{$newthreadid}}[6];            ${$uid.$curboard}{'lasttopicstate'} = ${$BoardTotals{$newthreadid}}[6];
       }        }
       &BoardTotals("update", $curboard);         &BoardSetLastInfo($curboard,\@curmessindex); 
   }    }
   
   # update new board totals if needed    # update new board totals if needed
   if ($curboard ne $newboard) {    if ($curboard ne $newboard) {
       &BoardTotals("load", $newboard);        &BoardTotals("load", $newboard);
       if ($FORM{'newthread'} eq 'new') { ${$uid.$newboard}{'threadcount'}++; }        if ($FORM{'newthread'} eq 'new') { ${$uid.$newboard}{'threadcount'}++; }
       ${$uid.$newboard}{'messagecount'} += @postnum + ($forcenewinfo ? 1 : 0);        ${$uid.$newboard}{'messagecount'} += @postnum + ($forcenewinfo ? 1 : 0);
       if (${$uid.$newboard}{'threadcount'} == 1 || ${$BoardTotals{$newthreadid}}[0] >= ${$uid.$newboard}{'lastposttime'}) {        if (${$uid.$newboard}{'threadcount'} == 1 || ${$BoardTotals{$newthreadid}}[0] >= ${$uid.$newboard}{'lastposttime'}) {
           ${$uid.$newboard}{'lastposttime'}   = ${$BoardTotals{$newthreadid}}[0];            ${$uid.$newboard}{'lastposttime'}   = ${$BoardTotals{$newthreadid}}[0];
           ${$uid.$newboard}{'lastposter'}     = ${$BoardTotals{$newthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$newthreadid}}[4]" : ${$BoardTotals{$newthreadid}}[1];            ${$uid.$newboard}{'lastposter'}     = ${$BoardTotals{$newthreadid}}[1] eq 'Guest' ? "Guest-${$BoardTotals{$newthreadid}}[4]" : ${$BoardTotals{$newthreadid}}[1];
           ${$uid.$newboard}{'lastpostid'}     = $newthreadid;            ${$uid.$newboard}{'lastpostid'}     = $newthreadid;
           ${$uid.$newboard}{'lastreply'}      = ${$BoardTotals{$newthreadid}}[2]--;            ${$uid.$newboard}{'lastreply'}      = ${$BoardTotals{$newthreadid}}[2]--;
           ${$uid.$newboard}{'lastsubject'}    = ${$BoardTotals{$newthreadid}}[3];            ${$uid.$newboard}{'lastsubject'}    = ${$BoardTotals{$newthreadid}}[3];
           ${$uid.$newboard}{'lasticon'}       = ${$BoardTotals{$newthreadid}}[5];            ${$uid.$newboard}{'lasticon'}       = ${$BoardTotals{$newthreadid}}[5];
           ${$uid.$newboard}{'lasttopicstate'} = ${$BoardTotals{$newthreadid}}[6];            ${$uid.$newboard}{'lasttopicstate'} = ${$BoardTotals{$newthreadid}}[6];
       }        }
       &BoardTotals("update", $newboard);        &BoardTotals("update", $newboard);
   }    }
   
   # now fix all attachments.txt info    # now fix all attachments.txt info
   my $attachments;    my $attachments;
   for ($i = $postnum[0]; $i < @curthread; $i++){ # see if old thread had attachments    for ($i = $postnum[0]; $i < @curthread; $i++){ # see if old thread had attachments
       $attachments = (split(/\|/, $curthread[$i]))[12];        $attachments = (split(/\|/, $curthread[$i]))[12];
       chomp $attachments;        chomp $attachments;
       if ($attachments) {        if ($attachments) {
           $attachments = 1;            $attachments = 1;
           last;            last;
       }        }
   }    }
   if (!$attachments) { # see if new thread has attachments    if (!$attachments) { # see if new thread has attachments
       for ($i = $linkcount; $i < @utdnewthread; $i++){        for ($i = $linkcount; $i < @utdnewthread; $i++){
           $attachments = (split(/\|/, $utdnewthread[$i]))[12];            $attachments = (split(/\|/, $utdnewthread[$i]))[12];
           chomp $attachments;            chomp $attachments;
           if ($attachments) {            if ($attachments) {
               $attachments = 2;                $attachments = 2;
               last;                last;
           }            }
       }        }
   }    }
   if ($attachments) {    if ($attachments) {
       my ($attid,$attachmentname,$downloadscount,@newattachments,%attachments,$mreplies,$msub,$mname,$mdate,$mfn);        my ($attid,$attachmentname,$downloadscount,@newattachments,%attachments,$mreplies,$msub,$mname,$mdate,$mfn);
       fopen(ATM, "+<$vardir/attachments.txt", 1) || &fatal_error("cannot_open","$vardir/attachments.txt", 1);        fopen(ATM, "+<$vardir/attachments.txt", 1) || &fatal_error("cannot_open","$vardir/attachments.txt", 1);
       seek ATM, 0, 0;        seek ATM, 0, 0;
       while (<ATM>) {        while (<ATM>) {
           ($attid, undef, undef, undef, undef, undef, undef, $attachmentname, $downloadscount) = split(/\|/, $_);            ($attid, undef, undef, undef, undef, undef, undef, $attachmentname, $downloadscount) = split(/\|/, $_);
           push(@newattachments, $_) if ($attid != $curthreadid && $attid != $newthreadid) || ($attid == $curthreadid && $attachments != 1);            push(@newattachments, $_) if ($attid != $curthreadid && $attid != $newthreadid) || ($attid == $curthreadid && $attachments != 1);
           chomp $downloadscount;            chomp $downloadscount;
           $attachments{$attachmentname} = $downloadscount;            $attachments{$attachmentname} = $downloadscount;
       }        }
   
       $mreplies = 0;        $mreplies = 0;
       if ($attachments == 1) {        if ($attachments == 1) {
           foreach (@utdcurthread) { # fix new old thread attachments            foreach (@utdcurthread) { # fix new old thread attachments
               ($msub, $mname, undef, $mdate, undef, undef, undef, undef, undef, undef, undef, undef, $mfn) = split(/\|/, $_);                ($msub, $mname, undef, $mdate, undef, undef, undef, undef, undef, undef, undef, undef, $mfn) = split(/\|/, $_);
               chomp $mfn;                chomp $mfn;
               foreach (split(/,/, $mfn)) {                foreach (split(/,/, $mfn)) {
                   if (-e "$uploaddir/$_") {                    if (-e "$uploaddir/$_") {
                       my $asize = int((-s "$uploaddir/$_") / 1024) || 1;                        my $asize = int((-s "$uploaddir/$_") / 1024) || 1;
                       push (@newattachments, qq~$curthreadid|$mreplies|$msub|$mname|$curboard|$asize|$mdate|$_|~ . ($attachments{$_} || 0) . qq~\n~);                        push (@newattachments, qq~$curthreadid|$mreplies|$msub|$mname|$curboard|$asize|$mdate|$_|~ . ($attachments{$_} || 0) . qq~\n~);
                   }                    }
               }                }
               $mreplies++;                $mreplies++;
           }            }
       }        }
   
       $mreplies = 0;        $mreplies = 0;
       foreach (@utdnewthread) { # fix new thread attachments        foreach (@utdnewthread) { # fix new thread attachments
           ($msub, $mname, undef, $mdate, undef, undef, undef, undef, undef, undef, undef, undef, $mfn) = split(/\|/, $_);            ($msub, $mname, undef, $mdate, undef, undef, undef, undef, undef, undef, undef, undef, $mfn) = split(/\|/, $_);
           chomp $mfn;            chomp $mfn;
           foreach (split(/,/, $mfn)) {            foreach (split(/,/, $mfn)) {
               if (-e "$uploaddir/$_") {                if (-e "$uploaddir/$_") {
                   my $asize = int((-s "$uploaddir/$_") / 1024) || 1;                    my $asize = int((-s "$uploaddir/$_") / 1024) || 1;
                   push (@newattachments, qq~$newthreadid|$mreplies|$msub|$mname|$newboard|$asize|$mdate|$_|~ . ($attachments{$_} || 0) . qq~\n~);                    push (@newattachments, qq~$newthreadid|$mreplies|$msub|$mname|$newboard|$asize|$mdate|$_|~ . ($attachments{$_} || 0) . qq~\n~);
               }                }
           }            }
           $mreplies++;            $mreplies++;
       }        }
   
       truncate ATM, 0;        truncate ATM, 0;
       seek ATM, 0, 0;        seek ATM, 0, 0;
       print ATM sort { (split(/\|/,$a,8))[6] <=> (split(/\|/,$b,8))[6] } @newattachments;        print ATM sort { (split(/\|/,$a,8))[6] <=> (split(/\|/,$b,8))[6] } @newattachments;
       fclose(ATM);        fclose(ATM);
   }    }
   
   if ($#postnum == $#curthread) {    if ($#postnum == $#curthread) {
       if (-e "$datadir/$curthreadid.poll") {        if (-e "$datadir/$curthreadid.poll") {
           rename("$datadir/$curthreadid.poll", "$datadir/$newthreadid.poll");            rename("$datadir/$curthreadid.poll", "$datadir/$newthreadid.poll");
       }        }
       if (-e "$datadir/$curthreadid.polled") {        if (-e "$datadir/$curthreadid.polled") {
           rename("$datadir/$curthreadid.polled", "$datadir/$newthreadid.polled");            rename("$datadir/$curthreadid.polled", "$datadir/$newthreadid.polled");
       }        }
       if (-e "$datadir/$curthreadid.mail") {        if (-e "$datadir/$curthreadid.mail") {
           rename("$datadir/$curthreadid.mail", "$datadir/$newthreadid.mail");            rename("$datadir/$curthreadid.mail", "$datadir/$newthreadid.mail");
           require "$sourcedir/Notify.pl";            require "$sourcedir/Notify.pl";
           &ManageThreadNotify("load", $newthreadid);            &ManageThreadNotify("load", $newthreadid);
           my ($u,%t);            my ($u,%t);
           foreach $u (keys %thethread) {            foreach $u (keys %thethread) {
               &LoadUser($u);                &LoadUser($u);
               foreach (split(/,/, ${$uid.$u}{'thread_notifications'})) {                foreach (split(/,/, ${$uid.$u}{'thread_notifications'})) {
                   $t{$_} = 1;                    $t{$_} = 1;
               }                }
               delete $t{$curthreadid};                delete $t{$curthreadid};
               $t{$newthreadid} = 1;                $t{$newthreadid} = 1;
               ${$uid.$u}{'thread_notifications'} = join(',', keys %t);                ${$uid.$u}{'thread_notifications'} = join(',', keys %t);
               &UserAccount($u);                &UserAccount($u);
               undef %t;                undef %t;
           }            }
       }        }
   }    }
   
   # Mark current thread as read    # Mark current thread as read
   delete $yyuserlog{"$curthreadid--unread"};    delete $yyuserlog{"$curthreadid--unread"};
   &dumplog($curthreadid); # Save threads/boards as read    &dumplog($curthreadid); # Save threads/boards as read
   
   chomp $yyThreadLine;    chomp $yyThreadLine;
   
   if ($INFO{'moveit'} == 1) {    if ($INFO{'moveit'} == 1) {
       $currentboard = $curboard;        $currentboard = $curboard;
       return;        return;
   }    }
   if ($INFO{'ss_submit'}) {    if ($INFO{'ss_submit'}) {
       $currentboard = $newboard;        $currentboard = $newboard;
       $INFO{'num'} = $INFO{'thread'} = $FORM{'threadid'} = $curnum = $newthreadid;        $INFO{'num'} = $INFO{'thread'} = $FORM{'threadid'} = $curnum = $newthreadid;
       &redirectinternal;        &redirectinternal;
   }    }
   if ($debug == 1 or ($debug == 2 && $iamadmin)) {    if ($debug == 1 or ($debug == 2 && $iamadmin)) {
       require "$sourcedir/Debug.pl";        require "$sourcedir/Debug.pl";
       &Debug;        &Debug;
       $yydebug = qq~\n- $#utdnewthread<br />\n- @utdnewthread<br />\n- ${$newthreadid}{'lastpostdate'}<br />\n- ${$newthreadid}{'lastposter'}<br />\n- \$enable_notifications == $enable_notifications<br />\n- \$attachments = $attachments<br />\n<a href="javascript:load_thread($newthreadid,$linkcount);">continue</a>\n$yydebug~;        $yydebug = qq~\n- $#utdnewthread<br />\n- @utdnewthread<br />\n- ${$newthreadid}{'lastpostdate'}<br />\n- ${$newthreadid}{'lastposter'}<br />\n- \$enable_notifications == $enable_notifications<br />\n- \$attachments = $attachments<br />\n<a href="javascript:load_thread($newthreadid,$linkcount);">continue</a>\n$yydebug~;
   }    }
   
   &print_output_header;    &print_output_header;
   
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>$sstxt{'1'}</title> <title>$sstxt{'1'}</title>
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" /> <meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   function load_thread(threadid,replies) {    function load_thread(threadid,replies) {
       try{        try{
           if (typeof(opener.document) == 'object') throw '1';            if (typeof(opener.document) == 'object') throw '1';
           else throw '0';            else throw '0';
       } catch (e) {        } catch (e) {
           if (replies > 0 || ~ . ((($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse) ? 1 : 0) . qq~ == 1) replies = '/' + replies + '#' + replies;            if (replies > 0 || ~ . ((($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse) ? 1 : 0) . qq~ == 1) replies = '/' + replies + '#' + replies;
           else replies = '';            else replies = '';
           if (e == 1) {            if (e == 1) {
               opener.focus();                opener.focus();
               opener.location.href='$scripturl?num=' + threadid + replies;                opener.location.href='$scripturl?num=' + threadid + replies;
               self.close();                self.close();
           } else {            } else {
               location.href='$scripturl?num=' + threadid + replies;                location.href='$scripturl?num=' + threadid + replies;
           }            }
       }        }
   }    }
// --> // -->
</script> </script>
</head> </head>
<body onload="load_thread($newthreadid,$linkcount);"> <body onload="load_thread($newthreadid,$linkcount);">
&nbsp;$yydebug &nbsp;$yydebug
</body> </body>
</html>~; </html>~;
   
   &print_HTML_output_and_finish;    &print_HTML_output_and_finish;
} }
   
1; 1;