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