F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\MessageIndex.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\MessageIndex.pm
############################################################################### ###############################################################################
# MessageIndex.pl                                                             # # MessageIndex.pm                                                             #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# 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.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 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.                      #
############################################################################### ###############################################################################
  # use strict;
$messageindexplver = 'YaBB 2.5.2 $Revision: 1.0 $';  # use warnings; 
if ($action eq 'detailedversion') { return 1; }  no warnings qw(uninitialized once); 
  use CGI::Carp qw(fatalsToBrowser);
&LoadLanguage('MessageIndex');  our $VERSION = '2.6.12'; 
require "$templatesdir/$usemessage/MessageIndex.template";  
  $messageindexpmver = 'YaBB 2.6.12 $Revision: 1710 $';
  if ( $action eq 'detailedversion' ) { return 1; }
   
  get_micon();
  LoadLanguage('MessageIndex');
   
  if ( $INFO{'tsort'} eq q{} ) {
     $tsortcookie = "$cookietsort$currentboard$username";
     $tsort       = $yyCookies{$tsortcookie};
     $tsort =~ s/\D//gsm;
  }
  else {
     $tsort = $INFO{'tsort'};
     $tsort =~ s/\D//gsm;
     my $cookiename = "$cookietsort$currentboard$username";
     my $expiration = 'Sunday, 17-Jan-2038 00:00:00 GMT';
     push @otherCookies,
       write_cookie(
         -name    => "$cookiename",
         -value   => "$tsort",
         -path    => q{/},
         -expires => "$expiration" 
       );
  }
   
sub MessageIndex { sub MessageIndex {
   # Check if board was 'shown to all' - and whether they can view the board  
   if (&AccessCheck($currentboard, '', $boardperms) ne "granted") { &fatal_error("no_access"); }     # Check if board was 'shown to all' - and whether they can view the board 
   if ($annboard eq $currentboard && !$iamadmin && !$iamgmod) { &fatal_error("no_access"); }     if ( AccessCheck( $currentboard, q{}, $boardperms ) ne 'granted' ) { 
         fatal_error('no_access');
   my ($counter, $mcount, $buffer, $pages, $showmods, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $dlp, $threadlength);     } 
   my ($numanns, $threadcount, $countsticky, $countnosticky, $stkynum, @tmpanns, @anns, @threadlist, @stickythreadlist, @nostickythreadlist, @threads);     if ( $annboard eq $currentboard && !$iamadmin && !$iamgmod && !$iamfmod ) { 
   &BoardTotals("load", $currentboard);         fatal_error('no_access'); 
     }
   # Build a list of the board's moderators.  
   if (keys %moderators > 0) {     my ( 
       if (keys %moderators == 1) { $showmods = qq~($messageindex_txt{'298'}: ~; }         $counter, $mcount, $showmods, $mnum,     $msub, 
       else { $showmods = qq~($messageindex_txt{'63'}: ~; }         $mname,   $memail, $mdate,    $mreplies, $musername, 
         $micon,   $mstate, $dlp,
       while ($_ = each(%moderators)) {     ); 
           &FormatUserName($_);     my ( 
           $showmods .= &QuickLinks($_,1) . ", ";         $numanns,            $threadcount, $countsticky, 
       }         $stkynum,            @tmpanns,     @threadlist, 
       $showmods =~ s/, \Z/)/;         @nostickythreadlist, @threads,     $usermessagepage 
   }     ); 
   if (keys %moderatorgroups > 0) {     BoardTotals( 'load', $currentboard ); 
       if (keys %moderatorgroups == 1) { $showmodgroups = qq~($messageindex_txt{'298a'}: ~; }  
       else { $showmodgroups = qq~($messageindex_txt{'63a'}: ~; }     # See if we just want a message list from ajax 
     if ( $INFO{'messagelist'} ) { $messagelist = $INFO{'messagelist'}; }
       my ($tmpmodgrp,$thismodgrp);  
       while ($_ = each(%moderatorgroups)) {  # Load template here for conditionals based on whether we're ajax loading or not. 
           $tmpmodgrp = $moderatorgroups{$_};     get_template('MessageIndex'); 
           ($thismodgrp, undef) = split(/\|/, $NoPost{$tmpmodgrp}, 2);  
           $showmodgroups .= qq~$thismodgrp, ~;     # Build a list of the board's moderators. We don't need this if it's ajax. 
       }     if ( !$messagelist ) { 
       $showmodgroups =~ s/, \Z/)/;         if ( keys %moderators > 0 ) { 
   }             if ( keys %moderators == 1 ) { 
   if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~ - ~; }                 $showmods = qq~($messageindex_txt{'298'}: ~; 
             }
   # Load announcements, if they exist.             else { $showmods = qq~($messageindex_txt{'63'}: ~; } 
   if ($annboard && $annboard ne $currentboard && ${$uid.$currentboard}{'rbin'} != 1) {  
       chomp $annboard;             while ( $_ = each %moderators ) { 
       fopen(ANN, "$boardsdir/$annboard.txt");                 FormatUserName($_); 
       @tmpanns = <ANN>;                 $showmods .= QuickLinks( $_, 1 ) . q{, }; 
       fclose(ANN);             } 
       foreach my $realanns (@tmpanns) {             $showmods =~ s/, \Z/)/sm; 
           my $threadstatus = (split /\|/, $realanns)[8];         } 
           if ($threadstatus =~ /h/i && !$iamadmin && !$iamgmod && !$iammod) { next; }         if ( keys %moderatorgroups > 0 ) { 
           push (@threads, $realanns);             if ( keys %moderatorgroups == 1 ) { 
           $numanns++;                 $showmodgroups = qq~($messageindex_txt{'298a'}: ~; 
       }            }
       undef @tmpanns;             else { $showmodgroups = qq~($messageindex_txt{'63a'}: ~; } 
   }  
             my ( $tmpmodgrp, $thismodgrp );
   # Determine what category we are in.             while ( $_ = each %moderatorgroups ) { 
   $catid = ${$uid.$currentboard}{'cat'};                 $tmpmodgrp = $moderatorgroups{$_}; 
   ($cat, undef) = split(/\|/, $catinfo{$catid});                 ( $thismodgrp, undef ) = split /\|/xsm, $NoPost{$tmpmodgrp}, 2; 
   &ToChars($cat);                 $showmodgroups .= qq~$thismodgrp, ~; 
             }
   fopen(BRDTXT, "$boardsdir/$currentboard.txt") || &fatal_error("cannot_open","$boardsdir/$currentboard.txt", 1);             $showmodgroups =~ s/, \Z/)/sm; 
   @threadlist = <BRDTXT>;         } 
   fclose(BRDTXT);         if ( $showmodgroups ne q{} && $showmods ne q{} ) { 
   foreach my $threadlist (@threadlist) {             $showmods .= q~ - ~; 
       my $threadstatus = (split /\|/, $threadlist)[8];         } 
       if ($threadstatus =~ /h/i && !$iamadmin && !$iamgmod && !$iammod) { next; }         if ( ${ $uid . $currentboard }{'brdpasswr'} ) { 
       if ($threadstatus =~ /s/i) {             my $cookiename = "$cookiepassword$currentboard$username"; 
           push (@threads, $threadlist);             my $crypass    = ${ $uid . $currentboard }{'brdpassw'}; 
           $countsticky++;             if ( $iamguest ) { 
       } else {                 BoardPassw_g(); 
           $nostickythreadlist[$threadcount] = $threadlist;             } 
           $threadcount++;             elsif ( !$staff && $yyCookies{$cookiename} ne $crypass ) { 
       }                 BoardPassw(); 
   }            }
   undef @threadlist;         } 
     }
   $threadcount = $threadcount + $countsticky + $numanns;  
   my $maxindex = $INFO{'view'} eq 'all' ? $threadcount : $maxdisplay;     # Thread Tools 
     if ($useThreadtools) {
   # There are three kinds of lies: lies, damned lies, and statistics.         LoadTools( 0, 'newthread', 'createpoll', 'notify', 'markboardread' ); 
   # - Mark Twain     } 
   
   # Construct the page links for this board.     # Load announcements, if they exist. 
   if (!$iamguest) { ($usermessagepage, undef, undef, undef) = split(/\|/, ${$uid.$username}{'pageindex'}); }     if (   $annboard 
   my ($pagetxtindex, $pagetextindex, $pagedropindex1, $pagedropindex2, $all, $allselected);         && $annboard ne $currentboard 
   $indexdisplaynum = 3;              # max number of pages to display         && ${ $uid . $currentboard }{'rbin'} != 1 ) 
   $dropdisplaynum  = 10;     { 
   $startpage = 0;         chomp $annboard; 
   $max = $threadcount;         fopen( ANN, "$boardsdir/$annboard.txt" ); 
   if (substr($INFO{'start'}, 0, 3) eq 'all' && $showpageall != 0) { $maxindex = $max; $all = 1; $allselected = qq~ selected="selected"~; $start = 0; }         @tmpanns = <ANN>; 
   else { $start = $INFO{'start'} || 0; }         fclose(ANN); 
   if ($start > $threadcount - 1) { $start = $threadcount - 1; }         foreach my $realanns (@tmpanns) { 
   elsif ($start < 0) { $start = 0; }             my $threadstatus = ( split /\|/xsm, $realanns )[8]; 
   $start    = int($start / $maxindex) * $maxindex;             if ( $threadstatus =~ /h/ism && !$staff ) { next; } 
   $tmpa     = 1;             push @threads, $realanns; 
   $pagenumb = int(($threadcount - 1) / $maxindex) + 1;             $numanns++; 
         }
   if ($start >= (($indexdisplaynum - 1) * $maxindex)) {         undef @tmpanns; 
       $startpage = $start - (($indexdisplaynum - 1) * $maxindex);     } 
       $tmpa = int($startpage / $maxindex) + 1;  
   }     # Determine what category we are in. 
   if ($threadcount >= $start + ($indexdisplaynum * $maxindex)) { $endpage = $start + ($indexdisplaynum * $maxindex); }     $catid = ${ $uid . $currentboard }{'cat'}; 
   else { $endpage = $threadcount }     ( $cat, undef ) = split /\|/xsm, $catinfo{$catid}; 
   $lastpn = int(($threadcount - 1) / $maxindex) + 1;     ToChars($cat); 
   $lastptn = ($lastpn - 1) * $maxindex;  
   $pageindex1 = qq~<span class="small" style="float: left; height: 21px; margin: 0px; margin-top: 2px;"><img src="$imagesdir/index_togl.gif" border="0" alt="$messageindex_txt{'19'}" title="$messageindex_txt{'19'}" style="vertical-align: middle;" /> $messageindex_txt{'139'}: $pagenumb</span>~;     fopen( BRDTXT, "$boardsdir/$currentboard.txt" ) 
   $pageindex2 = $pageindex1;       or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
   if ($pagenumb > 1 || $all) {     @threadlist = <BRDTXT>; 
     fclose(BRDTXT);
       if ($usermessagepage == 1 || $iamguest) {     $sort_subject = 
           $pagetxtindexst = qq~<span class="small" style="float: left; height: 21px; margin: 0px; margin-top: 2px;">~;  qq~<a href="$scripturl?board=$currentboard;tsort=3" rel="nofollow">$messageindex_txt{'70'}</a>~; 
           if (!$iamguest) { $pagetxtindexst .= qq~<a href="$scripturl?board=$INFO{'board'};start=$start;action=messagepagedrop"><img src="$imagesdir/index_togl.gif" border="0" alt="$messageindex_txt{'19'}" title="$messageindex_txt{'19'}" style="vertical-align: middle;" /></a> $messageindex_txt{'139'}: ~; }     $sort_starter = 
           else { $pagetxtindexst .= qq~<img src="$imagesdir/index_togl.gif" border="0" alt="$messageindex_txt{'139'}" title="$messageindex_txt{'139'}" style="vertical-align: middle;" /> $messageindex_txt{'139'}: ~; }  qq~<a href="$scripturl?board=$currentboard;tsort=5" rel="nofollow">$messageindex_txt{'109'}</a>~; 
           if ($startpage > 0) { $pagetxtindex = qq~<a href="$scripturl?board=$currentboard/0" style="font-weight: normal;">1</a>&nbsp;<a href='javascript: void(0);' onclick='ListPages2("$currentboard","$threadcount");'>...</a>&nbsp;~; }     $sort_answer = 
           if ($startpage == $maxindex) { $pagetxtindex = qq~<a href="$scripturl?board=$currentboard/0" style="font-weight: normal;">1</a>&nbsp;~; }  qq~<a href="$scripturl?board=$currentboard;tsort=7" rel="nofollow">$messageindex_txt{'110'}</a>~; 
           for ($counter = $startpage; $counter < $endpage; $counter += $maxindex) {     $sort_lastpostim = 
               $pagetxtindex .= $start == $counter ? qq~<b>$tmpa</b>&nbsp;~ : qq~<a href="$scripturl?board=$currentboard/$counter" style="font-weight: normal;">$tmpa</a>&nbsp;~;  qq~<a href="$scripturl?board=$currentboard;tsort=0" rel="nofollow">$messageindex_txt{'22'}</a>~; 
               $tmpa++;  
           }     my %starter; 
           if ($endpage < $threadcount - $maxindex) { $pageindexadd = qq~<a href='javascript: void(0);' onclick='ListPages2("$currentboard","$threadcount");'>...</a>&nbsp;~; }     @temp_list = @threadlist; 
           if ($endpage != $threadcount) { $pageindexadd .= qq~<a href="$scripturl?board=$currentboard/$lastptn" style="font-weight: normal;">$lastpn</a>~; }  
     *starter = sub {
           $pagetxtindex .= $pageindexadd;         if ( exists $user_info{ $_[0] } ) { return $user_info{ $_[0] }; } 
           $pageindex1 = qq~$pagetxtindexst $pagetxtindex</span>~;         if ( !exists $memberinf{ $_[0] } ) { 
           $pageindex2 = $pageindex1;             return lc( ( split /\|/xsm, $_[1], 4 )[2] ); 
       } else {         } 
           $pagedropindex1 = qq~<span style="float: left; width: 350px; margin: 0px; margin-top: 2px; border: 0px;">~;         $user_info{ $_[0] } = 
           $pagedropindex1 .= qq~<span style="float: left; height: 21px; margin: 0; margin-right: 4px;"><a href="$scripturl?board=$INFO{'board'};start=$start;action=messagepagetext"><img src="$imagesdir/index_togl.gif" border="0" alt="$messageindex_txt{'19'}" title="$messageindex_txt{'19'}" /></a></span>~;           lc( ( split /\|/xsm, $memberinf{ $_[0] }, 2 )[0] ); 
           $pagedropindex2 = $pagedropindex1;     }; 
           $tstart = $start;  
           #if (substr($INFO{'start'}, 0, 3) eq "all") { ($tstart, $start) = split(/\-/, $INFO{'start'}); }     if ( $tsort == 1 ) { 
           $d_indexpages = $pagenumb / $dropdisplaynum;         $sort_lastpostim = 
           $i_indexpages = int($pagenumb / $dropdisplaynum);  qq~<a href="$scripturl?board=$currentboard;tsort=0" rel="nofollow">$messageindex_txt{'22'}</a> $micon{'sort_first'}~; 
           if ($d_indexpages > $i_indexpages) { $indexpages = int($pagenumb / $dropdisplaynum) + 1; }         @threadlist = reverse @temp_list; 
           else { $indexpages = int($pagenumb / $dropdisplaynum) }    }
           $selectedindex = int(($start / $maxindex) / $dropdisplaynum);     elsif ( $tsort == 2 ) { 
         $sort_subject =
           if ($pagenumb > $dropdisplaynum) {  qq~<a href="$scripturl?board=$currentboard;tsort=3" rel="nofollow">$messageindex_txt{'70'}</a> $micon{'sort_up'}~; 
               $pagedropindex1 .= qq~<span style="float: left; height: 21px; margin: 0;"><select size="1" name="decselector1" id="decselector1" style="font-size: 9px; border: 2px inset;" onchange="if(this.options[this.selectedIndex].value) SelDec(this.options[this.selectedIndex].value, 'xx')">\n~;         @threadlist = reverse sort { 
               $pagedropindex2 .= qq~<span style="float: left; height: 21px; margin: 0;"><select size="1" name="decselector2" id="decselector2" style="font-size: 9px; border: 2px inset;" onchange="if(this.options[this.selectedIndex].value) SelDec(this.options[this.selectedIndex].value, 'xx')">\n~;             lc(   ( split /\|/xsm, $a, 3 )[1] ) cmp 
           }               lc( ( split /\|/xsm, $b, 3 )[1] ) 
           for ($i = 0; $i < $indexpages; $i++) {         } @temp_list; 
               $indexpage = ($i * $dropdisplaynum) * $maxindex;     } 
     elsif ( $tsort == 3 ) {
               $indexstart = ($i * $dropdisplaynum) + 1;         $sort_subject = 
               $indexend = $indexstart + ($dropdisplaynum - 1);  qq~<a href="$scripturl?board=$currentboard;tsort=2" rel="nofollow">$messageindex_txt{'70'}</a> $micon{'sort_down'}~; 
               if ($indexend > $pagenumb)    { $indexend   = $pagenumb; }         @threadlist = sort { 
               if ($indexstart == $indexend) { $indxoption = qq~$indexstart~; }             lc(   ( split /\|/xsm, $a, 3 )[1] ) cmp 
               else { $indxoption = qq~$indexstart-$indexend~; }               lc( ( split /\|/xsm, $b, 3 )[1] ) 
               $selected = "";         } @temp_list; 
               if ($i == $selectedindex) {     } 
                   $selected = qq~ selected="selected"~;     elsif ( $tsort == 4 ) { 
                   $pagejsindex = qq~$indexstart|$indexend|$maxindex|$indexpage~;         ManageMemberinfo('load'); 
               }         $sort_starter = 
               if ($pagenumb > $dropdisplaynum) {  qq~<a href="$scripturl?board=$currentboard;tsort=5" rel="nofollow">$messageindex_txt{'109'}</a> $micon{'sort_up'}~; 
                   $pagedropindex1 .= qq~<option value="$indexstart|$indexend|$maxindex|$indexpage"$selected>$indxoption</option>\n~;         @threadlist = reverse sort { 
                   $pagedropindex2 .= qq~<option value="$indexstart|$indexend|$maxindex|$indexpage"$selected>$indxoption</option>\n~;             starter( ( split /\|/xsm, $a, 8 )[6], $a ) 
               }               cmp starter( ( split /\|/xsm, $b, 8 )[6], $b ) 
           }         } @temp_list; 
           if ($pagenumb > $dropdisplaynum) {         undef %memberinf; 
               $pagedropindex1 .= qq~</select>\n</span>~;     } 
               $pagedropindex2 .= qq~</select>\n</span>~;     elsif ( $tsort == 5 ) { 
           }         ManageMemberinfo('load'); 
           $pagedropindex1 .= qq~<span id="ViewIndex1" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;         $sort_starter = 
           $pagedropindex2 .= qq~<span id="ViewIndex2" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;  qq~<a href="$scripturl?board=$currentboard;tsort=4" rel="nofollow">$messageindex_txt{'109'}</a> $micon{'sort_down'}~; 
           $tmpmaxindex = $maxindex;         @threadlist = sort { 
           #if (substr($INFO{'start'}, 0, 3) eq "all") { $maxindex = $maxindex * $dropdisplaynum; }             starter( ( split /\|/xsm, $a, 8 )[6], $a ) 
           $prevpage = $start - $tmpmaxindex;               cmp starter( ( split /\|/xsm, $b, 8 )[6], $b ) 
           $nextpage = $start + $maxindex;         } @temp_list; 
           $pagedropindexpvbl = qq~<img src="$imagesdir/index_left0.gif" height="14" width="13" border="0" alt="" style="margin: 0px; display: inline; vertical-align: middle;" />~;         undef %memberinf; 
           $pagedropindexnxbl = qq~<img src="$imagesdir/index_right0.gif" height="14" width="13" border="0" alt="" style="margin: 0px; display: inline; vertical-align: middle;" />~;     } 
           if ($start < $maxindex) { $pagedropindexpv .= qq~<img src="$imagesdir/index_left0.gif" height="14" width="13" border="0" alt="" style="display: inline; vertical-align: middle;" />~; }     elsif ( $tsort == 6 ) { 
           else { $pagedropindexpv .= qq~<img src="$imagesdir/index_left.gif" border="0" height="14" width="13" alt="$pidtxt{'02'}" title="$pidtxt{'02'}" style="display: inline; vertical-align: middle; cursor: pointer;" onclick="location.href=\\'$scripturl?board=$currentboard/$prevpage\\'" ondblclick="location.href=\\'$scripturl?board=$currentboard/0\\'" />~; }         $sort_answer = 
           if ($nextpage > $lastptn) { $pagedropindexnx .= qq~<img src="$imagesdir/index_right0.gif" border="0" height="14" width="13" alt="" style="display: inline; vertical-align: middle;" />~; }  qq~<a href="$scripturl?board=$currentboard;tsort=7" rel="nofollow">$messageindex_txt{'110'}</a> $micon{'sort_up'}~; 
           else { $pagedropindexnx .= qq~<img src="$imagesdir/index_right.gif" height="14" width="13" border="0" alt="$pidtxt{'03'}" title="$pidtxt{'03'}" style="display: inline; vertical-align: middle; cursor: pointer;" onclick="location.href=\\'$scripturl?board=$currentboard/$nextpage\\'" ondblclick="location.href=\\'$scripturl?board=$currentboard/$lastptn\\'" />~; }         @threadlist = 
           $pageindex1 = qq~$pagedropindex1</span>~;           reverse 
           $pageindex2 = qq~$pagedropindex2</span>~;           sort { ( split /\|/xsm, $a, 7 )[5] <=> ( split /\|/xsm, $b, 7 )[5] } 
           @temp_list;
           $pageindexjs = qq~     } 
<script language="JavaScript1.2" type="text/javascript">     elsif ( $tsort == 7 ) { 
<!--         $sort_answer = 
   function SelDec(decparam, visel) {  qq~<a href="$scripturl?board=$currentboard;tsort=6" rel="nofollow">$messageindex_txt{'110'}</a> $micon{'sort_down'}~; 
       splitparam = decparam.split("|");         @threadlist = 
       var vistart = parseInt(splitparam[0]);           sort { ( split /\|/xsm, $a, 7 )[5] <=> ( split /\|/xsm, $b, 7 )[5] } 
       var viend = parseInt(splitparam[1]);           @temp_list; 
       var maxpag = parseInt(splitparam[2]);     } 
       var pagstart = parseInt(splitparam[3]);     else { 
       //var allpagstart = parseInt(splitparam[3]);         $sort_lastpostim = 
       if (visel == 'xx' && decparam == '$pagejsindex') visel = '$tstart';  qq~<a href="$scripturl?board=$currentboard;tsort=1" rel="nofollow">$messageindex_txt{'22'}</a> $micon{'sort_up'}~; 
       var pagedropindex = '<table border="0" cellpadding="0" cellspacing="0"><tr>';     } 
       for(i=vistart; i<=viend; i++) {  
           if (visel == pagstart) pagedropindex += '<td class="titlebg" height="14" style="height: 14px; padding-left: 1px; padding-right: 1px; font-size: 9px; font-weight: bold;">' + i + '</td>';     undef @temp_list; 
           else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?board=$currentboard/' + pagstart + '">' + i + '</a></td>';     undef %starter; 
           pagstart += maxpag;  
       }     foreach my $threadlist (@threadlist) { 
       ~;         my $threadstatus = ( split /\|/xsm, $threadlist )[8]; 
       if ($showpageall) {        if ( $threadstatus =~ /h/ism && !$staff ) {
           $pageindexjs .= qq~             next; 
           if (vistart != viend) {         } 
               if(visel == 'all') pagedropindex += '<td class="titlebg" height="14" style="height: 14px; padding-left: 1px; padding-right: 1px; font-size: 9px; font-weight: normal;"><b>$pidtxt{'01'}</b></td>';         if ( $threadstatus =~ /s/ism ) { 
               else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?board=$currentboard/all">$pidtxt{'01'}</a></td>';             push @threads, $threadlist; 
           }             $countsticky++; 
           ~;         } 
       }         else { 
       $pageindexjs .= qq~             $nostickythreadlist[$threadcount] = $threadlist; 
       if(visel != 'xx') pagedropindex += '<td height="14" class="small" style="height: 14px; padding-left: 4px;">$pagedropindexpv$pagedropindexnx</td>';             $threadcount++; 
       else pagedropindex += '<td height="14" class="small" style="height: 14px; padding-left: 4px;">$pagedropindexpvbl$pagedropindexnxbl</td>';         } 
       pagedropindex += '</tr></table>';     } 
       document.getElementById("ViewIndex1").innerHTML=pagedropindex;     undef @threadlist; 
       document.getElementById("ViewIndex1").style.visibility = "visible";  
       document.getElementById("ViewIndex2").innerHTML=pagedropindex;     $threadcount = $threadcount + $countsticky + $numanns; 
       document.getElementById("ViewIndex2").style.visibility = "visible";     my $maxindex = $INFO{'view'} eq 'all' ? $threadcount : $maxdisplay; 
       ~;  
           if ($pagenumb > $dropdisplaynum) {     # Construct the page links for this board. 
               $pageindexjs .= qq~     if ( !$iamguest ) { 
       document.getElementById("decselector1").value = decparam;         ( $usermessagepage, undef, undef, undef ) = 
       document.getElementById("decselector2").value = decparam;           split /\|/xsm, ${ $uid . $username }{'pageindex'}; 
       ~;     } 
           }     my ( $pagetxtindex, $pagedropindex1, $pagedropindex2, $all, $allselected ); 
           $pageindexjs .= qq~     $indexdisplaynum = 3;              # max number of pages to display 
   }     $dropdisplaynum  = 10; 
   document.onload = SelDec('$pagejsindex', '$tstart');     $startpage       = 0; 
//-->     $max             = $threadcount; 
     if ( substr( $INFO{'start'}, 0, 3 ) eq 'all' && $showpageall != 0 ) {
         $maxindex    = $max;
         $all         = 1;
         $allselected = q~ selected="selected"~;
         $start       = 0;
     }
     else { $start = $INFO{'start'} || 0; }
     if ( $start > $threadcount - 1 ) { $start = $threadcount - 1; }
     elsif ( $start < 0 ) { $start = 0; }
     $start    = int( $start / $maxindex ) * $maxindex;
     $tmpa     = 1;
     $pagenumb = int( ( $threadcount - 1 ) / $maxindex ) + 1;
   
     if ( $start >= ( ( $indexdisplaynum - 1 ) * $maxindex ) ) {
         $startpage = $start - ( ( $indexdisplaynum - 1 ) * $maxindex );
         $tmpa = int( $startpage / $maxindex ) + 1;
     }
     if ( $threadcount >= $start + ( $indexdisplaynum * $maxindex ) ) {
         $endpage = $start + ( $indexdisplaynum * $maxindex );
     }
     else { $endpage = $threadcount }
     $lastpn = int( ( $threadcount - 1 ) / $maxindex ) + 1;
     $lastptn = ( $lastpn - 1 ) * $maxindex;
     $pageindex1 =
  qq~<span class="small pgindex"><img src="$index_togl{'index_togl'}" alt="$messageindex_txt{'19'}" title="$messageindex_txt{'19'}" /> $messageindex_txt{'139'}: $pagenumb</span>~;
     $pageindex2 = $pageindex1;
   
     if ( $pagenumb > 1 || $all ) {
   
         if ( $usermessagepage == 1 || $iamguest ) {
             $pagetxtindexst = q~<span class="small pgindex">~;
             if ( !$iamguest ) {
                 $pagetxtindexst .=
  qq~<a href="$scripturl?board=$INFO{'board'};start=$start;action=messagepagedrop"><img src="$index_togl{'index_togl'}"  alt="$messageindex_txt{'19'}" title="$messageindex_txt{'19'}" /></a> $messageindex_txt{'139'}: ~;
             }
             else {
                 $pagetxtindexst .=
  qq~<img src="$index_togl{'index_togl'}"  alt="$messageindex_txt{'139'}" title="$messageindex_txt{'139'}" /> $messageindex_txt{'139'}: ~;
             }
             if ( $startpage > 0 ) {
                 if ($messagelist) {
                     $pagetxtindex =
  qq~<a href="$scripturl?board=$currentboard/0">1</a>&nbsp;<a href='javascript: void(0);' onclick='ListPages2("$currentboard","$threadcount");'>...</a>&nbsp;~;
                 }
                 if ( $startpage == $maxindex ) {
                     $pagetxtindex =
  qq~<a href="$scripturl?board=$currentboard/0"><span class="small">1</span></a>&nbsp;~;
                 }
             }
             foreach my $counter ( $startpage .. ( $endpage - 1 ) ) {
                 if ( $counter % $maxindex == 0 ) {
                     if ($messagelist) {
                         $pagetxtindex .=
                           $start == $counter
                           ? qq~<b>[$tmpa]</b>&nbsp;~
                           : qq~<a href="javascript:MessageList('$scripturl?board=$currentboard/$counter;messagelist=1','$yyhtml_root','$currentboard', 1)"><span class="small">$tmpa</span></a>&nbsp;~;
                     }
                     else {
                         $pagetxtindex .=
                           $start == $counter
                           ? qq~<b>[$tmpa]</b>&nbsp;~
                           : qq~<a href="$scripturl?board=$currentboard/$counter"><span class="small">$tmpa</span></a>&nbsp;~;
                     }
                     $tmpa++;
                 }
             }
             if ( $endpage < $threadcount - $maxindex ) {
                 $pageindexadd =
  qq~<a href='javascript: void(0);' onclick='ListPages2("$currentboard","$threadcount");'>...</a>&nbsp;~;
             }
             if ( $endpage != $threadcount ) {
                 $pageindexadd .=
  qq~<a href="$scripturl?board=$currentboard/$lastptn"><span class="small">$lastpn</span></a>~;
             }
   
             $pagetxtindex .= $pageindexadd;
             $pageindex1 = qq~$pagetxtindexst $pagetxtindex</span>~;
             $pageindex2 = $pageindex1;
         }
         else {
             $pagedropindex1 = q~<span class="pagedropindex">~;
             $pagedropindex1 .=
  qq~<span class="pagedropindex_inner"><a href="$scripturl?board=$INFO{'board'};start=$start;action=messagepagetext"><img src="$index_togl{'index_togl'}"  alt="$messageindex_txt{'19'}" title="$messageindex_txt{'19'}" /></a></span>~;
             $pagedropindex2 = $pagedropindex1;
             $tstart         = $start;
   
  #if (substr($INFO{'start'}, 0, 3) eq 'all') { ($tstart, $start) = split(/\-/, $INFO{'start'}); }
             $d_indexpages = $pagenumb / $dropdisplaynum;
             $i_indexpages = int( $pagenumb / $dropdisplaynum );
             if ( $d_indexpages > $i_indexpages ) {
                 $indexpages = int( $pagenumb / $dropdisplaynum ) + 1;
             }
             else { $indexpages = int( $pagenumb / $dropdisplaynum ) }
             $selectedindex = int( ( $start / $maxindex ) / $dropdisplaynum );
   
             if ( $pagenumb > $dropdisplaynum ) {
                 $pagedropindex1 .=
  qq~<span class="decselector"><select size="1" name="decselector1" id="decselector1" class="decselector_sel" onchange="if(this.options[this.selectedIndex].value) SelDec(this.options[this.selectedIndex].value, 'xx')">\n~;
                 $pagedropindex2 .=
  qq~<span class="decselector"><select size="1" name="decselector2" id="decselector2" class="decselector_sel" onchange="if(this.options[this.selectedIndex].value) SelDec(this.options[this.selectedIndex].value, 'xx')">\n~;
             }
             for my $i ( 0 .. ( $indexpages - 1 ) ) {
                 $indexpage = ( $i * $dropdisplaynum ) * $maxindex;
   
                 $indexstart = ( $i * $dropdisplaynum ) + 1;
                 $indexend = $indexstart + ( $dropdisplaynum - 1 );
                 if ( $indexend > $pagenumb ) { $indexend = $pagenumb; }
                 if ( $indexstart == $indexend ) {
                     $indxoption = qq~$indexstart~;
                 }
                 else { $indxoption = qq~$indexstart-$indexend~; }
                 $selected = q{};
                 if ( $i == $selectedindex ) {
                     $selected = q~ selected="selected"~;
                     $pagejsindex =
                       qq~$indexstart|$indexend|$maxindex|$indexpage~;
                 }
                 if ( $pagenumb > $dropdisplaynum ) {
                     $pagedropindex1 .=
  qq~<option value="$indexstart|$indexend|$maxindex|$indexpage"$selected>$indxoption</option>\n~;
                     $pagedropindex2 .=
  qq~<option value="$indexstart|$indexend|$maxindex|$indexpage"$selected>$indxoption</option>\n~;
                 }
             }
             if ( $pagenumb > $dropdisplaynum ) {
                 $pagedropindex1 .= qq~</select>\n</span>~;
                 $pagedropindex2 .= qq~</select>\n</span>~;
             }
             $pagedropindex1 .=
  q~<span id="ViewIndex1" class="droppageindex viewindex_hid">&nbsp;</span>~;
             $pagedropindex2 .=
  q~<span id="ViewIndex2" class="droppageindex viewindex_hid">&nbsp;</span>~;
             $tmpmaxindex = $maxindex;
   
  #if (substr($INFO{'start'}, 0, 3) eq 'all') { $maxindex = $maxindex * $dropdisplaynum; }
             $prevpage = $start - $tmpmaxindex;
             $nextpage = $start + $maxindex;
             $pagedropindexpvbl =
  qq~<img src="$index_togl{'index_left0'}" height="14" width="13"  alt="" />~;
             $pagedropindexnxbl =
  qq~<img src="$index_togl{'index_right0'}" height="14" width="13"  alt="" />~;
             if ( $start < $maxindex ) {
                 $pagedropindexpv .=
  qq~<img src="$index_togl{'index_left0'}" height="14" width="13"  alt="" />~;
             }
             else {
                 $pagedropindexpv .=
  qq~<img src="$index_togl{'index_left'}"  height="14" width="13" alt="$pidtxt{'02'}" title="$pidtxt{'02'}" class="cursor" ~;
                 if ($messagelist) {
                     $pagedropindexpv .=
  qq~onclick="MessageList(\\'$scripturl?board=$currentboard/$prevpage;messagelist=1\\',\\'$yyhtml_root\\', \\'$currentboard\\', 1)" ondblclick="MessageList(\\'$scripturl?board=$currentboard/0;messagelist=1\\', \\'$yyhtml_root\\',\\'$currentboard\\', 1)" />~;
                 }
                 else {
                     $pagedropindexpv .=
  qq~onclick="location.href=\\'$scripturl?board=$currentboard/$prevpage\\'" ondblclick="location.href=\\'$scripturl?board=$currentboard/0\\'" />~;
                 }
             }
             if ( $nextpage > $lastptn ) {
                 $pagedropindexnx .=
  qq~<img src="$index_togl{'index_right0'}"  height="14" width="13" alt="" />~;
             }
             else {
                 $pagedropindexnx .=
  qq~<img src="$index_togl{'index_right'}" height="14" width="13"  alt="$pidtxt{'03'}" title="$pidtxt{'03'}" class="cursor" ~;
                 if ($messagelist) {
                     $pagedropindexnx .=
  qq~onclick="MessageList(\\'$scripturl?board=$currentboard/$nextpage;messagelist=1\\', \\'$yyhtml_root\\',\\'$currentboard\\', 1)" ondblclick="MessageList(\\'$scripturl?board=$currentboard/$lastptn;messagelist=1\\', \\'$yyhtml_root\\',\\'$currentboard\\', 1)" />~;
                 }
                 else {
                     $pagedropindexnx .=
  qq~onclick="location.href=\\'$scripturl?board=$currentboard/$nextpage\\'" ondblclick="location.href=\\'$scripturl?board=$currentboard/$lastptn\\'" />~;
                 }
             }
   
             # make select box have links for ajax vs default url
             if ($messagelist) {
                 $default_or_ajax =
  qq~javascript:MessageList(\\'$scripturl?board=$currentboard/' + pagstart + ';messagelist=1\\', \\'$yyhtml_root\\',\\'$currentboard\\', 1)~;
             }
             else {
                 $default_or_ajax =
                   qq~$scripturl?board=$currentboard/' + pagstart + '~;
             }
             $pageindex1 = qq~$pagedropindex1</span>~;
             $pageindex2 = qq~$pagedropindex2</span>~;
   
             $pageindexjs = qq~
  <script id="RunSelDec" type="text/javascript">
     function SelDec(decparam, visel) {
         splitparam = decparam.split("|");
         var vistart = parseInt(splitparam[0]);
         var viend = parseInt(splitparam[1]);
         var maxpag = parseInt(splitparam[2]);
         var pagstart = parseInt(splitparam[3]);
         //var allpagstart = parseInt(splitparam[3]);
         if (visel == 'xx' && decparam == '$pagejsindex') visel = '$tstart';
         var pagedropindex = '$visel_0';
         for(i=vistart; i<=viend; i++) {
             if (visel == pagstart) pagedropindex += '$visel_1a<b>' + i + '</b>$visel_1b';
             else pagedropindex += '$visel_2a<a href="$scripturl?board=$currentboard/' + pagstart + '">' + i + '</a>$visel_1b';
             pagstart += maxpag;
         }
         ~;
             if ($showpageall) {
                 $pageindexjs .= qq~
             if (vistart != viend) {
                 if(visel == 'all') pagedropindex += '$visel_1a<b>$pidtxt{'01'}</b></td>';
                 else pagedropindex += '$visel_2a<a href="$scripturl?board=$currentboard/all">$pidtxt{'01'}</a>$visel_1b';
             }
             ~;
             }
             $pageindexjs .= qq~
         if(visel != 'xx') pagedropindex += '$visel_3a$pagedropindexpv$pagedropindexnx$visel_1b';
         else pagedropindex += '$visel_3a$pagedropindexpvbl$pagedropindexnxbl$visel_1b';
         pagedropindex += '$visel_4';
         document.getElementById("ViewIndex1").innerHTML=pagedropindex;
         document.getElementById("ViewIndex1").style.visibility = "visible";
         document.getElementById("ViewIndex2").innerHTML=pagedropindex;
         document.getElementById("ViewIndex2").style.visibility = "visible";
         ~;
             if ( $pagenumb > $dropdisplaynum ) {
                 $pageindexjs .= q~
         document.getElementById("decselector1").value = decparam;
         document.getElementById("decselector2").value = decparam;
         ~;
             }
             $pageindexjs .= qq~
     }
     var pagejsindex = "$pagejsindex";
     var tstart = "$tstart";
     document.onload = SelDec(pagejsindex, tstart);
</script> </script>
~; ~;
       }        }
   }    }
   
     if ( $start <= $#threads ) { $stkynum = scalar @threads; }
     push @threads, @nostickythreadlist;
     undef @nostickythreadlist;
     @threads = splice @threads, $start, $maxindex;
     chomp @threads;
   
     my %attachments;
     if ( ( -s "$vardir/attachments.txt" ) > 5 ) {
         fopen( ATM, "$vardir/attachments.txt" );
         while (<ATM>) {
             $attachments{ ( split /\|/xsm, $_, 2 )[0] }++;
         }
         fclose(ATM);
     }
   
     LoadCensorList();
   
     # check the Multi-admin setting
     my $multiview = 0;
     if ($staff) {
         if (   ( $iamadmin && $adminview == 3 )
             || ( $iamgmod && $gmodview == 3 )
             || ( $iamfmod && $fmodview == 3 )
             || ( $iammod  && $modview == 3 ) )
         {
             $multiview = 3;
         }
         elsif (( $iamadmin && $adminview == 2 )
             || ( $iamgmod && $gmodview == 2 )
             || ( $iamfmod && $fmodview == 2 )
             || ( $iammod  && $modview == 2 ) )
         {
             $multiview = 2;
         }
         elsif (( $iamadmin && $adminview == 1 )
             || ( $iamgmod && $gmodview == 1 )
             || ( $iamfmod && $fmodview == 1 )
             || ( $iammod  && $modview == 1 ) )
         {
             $multiview = 1;
         }
     }
   
     # Print the header and board info.
     ( $boardname, undef ) = split /\|/xsm, $board{$currentboard};
     my $curboardname = $boardname;
     ToChars($curboardname);
     if ( $multiview == 1 ) {
         $yymain .=
           qq~<script type="text/javascript">
  function NoPost(op) {
     if (document.getElementById("toboard").options[op].className == "nopost") {
         alert("$messageindex_txt{'nopost'}");
         document.getElementById("toboard").selectedIndex = 0;
     }
  }
  </script>
  \n~;
     }
   
     if ( $multiview >= 2 ) {
         my $modul = $currentboard eq $annboard ? 4 : 5;
         $yymain .=
  qq~<script src="$yyhtml_root/MessageIndex.js" type="text/javascript"></script>
  <script type="text/javascript">
  function NoPost(op) {
     if (document.getElementById("toboard").options[op].className == "nopost") {
         alert("$messageindex_txt{'nopost'}");
         document.getElementById("toboard").selectedIndex = 0;
     }
  }
  </script>
  \n~;
     }
   
   if ($start <= $#threads) { $stkynum = scalar @threads; }     my $homelink = qq~<a href="$scripturl">$mbname</a>~; 
   push (@threads, @nostickythreadlist);     my $catlink  = qq~<a href="$scripturl?catselect=$catid">$cat</a>~; 
   undef @nostickythreadlist;     my $boardlink = 
   @threads = splice(@threads, $start, $maxindex);  qq~<a href="$scripturl?board=$currentboard" class="a"><b>$curboardname</b></a>~; 
   chomp @threads;     my $modslink = qq~$showmods~; 
   
   my %attachments;     $boardtree   = q{}; 
   if (-s "$vardir/attachments.txt" > 5) {     $parentboard = $currentboard; 
       fopen(ATM, "$vardir/attachments.txt");     while ($parentboard) { 
       while (<ATM>) {         my ( $pboardname, undef, undef ) = 
           $attachments{(split(/\|/, $_, 2))[0]}++;           split /\|/xsm, $board{"$parentboard"}; 
       }         ToChars($pboardname); 
       fclose(ATM);  
   }         if ( ${ $uid . $parentboard }{'canpost'} || !$subboard{$parentboard} ) { 
             $pboardname =
   &LoadCensorList;  qq~<a href="$scripturl?board=$parentboard" class="a"><b>$pboardname</b></a>~; 
         }
   # Print the header and board info.         else { 
   &ToChars($boardname);             $pboardname = 
   if ((($iammod && $modview == 1 && !$iamadmin && !$iamgmod) || ($iamadmin && $adminview == 1) || ($iamgmod && $gmodview == 1)) && $sessionvalid == 1) {  qq~<a href="$scripturl?boardselect=$parentboard;subboards=1" class="a"><b>$pboardname</b></a>~; 
       $yymain .= qq~<script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>~;         } 
   }         $boardtree   = qq~ &rsaquo; $pboardname$boardtree~; 
         $parentboard = ${ $uid . $parentboard }{'parent'};
   my $homelink = qq~<a href="$scripturl">$mbname</a>~;     } 
   my $catlink = qq~<a href="$scripturl?catselect=$catid">$cat</a>~;  
   my $boardlink = qq~<a href="$scripturl?board=$currentboard" class="a"><b>$boardname</b></a>~;     # check how many col's must be spanned 
   my $modslink = qq~$showmods~;     if ( $multiview > 0 ) { 
         $colspan = 7;
   # check howmany col's must be spanned     } 
   if ((($iamadmin && $adminview >= 1) || ($iamgmod && $gmodview >= 1) || ($iammod && $modview >= 1 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {    else {
       $colspan = 8;         $colspan = 6; 
   } else {     } 
       $colspan = 7;  
   }     if ( !$iamguest ) { 
         my $brdid = q{};
   if (!$iamguest) {        if ( $messagelist ) {
       $markalllink = qq~$menusep<a href="javascript:MarkAllAsRead('$scripturl?board=$INFO{'board'};action=markasread','$imagesdir')">$img{'markboardread'}</a>~;             $mthreadslang = 1; 
       $notify_board = qq~$menusep<a href="$scripturl?action=boardnotify;board=$INFO{'board'}">$img{'notify'}</a>~;             $brdid = q{new_} . $INFO{'board'}; 
   }        }
         $markalllink =
   if (&AccessCheck($currentboard, 1) eq "granted") {  qq~$menusep<a href="javascript:MarkAllAsRead('$scripturl?board=$INFO{'board'};action=markasread','$imagesdir','$mthreadslang','$brdid')">$img{'markboardread'}</a>~; 
       # when Quick-Post and Quick-Jump: focus message first, then the subject to have a better display  
       $postlink = qq~$menusep<a href="~ . ($enable_quickpost && $enable_quickjump ? 'javascript:document.postmodify.message.focus();document.postmodify.subject.focus();' : qq~$scripturl?board=$INFO{'board'};action=post;title=StartNewTopic~) . qq~">$img{'newthread'}</a>~;         $notify_board = 
   }  qq~$menusep<a href="$scripturl?action=boardnotify;board=$INFO{'board'}">$img{'notify'}</a>~; 
   if (&AccessCheck($currentboard, 3) eq "granted") {     } 
       $polllink = qq~$menusep<a href="$scripturl?board=$INFO{'board'};action=post;title=CreatePoll">$img{'createpoll'}</a>~;  
   }     if ( AccessCheck( $currentboard, 1 ) eq 'granted' ) { 
   
   if ((($iamadmin && $adminview == 3) || ($iamgmod && $gmodview == 3) || ($iammod && $modview == 3 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {  # when Quick-Post and Quick-Jump: focus message first, then the subject to have a better display 
       if ($currentboard eq $annboard) {        if ($messagelist) {
           $adminlink = qq~<img src="$imagesdir/announcementlock.gif" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}" border="0" /><img src="$imagesdir/hide.gif" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}" border="0" /><img src="$imagesdir/admin_move.gif" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}" border="0" /><img src="$imagesdir/admin_rem.gif" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}" border="0" />~;             if ($mdrop_postpopup) { 
       } else {                 $postlink = 
           $adminlink = qq~<img src="$imagesdir/locked.gif" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}" border="0" /><img src="$imagesdir/sticky.gif" alt="$messageindex_txt{'781'}" title="$messageindex_txt{'781'}" border="0" /><img src="$imagesdir/hide.gif" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}" border="0" /><img src="$imagesdir/admin_move.gif" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}" border="0" /><img src="$imagesdir/admin_rem.gif" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}" border="0" />~;  qq~$menusep<a href="javascript:void(0)" onclick="PostPage('$scripturl?board=$INFO{'board'};action=post;title=StartNewTopic','$INFO{'board'}')">$img{'newthread'}</a>~; 
       }            }
       $adminheader =~ s/({|<)yabb admin(}|>)/$adminlink/g;             else { 
   } elsif ((($iamadmin && $adminview != 0) || ($iamgmod && $gmodview != 0) || ($iammod && $modview != 0 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {                 $postlink = 
       $adminlink = qq~$messageindex_txt{'2'}~;  qq~$menusep<a href="$scripturl?board=$INFO{'board'};action=post;title=StartNewTopic">$img{'newthread'}</a>~; 
       $adminheader =~ s/({|<)yabb admin(}|>)/$adminlink/g;             } 
   }        }
         else {
   # check to display moderator column             if ($mindex_postpopup) { 
   my $tmpstickyheader;                 $postlink = 
   if ($stkynum) {  qq~$menusep<a href="javascript:void(0)" onclick="PostPage('$scripturl?board=$INFO{'board'};action=post;title=StartNewTopic','$INFO{'board'}')">$img{'newthread'}</a>~; 
       $stickyheader =~ s/({|<)yabb colspan(}|>)/$colspan/g;             } 
       $tmpstickyheader = $stickyheader;             else { 
   }                 $postlink = qq~$menusep<a href="~ 
                   . (
   # load Favorites in a hash                     $enable_quickpost && $enable_quickjump 
   if (${$uid.$username}{'favorites'}) { foreach (split(/,/, ${$uid.$username}{'favorites'})) { $favicon{$_} = 1; } }                     ? 'javascript:document.postmodify.message.focus();document.postmodify.subject.focus();' 
                     : qq~$scripturl?board=$INFO{'board'};action=post;title=StartNewTopic~
   # Begin printing the message index for current board.                   ) . qq~">$img{'newthread'}</a>~; 
   $counter = $start;             } 
   &dumplog($currentboard); # Mark current board as seen         } 
   my $dmax = $date - ($max_log_days_old * 86400);     } 
   foreach (@threads) {    if ( AccessCheck( $currentboard, 3 ) eq 'granted' ) {
       ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $_);         $polllink = 
  qq~$menusep<a href="$scripturl?board=$INFO{'board'};action=post;title=CreatePoll">$img{'createpoll'}</a>~;
       &MessageTotals('load', $mnum);     } 
   
       my $goodboard = $mstate =~ /a/i ? $annboard : $currentboard;     if ( $multiview == 3 ) { 
       if (${$mnum}{'board'} ne $goodboard) {         my $adminlink; 
           ${$mnum}{'board'} = $goodboard if $goodboard;         if ( $currentboard eq $annboard ) { 
           &MessageTotals('recover', $mnum);             $adminlink = 
       }  qq~<img src="$micon_bg{'announcementlock'}" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}" /><img src="$micon_bg{'hide'}" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}" /><img src="$micon_bg{'admin_move'}" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}" /><img src="$micon_bg{'admin_rem'}" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}" />~; 
         }
       $permlinkboard = ${$mnum}{'board'} eq $annboard ? $annboard : $currentboard;         else { 
       my $permdate = &permtimer($mnum);             $adminlink = 
       my $message_permalink = qq~<a href="http://$perm_domain/$symlink$permdate/$permlinkboard/$mnum">$messageindex_txt{'10'}</a>~;  qq~<img src="$micon_bg{'locked'}" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}" /><img src="$micon_bg{'sticky'}" alt="$messageindex_txt{'781'}" title="$messageindex_txt{'781'}" /><img src="$micon_bg{'hide'}" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}" /><img src="$micon_bg{'admin_move'}" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}" /><img src="$micon_bg{'admin_rem'}" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}" />~; 
         }
       $threadclass = 'thread';         $adminheader =~ s/{yabb admin}/$adminlink/gsm; 
       if ($mstate =~ /h/i) { $threadclass = 'hide'; }    }
       elsif ($mstate =~ /l/i) { $threadclass = 'locked'; }     elsif ( 
       elsif ($mreplies >= $VeryHotTopic) { $threadclass = 'veryhotthread'; }         ( 
       elsif ($mreplies >= $HotTopic) { $threadclass = 'hotthread'; }                ( $iamadmin && $adminview != 0 ) 
       elsif ($mstate == '') { $threadclass = 'thread'; }             || ( $iamgmod && $gmodview != 0 ) 
       if ($threadclass eq 'hide' && $mstate =~ /s/i && $mstate !~ /l/i) { $threadclass = 'hidesticky'; }             || ( $iamfmod && $fmodview != 0 ) 
       elsif ($threadclass eq 'hide' && $mstate =~ /l/i && $mstate !~ /s/i) { $threadclass = 'hidelock'; }             || (   $iammod 
       elsif ($threadclass eq 'hide' && $mstate =~ /s/i && $mstate =~ /l/i) { $threadclass = 'hidestickylock'; }                 && $modview != 0 
       elsif ($threadclass eq 'locked' && $mstate =~ /s/i && $mstate !~ /h/i) { $threadclass = 'stickylock'; }                 && !$iamadmin 
       elsif ($mstate =~ /s/i && $mstate !~ /h/i) { $threadclass = 'sticky'; }                 && !$iamgmod 
       elsif (${$mnum}{'board'} eq $annboard && $mstate !~ /h/i) { $threadclass = $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; }                 && !$iamfmod ) 
         )
       my ($movedSubject, $movedFlag) = &Split_Splice_Move($msub,$mnum);         && $sessionvalid == 1 
       $threadclass = 'locked_moved' if $movedFlag;       ) 
     {
       if (!$iamguest && $max_log_days_old) {         $adminlink = qq~$messageindex_txt{'2'}~; 
           # Decide if thread should have the "NEW" indicator next to it.         $adminheader =~ s/{yabb admin}/$adminlink/gsm; 
           # Do this by reading the user's log for last read time on thread,     } 
           # and compare to the last post time on the thread.  
           $dlp = int($yyuserlog{$mnum}) > int($yyuserlog{"$currentboard--mark"}) ? int($yyuserlog{$mnum}) : int($yyuserlog{"$currentboard--mark"});     # check to display moderator column 
           if (!$movedFlag && ($yyuserlog{"$mnum--unread"} || (!$dlp && $mdate > $dmax) || ($dlp > $dmax && $dlp < $mdate))) {     my $tmpstickyheader; 
               if (${$mnum}{'board'} eq $annboard) {    if ($stkynum) {
                   $new = qq~<a href="$scripturl?virboard=$currentboard;num=$mnum/new#new"><img src="$imagesdir/new.gif" alt="$messageindex_txt{'302'}" title="$messageindex_txt{'302'}" border="0"/></a>~;         $stickyheader =~ s/{yabb colspan}/$colspan/gsm; 
               } else {         $tmpstickyheader = $stickyheader; 
                   $new = qq~<a href="$scripturl?num=$mnum/new#new"><img src="$imagesdir/new.gif" alt="$messageindex_txt{'302'}" title="$messageindex_txt{'302'}" border="0"/></a>~;     } 
               }  
           } else {     # load Favorites in a hash 
               $new = '';     if ( ${ $uid . $username }{'favorites'} ) { 
           }         foreach ( split /,/xsm, ${ $uid . $username }{'favorites'} ) { 
       }             $favicon{$_} = 1; 
         }
       $micon = qq~<img src="$imagesdir/$micon.gif" alt="" border="0" align="middle" />~;     } 
       $mpoll = "";  
       if (-e "$datadir/$mnum.poll") {     # Count threads to alternate colors 
           $mpoll = qq~<b>$messageindex_txt{'15'}: </b>~;     my $alternatethreadcolor = 0; 
           fopen(POLL, "$datadir/$mnum.poll");  
           my @poll = <POLL>;     # Begin printing the message index for current board. 
           fclose(POLL);     $counter = $start; 
           my ($poll_question, $poll_locked, $poll_uname, $poll_name, $poll_email, $poll_date, $guest_vote, $hide_results, $multi_vote, $poll_mod, $poll_modname, $poll_comment, $vote_limit, $pie_radius, $pie_legends, $poll_end) = split(/\|/, $poll[0]);     dumplog($currentboard);    # Mark current board as seen 
           chomp $poll_end;     my $dmax = $date - ( $max_log_days_old * 86400 ); 
           if ($poll_end && !$poll_locked && $poll_end < $date) {    foreach (@threads) {
               $poll_locked = 1;         ( 
               $poll_end = '';             $mnum,     $msub,      $mname, $memail, $mdate, 
               $poll[0] = "$poll_question|$poll_locked|$poll_uname|$poll_name|$poll_email|$poll_date|$guest_vote|$hide_results|$multi_vote|$poll_mod|$poll_modname|$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n";             $mreplies, $musername, $micon, $mstate 
               fopen(POLL, ">$datadir/$mnum.poll");         ) = split /\|/xsm, $_; 
               print POLL @poll;  
               fclose(POLL);         my ( $movedSubject, $movedFlag ) = Split_Splice_Move( $msub, $mnum ); 
           }  
           $micon = qq~$img{'pollicon'}~;         MessageTotals( 'load', $mnum ); 
           if ($poll_locked) { $micon = $img{'polliconclosed'}; }  
           elsif (!$iamguest && $max_log_days_old && $mdate > $date - ($max_log_days_old * 86400)) {         my $altthdcolor = 
               if ($dlp < $createpoll_date) {           ( ( $alternatethreadcolor % 2 ) == 1 ) ? 'windowbg' : 'windowbg2'; 
                   $micon = qq~$img{'polliconnew'}~;         $alternatethreadcolor++; 
               } else {  
                   fopen(POLLED, "$datadir/$mnum.polled");         my $goodboard = $mstate =~ /a/ism ? $annboard : $currentboard; 
                   $polled = <POLLED>;         if ( ${$mnum}{'board'} ne $goodboard ) { 
                   fclose(POLLED);             if ($goodboard) { ${$mnum}{'board'} = $goodboard; } 
                   (undef, undef, undef, $vote_date, undef) = split(/\|/, $polled);             MessageTotals( 'recover', $mnum ); 
                   if ($dlp < $vote_date) { $micon = qq~$img{'polliconnew'}~; }        }
               }  
           }         $permlinkboard = 
       }           ${$mnum}{'board'} eq $annboard ? $annboard : $currentboard; 
         my $permdate = permtimer($mnum);
       # Load the current nickname of the account name of the thread starter.         my $message_permalink = 
       if ($musername ne 'Guest') {  qq~<a href="http://$perm_domain/$symlink$permdate/$permlinkboard/$mnum">$messageindex_txt{'10'}</a>~; 
           &LoadUser($musername);  
           # See if they are an ex-member.         $threadclass = 'thread'; 
           if ((${$uid.$musername}{'regdate'} && $mdate > ${$uid.$musername}{'regtime'}) || ${$uid.$musername}{'position'} eq "Administrator" || ${$uid.$musername}{'position'} eq "Global Moderator") {         if    ( $mstate =~ /h/ism ) { $threadclass = 'hide'; } 
               $mname = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}">${$uid.$musername}{'realname'}</a>~;         elsif ( $mstate =~ /l/ism ) { $threadclass = 'locked'; } 
           } else {         elsif ( $mreplies >= $VeryHotTopic ) { $threadclass = 'veryhotthread'; } 
               $mname .= qq~ ($messageindex_txt{'470a'})~;         elsif ( $mreplies >= $HotTopic )     { $threadclass = 'hotthread'; } 
           }        elsif ( $mstate eq q{} ) { $threadclass = 'thread'; }
       } else {         if ( $threadclass eq 'hide' && $mstate =~ /s/ism && $mstate !~ /l/ism ) 
           $mname .= " ($maintxt{'28'})";         { 
       }             $threadclass = 'hidesticky'; 
         }
       # Build the page links list.         elsif ($threadclass eq 'hide' 
       my ($pages, $pagesall);             && $mstate =~ /l/ism 
       if ($showpageall) { $pagesall = qq~<a href="$scripturl?num=$mnum/all">$pidtxt{'01'}</a>~; }             && $mstate !~ /s/ism ) 
       if (int(($mreplies + 1) / $maxmessagedisplay) > 6) {        {
           $pages = qq~ <a href="$scripturl?num=$mnum/~ . (!$ttsreverse ? "0#0" : "$mreplies#$mreplies") . qq~">1</a>~;             $threadclass = 'hidelock'; 
           $pages .= qq~ <a href="$scripturl?num=$mnum/~ . (!$ttsreverse ? "$maxmessagedisplay#$maxmessagedisplay" : ($mreplies - $maxmessagedisplay) . '#' . ($mreplies - $maxmessagedisplay)) . qq~">2</a>~;         } 
           $endpage = int($mreplies / $maxmessagedisplay) + 1;         elsif ($threadclass eq 'hide' 
           $i = ($endpage - 1) * $maxmessagedisplay;             && $mstate =~ /s/ism 
           $j = $i - $maxmessagedisplay;             && $mstate =~ /l/ism ) 
           $k = $endpage - 1;         { 
           $tmpa = $endpage - 2;             $threadclass = 'hidestickylock'; 
           $tmpb = $j - $maxmessagedisplay;         } 
           $pages .= qq~ <a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>~;         elsif ($threadclass eq 'locked' 
           $pages .= qq~ <a href="$scripturl?num=$mnum/~ . (!$ttsreverse ? "$tmpb#$tmpb" : ($mreplies - $tmpb) . '#' . ($mreplies - $tmpb)) . qq~">$tmpa</a>~;             && $mstate =~ /s/ism 
           $pages .= qq~ <a href="$scripturl?num=$mnum/~ . (!$ttsreverse ? "$j#$j" : ($mreplies - $j) . '#' . ($mreplies - $j)) . qq~">$k</a>~;             && $mstate !~ /h/ism ) 
           $pages .= qq~ <a href="$scripturl?num=$mnum/~ . (!$ttsreverse ? "$i#$i" : ($mreplies - $i) . '#' . ($mreplies - $i)) . qq~">$endpage</a>~;         { 
           $pages = qq~<br /><span class="small">&#171; $messageindex_txt{'139'} $pages $pagesall &#187;</span>~;             $threadclass = 'stickylock'; 
       } elsif ($mreplies + 1 > $maxmessagedisplay) {         } 
           $tmpa = 1;         elsif ( $mstate =~ /s/ism && $mstate !~ /h/ism ) { 
           for ($tmpb = 0; $tmpb < $mreplies + 1; $tmpb += $maxmessagedisplay) {             $threadclass = 'sticky'; 
               $pages .= qq~<a href="$scripturl?num=$mnum/~ . (!$ttsreverse ? "$tmpb#$tmpb" : ($mreplies - $tmpb) . '#' . ($mreplies - $tmpb)) . qq~">$tmpa</a>\n~;         } 
               ++$tmpa;         elsif ( ${$mnum}{'board'} eq $annboard && $mstate !~ /h/ism ) { 
           }             $threadclass = 
           $pages =~ s/\n\Z//;               $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; 
           $pages = qq~<br /><span class="small">&#171; $messageindex_txt{'139'} $pages $pagesall &#187;</span>~;         } 
       }         ### Start Sticky Shimmy Shuffle mod 
         my $stickdir;
       # build number of views         if ($staff) { 
       my $views = ${$mnum}{'views'} ? ${$mnum}{'views'} - 1 : 0;             if ( $threadclass eq 'sticky' || $threadclass eq 'stickylock'  || $threadclass eq 'hidesticky' || $threadclass eq 'hidestickylock') { 
       $lastposter = ${$mnum}{'lastposter'};                 $stickdir = 
       if ($lastposter =~ m~\AGuest-(.*)~) {  qq~&nbsp;&nbsp;<a href="$scripturl?action=rearrsticky;board=$currentboard;num=$mnum;direction=up" title="$messageindex_txt{'move_up'}"><span class="sticky_stick"><b>&uarr;</b></span></a><a href="$scripturl?action=rearrsticky;board=$currentboard;num=$mnum;direction=down" title="$messageindex_txt{'move_down'}"><span class="sticky_stick"><b>&darr;</b></span> </a>~; 
           $lastposter = $1 . " ($maintxt{'28'})";             } 
       } else {  elsif (( $threadclass eq 'announcement' || $threadclass eq 'announcementlock' || ${$mnum}{'board'} eq $annboard && $mstate =~ /h/ism ) 
           &LoadUser($lastposter);                 && ( $iamadmin || $iamgmod ) ) 
           if ((${$uid.$lastposter}{'regdate'} && ${$mnum}{'lastpostdate'} > ${$uid.$lastposter}{'regtime'}) || ${$uid.$lastposter}{'position'} eq "Administrator" || ${$uid.$lastposter}{'position'} eq "Global Moderator") {            {
               $lastposter = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$lastposter}">${$uid.$lastposter}{'realname'}</a>~;                 $stickdir = 
           } else {  qq~&nbsp;&nbsp;<a href="$scripturl?action=rearrsticky;board=$annboard;num=$mnum;direction=up;oldboard=$currentboard;" title="$messageindex_txt{'move_up'}"><span class="sticky_stick"><b>&uarr;</b></span></a><a href="$scripturl?action=rearrsticky;board=$annboard;num=$mnum;direction=down;oldboard=$currentboard;" title="$messageindex_txt{'move_down'}"><span class="sticky_stick"><b>&darr;</b></span> </a>~; 
               # Need to load thread to see lastposters DISPLAYname if is Ex-Member             } 
               fopen(EXMEMBERTHREAD, "$datadir/$mnum.txt") || &fatal_error('cannot_open', "$datadir/$mnum.txt", 1);         } 
               my @x = <EXMEMBERTHREAD>;         ### End Sticky Shimmy Shuffle Mod 
               fclose(EXMEMBERTHREAD);  
               $lastposter = (split(/\|/, $x[$#x], 3))[1] . " - $messageindex_txt{'470a'}";         if ($movedFlag) { $threadclass = 'locked_moved'; } 
           }  
       }         if ( !$iamguest && $max_log_days_old ) { 
       $lastpostername = $lastposter || $messageindex_txt{'470'};  
             # Decide if thread should have the "NEW" indicator next to it.
       if (($stkynum && ($counter >= $stkynum)) && ($stkyshowed < 1)) {             # Do this by reading the user's log for last read time on thread, 
           $nonstickyheader =~ s/({|<)yabb colspan(}|>)/$colspan/g;             # and compare to the last post time on the thread. 
           $tmptempbar .= $nonstickyheader;             $dlp = 
           $stkyshowed = 1;               int( $yyuserlog{$mnum} ) > 
       }               int( $yyuserlog{"$currentboard--mark"} ) 
               ? int( $yyuserlog{$mnum} )
       # Check if the thread contains attachments and create a paper-clip icon if it does               : int $yyuserlog{"$currentboard--mark"}; 
       my $alt = $attachments{$mnum} == 1 ? $messageindex_txt{'5'} : $messageindex_txt{'4'};             if ( 
       $temp_attachment = $attachments{$mnum} ?                 !$movedFlag 
           (($guest_media_disallowed && $iamguest) ?                 && (   $yyuserlog{"$mnum--unread"} 
               qq~<img src="$imagesdir/paperclip.gif" alt="$messageindex_txt{'3'} $attachments{$mnum} $alt" title="$messageindex_txt{'3'} $attachments{$mnum} $alt" />~ :                     || ( !$dlp && $mdate > $dmax ) 
               qq~<a href="javascript:void(window.open('$scripturl?action=viewdownloads;thread=$mnum','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))">~ . qq~<img src="$imagesdir/paperclip.gif" alt="$messageindex_txt{'3'} $attachments{$mnum} $alt" title="$messageindex_txt{'3'} $attachments{$mnum} $alt" style="border-style:none;" /></a>~) :                     || ( $dlp > $dmax && $dlp < $mdate ) ) 
           "";               ) 
             {
       $mcount++;                 if ( ${$mnum}{'board'} eq $annboard ) { 
       # Print the thread info.                     $new = 
       $mydate = &timeformat($mdate);  qq~<a href="$scripturl?virboard=$currentboard;num=$mnum/new#new">$newload{'new_mess'}</a>~; 
       if ((($iamadmin && $adminview == 3) || ($iamgmod && $gmodview == 3) || ($iammod && $modview == 3 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {                 } 
           if ($currentboard eq $annboard) {                else {
               $adminbar = qq~                     $new = 
       <input type="checkbox" name="lockadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />  qq~<a href="$scripturl?num=$mnum/new#new">$newload{'new_mess'}</a>~; 
       <input type="checkbox" name="hideadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />                 } 
       <input type="checkbox" name="moveadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />             } 
       <input type="checkbox" name="deleteadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />             else { 
       ~;                 $new = q{}; 
           } elsif ($counter < $numanns) {             } 
               $adminbar = qq~&nbsp;~;         } 
           } else {  
               $adminbar = qq~         $micon = qq~$micon{$micon}~; 
       <input type="checkbox" name="lockadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />         $mpoll = q{}; 
       <input type="checkbox" name="stickadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />         if ( -e "$datadir/$mnum.poll" ) { 
       <input type="checkbox" name="hideadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />             $mpoll = qq~<b>$messageindex_txt{'15'}: </b>~; 
       <input type="checkbox" name="moveadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />             fopen( POLL, "$datadir/$mnum.poll" ); 
       <input type="checkbox" name="deleteadmin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />             my @poll = <POLL>; 
       ~;             fclose(POLL); 
           }             my ( 
           $admincol = $admincolumn;                 $poll_question, $poll_locked, $poll_uname,   $poll_name, 
           $admincol =~ s/({|<)yabb admin(}|>)/$adminbar/g;                 $poll_email,    $poll_date,   $guest_vote,   $hide_results, 
       } elsif ((($iamadmin && $adminview == 2) || ($iamgmod && $gmodview == 2) || ($iammod && $modview == 2 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {                 $multi_vote,    $poll_mod,    $poll_modname, $poll_comment, 
           if ($currentboard ne $annboard && $counter < $numanns) {                 $vote_limit,    $pie_radius,  $pie_legends,  $poll_end 
               $adminbar = qq~&nbsp;~;             ) = split /\|/xsm, $poll[0]; 
           } else {             chomp $poll_end; 
               $adminbar = qq~<input type="checkbox" name="admin$mcount" class="windowbg" style="border: 0px;" value="$mnum" />~;             if ( $poll_end && !$poll_locked && $poll_end < $date ) { 
           }                 $poll_locked = 1; 
           $admincol = $admincolumn;                 $poll_end    = q{}; 
           $admincol =~ s/({|<)yabb admin(}|>)/$adminbar/g;                 $poll[0] = 
       } elsif ((($iamadmin && $adminview == 1) || ($iamgmod && $gmodview == 1) || ($iammod && $modview == 1 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {  "$poll_question|$poll_locked|$poll_uname|$poll_name|$poll_email|$poll_date|$guest_vote|$hide_results|$multi_vote|$poll_mod|$poll_modname|$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n"; 
           if ($currentboard eq $annboard) {                 fopen( POLL, ">$datadir/$mnum.poll" ); 
               $adminbar = qq~                 print {POLL} @poll or croak "$croak{'print'} POLL"; 
       <a href="$scripturl?action=lock;thread=$mnum;tomessageindex=1"><img src="$imagesdir/announcementlock.gif" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}" border="0" /></a>&nbsp;                 fclose(POLL); 
       <a href="$scripturl?action=hide;thread=$mnum;tomessageindex=1"><img src="$imagesdir/hide.gif" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}" border="0" /></a>&nbsp;             } 
       <a href="javascript:void(window.open('$scripturl?action=split_splice;board=$currentboard;thread=$mnum;oldposts=all;leave=0;newcat=${$uid.$currentboard}{'cat'};newboard=$currentboard;position=end','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))"><img src="$imagesdir/admin_move.gif" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}" border="0" /></a>&nbsp;  
       <a href="$scripturl?action=removethread;thread=$mnum" onclick="return confirm('$messageindex_txt{'162'}')"><img src="$imagesdir/admin_rem.gif" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}" border="0" /></a>             $micon = qq~$micon{'pollicon'}~; 
       ~;             if ($poll_locked) { $micon = $micon{'polliconclosed'}; } 
           } elsif ($counter < $numanns) {             elsif ( !$iamguest 
               $adminbar = qq~&nbsp;~;                 && $max_log_days_old 
           } else {                 && $mdate > $date - ( $max_log_days_old * 86400 ) ) 
               $adminbar = qq~             { 
       <a href="$scripturl?action=lock;thread=$mnum;tomessageindex=1"><img src="$imagesdir/locked.gif" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}" border="0" /></a>&nbsp;                 if ( $dlp < $createpoll_date ) { 
       <a href="$scripturl?action=sticky;thread=$mnum"><img src="$imagesdir/sticky.gif" alt="$messageindex_txt{'781'}" title="$messageindex_txt{'781'}" border="0" /></a>&nbsp;                     $micon = qq~$micon{'polliconnew'}~; 
       <a href="$scripturl?action=hide;thread=$mnum;tomessageindex=1"><img src="$imagesdir/hide.gif" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}" border="0" /></a>&nbsp;                 } 
       <a href="javascript:void(window.open('$scripturl?action=split_splice;board=$currentboard;thread=$mnum;oldposts=all;leave=0;newcat=${$uid.$currentboard}{'cat'};newboard=$currentboard;position=end','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))"><img src="$imagesdir/admin_move.gif" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}" border="0" /></a>&nbsp;                 else { 
       <a href="$scripturl?action=removethread;thread=$mnum" onclick="return confirm('$messageindex_txt{'162'}')"><img src="$imagesdir/admin_rem.gif" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}" border="0" /></a>                     fopen( POLLED, "$datadir/$mnum.polled" ); 
       ~;                     $polled = <POLLED>; 
           }                     fclose(POLLED); 
           $admincol = $admincolumn;                     ( undef, undef, undef, $vote_date, undef ) = 
           $admincol =~ s/({|<)yabb admin(}|>)/$adminbar/g;                       split /\|/xsm, $polled; 
       }                     if ( $dlp < $vote_date ) { 
                         $micon = qq~$micon{'polliconnew'}~;
       $msub = &Censor($msub);                     } 
       &ToChars($msub);                 } 
       if(!$movedFlag) {             } 
           if (${$mnum}{'board'} eq $annboard) {         } 
               $msublink = qq~<a href="$scripturl?virboard=$currentboard;num=$mnum">$msub</a>~;  
           } else {         # Load the current nickname of the account name of the thread starter. 
               $msublink = qq~<a href="$scripturl?num=$mnum">$msub</a>~;         if ( $musername ne 'Guest' ) { 
           }             LoadUser($musername); 
       } elsif ($movedFlag < 100) {  
           &Split_Splice_Move($msub,0);             # See if they are an ex-member. 
           $msublink = qq~$msub<br /><span class="small">$movedSubject</span>~;             if ( 
       } else {                 ( 
           $msub =~ /^(Re: )?\[m.*?\]: '(.*)'/; # newer then code in &Split_Splice_Move                     ${ $uid . $musername }{'regdate'} 
           $msublink = qq~$maintxt{'758'}: '<a href="$scripturl?num=$movedFlag">$2</a>'<br /><span class="small">$movedSubject</span>~;                     && $mdate > ${ $uid . $musername }{'regtime'} 
       }                 ) 
                 || ${ $uid . $musername }{'position'} eq 'Administrator' 
       my $tempbar = $movedFlag ? $threadbarMoved : $threadbar;                 || ${ $uid . $musername }{'position'} eq 'Global Moderator' 
       $tempbar =~ s/({|<)yabb admin column(}|>)/$admincol/g;               ) 
       $tempbar =~ s/({|<)yabb threadpic(}|>)/<img src="$imagesdir\/$threadclass.gif" alt="" \/>/g;             { 
       $tempbar =~ s/({|<)yabb icon(}|>)/$micon/g;                 if ( $iamguest) { 
       $tempbar =~ s/({|<)yabb new(}|>)/$new/g;                     $mname = $format_unbold{$musername}; 
       $tempbar =~ s/({|<)yabb poll(}|>)/$mpoll/g;                 } 
       $tempbar =~ s/({|<)yabb favorite(}|>)/ ($favicon{$mnum} ? qq~<img src="$imagesdir\/addfav.gif" alt="$img_txt{'70'}" title="$img_txt{'70'}" \/>~ : '') /eg;                 else { 
       $tempbar =~ s/({|<)yabb subjectlink(}|>)/$msublink/g;                     $mname = 
       $tempbar =~ s/({|<)yabb attachmenticon(}|>)/$temp_attachment/g;  qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}">$format_unbold{$musername}</a>~; 
       $tempbar =~ s/({|<)yabb pages(}|>)/$pages/g;                 } 
       $tempbar =~ s/({|<)yabb starter(}|>)/$mname/g;             } 
       $tempbar =~ s/({|<)yabb replies(}|>)/ &NumberFormat($mreplies) /eg;             else { 
       $tempbar =~ s/({|<)yabb views(}|>)/ &NumberFormat($views) /eg;                 $mname .= qq~ ($messageindex_txt{'470a'})~; 
       $tempbar =~ s/({|<)yabb lastpostlink(}|>)/<a href="$scripturl?num=$mnum\/$mreplies#$mreplies">$img{'lastpost'} $mydate<\/a>/g;             } 
       $tempbar =~ s/({|<)yabb lastposter(}|>)/$lastpostername/g;         } 
       if($accept_permalink == 1) {        else {
           $tempbar =~ s/({|<)yabb permalink(}|>)/$message_permalink/g;             $mname .= " ($maintxt{'28'})"; 
       } else {         } 
           $tempbar =~ s/({|<)yabb permalink(}|>)//g;  
       }         # Build the page links list. 
       $tmptempbar .= $tempbar;         my $pagesall = q{}; 
       $counter++;         my $pages    = q{}; 
   }         if ($showpageall) { 
             $pagesall =
   # Put a "no messages" message if no threads exisit - just a  bit more friendly...               qq~<a href="$scripturl?num=$mnum/all">$pidtxt{'01'}</a>~; 
   if (!$tmptempbar) {         } 
       $tmptempbar = qq~         $maxmessagedisplay ||= 10; 
       <tr>         if ( int( ( $mreplies + 1 ) / $maxmessagedisplay ) > 6 ) { 
           <td class="windowbg2" valign="middle" align="center" colspan="$colspan"><br />$messageindex_txt{'841'}<br /><br /></td>             $pages = 
       </tr>                 qq~ <a href="$scripturl?num=$mnum/~ 
       ~;               . ( !$ttsreverse ? '0#0' : "$mreplies#$mreplies" ) 
   }               . q~"><span class="small">1</span></a>~; 
             $pages .= qq~ <a href="$scripturl?num=$mnum/~
   my $multiview = 0;               . ( 
   my $tmptempfooter;                 !$ttsreverse 
   if    ((($iamadmin && $adminview == 3) || ($iamgmod && $gmodview == 3) || ($iammod && $modview == 3 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) { $multiview = 3; }                 ? "$maxmessagedisplay#$maxmessagedisplay" 
   elsif ((($iamadmin && $adminview == 2) || ($iamgmod && $gmodview == 2) || ($iammod && $modview == 2 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) { $multiview = 2; }                 : ( $mreplies - $maxmessagedisplay ) . q{#} 
                   . ( $mreplies - $maxmessagedisplay )
   if ($multiview >= 2) {               ) . q~">2</a>~; 
       my $boardlist = &moveto;  
       if ($multiview eq '3') {             $endpage = int( $mreplies / $maxmessagedisplay ) + 1; 
           $tempfooter    = $subfooterbar;             $i       = ( $endpage - 1 ) * $maxmessagedisplay; 
           $adminselector = qq~             $j       = $i - $maxmessagedisplay; 
               <label for="toboard">$messageindex_txt{'133'}</label>: <input type="checkbox" name="newinfo" value="1" title="$messageindex_txt{199}" class="titlebg" style="border: 0px;" ondblclick="alert('$messageindex_txt{200}')" /> <select name="toboard" id="toboard">$boardlist</select><input type="submit" value="$messageindex_txt{'462'}" class="button" />             $k       = $endpage - 1; 
           ~;             $tmpa    = $endpage - 2; 
           if ($currentboard eq $annboard) {             $tmpb    = $j - $maxmessagedisplay; 
               $admincheckboxes = qq~             $pages .= 
               <input type="checkbox" name="lockall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(1); else uncheckAll(1);" />  qq~ <a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>~; 
               <input type="checkbox" name="hideall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(2); else uncheckAll(2);" />             $pages .= qq~ <a href="$scripturl?num=$mnum/~ 
               <input type="checkbox" name="moveall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(3); else uncheckAll(3);" />               . ( 
               <input type="checkbox" name="deleteall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(4); else uncheckAll(4);" />                 !$ttsreverse 
               <input type="hidden" name="fromboard" value="$currentboard" />                 ? "$tmpb#$tmpb" 
           ~;                 : ( $mreplies - $tmpb ) . q{\x23} . ( $mreplies - $tmpb ) 
           } else {               ) . qq~"><span class="small">$tmpa</span></a>~; 
               $admincheckboxes = qq~             $pages .= qq~ <a href="$scripturl?num=$mnum/~ 
               <input type="checkbox" name="lockall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(1); else uncheckAll(1);" />               . ( 
               <input type="checkbox" name="stickall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(2); else uncheckAll(2);" />                 !$ttsreverse 
               <input type="checkbox" name="hideall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(3); else uncheckAll(3);" />                 ? "$j#$j" 
               <input type="checkbox" name="moveall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(4); else uncheckAll(4);" />                 : ( $mreplies - $j ) . q{#} . ( $mreplies - $j ) 
               <input type="checkbox" name="deleteall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(5); else uncheckAll(5);" />               ) . qq~"><span class="small">$k</span></a>~; 
               <input type="hidden" name="fromboard" value="$currentboard" />             $pages .= qq~ <a href="$scripturl?num=$mnum/~ 
           ~;               . ( 
           }                 !$ttsreverse 
           $tempfooter =~ s/({|<)yabb admin selector(}|>)/$adminselector/g;                 ? "$i#$i" 
           $tempfooter =~ s/({|<)yabb admin checkboxes(}|>)/$admincheckboxes/g;                 : ( $mreplies - $i ) . q{#} . ( $mreplies - $i ) 
       } elsif ($multiview eq '2') {               ) . qq~"><span class="small">$endpage</span></a>~; 
           $tempfooter = $subfooterbar;             $pages = 
           if ($currentboard eq $annboard) {  qq~<br /><span class="small">&laquo; $messageindex_txt{'139'} $pages $pagesall &raquo;</span>~; 
               $adminselector = qq~         } 
               <input type="radio" name="multiaction" id="multiactionlock" value="lock" class="titlebg" style="border: 0px;" /> <label for="multiactionlock">$messageindex_txt{'104'}</label>         elsif ( $mreplies + 1 > $maxmessagedisplay ) { 
               <input type="radio" name="multiaction" id="multiactionhide" value="hide" class="titlebg" style="border: 0px;" /> <label for="multiactionhide">$messageindex_txt{'844'}</label>             $tmpa = 1; 
               <input type="radio" name="multiaction" id="multiactiondelete" value="delete" class="titlebg" style="border: 0px;" /> <label for="multiactiondelete">$messageindex_txt{'31'}</label>             foreach my $tmpb ( 0 .. $mreplies ) { 
               <input type="radio" name="multiaction" id="multiactionmove" value="move" class="titlebg" style="border: 0px;" /> <label for="multiactionmove">$messageindex_txt{'133'}</label>: <input type="checkbox" name="newinfo" value="1" title="$messageindex_txt{199}" class="titlebg" style="border: 0px;" ondblclick="alert('$messageindex_txt{200}')" /> <select name="toboard" onchange="document.multiadmin.multiaction[3].checked=true;">$boardlist</select>                 if ( $tmpb % $maxmessagedisplay == 0 ) { 
               <input type="hidden" name="fromboard" value="$currentboard" />                     $pages .= qq~<a href="$scripturl?num=$mnum/~ 
               <input type="submit" value="$messageindex_txt{'462'}" class="button" />                       . ( 
           ~;                         !$ttsreverse 
           } else {                         ? "$tmpb#$tmpb" 
               $adminselector = qq~                         : ( $mreplies - $tmpb ) . q{\x23} . ( $mreplies - $tmpb ) 
               <input type="radio" name="multiaction" id="multiactionlock" value="lock" class="titlebg" style="border: 0px;" /> <label for="multiactionlock">$messageindex_txt{'104'}</label>                       ) . qq~"><span class="small">$tmpa</span></a>\n~; 
               <input type="radio" name="multiaction" id="multiactionstick" value="stick" class="titlebg" style="border: 0px;" /> <label for="multiactionstick">$messageindex_txt{'781'}</label>                     ++$tmpa; 
               <input type="radio" name="multiaction" id="multiactionhide" value="hide" class="titlebg" style="border: 0px;" /> <label for="multiactionhide">$messageindex_txt{'844'}</label>                 } 
               <input type="radio" name="multiaction" id="multiactiondelete" value="delete" class="titlebg" style="border: 0px;" /> <label for="multiactiondelete">$messageindex_txt{'31'}</label>             } 
               <input type="radio" name="multiaction" id="multiactionmove" value="move" class="titlebg" style="border: 0px;" /> <label for="multiactionmove">$messageindex_txt{'133'}</label>: <input type="checkbox" name="newinfo" value="1" title="$messageindex_txt{199}" class="titlebg" style="border: 0px;" ondblclick="alert('$messageindex_txt{200}')" /> <select name="toboard" onchange="document.multiadmin.multiaction[4].checked=true;">$boardlist</select>             $pages =~ s/\n\Z//xsm; 
               <input type="hidden" name="fromboard" value="$currentboard" />             $pages = 
               <input type="submit" value="$messageindex_txt{'462'}" class="button" />  qq~<br /><span class="small">&laquo; $messageindex_txt{'139'} $pages $pagesall &raquo;</span>~; 
           ~;         } 
           }  
           $admincheckboxes = qq~         # build number of views 
               <input type="checkbox" name="checkall" id="checkall" value="" class="titlebg" style="border: 0px;" onclick="if (this.checked) checkAll(0); else uncheckAll(0);" />         my $views = ${$mnum}{'views'} ? ${$mnum}{'views'} - 1 : 0; 
           ~;         $lastposter = ${$mnum}{'lastposter'}; 
           $tempfooter =~ s/({|<)yabb admin selector(}|>)/$adminselector/g;         if ( $lastposter =~ m{\AGuest-(.*)}xsm ) { 
           $tempfooter =~ s/({|<)yabb admin checkboxes(}|>)/$admincheckboxes/g;             $lastposter = $1 . " ($maintxt{'28'})"; 
       }        }
   }         else { 
   $tmptempfooter .= $tempfooter;             LoadUser($lastposter); 
             if (
   $yabbicons = qq~                 ( 
   <img src="$imagesdir/thread.gif" alt="$messageindex_txt{'457'}" title="$messageindex_txt{'457'}" /> $messageindex_txt{'457'}<br />                        ${ $uid . $lastposter }{'regdate'} 
   <img src="$imagesdir/sticky.gif" alt="$messageindex_txt{'779'}" title="$messageindex_txt{'779'}" /> $messageindex_txt{'779'}<br />                     && ${$mnum}{'lastpostdate'} > 
   <img src="$imagesdir/locked.gif" alt="$messageindex_txt{'456'}" title="$messageindex_txt{'456'}" /> $messageindex_txt{'456'}<br />                     ${ $uid . $lastposter }{'regtime'} 
   <img src="$imagesdir/stickylock.gif" alt="$messageindex_txt{'456'}" title="$messageindex_txt{'780'}" /> $messageindex_txt{'780'}<br />                 ) 
   <img src="$imagesdir/locked_moved.gif" alt="$messageindex_txt{'845'}" title="$messageindex_txt{'845'}" /> $messageindex_txt{'845'}<br />                 || ${ $uid . $lastposter }{'position'} eq 'Administrator' 
                 || ${ $uid . $lastposter }{'position'} eq 'Global Moderator' 
               )
             {
                 if ( $iamguest) {
                     $lastposter = $format_unbold{$lastposter};
                 }
                 else {
                     $lastposter =
  qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$lastposter}">$format_unbold{$lastposter}</a>~;
                 }
             }
             else {
   
             # Need to load thread to see lastposters DISPLAYname if is Ex-Member
                 fopen( EXMEMBERTHREAD, "$datadir/$mnum.txt" )
                   or fatal_error( 'cannot_open', "$datadir/$mnum.txt", 1 );
                 my @x = <EXMEMBERTHREAD>;
                 fclose(EXMEMBERTHREAD);
                 $lastposter =
                   ( split /\|/xsm, $x[-1], 3 )[1]
                   . " - $messageindex_txt{'470a'}";
             }
         }
         $lastpostername = $lastposter || $messageindex_txt{'470'};
   
         if ( ( $stkynum && ( $counter >= $stkynum ) ) && ( $stkyshowed < 1 ) ) {
             $nonstickyheader =~ s/{yabb colspan}/$colspan/gsm;
             $tmptempbar .= $nonstickyheader;
             $stkyshowed = 1;
         }
   
  # Check if the thread contains attachments and create a paper-clip icon if it does
         my $alt =
             $attachments{$mnum} == 1
           ? $messageindex_txt{'5'}
           : $messageindex_txt{'4'};
         $temp_attachment =
           $attachments{$mnum}
           ? (
             ( $guest_media_disallowed && $iamguest )
             ? qq~<img src="$micon_bg{'paperclip'}" alt="$messageindex_txt{'3'} $attachments{$mnum} $alt" title="$messageindex_txt{'3'} $attachments{$mnum} $alt" />~
             : $msg_attach_win
               . qq~<img src="$micon_bg{'paperclip'}" alt="$messageindex_txt{'3'} $attachments{$mnum} $alt" title="$messageindex_txt{'3'} $attachments{$mnum} $alt" /></a>~
           )
           : q{};
         $temp_attachment =~ s/{yabb mnum}/$mnum/sm;
   
         $mcount++;
   
         # Print the thread info.
         $mydate = timeformat($mdate);
         if (
             (
                    ( $iamadmin && $adminview == 3 )
                 || ( $iamgmod && $gmodview == 3 )
                 || ( $iamfmod && $fmodview == 3 )
                 || (   $iammod
                     && $modview == 3
                     && !$iamadmin
                     && !$iamgmod
                     && !$iamfmod )
             )
             && $sessionvalid == 1
           )
         {
             if ( $currentboard eq $annboard ) {
                 $adminbar = qq~
         <input type="checkbox" name="lockadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="hideadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="moveadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="deleteadmin$mcount" class="windowbg" value="$mnum" />
         ~;
             }
             elsif ( $counter < $numanns ) {
                 $adminbar = q~&nbsp;~;
             }
             else {
                 $adminbar = qq~
         <input type="checkbox" name="lockadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="stickadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="hideadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="moveadmin$mcount" class="windowbg" value="$mnum" />
         <input type="checkbox" name="deleteadmin$mcount" class="windowbg" value="$mnum" />
         ~;
             }
             $admincol = $admincolumn;
             $admincol =~ s/{yabb admin}/$adminbar/gsm;
         }
         elsif (
             (
                    ( $iamadmin && $adminview == 2 )
                 || ( $iamgmod && $gmodview == 2 )
                 || ( $iamfmod && $fmodview == 2 )
                 || (   $iammod
                     && $modview == 2
                     && !$iamadmin
                     && !$iamgmod
                     && !$iamfmod )
             )
             && $sessionvalid == 1
           )
         {
             if ( $currentboard ne $annboard && $counter < $numanns ) {
                 $adminbar = q~&nbsp;~;
             }
             else {
                 $adminbar =
  qq~<input type="checkbox" name="admin$mcount" class="windowbg" value="$mnum" />~;
             }
             $admincol = $admincolumn;
             $admincol =~ s/{yabb admin}/$adminbar/gsm;
         }
         elsif (
             (
                    ( $iamadmin && $adminview == 1 )
                 || ( $iamgmod && $gmodview == 1 )
                 || ( $iamfmod && $fmodview == 1 )
                 || (   $iammod
                     && $modview == 1
                     && !$iamadmin
                     && !$iamgmod
                     && !$iamfmod )
             )
             && $sessionvalid == 1
           )
         {
             if ( $currentboard eq $annboard ) {
                 $adminbar = qq~
         <a href="$scripturl?action=lock;thread=$mnum;tomessageindex=1"><img src="$micon_bg{'announcementlock'}" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}"  /></a>&nbsp;
         <a href="$scripturl?action=hide;thread=$mnum;tomessageindex=1"><img src="$micon_bg{'hide'}" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}"  /></a>&nbsp;
         <a href="javascript:void(window.open('$scripturl?action=split_splice;board=$currentboard;thread=$mnum;oldposts=all;leave=0;newcat=${$uid.$currentboard}{'cat'};newboard=$currentboard;position=end','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))"><img src="$micon_bg{'admin_move'}" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}"  /></a>&nbsp;
         <a href="$scripturl?action=removethread;thread=$mnum" onclick="return confirm('$messageindex_txt{'162'}')"><img src="$micon_bg{'admin_rem'}" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}"  /></a>
         ~;
             }
             elsif ( $counter < $numanns ) {
                 $adminbar = q~&nbsp;~;
             }
             else {
                 $adminbar = qq~
         <a href="$scripturl?action=lock;thread=$mnum;tomessageindex=1"><img src="$micon_bg{'locked'}" alt="$messageindex_txt{'104'}" title="$messageindex_txt{'104'}"  /></a>&nbsp;
         <a href="$scripturl?action=sticky;thread=$mnum"><img src="$micon_bg{'sticky'}" alt="$messageindex_txt{'781'}" title="$messageindex_txt{'781'}"  /></a>&nbsp;
         <a href="$scripturl?action=hide;thread=$mnum;tomessageindex=1"><img src="$micon_bg{'hide'}" alt="$messageindex_txt{'844'}" title="$messageindex_txt{'844'}"  /></a>&nbsp;
         <a href="javascript:void(window.open('$scripturl?action=split_splice;board=$currentboard;thread=$mnum;oldposts=all;leave=0;newcat=${$uid.$currentboard}{'cat'};newboard=$currentboard;position=end','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))"><img src="$micon_bg{'admin_move'}" alt="$messageindex_txt{'132'}" title="$messageindex_txt{'132'}"  /></a>&nbsp;
         <a href="$scripturl?action=removethread;thread=$mnum" onclick="return confirm('$messageindex_txt{'162'}')"><img src="$micon_bg{'admin_rem'}" alt="$messageindex_txt{'54'}" title="$messageindex_txt{'54'}"  /></a>
         ~;
             }
             $admincol = $admincolumn;
             $admincol =~ s/{yabb admin}/$adminbar/gsm;
         }
   
         $msub = Censor($msub);
         ToChars($msub);
         if ( !$movedFlag ) {
             if ( $enabletopichover && !$messagelist && ( ${ $uid . $username }{'topicpreview'} || $iamguest ) ) {
                 fopen( MNUM, "$datadir/$mnum.txt" );
                 my $thetopic = <MNUM>;
                 fclose(MNUM);
                 my $themessage = ( split /\|/xsm, $thetopic )[8];
                 $clip          = 0;
                 $msglength     = 200;
                 $testlength    = 0;
                 $pretextlength = 0;
                 FromHTML($themessage);
                 $themessage =~ s~\[img\].*?\[\/img\]~[b][$messageindex_tp{'image_tp'}][/b]~igsm;
                 $themessage =~ s~\[media].*?\[/media]~[b][$messageindex_tp{'media_tp'}][/b]~igsm;
                 $themessage =~ s~\[code(.*?)].*?\[/code]~[b][XCODE$1][/b]~igsm;
                 $themessage =~ s/<br>/<br \/>/igsm;
                 $themessage =~ s/(<br \/>){2,}/<br \/>/igsm;
                 $themessage =~ s/^<br \/>//igsm;
   
                 *fixtags = sub {
                     ( $tmpmessage, $pretext, $pretag, $tagtext, $posttag ) = @_;
                     $testmessage = $tmpmessage;
                     $testmessage =~ s/\[.*?\]//gsm;
                     $testmessage =~ s/\<.*?\>//gsm;
                     $testlength    = length $testmessage;
                     $pretextlength = length $pretext;
                     $pretext =~ s/\[(.*?\])/|$1/gsm;
                     $pretag  =~ s/\[/|/sm;
                     $tagtext =~ s/\[(.*?\])/|$1/gsm;
                     $posttag =~ s/\[/|/sm;
   
                     if ( $pretextlength > $msglength ) {
                         return $pretext;
                     }
                     if ( $testlength > $msglength ) {
                         $clip        = 1;
                         $lgtagtxtrem = ( $msglength - $pretextlength ) - 3;
                         $tagtextrem  = substr $tagtext, 0, $lgtagtxtrem;
                         $msglength += ( length($tmpmessage) - $testlength );
                         return
                             $pretext
                           . $pretag
                           . $tagtextrem . '...' 
                           . $posttag;
                     }
                     $msglength += ( length($tmpmessage) - $testlength );
                     return $pretext . $pretag . $tagtext . $posttag;
                 };
   
                 while ($testlength < $msglength
                     && $themessage =~
  s/^((.*?)(\[(\w+?)[\s|\=]*(.*?)\])(.*?)(\[\/\4\]))/ fixtags($1,$2,$3,$6,$7) /eisgm
                   )
                 {
                 }
                 $themessage =~ s/\|(.*?\])/[$1/gsm;
                 $themessage = substr $themessage, 0, $msglength;
                 if ( length($themessage) > ( $msglength - 1 ) && !$clip ) {
                     $themessage .= '...';
                 }
                 $message     = $themessage;
                 $displayname = ${ $uid . $musername }{'realname'};
                 wrap();
                 if ($enable_ubbc) {
                     if ( !$yyYaBBCloaded ) { require Sources::YaBBC; }
                     DoUBBC();
                 }
                 wrap2();
                 $themessage = $message;
                 $message    = q{};
                 ToChars($themessage);
                 $themessage =~ s/XCODE/$messageindex_tp{'code_tp'}/gsm;
   
                 $themessage = Censor($themessage);
                 my $topicsum =
  qq~<div class="windowbg2 topic-hover" id="$mnum">$themessage</div>~;
   
                 if ( ${$mnum}{'board'} eq $annboard ) {
                     $msublink =
  qq~<a href="$scripturl?virboard=$currentboard;num=$mnum" onmouseover="topicSum(event, '$mnum')" onmouseout="hidetopicSum('$mnum')" onclick="hidetopicSum('$mnum')">$msub</a>$topicsum<div style="float: right; font-size: xx-small;">$stickdir</div>~;
                 }
                 else {
                     $msublink =
  qq~<a href="$scripturl?num=$mnum" onmouseover="topicSum(event, '$mnum')" onmouseout="hidetopicSum('$mnum')" onclick="hidetopicSum('$mnum')">$msub</a>$topicsum<div style="float:right; font-size:xx-small">$stickdir</div>~;
                 }
             }
             else {
                 if ( ${$mnum}{'board'} eq $annboard ) {
                     $msublink =
  qq~<a href="$scripturl?virboard=$currentboard;num=$mnum">$msub</a><div style="float:right; font-size:xx-small">$stickdir</div>~;
                 }
                 else {
                      $msublink = qq~<a href="$scripturl?num=$mnum">$msub</a><div style="float:right; font-size:xx-small">$stickdir</div>~;
                 }
             }
         }
         elsif ( $movedFlag < 100 ) {
             Split_Splice_Move( $msub, 0 );
             $msublink = qq~$msub<br /><span class="small">$movedSubject</span>~;
         }
         else {
             $msub =~ /^(Re: )?\[m.*?\]: '(.*)'/sm;
   
             $msublink =
  qq~$maintxt{'758'}: '<a href="$scripturl?num=$movedFlag">$2</a>'<br /><span class="small">$movedSubject</span>~;
         }
   
         my $mydate  = timeformat($mdate);
         my $thicon  = $micon{$threadclass};
         my $tempbar = $movedFlag ? $threadbarMoved : $threadbar;
         $tempbar =~ s/{yabb admin column}/$admincol/gsm;
         $tempbar =~ s/{yabb threadpic}/$thicon/gsm;
         $tempbar =~ s/{yabb icon}/$micon/gsm;
         $tempbar =~ s/{yabb new}/$new/gsm;
         $tempbar =~ s/{yabb poll}/$mpoll/gsm;
         $tempbar =~ s/{yabb favorite}/ ($favicon{$mnum} ? qq~$micon{'addfav'}~ : q{}) /egsm;
         $tempbar =~ s/{yabb subjectlink}/$msublink/gsm;
         $tempbar =~ s/{yabb attachmenticon}/$temp_attachment/gsm;
         $tempbar =~ s/{yabb pages}/$pages/gsm;
         $tempbar =~ s/{yabb starter}/$mname/gsm;
         $tempbar =~ s/{yabb starttime}/ timeformat($mnum,0,0,0,1)/egsm;
         $tempbar =~ s/{yabb replies}/ NumberFormat($mreplies) /egsm;
         $tempbar =~ s/{yabb views}/ NumberFormat($views) /egsm;
         $tempbar =~ s/{yabb lastpostlink}/<a href="$scripturl?num=$mnum\/$mreplies#$mreplies">$img{'lastpost'} $mydate<\/a>/gsm;
         $tempbar =~ s/{yabb lastposter}/$lastpostername/gsm;
         $tempbar =~ s/{yabb altthdcolor}/$altthdcolor/gsm;
   
         if ( $accept_permalink == 1 ) {
             $tempbar =~ s/{yabb permalink}/$message_permalink/gsm;
         }
         else {
             $tempbar =~ s/{yabb permalink}//gsm;
         }
         $tmptempbar .= $tempbar;
         $counter++;
     }
   
  # Put a "no messages" message if no threads exist - just a  bit more friendly...
     if ( !$tmptempbar ) {
         $tmptempbar = $brd_tmptempbar;
         $tmptempbar =~ s/{yabb colspan}/$colspan/sm;
     }
   
     $multiview = 0;
     my $tmptempfooter;
     if (
         (
                ( $iamadmin && $adminview == 3 )
             || ( $iamgmod && $gmodview == 3 )
             || ( $iamfmod && $fmodview == 3 )
             || (   $iammod
                 && $modview == 3
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
         )
         && $sessionvalid == 1
       )
     {
         $multiview = 3;
     }
     elsif (
         (
                ( $iamadmin && $adminview == 2 )
             || ( $iamgmod && $gmodview == 2 )
             || ( $iamfmod && $fmodview == 2 )
             || (   $iammod
                 && $modview == 2
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
         )
         && $sessionvalid == 1
       )
     {
         $multiview = 2;
     }
   
     if ( $multiview >= 2 ) {
         my $boardlist = moveto();
         if ( $multiview eq '3' ) {
             $tempfooter    = $subfooterbar;
             $adminselector = qq~
                 <label for="toboard">$messageindex_txt{'133'}</label>: <input type="checkbox" name="newinfo" value="1" title="$messageindex_txt{199}" class="titlebg" ondblclick="alert('$messageindex_txt{200}')" /> <select name="toboard" id="toboard" onchange="NoPost(this.selectedIndex)">$boardlist</select><input type="submit" value="$messageindex_txt{'462'}" class="button" />
             ~;
             if ( $currentboard eq $annboard ) {
                 $admincheckboxes = qq~
                 <input type="checkbox" name="lockall" value="" class="titlebg" onclick="if (this.checked) checkAll(1); else uncheckAll(1);" />
                 <input type="checkbox" name="hideall" value="" class="titlebg" onclick="if (this.checked) checkAll(2); else uncheckAll(2);" />
                 <input type="checkbox" name="moveall" value="" class="titlebg" onclick="if (this.checked) checkAll(3); else uncheckAll(3);" />
                 <input type="checkbox" name="deleteall" value="" class="titlebg" onclick="if (this.checked) checkAll(4); else uncheckAll(4);" />
                 <input type="hidden" name="fromboard" value="$currentboard" />
             ~;
             }
             else {
                 $admincheckboxes = qq~
                 <input type="checkbox" name="lockall" value="" class="titlebg" onclick="if (this.checked) checkAll(1); else uncheckAll(1);" />
                 <input type="checkbox" name="stickall" value="" class="titlebg" onclick="if (this.checked) checkAll(2); else uncheckAll(2);" />
                 <input type="checkbox" name="hideall" value="" class="titlebg" onclick="if (this.checked) checkAll(3); else uncheckAll(3);" />
                 <input type="checkbox" name="moveall" value="" class="titlebg" onclick="if (this.checked) checkAll(4); else uncheckAll(4);" />
                 <input type="checkbox" name="deleteall" value="" class="titlebg" onclick="if (this.checked) checkAll(5); else uncheckAll(5);" />
                 <input type="hidden" name="fromboard" value="$currentboard" />
             ~;
             }
             $tempfooter =~ s/{yabb admin selector}/$adminselector/gsm;
             $tempfooter =~
               s/{yabb admin checkboxes}/$admincheckboxes/gsm;
         }
         elsif ( $multiview eq '2' ) {
             $tempfooter = $subfooterbar;
             if ( $currentboard eq $annboard ) {
                 $adminselector = qq~
                 <input type="radio" name="multiaction" id="multiactionlock" value="lock" class="titlebg" /> <label for="multiactionlock">$messageindex_txt{'104'}</label>
                 <input type="radio" name="multiaction" id="multiactionhide" value="hide" class="titlebg" /> <label for="multiactionhide">$messageindex_txt{'844'}</label>
                 <input type="radio" name="multiaction" id="multiactiondelete" value="delete" class="titlebg" /> <label for="multiactiondelete">$messageindex_txt{'31'}</label>
                 <input type="radio" name="multiaction" id="multiactionmove" value="move" class="titlebg" /> <label for="multiactionmove">$messageindex_txt{'133'}</label>: <input type="checkbox" name="newinfo" value="1" title="$messageindex_txt{199}" class="titlebg" ondblclick="alert('$messageindex_txt{200}')" />
                 <select name="toboard" id="toboard" onchange="NoPost(this.selectedIndex); document.multiadmin.multiaction[3].checked=true;">$boardlist</select>
                 <input type="hidden" name="fromboard" value="$currentboard" />
                 <input type="submit" value="$messageindex_txt{'462'}" class="button" />
             ~;
             }
             else {
                 $adminselector = qq~
                 <input type="radio" name="multiaction" id="multiactionlock" value="lock" class="titlebg" /> <label for="multiactionlock">$messageindex_txt{'104'}</label>
                 <input type="radio" name="multiaction" id="multiactionstick" value="stick" class="titlebg" /> <label for="multiactionstick">$messageindex_txt{'781'}</label>
                 <input type="radio" name="multiaction" id="multiactionhide" value="hide" class="titlebg" /> <label for="multiactionhide">$messageindex_txt{'844'}</label>
                 <input type="radio" name="multiaction" id="multiactiondelete" value="delete" class="titlebg" /> <label for="multiactiondelete">$messageindex_txt{'31'}</label>
                 <input type="radio" name="multiaction" id="multiactionmove" value="move" class="titlebg" /> <label for="multiactionmove">$messageindex_txt{'133'}</label>: <input type="checkbox" name="newinfo" value="1" title="$messageindex_txt{199}" class="titlebg" ondblclick="alert('$messageindex_txt{200}')" />
                 <select name="toboard" id="toboard" onchange="NoPost(this.selectedIndex); document.multiadmin.multiaction[4].checked=true;">$boardlist</select>
                 <input type="hidden" name="fromboard" value="$currentboard" />
                 <input type="submit" value="$messageindex_txt{'462'}" class="button" />
             ~;
             }
             $admincheckboxes = q~
                 <input type="checkbox" name="checkall" id="checkall" value="" class="titlebg" onclick="if (this.checked) checkAll(0); else uncheckAll(0);" />
             ~;
             $tempfooter =~ s/{yabb admin selector}/$adminselector/gsm;
             $tempfooter =~
               s/{yabb admin checkboxes}/$admincheckboxes/gsm;
         }
         $tmptempfooter = $subfooterbar;
         $tmptempfooter =~ s/{yabb admin selector}/$adminselector/gsm;
         $tmptempfooter =~
           s/{yabb admin checkboxes}/$admincheckboxes/gsm;
     }
   
     if ( !$messagelist ) {
         $yabbicons = qq~
     $micon{'thread'} $messageindex_txt{'457'}<br />
     $micon{'sticky'} $messageindex_txt{'779'}<br />
     $micon{'locked'} $messageindex_txt{'456'}<br />
     $micon{'stickylock'} $messageindex_txt{'780'}<br />
     $micon{'locked_moved'} $messageindex_txt{'845'}<br />
~; ~;
   if (($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {         if ( ($staff) 
       $yabbadminicons = qq~<img src="$imagesdir/hide.gif" alt="$messageindex_txt{'458'}" title="$messageindex_txt{'458'}" /> $messageindex_txt{'458'}<br />~;             && $sessionvalid == 1 ) 
       $yabbadminicons .= qq~<img src="$imagesdir/hidesticky.gif" alt="$messageindex_txt{'459'}" title="$messageindex_txt{'459'}" /> $messageindex_txt{'459'}<br />~;         { 
       $yabbadminicons .= qq~<img src="$imagesdir/hidelock.gif" alt="$messageindex_txt{'460'}" title="$messageindex_txt{'460'}" /> $messageindex_txt{'460'}<br />~;             $yabbadminicons = qq~ 
       $yabbadminicons .= qq~<img src="$imagesdir/hidestickylock.gif" alt="$messageindex_txt{'461'}" title="$messageindex_txt{'461'}" /> $messageindex_txt{'461'}<br />~;     $micon{'hide'} $messageindex_txt{'458'}<br /> 
   }     $micon{'hidesticky'} $messageindex_txt{'459'}<br /> 
   $yabbadminicons .= qq~     $micon{'hidelock'} $messageindex_txt{'460'}<br /> 
   <img src="$imagesdir/announcement.gif" alt="$messageindex_txt{'779a'}" title="$messageindex_txt{'779a'}" /> $messageindex_txt{'779a'}<br />     $micon{'hidestickylock'} $messageindex_txt{'461'}<br />~; 
   <img src="$imagesdir/announcementlock.gif" alt="$messageindex_txt{'779b'}" title="$messageindex_txt{'779b'}" /> $messageindex_txt{'779b'}<br />         } 
   <img src="$imagesdir/hotthread.gif" alt="$messageindex_txt{'454'} $HotTopic $messageindex_txt{'454a'}" title="$messageindex_txt{'454'} $HotTopic $messageindex_txt{'454a'}" /> $messageindex_txt{'454'} $HotTopic $messageindex_txt{'454a'}<br />         $yabbadminicons .= qq~ 
   <img src="$imagesdir/veryhotthread.gif" alt="$messageindex_txt{'455'} $VeryHotTopic $messageindex_txt{'454a'}" title="$messageindex_txt{'455'} $VeryHotTopic $messageindex_txt{'454a'}" /> $messageindex_txt{'455'} $VeryHotTopic $messageindex_txt{'454a'}<br />     $micon{'announcement'} $messageindex_txt{'779a'}<br /> 
     $micon{'announcementlock'} $messageindex_txt{'779b'}<br />
     $micon{'hotthread'} $messageindex_txt{'454'} $HotTopic $messageindex_txt{'454a'}<br />
     $micon{'veryhotthread'} $messageindex_txt{'455'} $VeryHotTopic $messageindex_txt{'454a'}<br />
~; ~;
   
   &LoadAccess;         LoadAccess(); 
     }
   
   #template it    #template it
   $messageindex_template =~ s/({|<)yabb board(}|>)/$boardlink/g;     $messageindex_template =~ s/{yabb board}/$boardlink/gsm; 
   $template_mods = qq~$modslink$showmodgroups~;    $template_mods = qq~$modslink$showmodgroups~;
     if ($iamadmin) {
   my ($rss_link, $rss_text);         require Sources::AddModerators; 
   if (!$rss_disabled) {         ModSearch(); 
       $rss_link = qq~<a href="$scripturl?action=RSSboard;board=$currentboard" target="_blank"><img src="$imagesdir/rss.png" border="0" alt="$maintxt{'rssfeed'}" title="$maintxt{'rssfeed'}" style="vertical-align: middle;" /></a>~;         $template_mods .= 
       $rss_text = qq~<a href="$scripturl?action=RSSboard;board=$INFO{'board'}" target="_blank">$messageindex_txt{843}</a>~;  qq~<br /><a href="javascript:void(0);" onclick="ModSettings()"><span class="small">$addmod_txt{'modsearch'}</span></a>~; 
   }    }
   $yyrssfeed = $rss_text;  
   $yyrss = $rss_link;     my ( $rss_link, $rss_text ); 
   $messageindex_template =~ s/({|<)yabb rssfeed(}|>)/$rss_text/g;     if ( !$rss_disabled ) { 
   $messageindex_template =~ s/({|<)yabb rss(}|>)/$rss_link/g;         $rss_link = 
  qq~<a href="$scripturl?action=RSSboard;board=$currentboard" target="_blank"><img src="$micon_bg{'rss'}"  alt="$maintxt{'rssfeed'}" title="$maintxt{'rssfeed'}" /></a>~;
   $messageindex_template =~ s/({|<)yabb home(}|>)/$homelink/g;         $rss_text = 
   $messageindex_template =~ s/({|<)yabb category(}|>)/$catlink/g;  qq~<a href="$scripturl?action=RSSboard;board=$INFO{'board'}" target="_blank">$messageindex_txt{843}</a>~; 
   $messageindex_template =~ s/({|<)yabb board(}|>)/$boardlink/g;     } 
   $messageindex_template =~ s/({|<)yabb moderators(}|>)/$template_mods/g;     $yyrssfeed = $rss_text; 
     $yyrss     = $rss_link;
   if ($ShowBDescrip) {     $messageindex_template =~ s/{yabb rssfeed}/$rss_text/gsm; 
       if ($bdescrip ne "") {     $messageindex_template =~ s/{yabb rss}/$rss_link/gsm; 
           &ToChars($bdescrip);  
           $boarddescription      =~ s/({|<)yabb boarddescription(}|>)/$bdescrip/g;     $messageindex_template =~ s/{yabb home}/$homelink/gsm; 
           $messageindex_template =~ s/({|<)yabb description(}|>)/$boarddescription/g;     $messageindex_template =~ s/{yabb category}/$catlink/gsm; 
       }     $messageindex_template =~ s/{yabb board}/$boardlink/gsm; 
       else {     $messageindex_template =~ s/{yabb moderators}/$template_mods/gsm; 
           $messageindex_template =~ s/({|<)yabb description(}|>)//g;     if ($enabletopichover) { 
       }         if ( !$iamguest && !$INFO{'messagelist'} ) { 
       if (${$uid.$currentboard}{'ann'} == 1)  { ${$uid.$currentboard}{'pic'} = "ann.gif"; }             if ( ${ $uid . $username }{'topicpreview'} ) { 
       elsif (${$uid.$currentboard}{'rbin'} == 1) { ${$uid.$currentboard}{'pic'} = "recycle.gif"; }                 $enab_topicprev = 
       else { if (!${$uid.$currentboard}{'pic'}) { ${$uid.$currentboard}{'pic'} = "boards.gif"; } }  qq~<a href="$scripturl?board=$INFO{'board'};start=$start;action=topicpreview;todo=disable"><img src="$imagesdir/$hoveroff" alt="$messageindex_tp{'disabletp'}" title="$messageindex_tp{'disabletp'}" /><br /></a>~; 
       $bdpic = ${$uid.$currentboard}{'pic'};             } 
       if ($bdpic =~ /\//i) { $bdpic = qq~ <img src="$bdpic" alt="$boardname" title="$boardname" border="0" align="middle" /> ~; }             else { 
       elsif ($bdpic) { $bdpic = qq~ <img src="$imagesdir/$bdpic" alt="$boardname" title="$boardname" border="0" align="middle" /> ~; }                 $enab_topicprev = 
       $messageindex_template =~ s/({|<)yabb bdpicture(}|>)/$bdpic/g;  qq~<a href="$scripturl?board=$INFO{'board'};start=$start;action=topicpreview;todo=enable"><img src="$imagesdir/$hoveron" alt="$messageindex_tp{'enabletp'}" title="$messageindex_tp{'enabletp'}" /><br /></a>~; 
       $tmpthreadcount = &NumberFormat(${$uid.$currentboard}{'threadcount'});             } 
       $tmpmessagecount = &NumberFormat(${$uid.$currentboard}{'messagecount'});         } 
       $messageindex_template =~ s/({|<)yabb threadcount(}|>)/$tmpthreadcount/g;     } 
       $messageindex_template =~ s/({|<)yabb messagecount(}|>)/$tmpmessagecount/g;     else { 
   }         $enab_topicprev = q{}; 
   $messageindex_template =~ s/({|<)yabb colspan(}|>)/$colspan/g;     } 
     $messageindex_template =~ s/{yabb topicpreview}/$enab_topicprev/gsm;
   $topichandellist =~ s/({|<)yabb notify button(}|>)/$notify_board/g;     $messageindex_template =~ s/{yabb sortsubject}/$sort_subject/gsm; 
   $topichandellist =~ s/({|<)yabb markall button(}|>)/$markalllink/g;     $messageindex_template =~ s/{yabb sortstarter}/$sort_starter/gsm; 
   $topichandellist =~ s/({|<)yabb new post button(}|>)/$postlink/g;     $messageindex_template =~ s/{yabb sortanswer}/$sort_answer/gsm; 
   $topichandellist =~ s/({|<)yabb new poll button(}|>)/$polllink/g;     $messageindex_template =~ 
   $topichandellist =~ s/\Q$menusep//i;       s/{yabb sortlastpostim}/$sort_lastpostim/gsm; 
   
   $messageindex_template =~ s/({|<)yabb topichandellist(}|>)/$topichandellist/g;     if ($ShowBDescrip) { 
   $messageindex_template =~ s/({|<)yabb pageindex top(}|>)/$pageindex1/g;         if ( $bdescrip ne q{} ) { 
   $messageindex_template =~ s/({|<)yabb pageindex bottom(}|>)/$pageindex2/g;             ToChars($bdescrip); 
             $boarddescription =~
   if ((($iamadmin && $adminview == 3) || ($iamgmod && $gmodview == 3) || ($iammod && $modview == 3 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {               s/{yabb boarddescription}/$bdescrip/gsm; 
       $messageindex_template =~ s/({|<)yabb admin column(}|>)/$adminheader/g;             $messageindex_template =~ 
   } elsif ((($iamadmin && $adminview != 0) || ($iamgmod && $gmodview != 0) || ($iammod && $modview != 0 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {               s/{yabb description}/$boarddescription/gsm; 
       $messageindex_template =~ s/({|<)yabb admin column(}|>)/$adminheader/g;         } 
   } else {        else {
       $messageindex_template =~ s/({|<)yabb admin column(}|>)//g;             $messageindex_template =~ s/{yabb description}//gsm; 
   }        }
     }
   if ((($iamadmin && $adminview >= 2) || ($iamgmod && $gmodview >= 2) || ($iammod && $modview >= 2 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {     $bdpic = qq~$imagesdir/boards.$bdpicExt~; 
       $formstart = qq~<form name="multiadmin" action="$scripturl?board=$currentboard;action=multiadmin" method="post" style="display: inline">~;     fopen( BRDPIC, "<$boardsdir/brdpics.db" ); 
       $formend   = qq~<input type="hidden" name="allpost" value="$INFO{'start'}" /></form>~;     my @brdpics = <BRDPIC>; 
       $messageindex_template =~ s/({|<)yabb modupdate(}|>)/$formstart/g;     fclose( BRDPIC); 
       $messageindex_template =~ s/({|<)yabb modupdateend(}|>)/$formend/g;     chomp @brdpics; 
   } else {    for (@brdpics) {
       $messageindex_template =~ s/({|<)yabb modupdate(}|>)//g;         my ( $brdnm, $style, $brdpic ) = split /[|]/xsm, $_; 
       $messageindex_template =~ s/({|<)yabb modupdateend(}|>)//g;         if ( $brdnm eq $currentboard && $template eq $style) { 
   }             if ( $brdpic =~ /\//ism ) { 
   if ($tmpstickyheader) {                 $bdpic = $brdpic; 
       $messageindex_template =~ s/({|<)yabb stickyblock(}|>)/$tmpstickyheader/g;             } 
   } else {            elsif ( -e "$htmldir/Templates/Forum/$useimages/Boards/$brdpic" ) {
       $messageindex_template =~ s/({|<)yabb stickyblock(}|>)//g;                 $bdpic = qq~$imagesdir/Boards/$brdpic~; 
   }            }
   $messageindex_template =~ s/({|<)yabb threadblock(}|>)/$tmptempbar/g;         } 
   if ($tmptempfooter) {     } 
       $messageindex_template =~ s/({|<)yabb adminfooter(}|>)/$tmptempfooter/g;     if ( ${ $uid . $currentboard }{'ann'} == 1 ) { 
   } else {         $bdpic = qq~$imagesdir/ann.$bdpicExt~; 
       $messageindex_template =~ s/({|<)yabb adminfooter(}|>)//g;     } 
   }     if ( ${ $uid . $currentboard }{'rbin'} == 1 ) { 
   $messageindex_template =~ s/({|<)yabb icons(}|>)/$yabbicons/g;         $bdpic = qq~$imagesdir/recycle.$bdpicExt~; 
   $messageindex_template =~ s/({|<)yabb admin icons(}|>)/$yabbadminicons/g;     } 
   $messageindex_template =~ s/({|<)yabb access(}|>)/ &LoadAccess /e;  
   $yymain .= qq~     $bdpic = 
   $messageindex_template  qq~ <img src="$bdpic" alt="$curboardname" title="$curboardname" id="brd_img_resize" /> ~; 
   $pageindexjs  
   ~;     $messageindex_template =~ s/{yabb bdpicture}/$bdpic/gsm; 
     my $tmpthreadcount = NumberFormat( ${ $uid . $currentboard }{'threadcount'} );
   if ((($iamadmin && $adminview >= 2) || ($iamgmod && $gmodview >= 2) || ($iammod && $modview >= 2 && !$iamadmin && !$iamgmod)) && $sessionvalid == 1) {     my $tmpmessagecount = NumberFormat( ${ $uid . $currentboard }{'messagecount'} ); 
       my $modul = $currentboard eq $annboard ? 4 : 5;     $messageindex_template =~ s/{yabb threadcount}/$tmpthreadcount/gsm; 
     $messageindex_template =~ s/{yabb messagecount}/$tmpmessagecount/gsm;
       if ($sessionvalid == 1) {     $messageindex_template =~ s/{yabb new_load}/$newload/gsm; 
           $yymain .= qq~  
<script language="JavaScript1.2" type="text/javascript">     $messageindex_template =~ s/{yabb colspan}/$colspan/gsm; 
<!--    ### Board Rules Start ### 
   function checkAll(j) {    if ( ${ $uid . $currentboard }{'rules'} == 1 ) {
       for (var i = 0; i < document.multiadmin.elements.length; i++) {         ToChars( ${ $uid . $currentboard }{'rulestitle'} ); 
           if (document.multiadmin.elements[i].type == "checkbox" && !/all\$/.test(document.multiadmin.elements[i].name) && (j == 0 || (j != 0 && (i % $modul) == (j - 1))))         ToChars( ${ $uid . $currentboard }{'rulesdesc'} ); 
               document.multiadmin.elements[i].checked = true;         $tmpruletxt = qq~${$uid.$currentboard}{'rulesdesc'}~; 
       }  
   }         if ( !$iamguest && ${ $uid . $currentboard }{'rulescollapse'} == 1 ) { 
   function uncheckAll(j) {             $tmprulelgt = length( ${ $uid . $currentboard }{'rulesdesc'} ); 
       for (var i = 0; i < document.multiadmin.elements.length; i++) {             $rulestitle = 
           if (document.multiadmin.elements[i].type == "checkbox" && !/all\$/.test(document.multiadmin.elements[i].name) && (j == 0 || (j != 0 && (i % $modul) == (j - 1))))  qq~<img src="$imagesdir/$newload{'brd_col'}" id="bdrulecollapse" alt="$boardindex_exptxt{'2'}" title="$boardindex_exptxt{'2'}" class="cursor" onclick="collapseBDrule($tmprulelgt);" />~; 
               document.multiadmin.elements[i].checked = false;             my @collbdrules = 
       }               split /\|/xsm, ${ $uid . $username }{'collapsebdrules'}; 
   }             for my $i ( 0 .. $#collbdrules ) { 
//-->                 ( $rulebd, $rulelgt ) = split /,/xsm, $collbdrules[$i]; 
                 if ( $rulebd eq $currentboard && $rulelgt == $tmprulelgt ) {
                     $tmpruletxt = qq~$messageindex_txt{'collruletext'}~;
                     $rulestitle =
  qq~<img src="$imagesdir/$newload{'brd_exp'}" id="bdrulecollapse" alt="$boardindex_exptxt{'1'}" title="$boardindex_exptxt{'1'}" class="cursor" onclick="collapseBDrule($tmprulelgt);" />~;
                 }
             }
         }
   
         $rulestitle .= qq~&nbsp;${$uid.$currentboard}{'rulestitle'}~;
         $rulesdesc = qq~<div id="bdruledesc">$tmpruletxt</div>~;
   
         if ( !$iamguest && ${ $uid . $currentboard }{'rulescollapse'} == 1 ) {
             $mycat_col = $newload{'brd_col'};
             $mycat_exp = $newload{'brd_exp'};
             $rulesdesc .= qq~
             <textarea id="actruletxt" name="actruletxt" rows="1" cols="1" style="display: none;">${$uid.$currentboard}{'rulesdesc'}</textarea>
             <input type="hidden" id="tmpruletxt" value="$messageindex_txt{'collruletext'}" />
             <script type="text/javascript">
             function collapseBDrule(rulelgt) {
                 var tmpruletxt = document.getElementById('tmpruletxt').value;
                 var actruletxt = document.getElementById('actruletxt').value;
                 if (document.getElementById("bdruledesc").innerHTML == tmpruletxt) linkdesclg = 1;
                 else linkdesclg = rulelgt;
                 var thisboard = "$currentboard";
                 var doexpand = "$boardindex_exptxt{'1'}";
                 var docollaps = "$boardindex_exptxt{'2'}";
                 if (document.getElementById("bdruledesc").innerHTML == tmpruletxt) {
                     document.getElementById("bdruledesc").innerHTML = actruletxt;
                     document.getElementById('bdrulecollapse').src = "$imagesdir/$mycat_col";
                     document.getElementById('bdrulecollapse').alt = docollaps;
                     document.getElementById('bdrulecollapse').title = docollaps;
                 }
                 else {
                     document.getElementById("bdruledesc").innerHTML = tmpruletxt;
                     document.getElementById('bdrulecollapse').src="$imagesdir/$mycat_exp";
                     document.getElementById('bdrulecollapse').alt = doexpand;
                     document.getElementById('bdrulecollapse').title = doexpand;
                 }
                 var url = '$scripturl?action=bdrulecoll&rulebd=' + thisboard + '&rulelg=' + linkdesclg;
                 GetXmlHttpObject();
                 if (xmlHttp === null) return;
                 xmlHttp.open("GET",url,true);
                 xmlHttp.send(null);
             }
             </script>
             ~;
         }
   
         $messageindex_template =~ s/{yabb rulestitle}/$rulestitle/gsm;
         $messageindex_template =~
           s/{yabb rulesdescription}/$rulesdesc/gsm;
     }
     ### Board Rules End ###
   
     $tool_sep = $useThreadtools ? q{|||} : q{};
   
     $topichandellist =~
       s/{yabb notify button}/$notify_board$tool_sep/gsm;
     $topichandellist =~
       s/{yabb markall button}/$markalllink$tool_sep/gsm;
     $topichandellist =~ s/{yabb new post button}/$postlink$tool_sep/gsm;
     $topichandellist =~ s/{yabb new poll button}/$polllink$tool_sep/gsm;
     $topichandellist =~ s/\Q$menusep//ixsm;
   
     @threadin = ( "$notify_board","$markalllink","$postlink","$polllink",);
     @threadout = ();
     my $sepcn = 0;
     for (@threadin) {
         if ($_ ) {
            if ( !$useThreadtools ) { $threadout[$sepcn] = "$_$my_ttsep";}
            else  { $threadout[$sepcn] = "$my_ttsep$_"; }
         }
         else  { $threadout[$sepcn] = q{}; }
         $sepcn++;
     }
   
     $outside_threadtools =~
       s/{yabb notify button}/$threadout[0]/gsm;
     $outside_threadtools =~
       s/{yabb markall button}/$threadout[1]/gsm;
     $outside_threadtools =~
       s/{yabb new post button}/$threadout[2]/gsm;
     $outside_threadtools =~
       s/{yabb new poll button}/$threadout[3]/gsm;
  ## Mod Hook outside_threadtools ##
     if ( $my_ttsep ne q{ } ) {
         $outside_threadtools =~ s/\Q$my_ttsep//ixsm;
     }
   
     if ( !$useThreadtools ) {
         if ( $menusep ne q{ } ) {
             $outside_threadtools =~ s/\Q$menusep//ixsm;
         }
         $topichandellist     = $outside_threadtools . $topichandellist;
         $outside_threadtools = q{};
     }
     else {
         $outside_threadtools =~ s/\[tool=(.+?)\](.+?)\[\/tool\]/$tmpimg{$1}/gsm;
         $topichandellist     =~ s/\[tool=(.+?)\](.+?)\[\/tool\]/$2/gsm;
     }
   
     $topichandellist2 = $topichandellist;
   
     # Thread Tools #
     if ($useThreadtools) {
         $dropid = q{};
         if ($messagelist) { $dropid = $INFO{'board'}; }
         $topichandellist2 = MakeTools( "bottom$dropid", $maintxt{'62'}, $topichandellist2 );
         $topichandellist = MakeTools( "top$dropid", $maintxt{'62'}, $topichandellist );
     }
   
     $messageindex_template =~
       s/{yabb outsidethreadtools}/$outside_threadtools/gsm;
     $messageindex_template =~
       s/{yabb topichandellist}/$topichandellist/gsm;
     $messageindex_template =~
       s/{yabb topichandellist2}/$topichandellist2/gsm;
     $messageindex_template =~ s/{yabb pageindex top}/$pageindex1/gsm;
     $messageindex_template =~ s/{yabb pageindex bottom}/$pageindex2/gsm;
   
     if (
         (
                ( $iamadmin && $adminview == 3 )
             || ( $iamgmod && $gmodview == 3 )
             || ( $iamfmod && $fmodview == 3 )
             || (   $iammod
                 && $modview == 3
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
         )
         && $sessionvalid == 1
       )
     {
         $messageindex_template =~
           s/{yabb admin column}/$adminheader/gsm;
     }
     elsif (
         (
                ( $iamadmin && $adminview != 0 )
             || ( $iamgmod && $gmodview != 0 )
             || ( $iamfmod && $fmodview != 0 )
             || (   $iammod
                 && $modview != 0
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
         )
         && $sessionvalid == 1
       )
     {
         $messageindex_template =~
           s/{yabb admin column}/$adminheader/gsm;
     }
     else {
         $messageindex_template =~ s/{yabb admin column}//gsm;
     }
   
     if (
         (
                ( $iamadmin && $adminview >= 2 )
             || ( $iamgmod && $gmodview >= 2 )
             || ( $iamfmod && $fmodview >= 2 )
             || (   $iammod
                 && $modview >= 2
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
         )
         && $sessionvalid == 1
       )
     {
         if ( !$messagelist ) {
             $formstart =
  qq~<form name="multiadmin" action="$scripturl?board=$currentboard;action=multiadmin" method="post" style="display: inline">~;
         }
         else {
             $formstart = qq~
             <form name="multiadmin$currentboard" id="multiadmin$currentboard" action="$scripturl?board=$currentboard;action=multiadmin" method="post" style="display: inline">
             <input type="hidden" name="formsession" value="$formsession" />
             ~;
         }
         $formend =
  qq~<input type="hidden" name="allpost" value="$INFO{'start'}" /></form>~;
         $messageindex_template =~ s/{yabb modupdate}/$formstart/gsm;
         $messageindex_template =~ s/{yabb modupdateend}/$formend/gsm;
     }
     else {
         $messageindex_template =~ s/{yabb modupdate}//gsm;
         $messageindex_template =~ s/{yabb modupdateend}//gsm;
     }
     if ($tmpstickyheader) {
         $messageindex_template =~
           s/{yabb stickyblock}/$tmpstickyheader/gsm;
     }
     else {
         $messageindex_template =~ s/{yabb stickyblock}//gsm;
     }
     $messageindex_template =~ s/{yabb threadblock}/$tmptempbar/gsm;
     if ($tmptempfooter) {
         $messageindex_template =~
           s/{yabb adminfooter}/$tmptempfooter/gsm;
     }
     else {
         $messageindex_template =~ s/{yabb adminfooter}//gsm;
     }
     $messageindex_template =~ s/{yabb icons}/$yabbicons/gsm;
     $messageindex_template =~ s/{yabb admin icons}/$yabbadminicons/gsm;
     $messageindex_template =~
       s/{yabb access}/ $messagelist ? q{} : LoadAccess() /esm;
   
     # Show subboards
     if ( $subboard{$currentboard} ) {
         $show_subboards = 1;
         $subboard_sel   = $currentboard;
         require Sources::BoardIndex;
         $boardindex_template = BoardIndex();
     }
   
     $yymain .= qq~
     $boardindex_template
     $messageindex_template
     $pageindexjs
     <script type="text/javascript">
     function topicSum(e, topicsumm) {
         document.getElementById(topicsumm).style.display = 'block';
         var dheight = document.getElementById(topicsumm).offsetHeight;
         var dtop = document.all ? e.clientY + document.documentElement.scrollTop - (dheight + 30) : e.pageY - (dheight + 30);
         document.getElementById(topicsumm).style.top = dtop + 'px';
     }
   
     function hidetopicSum(topicsumm) {
         document.getElementById(topicsumm).style.display = 'none';
     }
   
     </script>
     ~;
   
     if (
         (
                ( $iamadmin && $adminview >= 2 )
             || ( $iamgmod && $gmodview >= 2 )
             || ( $iamfmod && $fmodview >= 2 )
             || (   $iammod
                 && $modview >= 2
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
         )
         && $sessionvalid == 1
       )
     {
         my $modul = $currentboard eq $annboard ? 4 : 5;
   
         if ( $sessionvalid == 1 ) {
             $yymain .= qq~
  <script type="text/javascript">
     function checkAll(j) {
         for (var i = 0; i < document.multiadmin.elements.length; i++) {
             if (document.multiadmin.elements[i].type == "checkbox" && !(/all\$/).test(document.multiadmin.elements[i].name) && (j === 0 || (j !== 0 && (i % $modul) == (j - 1))))
                 document.multiadmin.elements[i].checked = true;
         }
     }
     function uncheckAll(j) {
         for (var i = 0; i < document.multiadmin.elements.length; i++) {
             if (document.multiadmin.elements[i].type == "checkbox" && !(/all\$/).test(document.multiadmin.elements[i].name) && (j === 0 || (j !== 0 && (i % $modul) == (j - 1))))
                 document.multiadmin.elements[i].checked = false;
         }
     }
</script>\n~; </script>\n~;
       }        }
   }    }
   
   $yyjavascript .= qq~\nvar markallreadlang = '$messageindex_txt{'500'}';\nvar markfinishedlang = '$messageindex_txt{'500a'}';~;     $yyjavascript .= 
   $yymain .= qq~  qq~\nvar markallreadlang = '$messageindex_txt{'500'}';\nvar markfinishedlang = '$messageindex_txt{'500a'}';~; 
<script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script>     $yymain .= qq~ 
<script language="JavaScript1.2" type="text/javascript"> <script type="text/javascript">
<!--    function ListPages(tid) { window.open('$scripturl?action=pages;num='+tid, '', 'menubar=no,toolbar=no,top=50,left=50,scrollbars=yes,resizable=no,width=400,height=300'); } 
   function ListPages(tid) { window.open('$scripturl?action=pages;num='+tid, '', 'menubar=no,toolbar=no,top=50,left=50,scrollbars=yes,resizable=no,width=400,height=300'); }    function ListPages2(bid,cid) { window.open('$scripturl?action=pages;board='+bid+';count='+cid, '', 'menubar=no,toolbar=no,top=50,left=50,scrollbars=yes,resizable=no,width=400,height=300'); }
   function ListPages2(bid,cid) { window.open('$scripturl?action=pages;board='+bid+';count='+cid, '', 'menubar=no,toolbar=no,top=50,left=50,scrollbars=yes,resizable=no,width=400,height=300'); }  
//-->  
</script> </script>
   ~;    ~;
   
     # Make browsers aware of our RSS
     if ( !$rss_disabled && $INFO{'board'} )
     {    # Check to see if we're on a real board, not announcements
         $yyinlinestyle .=
  qq~    <link rel="alternate" type="application/rss+xml" title="$messageindex_txt{'843'}" href="$scripturl?action=RSSboard;board=$INFO{'board'}" />~;
     }
   
     if ( !$messagelist ) {
         $yynavback =
           qq~$tabsep <a href="$scripturl">&lsaquo; $img_txt{'103'}</a> &nbsp; ~;
         $yynavigation = qq~&rsaquo; $catlink$boardtree~;
         $yytitle      = $curboardname;
   
         if ( $postlink && $enable_quickpost && !$mindex_postpopup ) {
             $yymain =~
  s/(<!-- Icon and access info end -->)/$1\n<div class="q_post_space">{yabb forumjump}<\/div>/sm;
             require Sources::Post;
             $action        = 'post';
             $INFO{'title'} = 'StartNewTopic';
             $Quick_Post    = 1;
             Post();
         }
         template();
     }
     else {
         print "Content-type: text/html; charset=$yymycharset\n\n" 
           or croak "$croak{'print'} content-type";
         print qq~
         $messageindex_template
         $pageindexjs
         ~ or croak "$croak{'print'} content";
         CORE::exit;    # This is here only to avoid server error log entries!
     }
     return;
  }
   
  sub collapse_bdrule {
     $tmpboardrules = q{};
     my @tmpbdrule = split /\|/xsm, ${ $uid . $username }{'collapsebdrules'};
     for my $i ( 0 .. $#tmpbdrule ) {
         my ( $tmrulebd, $tmrulelgt ) = split /,/xsm, $tmpbdrule[$i];
         if ( $tmrulebd ne $INFO{'rulebd'} ) {
             $tmpboardrules .= qq~$tmpbdrule[$i]|~;
         }
     }
     if ( $INFO{'rulelg'} > 1 ) {
         $tmpboardrules .= qq~$INFO{'rulebd'},$INFO{'rulelg'}~;
     }
     $tmpboardrules =~ s/\|\Z//xsm;
     ${ $uid . $username }{'collapsebdrules'} = $tmpboardrules;
     UserAccount( $username, 'update' );
     $elenable = 0;
     croak q{};
     return;
  }
   
   # Make browsers aware of our RSS  sub MarkRead {    # Mark all threads in this board as read. 
   if(!$rss_disabled && $INFO{'board'}) { # Check to see if we're on a real board, not announcements                   # Load the log file 
       $yyinlinestyle .= qq~<link rel="alternate" type="application/rss+xml" title="$messageindex_txt{'843'}" href="$scripturl?action=RSSboard;board=$INFO{'board'}" />\n~;     getlog(); 
   }  
   $tabsep = qq~<img src="$imagesdir/tabsep211.png" border="0" alt="" style="vertical-align: middle;" />~;     # Look for any threads marked unread in the current board and remove them 
   $yynavback = qq~$tabsep <a href="$scripturl">&lsaquo; $img_txt{'103'}</a> $tabsep~;     fopen( BRDTXT, "$boardsdir/$currentboard.txt" ) 
   $yynavigation = qq~&rsaquo; $catlink &rsaquo; $boardname~;       or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
   $yytitle = $boardname;     my @threadlist = map { /^(\d+)\|/xsm } <BRDTXT>; 
   if ($postlink and $enable_quickpost) {     fclose(BRDTXT); 
       $yymain =~ s~(<!-- Icon and access info end -->)~$1\n<div style="text-align: right; padding-top: 10px; padding-bottom: 10px;">{yabb forumjump}</div>~;  
       require "$sourcedir/Post.pl";     # Loop through @threadlist and delete the corresponding item from %yyuserlog 
       $action = 'post';     foreach (@threadlist) { delete $yyuserlog{"$_--unread"}; } 
       $INFO{'title'} = 'StartNewTopic';  
       $Quick_Post = 1;     # Write it out 
       &Post;     dumplog("$currentboard--mark"); 
   }  
   &template;     if ( $INFO{'oldmarkread'} ) { 
}         redirectinternal(); 
     }
sub MarkRead { # Mark all threads in this board as read.     $elenable = 0; 
   # Load the log file     croak q{};    # This is here only to avoid server error log entries! 
   &getlog;  
   
   # Look for any threads marked unread in the current board and remove them  
   fopen(BRDTXT, "$boardsdir/$currentboard.txt") || &fatal_error("cannot_open","$boardsdir/$currentboard.txt", 1);  
   my @threadlist = map {/^(\d+)\|/} <BRDTXT>;  
   fclose(BRDTXT);  
   
   # Loop through @threadlist and delete the corresponding item from %yyuserlog  
   foreach (@threadlist) { delete $yyuserlog{"$_--unread"}; }  
   
   # Write it out  
   &dumplog("$currentboard--mark");  
   
   if($INFO{'oldmarkread'}) {  
       &redirectinternal;  
   }  
   $elenable = 0;  
   die ""; # This is here only to avoid server error log entries!  
} }
   
sub ListPages { sub ListPages {
   my ($pcount, $maxvalue, $tlink);     my ( $pcount, $maxvalue, $tlink ); 
   if ($INFO{'num'} ne '') {    if ( $INFO{'num'} ne q{} ) {
       $tlink = $INFO{'num'};        $tlink    = $INFO{'num'};
       $pcount = ${$INFO{'num'}}{'replies'} + 1;        $pcount   = ${ $INFO{'num'} }{'replies'} + 1;
       $maxvalue = $maxmessagedisplay;        $maxvalue = $maxmessagedisplay;
       $jcode = 'num=';        $jcode    = 'num=';
   }    }
   if ($INFO{'board'} ne '') {    if ( $INFO{'board'} ne q{} ) {
       $tlink = $INFO{'board'};        $tlink    = $INFO{'board'};
       $pcount = $INFO{'count'};        $pcount   = $INFO{'count'};
       $maxvalue = $maxdisplay;        $maxvalue = $maxdisplay;
       $jcode = 'board=';        $jcode    = 'board=';
   }    }
   
   $tmpa = 1;    $tmpa = 1;
   for ($tmpb = 0; $tmpb < $pcount; $tmpb += $maxvalue) {    foreach my $tmpb ( 0 .. ( $pcount - 1 ) ) {
       $pages .= qq~<a href='javascript: opp_page("$tlink","~ . ((!$ttsreverse or $INFO{'board'}) ? $tmpb : (${$INFO{'num'}}{'replies'} - $tmpb)) . qq~");'>$tmpa</a>\n~;         if ( $tmpb % $maxvalue == 0 ) { 
       ++$tmpa;             $pages .= qq~<a href='javascript: opp_page("$tlink","~ 
   }               . ( 
   $pages =~ s/\n\Z//;                 ( !$ttsreverse || $INFO{'board'} ) 
                 ? $tmpb
   &print_output_header;                 : ( ${ $INFO{'num'} }{'replies'} - $tmpb ) 
               ) . qq~");'>$tmpa</a>\n~;
   $output = qq~<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">             ++$tmpa; 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">         } 
<head>     } 
<meta http-equiv="Content-Type" content="text/html; charset=$yycharset" />     $pages =~ s/\n\Z//xsm; 
<title>$messageindex_txt{'139'} $messageindex_txt{'18'}</title>  
<link rel="stylesheet" href="$forumstylesurl/$usestyle.css" type="text/css" />     print_output_header(); 
</head>     get_template('MessageIndex'); 
<body style="min-width: 350px;">  
   <script language="JavaScript1.2" type="text/javascript">     $output = $msg_listpages; 
   <!--     $output =~ s/{yabb jcode}/$jcode/sm; 
   function opp_page(tid,pid) {     $output =~ s/{yabb pages}/$pages/sm; 
       opener.location= "$scripturl?$jcode" + tid + "/" + pid;  
       self.close();  
   }  
   //-->  
   </script>  
   <table border="0" cellpadding="4" cellspacing="1" width="100%" class="bordercolor">  
   <tr>  
       <td class="titlebg" align="center">$messageindex_txt{'139'} $messageindex_txt{'18'}</td>  
   </tr>  
   <tr>  
       <td class="catbg" align="center">  
       <br /><br /><br /><br />  
       <p>&laquo; $messageindex_txt{'139'} $pages &raquo;</p>  
       <br /><br /><br /><br />  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg" align="center"><a href="javascript: window.close();">$messageindex_txt{'903'}</a></td>  
   </tr>  
   </table>  
</body>  
</html>~;  
   
   &print_HTML_output_and_finish;     print_HTML_output_and_finish(); 
     return;
} }
   
sub MessagePageindex { sub MessagePageindex {
   # my ($msindx, $trindx, $mbindx);     my ( $msindx, $trindx, $mbindx, $pmindx ) = 
   my ($msindx, $trindx, $mbindx, $pmindx) = split(/\|/, ${$uid.$username}{'pageindex'});       split /\|/xsm, ${ $uid . $username }{'pageindex'}; 
   if ($INFO{'action'} eq "messagepagedrop") {    if ( $INFO{'action'} eq 'messagepagedrop' ) {
       ${$uid.$username}{'pageindex'} = qq~0|$trindx|$mbindx|$pmindx~;        ${ $uid . $username }{'pageindex'} = qq~0|$trindx|$mbindx|$pmindx~;
   }    }
   if ($INFO{'action'} eq "messagepagetext") {    elsif ( $INFO{'action'} eq 'messagepagetext' ) {
       ${$uid.$username}{'pageindex'} = qq~1|$trindx|$mbindx|$pmindx~;        ${ $uid . $username }{'pageindex'} = qq~1|$trindx|$mbindx|$pmindx~;
   }    }
   &UserAccount($username, "update");     UserAccount( $username, 'update' ); 
   &redirectinternal;     redirectinternal(); 
     return;
} }
   
sub moveto { sub moveto {
   my ($boardlist, $catid, $board, $category, $boardname, $boardperms, $boardview, $brdlist, @bdlist, $catname, $catperms, $access);     my ( 
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }         $boardlist,  $catid,     $board,   $boardname, 
   foreach $catid (@categoryorder) {         $boardperms, $boardview, $brdlist, @bdlist, 
       $brdlist = $cat{$catid};         $catname,    $catperms,  $access 
       if(!$brdlist) { next; }     ); 
       @bdlist = split(/,/, $brdlist);     get_forum_master(); 
       ($catname, $catperms) = split(/\|/, $catinfo{"$catid"});  
     *move_subboards = sub {
       $access = &CatAccess($catperms);         my @x = @_; 
       if (!$access) { next; }         $indent += 2; 
       &ToChars($catname);         foreach my $board (@x) { 
       $boardlist .= qq~<optgroup label="$catname">~;             my $dash; 
       foreach $board (@bdlist) {             if ( $indent > 0 ) { $dash = q{-}; } 
           ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$board"});  
           &ToChars($boardname);             ( $boardname, $boardperms, $boardview ) = 
           $access = &AccessCheck($board, '', $boardperms);               split /\|/xsm, $board{"$board"}; 
           if (!$iamadmin && $access ne "granted") { next; }             ToChars($boardname); 
           if ($board ne $currentboard) {             $access = AccessCheck( $board, q{}, $boardperms ); 
               $boardlist .= qq~<option value="$board">$boardname</option>\n~;             if ( !$iamadmin && $access ne 'granted' ) { next; } 
           }             my $bdnopost = q{}; 
       }             if ( $board ne $currentboard ) { 
       $boardlist .= qq~</optgroup>~;                 $my_board = $board; 
   }                 if ( !${ $uid . $board }{'canpost'} && $subboard{$board} ) { 
   $boardlist;                     $alert    = qq~$messageindex_txt{'nopost'}~; 
                     $bdnopost = qq~ class="nopost" onclick="alert('$alert')"~;
                     $my_board = q{};
                 }
                 $boardlist .=
                     qq~<option$bdnopost value="$my_board">~
                   . ( '&nbsp;' x $indent )
                   . ( $dash x ( $indent / 2 ) )
                   . qq~$boardname</option>\n~;
             }
             if ( $subboard{$board} ) {
                 move_subboards( split /\|/xsm, $subboard{$board} );
             }
         }
         $indent -= 2;
     };
   
     foreach my $catid (@categoryorder) {
         $brdlist = $cat{$catid};
         if ( !$brdlist ) { next; }
         (@bdlist) = split /\,/xsm, $cat{$catid};
   
         #@bdlist = split(/\,/, $brdlist);
         ( $catname, $catperms ) = split /\|/xsm, $catinfo{$catid};
   
         $access = CatAccess($catperms);
         if ( !$access ) { next; }
         ToChars($catname);
         $boardlist .= qq~<optgroup label="$catname">~;
         my $indent = -2;
         move_subboards(@bdlist);
         $boardlist .= q~</optgroup>~;
     }
     return $boardlist;
} }
   
sub LoadAccess { sub LoadAccess {
   my $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'808'}<br />";     my $yesaccesses = 
   my $noaccesses = "";       "$load_txt{'805'} $load_txt{'806'} $load_txt{'808'}<br />"; 
     my $noaccesses = q{};
   
     # Reply Check
     if ( AccessCheck( $currentboard, 2 ) eq 'granted' ) {
         $yesaccesses .=
           "$load_txt{'805'} $load_txt{'806'} $load_txt{'809'}<br />";
     }
     else {
         $noaccesses .=
           "$load_txt{'805'} $load_txt{'807'} $load_txt{'809'}<br />";
     }
   
     # start new Topic Check
     if ( AccessCheck( $currentboard, 1 ) eq 'granted' ) {
         $yesaccesses .=
           "$load_txt{'805'} $load_txt{'806'} $load_txt{'810'}<br />";
     }
     else {
         $noaccesses .=
           "$load_txt{'805'} $load_txt{'807'} $load_txt{'810'}<br />";
     }
   
     # Attachments Check
     $allowattach ||= 0;
     if (
            AccessCheck( $currentboard, 4 ) eq 'granted' 
         && $allowattach > 0
         && ${ $uid . $currentboard }{'attperms'} == 1
         && ( ( $allowguestattach == 0 && !$iamguest )
             || $allowguestattach == 1 )
       )
     {
         $yesaccesses .=
           "$load_txt{'805'} $load_txt{'806'} $load_txt{'813'}<br />";
     }
     else {
         $noaccesses .=
           "$load_txt{'805'} $load_txt{'807'} $load_txt{'813'}<br />";
     }
   
     # Poll Check
     if ( AccessCheck( $currentboard, 3 ) eq 'granted' ) {
         $yesaccesses .=
           "$load_txt{'805'} $load_txt{'806'} $load_txt{'811'}<br />";
     }
     else {
         $noaccesses .=
           "$load_txt{'805'} $load_txt{'807'} $load_txt{'811'}<br />";
     }
   
     # Zero Post Check
     if ( $username ne 'Guest' ) {
         if ( $INFO{'zeropost'} != 1 && AccessCheck( $currentboard, 2 ) eq 'granted' ) {
             $yesaccesses .=
               "$load_txt{'805'} $load_txt{'806'} $load_txt{'812'}<br />";
         }
         else {
             $noaccesses .=
               "$load_txt{'805'} $load_txt{'807'} $load_txt{'812'}<br />";
         }
     }
   
   # Reply Check     return qq~$yesaccesses<br />$noaccesses~; 
   my $rcaccess = &AccessCheck($currentboard, 2) || 0;  }
   if ($rcaccess eq "granted") { $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'809'}<br />"; }  
   else { $noaccesses .= "$load_txt{'805'} $load_txt{'807'} $load_txt{'809'}<br />"; }  
   
   # start new Topic Check  
   if (&AccessCheck($currentboard, 1) eq "granted") { $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'810'}<br />"; }  
   else { $noaccesses .= "$load_txt{'805'} $load_txt{'807'} $load_txt{'810'}<br />"; }  
   
   # Attachments Check  
   if (&AccessCheck($currentboard, 4) eq 'granted' && $allowattach && ${$uid.$currentboard}{'attperms'} == 1 && (($allowguestattach == 0 && !$iamguest) || $allowguestattach == 1)) { $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'813'}<br />"; }  
   else { $noaccesses .= "$load_txt{'805'} $load_txt{'807'} $load_txt{'813'}<br />"; }  
   
   # Poll Check  
   if (&AccessCheck($currentboard, 3) eq "granted") { $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'811'}<br />"; }  
   else { $noaccesses .= "$load_txt{'805'} $load_txt{'807'} $load_txt{'811'}<br />"; }  
   
   # Zero Post Check  
   if ($username ne 'Guest') {  
       if ($INFO{'zeropost'} != 1 && $rcaccess eq "granted") { $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'812'}<br />"; }  
       else { $noaccesses .= "$load_txt{'805'} $load_txt{'807'} $load_txt{'812'}<br />"; }  
   }  
   
   qq~$yesaccesses<br />$noaccesses~;  sub SetTopicPreview { 
     if ( $INFO{'todo'} eq 'disable' ) {
         ${ $uid . $username }{'topicpreview'} = '0';
     }
     else {
         ${ $uid . $username }{'topicpreview'} = '1';
     }
     UserAccount( $username, 'update' );
     redirectinternal();
     return;
} }
   
1; 1;