F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\Display.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\Display.pm
############################################################################### ###############################################################################
# Display.pl                                                                  # # Display.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 CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
$displayplver = 'YaBB 2.5.2 $Revision: 1.2 $'; $displaypmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
&LoadLanguage('Display');  LoadLanguage('Display'); 
&LoadLanguage('FA');  LoadLanguage('FA'); 
require "$templatesdir/$usedisplay/Display.template";  get_micon(); 
if ($iamgmod) { require "$vardir/gmodsettings.txt"; }  get_template('Display'); 
  get_gmod();
   
sub Display { sub Display {
   # Check if board was 'shown to all' - and whether they can view the topic  
   if (&AccessCheck($currentboard, '', $boardperms) ne "granted") { &fatal_error("no_access"); }  
   
   # Get the "NEW"est Post for this user.     # Check if board was 'shown to all' - and whether they can view the topic 
   my $newestpost;     if ( AccessCheck( $currentboard, q{}, $boardperms ) ne 'granted' ) { 
   if (!$iamguest && $max_log_days_old && $INFO{'start'} eq "new") {         fatal_error('no_access'); 
       # This decides which messages were already read in the thread to     } 
       # determing where the redirect should go. It is done by  
       # comparing times in the username.log and the boardnumber.txt files.     if ( $enable_guest_view_limit && $guestaccess ) { 
       &getlog;         my $iambot = 0; 
       my $mnum = $INFO{'num'};         my $user_host = 
       my $dlp = int($yyuserlog{$mnum}) > int($yyuserlog{"$currentboard--mark"}) ? int($yyuserlog{$mnum}) : int($yyuserlog{"$currentboard--mark"});           ( gethostbyaddr pack( 'C4', split /\./xsm, $user_ip ), 2 )[0]; 
       $dlp = $dlp > $date - ($max_log_days_old * 86400) ? $dlp : $date - ($max_log_days_old * 86400);         if ( -e "$vardir/bots.hosts" ) { 
             fopen( BOTS, "$vardir/bots.hosts" )
       unless (ref($thread_arrayref{$mnum})) {               or fatal_error( 'cannot_open', "$vardir/bots.hosts", 1 ); 
           fopen(MNUM, "$datadir/$mnum.txt");             my @botlist = <BOTS>; 
           @{$thread_arrayref{$mnum}} = <MNUM>;             fclose(BOTS); 
           fclose(MNUM);             chomp @botlist; 
       }             foreach (@botlist) { 
       my $i = -1;                 if ( $_         =~ /(.*?)\|(.*)/xsm ) { $bot_name = $1; } 
       foreach (@{$thread_arrayref{$mnum}}) {                 if ( $user_host =~ /$bot_name/ixsm )  { $iambot   = 1; } 
           $i++;             } 
           last if (split(/\|/, $_))[3] > $dlp;         } 
       }         if (   $iamguest 
             && !$iambot
       $newestpost = $INFO{'start'} = $i;             && $yyCookies{$cookieview} < $guest_view_limit ) 
   }         { 
             if ( $yyCookies{$cookieview} ) {
   if ($buddyListEnabled) { &loadMyBuddy; }                 $gtvlcount = $yyCookies{$cookieview}; 
   my $viewnum = $INFO{'num'};                 $gtvlcount =~ s/\D//gsm; 
                 $gtvlcount++;
   # strip off any non numeric values to avoid exploitation             } 
   $maxmessagedisplay ||= 10;             else { 
   my ($msubthread, $mnum, $mstate, $mdate, $msub, $mname, $memail, $mreplies, $musername, $micon, $mip, $mlm, $mlmb);                 $gtvlcount = 1; 
   my ($counter, $counterwords, $threadclass, $notify, $max, $start, $windowbg, $mattach, $pagedropindex, $template_viewers, $template_favorite, $template_pollmain, $navback, $mark_unread, $pollbutton, $icanbypass, $replybutton, $bypassReplyButton);             } 
             my $guest_view_limit_clength = q{+} . $cookieviewtime . 'm';
   &LoadCensorList;             $yySetCookies1 = write_cookie( 
                 -path    => q{/},
   # Determine category                 -name    => $cookieview, 
   $curcat = ${$uid.$currentboard}{'cat'};                 -value   => $gtvlcount, 
                 -expires => $guest_view_limit_clength
   # Figure out the name of the category             ); 
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }        }
         elsif ($iamguest
   if ($currentboard eq $annboard) {             && !$iambot 
       $vircurrentboard = $INFO{'virboard'};             && $yyCookies{$cookieview} >= $guest_view_limit ) 
       $vircurcat = ${$uid.$vircurrentboard}{'cat'};         { 
       ($vircat, undef) = split(/\|/, $catinfo{$vircurcat});             if ($guest_view_limit_block) { 
       ($virboardname, undef) = split(/\|/, $board{$vircurrentboard},2);                 $guest_view_limit_warn = q{}; 
       &ToChars($virboardname);                 $yytitle               = $display_txt{'guest_message'}; 
   }                 $yynavigation = qq~&rsaquo; $display_txt{'guest_message'}~; 
                 $yymain .= $my_guest_limit;
   ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});                 template(); 
   &ToChars($cat);                 exit; 
             }
   ($boardname, $boardperms, $boardview) = split(/\|/, $board{$currentboard});             else { 
                 $guest_view_limit_warn = $guest_view_limit_w;
   &ToChars($boardname);             } 
         }
   # Check to make sure this thread isn't locked.     } 
   ($mnum, $msubthread, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);  
     # Get the "NEW"est Post for this user.
   if ($mstate =~ /m/) {     my $newestpost; 
       $msubthread =~ / dest=(\d+)\]/;     if ( !$iamguest && $max_log_days_old && $INFO{'start'} eq 'new' ) { 
       my $newnum = $1;  
       if (-e "$datadir/$newnum.txt") {         # This decides which messages were already read in the thread to 
           $yySetLocation = "$scripturl?num=$newnum";         # determining where the redirect should go. It is done by 
           &redirectexit;         # comparing times in the username.log and the boardnumber.txt files. 
       }         getlog(); 
       eval { require "$datadir/movedthreads.cgi" };         my $mnum = $INFO{'num'}; 
       while (exists $moved_file{$newnum}) {         my $dlp = 
           $newnum = $moved_file{$newnum};             int( $yyuserlog{$mnum} ) > int( $yyuserlog{"$currentboard--mark"} ) 
           next if exists $moved_file{$newnum};           ? int( $yyuserlog{$mnum} ) 
           if (-e "$datadir/$newnum.txt") {           : int $yyuserlog{"$currentboard--mark"}; 
               $yySetLocation = "$scripturl?num=$newnum";         $dlp = 
               &redirectexit;             $dlp > $date - ( $max_log_days_old * 86400 ) 
           }           ? $dlp 
       }           : $date - ( $max_log_days_old * 86400 ); 
   }  
         if ( !ref $thread_arrayref{$mnum} ) {
   ($msubthread, undef) = &Split_Splice_Move($msubthread,0);             fopen( MNUM, "$datadir/$mnum.txt" ); 
   &ToChars($msubthread);             @{ $thread_arrayref{$mnum} } = <MNUM>; 
   $msubthread = &Censor($msubthread);             fclose(MNUM); 
         }
   # Build a list of this board's moderators.         my $i = -1; 
   if (keys %moderators > 0) {        foreach ( @{ $thread_arrayref{$mnum} } ) {
       if (keys %moderators == 1) { $showmods = qq~($display_txt{'298'}: ~; }             $i++; 
       else { $showmods = qq~($display_txt{'63'}: ~; }             last if ( split /\|/xsm, $_ )[3] > $dlp; 
         }
       while ($_ = each(%moderators)) {  
           &FormatUserName($_);         $newestpost = $INFO{'start'} = $i; 
           $showmods .= &QuickLinks($_,1) . ", ";     } 
       }  
       $showmods =~ s/, \Z/)/;     # Post and Thread Tools 
   }     if ($useThreadtools) { 
   if (keys %moderatorgroups > 0) {         LoadTools( 
       if (keys %moderatorgroups == 1) { $showmodgroups = qq~($display_txt{'298a'}: ~; }             2,           'addfav',     'remfav',     'addpoll', 
       else { $showmodgroups = qq~($display_txt{'63a'}: ~; }             'reply',     'add_notify', 'del_notify', 'print', 
             'sendtopic', 'markunread' 
       my ($tmpmodgrp,$thismodgrp);         ); 
       while ($_ = each(%moderatorgroups)) {     } 
           $tmpmodgrp = $moderatorgroups{$_};     if ($usePosttools) { 
           ($thismodgrp, undef) = split(/\|/, $NoPost{$tmpmodgrp}, 2);         LoadTools( 1, 'delete', 'admin_split', 'mquote', 'quote', 'modify', 
           $showmodgroups .= qq~$thismodgrp, ~;             'printp', 'alertmod' ); 
       }    }
       $showmodgroups =~ s/, \Z/)/;  
   }    if ($buddyListEnabled) { loadMyBuddy(); }
     my $viewnum = $INFO{'num'};
   ## now we have established credentials,  
   ## can this user bypass locks?     # strip off any non numeric values to avoid exploitation 
   ## work out who can bypass locked thread post only if bypass switched on     $maxmessagedisplay ||= 10; 
   if ($mstate =~ /l/i) {     my ( 
       if ($bypass_lock_perm) { $icanbypass = &checkUserLockBypass; }         $msubthread, $mnum,   $mstate,   $mdate,     $msub, 
       $enable_quickreply = 0;         $mname,      $memail, $mreplies, $musername, $micon, 
   }         $mip,        $mlm,    $mlmb 
     );
   my $permdate = &permtimer($mnum);     my ( 
   my $display_permalink = qq~<a href="http://$perm_domain/$symlink$permdate/$currentboard/$mnum">$display_txt{'10'}</a>~;         $counter,           $counterwords,     $threadclass, 
         $notify,            $max,              $start,
   # Look for a poll file for this thread.         $mattach,           $template_viewers, $template_favorite, 
   if (&AccessCheck($currentboard, 3) eq 'granted') {         $template_pollmain, $navback,          $mark_unread, 
       $pollbutton = qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=AddPoll">$img{'addpoll'}</a>~;         $pollbutton,        $icanbypass,       $replybutton, 
   }         $bypassReplyButton 
   if (-e "$datadir/$viewnum.poll") {     ); 
       $has_poll = 1;  
       $pollbutton = '';     LoadCensorList(); 
   } else {  
       $has_poll = 0;     # Determine category 
       if ($useraddpoll == 0) { $pollbutton = ''; }     $curcat = ${ $uid . $currentboard }{'cat'}; 
   }  
     # Figure out the name of the category
   # Get the class of this thread, based on lock status and number of replies.     get_forum_master(); 
   if ((!$iamguest || $enable_guestposting) && &AccessCheck($currentboard, 2) eq 'granted') {  
       $replybutton = qq~$menusep<a href="~ . ($enable_quickreply && $enable_quickjump ? 'javascript:document.postmodify.message.focus();' : qq~$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=PostReply~);     if ( $currentboard eq $annboard ) { 
       $bypassReplyButton = $replybutton . qq~" onclick="return confirm('$display_txt{'posttolocked'}');">$img{'reply'}</a> ~;         $vircurrentboard = $INFO{'virboard'}; 
       $replybutton .= qq~">$img{'reply'}</a> ~; #" make my text-editor happy;         $vircurcat       = ${ $uid . $vircurrentboard }{'cat'}; 
   }         ( $vircat, undef ) = split /\|/xsm, $catinfo{$vircurcat}; 
         ToChars($vircat);
   $threadclass = 'thread';         ( $virboardname, undef ) = split /\|/xsm, $board{$vircurrentboard}, 2; 
   ## hidden threads         ToChars($virboardname); 
   if ($mstate =~ /h/i) {     } 
       $threadclass = 'hide';  
       if (!$iamadmin && !$iamgmod && !$iammod) { &fatal_error('no_access'); }     ( $cat, $catperms ) = split /\|/xsm, $catinfo{"$curcat"}; 
   }     ToChars($cat); 
   ## locked thread  
   elsif ($mstate =~ /l/i) {     ( $boardname, $boardperms, $boardview ) = 
       $threadclass = 'locked';  ## same icon regardless       split /\|/xsm, $board{$currentboard}; 
       $pollbutton = '';  
       if   ($icanbypass) { $replybutton = $bypassReplyButton; }     ToChars($boardname); 
       else { $replybutton = ''; } # squish  
   }     # Check to make sure this thread isn't locked. 
   elsif ($mreplies >= $VeryHotTopic) { $threadclass = 'veryhotthread'; }     ( 
   elsif ($mreplies >= $HotTopic) { $threadclass = 'hotthread'; }         $mnum,     $msubthread, $mname, $memail, $mdate, 
   elsif ($mstate eq '') { $threadclass = 'thread'; }         $mreplies, $musername,  $micon, $mstate 
     ) = split /\|/xsm, $yyThreadLine;
   if ($threadclass eq 'hide') { ##  hidden  
       if ($mstate =~ /s/i && $mstate !~ /l/i) { $threadclass = 'hidesticky'; }     if ( $mstate =~ /m/sm ) { 
       elsif ($mstate =~ /l/i && $mstate !~ /s/i) {        if ( $msubthread =~ / dest=(\d+)\]/sm ) {
           $threadclass = 'hidelock'; $pollbutton = '';             my $newnum = $1; 
           if ($icanbypass) { $replybutton = $bypassReplyButton; }        }
           else { $replybutton = ''; } # squish         if ( -e "$datadir/$newnum.txt" ) { 
       }             $yySetLocation = "$scripturl?num=$newnum"; 
       elsif ($mstate =~ /s/i && $mstate =~ /l/i) {             redirectexit(); 
           $threadclass = 'hidestickylock'; $pollbutton  = '';         } 
           if ($icanbypass) { $replybutton = $bypassReplyButton; }         if ( eval { require Variables::Movedthreads; 1 } ) { 
           else { $replybutton = ''; } # squish             while ( exists $moved_file{$newnum} ) { 
       }                 $newnum = $moved_file{$newnum}; 
   }                 next if exists $moved_file{$newnum}; 
   elsif ($threadclass eq 'locked' && $mstate =~ /s/i) {                if ( -e "$datadir/$newnum.txt" ) {
       $threadclass = 'stickylock';                     $yySetLocation = "$scripturl?num=$newnum"; 
       if ($icanbypass) { $replybutton = $bypassReplyButton; }                     redirectexit(); 
       else { $replybutton = ''; } # squish                 } 
   }            }
   elsif ($mstate =~ /s/i) { $threadclass = 'sticky'; }        }
   elsif (${$mnum}{'board'} eq $annboard) { $threadclass = $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; }    }
   
   if (-e "$datadir/$mnum.mail" && !$iamguest) {     ( $msubthread, undef ) = Split_Splice_Move( $msubthread, 0 ); 
       require "$sourcedir/Notify.pl";     ToChars($msubthread); 
       &ManageThreadNotify("update", $mnum, $username, '', '', '1');     $msubthread = Censor($msubthread); 
   }  
     # Build a list of this board's moderators.
   if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~ - ~; }     if ( keys %moderators > 0 ) { 
         if ( keys %moderators == 1 ) { $showmods = qq~($display_txt{'298'}: ~; }
   # Build the page links list.         else                         { $showmods = qq~($display_txt{'63'}: ~; } 
   if (!$iamguest) {  
       (undef, $userthreadpage, undef,undef) = split(/\|/, ${$uid.$username}{'pageindex'});         while ( $_ = each %moderators ) { 
   }             FormatUserName($_); 
   my ($pagetxtindex, $pagetextindex, $pagedropindex1, $pagedropindex2, $all, $allselected);             $showmods .= QuickLinks( $_, 1 ) . q{, }; 
   $postdisplaynum = 3; # max number of pages to display         } 
   $dropdisplaynum = 10;         $showmods =~ s/, \Z/)/sm; 
   $startpage = 0;     } 
   $max = $mreplies + 1;     if ( keys %moderatorgroups > 0 ) { 
   if (substr($INFO{'start'}, 0, 3) eq 'all' && $showpageall != 0) { $maxmessagedisplay = $max; $all = 1; $allselected = qq~ selected="selected"~; $start = !$ttsreverse ? 0 : $mreplies; }         if ( keys %moderatorgroups == 1 ) { 
   else { $start = $INFO{'start'} !~ /\d/ ? (!$ttsreverse ? 0 : $mreplies) : $INFO{'start'}; }             $showmodgroups = qq~($display_txt{'298a'}: ~; 
   $start = $start > $mreplies ? $mreplies : $start;         } 
   $start = !$ttsreverse ? (int($start / $maxmessagedisplay) * $maxmessagedisplay) : (int(($mreplies - $start) / $maxmessagedisplay) * $maxmessagedisplay);         else { $showmodgroups = qq~($display_txt{'63a'}: ~; } 
   $tmpa = 1;  
   $pagenumb = int(($max - 1) / $maxmessagedisplay) + 1;         my ( $tmpmodgrp, $thismodgrp ); 
         while ( $_ = each %moderatorgroups ) {
   if ($start >= (($postdisplaynum - 1) * $maxmessagedisplay)) {             $tmpmodgrp = $moderatorgroups{$_}; 
       $startpage = $start - (($postdisplaynum - 1) * $maxmessagedisplay);             ( $thismodgrp, undef ) = split /\|/xsm, $NoPost{$tmpmodgrp}, 2; 
       $tmpa = int($startpage / $maxmessagedisplay) + 1;             $showmodgroups .= qq~$thismodgrp, ~; 
   }        }
   if ($max >= $start + ($postdisplaynum * $maxmessagedisplay)) { $endpage = $start + ($postdisplaynum * $maxmessagedisplay); }         $showmodgroups =~ s/, \Z/)/sm; 
   else { $endpage = $max; }    }
   $lastpn = int($mreplies / $maxmessagedisplay) + 1;  
   $lastptn = ($lastpn - 1) * $maxmessagedisplay;     ## now we have established credentials, 
   $pageindex1 = qq~<span class="small" style="float: left; height: 21px; margin: 0px; margin-top: 2px;"><img src="$imagesdir/index_togl.gif" border="0" alt="$display_txt{'19'}" title="$display_txt{'19'}" style="vertical-align: middle;" /> $display_txt{'139'}: $pagenumb</span>~;     ## can this user bypass locks? 
   $pageindex2 = $pageindex1;     ## work out who can bypass locked thread post only if bypass switched on 
   if ($pagenumb > 1 || $all) {    if ( $mstate =~ /l/ism ) {
       if ($userthreadpage == 1 || $iamguest) {         if ($bypass_lock_perm) { $icanbypass = checkUserLockBypass(); } 
           $pagetxtindexst = qq~<span class="small" style="float: left; height: 21px; margin: 0px; margin-top: 2px;">~;         $enable_quickreply = 0; 
           if (!$iamguest) { $pagetxtindexst .= qq~<a href="$scripturl?num=$viewnum;start=~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~;action=threadpagedrop"><img src="$imagesdir/index_togl.gif" border="0" alt="$display_txt{'19'}" style="vertical-align: middle;" /></a> $display_txt{'139'}: ~; }    }
           else { $pagetxtindexst .= qq~<img src="$imagesdir/index_togl.gif" border="0" alt="" style="vertical-align: middle;" /> $display_txt{'139'}: ~; }  
           if ($startpage > 0) { $pagetxtindex = qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? 0 : $mreplies) . qq~" style="font-weight: normal;">1</a>&nbsp;<a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>&nbsp;~; }     my $permdate = permtimer($mnum); 
           if ($startpage == $maxmessagedisplay) { $pagetxtindex = qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? 0 : $mreplies) . qq~" style="font-weight: normal;">1</a>&nbsp;~; }     my $display_permalink = 
           for ($counter = $startpage; $counter < $endpage; $counter += $maxmessagedisplay) {  qq~<a href="http://$perm_domain/$symlink$permdate/$currentboard/$mnum">$display_txt{'10'}</a>~; 
               $pagetxtindex .= $start == $counter ? qq~<b>$tmpa</b>&nbsp;~ : qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? $counter : ($mreplies - $counter)) . qq~" style="font-weight: normal;">$tmpa</a>&nbsp;~;  
               $tmpa++;     # Look for a poll file for this thread. 
           }     if ( AccessCheck( $currentboard, 3 ) eq 'granted' ) { 
           if ($endpage < $max - ($maxmessagedisplay)) { $pageindexadd = qq~<a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>&nbsp;~; }         $pollbutton = 
           if ($endpage != $max) { $pageindexadd .= qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? $lastptn : $mreplies - $lastptn) . qq~" style="font-weight: normal;">$lastpn</a>~; }  qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=AddPoll">$img{'addpoll'}</a>~; 
           $pagetxtindex .= qq~$pageindexadd~;     } 
           $pageindex1 = qq~$pagetxtindexst$pagetxtindex</span>~;     if ( -e "$datadir/$viewnum.poll" ) { 
           $pageindex2 = $pageindex1;         $has_poll   = 1; 
         $pollbutton = q{};
       } else {     } 
           $pagedropindex1 = qq~<span style="float: left; width: 350px; margin: 0px; margin-top: 2px; border: 0px;">~;     else { 
           $pagedropindex1 .= qq~<span style="float: left; height: 21px; margin: 0; margin-right: 4px;"><a href="$scripturl?num=$viewnum;start=~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~;action=threadpagetext"><img src="$imagesdir/index_togl.gif" border="0" alt="$display_txt{'19'}" title="$display_txt{'19'}" /></a></span>~;         $has_poll = 0; 
           $pagedropindex2 = $pagedropindex1;         if ( $useraddpoll == 0 ) { $pollbutton = q{}; } 
           $tstart = $start;     } 
           #if (substr($INFO{'start'}, 0, 3) eq "all") { ($tstart, $start) = split(/\-/, $INFO{'start'}); }  
           $d_indexpages = $pagenumb / $dropdisplaynum;     # Get the class of this thread, based on lock status and number of replies. 
           $i_indexpages = int($pagenumb / $dropdisplaynum);     if ( ( !$iamguest || $enable_guestposting ) 
           if ($d_indexpages > $i_indexpages) { $indexpages = int($pagenumb / $dropdisplaynum) + 1; }         && AccessCheck( $currentboard, 2 ) eq 'granted' ) 
           else { $indexpages = int($pagenumb / $dropdisplaynum) }     { 
           $selectedindex = int(($start / $maxmessagedisplay) / $dropdisplaynum);         my $tmplink = ( 
             $enable_quickreply && $enable_quickjump
           if ($pagenumb > $dropdisplaynum) {             ? 'javascript:document.postmodify.message.focus();' 
               $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~;             : qq~$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=PostReply~ 
               $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~;         ); 
           }         $replybutton = qq~<a href="$tmplink">$img{'reply'}</a>~; 
         $bypassReplyButton = qq~<a href="$tmplink" onclick="return confirm('$display_txt{'posttolocked'}');">$img{'reply'}</a>~;
           for ($i = 0; $i < $indexpages; $i++) {     } 
               $indexpage = !$ttsreverse ? ($i * $dropdisplaynum * $maxmessagedisplay) : ($mreplies - ($i * $dropdisplaynum * $maxmessagedisplay));  
               $indexstart = ($i * $dropdisplaynum) + 1;     $threadclass = 'thread'; 
               $indexend = $indexstart + ($dropdisplaynum - 1);     ## hidden threads 
               if ($indexend > $pagenumb)    { $indexend   = $pagenumb; }     if ( $mstate =~ /h/ism ) { 
               if ($indexstart == $indexend) { $indxoption = qq~$indexstart~; }         $threadclass = 'hide'; 
               else { $indxoption = qq~$indexstart-$indexend~; }        if ( !$staff ) { fatal_error('no_access'); }
               $selected = "";     } 
               if ($i == $selectedindex) {     ## locked thread 
                   $selected    = qq~ selected="selected"~;     elsif ( $mstate =~ /l/ism ) { 
                   $pagejsindex = qq~$indexstart|$indexend|$maxmessagedisplay|$indexpage~;         $threadclass = 'locked';                   ## same icon regardless 
               }         $pollbutton  = q{}; 
               if ($pagenumb > $dropdisplaynum) {         if   ($icanbypass) { $replybutton = $bypassReplyButton; } 
                   $pagedropindex1 .= qq~<option value="$indexstart|$indexend|$maxmessagedisplay|$indexpage"$selected>$indxoption</option>\n~;         else               { $replybutton = q{}; } 
                   $pagedropindex2 .= qq~<option value="$indexstart|$indexend|$maxmessagedisplay|$indexpage"$selected>$indxoption</option>\n~;     } 
               }    elsif ( $mreplies >= $VeryHotTopic ) { $threadclass = 'veryhotthread'; }
           }    elsif ( $mreplies >= $HotTopic )     { $threadclass = 'hotthread'; }
     elsif ( $mstate eq q{} ) { $threadclass = 'thread'; }
           if ($pagenumb > $dropdisplaynum) {  
               $pagedropindex1 .= qq~</select>\n</span>~;     ## stickies 
               $pagedropindex2 .= qq~</select>\n</span>~;     if ( $mstate =~ /s/ism ) { 
           }         if ( $threadclass eq 'hide' ) { 
           $pagedropindex1 .= qq~<span id="ViewIndex1" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;             if ( $mstate =~ /l/ism ) { 
           $pagedropindex2 .= qq~<span id="ViewIndex2" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;                 $threadclass = 'hidestickylock'; 
           $tmpmaxmessagedisplay = $maxmessagedisplay;                 $pollbutton  = q{}; 
           $prevpage = !$ttsreverse ? $start - $tmpmaxmessagedisplay : $mreplies - $start + $tmpmaxmessagedisplay;                 if   ($icanbypass) { $replybutton = $bypassReplyButton; } 
           $nextpage = !$ttsreverse ? $start + $maxmessagedisplay : $mreplies - $start - $maxmessagedisplay;                 else               { $replybutton = q{}; } 
           $pagedropindexpvbl = qq~<img src="$imagesdir/index_left0.gif" height="14" width="13" border="0" alt="" style="margin: 0px; display: inline; vertical-align: middle;" />~;             } 
           $pagedropindexnxbl = qq~<img src="$imagesdir/index_right0.gif" height="14" width="13" border="0" alt="" style="margin: 0px; display: inline; vertical-align: middle;" />~;             else { 
           if ((!$ttsreverse and $start < $maxmessagedisplay) or ($ttsreverse and $prevpage > $mreplies)) { $pagedropindexpv .= qq~<img src="$imagesdir/index_left0.gif" height="14" width="13" border="0" alt="" style="display: inline; vertical-align: middle;" />~; }                 $threadclass = 'hidesticky'; 
           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?num=$viewnum/$prevpage\\'" ondblclick="location.href=\\'$scripturl?num=$viewnum/~ . (!$ttsreverse ? 0 : $mreplies) . qq~\\'" />~; }            }
           if ((!$ttsreverse and $nextpage > $lastptn) or ($ttsreverse and $nextpage < $mreplies - $lastptn)) { $pagedropindexnx .= qq~<img src="$imagesdir/index_right0.gif" border="0" height="14" width="13" alt="" style="display: inline; vertical-align: middle;" />~; }        }
           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?num=$viewnum/$nextpage\\'" ondblclick="location.href=\\'$scripturl?num=$viewnum/~ . (!$ttsreverse ? $lastptn : $mreplies - $lastptn) . qq~\\'" />~; }        elsif ( $threadclass eq 'thread' ) { $threadclass = 'sticky'; }
           $pageindex1 = qq~$pagedropindex1</span>~;         elsif ( $threadclass eq 'locked' ) { 
           $pageindex2 = qq~$pagedropindex2</span>~;             $threadclass = 'stickylock'; 
             if   ($icanbypass) { $replybutton = $bypassReplyButton; }
           $pageindexjs = qq~             else               { $replybutton = q{}; } 
   function SelDec(decparam, visel) {         } 
       splitparam = decparam.split("|");     } 
       var vistart = parseInt(splitparam[0]);     elsif ( $threadclass eq 'hide' && $mstate =~ /l/ism ) { 
       var viend = parseInt(splitparam[1]);         $threadclass = 'hidelock'; 
       var maxpag = parseInt(splitparam[2]);         $pollbutton  = q{}; 
       var pagstart = parseInt(splitparam[3]);         if   ($icanbypass) { $replybutton = $bypassReplyButton; } 
       //var allpagstart = parseInt(splitparam[3]);         else               { $replybutton = q{}; } 
       if(visel == 'xx' && decparam == '$pagejsindex') visel = '$tstart';     } 
       var pagedropindex = '<table border="0" cellpadding="0" cellspacing="0"><tr>';     elsif ( ${$mnum}{'board'} eq $annboard ) { 
       for(i=vistart; i<=viend; i++) {         $threadclass = 
           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>';           $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; 
           else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?num=$viewnum/' + pagstart + '">' + i + '</a></td>';     } 
           pagstart ~ . (!$ttsreverse ? '+' : '-') . qq~= maxpag;  
       }     if ( -e "$datadir/$mnum.mail" && !$iamguest ) { 
       ~;         require Sources::Notify; 
       if ($showpageall) {         ManageThreadNotify( 'update', $mnum, $username, q{}, q{}, '1' ); 
           $pageindexjs .= qq~     } 
           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 ( $showmodgroups ne q{} && $showmods ne q{} ) { $showmods .= q~ - ~; } 
               else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?num=$viewnum/all">$pidtxt{'01'}</a></td>';  
           }     # Build the page links list. 
           ~;     if ( !$iamguest ) { 
       }         ( undef, $userthreadpage, undef, undef ) = 
       $pageindexjs .= qq~           split /\|/xsm, ${ $uid . $username }{'pageindex'}; 
       if(visel != 'xx') pagedropindex += '<td height="14" class="small" style="height: 14px; padding-left: 4px;">$pagedropindexpv$pagedropindexnx</td>';     } 
       else pagedropindex += '<td height="14" class="small" style="height: 14px; padding-left: 4px;">$pagedropindexpvbl$pagedropindexnxbl</td>';     my ( $pagetxtindex, $pagedropindex1, $pagedropindex2, $all, $allselected ); 
       pagedropindex += '</tr></table>';     $postdisplaynum = 3;               # max number of pages to display 
       document.getElementById("ViewIndex1").innerHTML=pagedropindex;     $dropdisplaynum = 10; 
       document.getElementById("ViewIndex1").style.visibility = "visible";     $startpage      = 0; 
       document.getElementById("ViewIndex2").innerHTML=pagedropindex;     $max            = $mreplies + 1; 
       document.getElementById("ViewIndex2").style.visibility = "visible";     if ( substr( $INFO{'start'}, 0, 3 ) eq 'all' && $showpageall != 0 ) { 
       ~;         $maxmessagedisplay = $max; 
           if ($pagenumb > $dropdisplaynum) {         $all               = 1; 
               $pageindexjs .= qq~         $allselected       = q~ selected="selected"~; 
       document.getElementById("decselector1").value = decparam;         $start             = !$ttsreverse ? 0 : $mreplies; 
       document.getElementById("decselector2").value = decparam;     } 
       ~;     else { 
           }         $start = 
           $pageindexjs .= qq~           $INFO{'start'} !~ /\d/xsm 
   }           ? ( !$ttsreverse ? 0 : $mreplies ) 
   SelDec('$pagejsindex', '~ . (!$ttsreverse ? $tstart : ($mreplies - $tstart)) . qq~');           : $INFO{'start'}; 
     }
     $start = $start > $mreplies ? $mreplies : $start;
     $start =
       !$ttsreverse
       ? ( int( $start / $maxmessagedisplay ) * $maxmessagedisplay )
       : (
         int( ( $mreplies - $start ) / $maxmessagedisplay ) *
           $maxmessagedisplay );
     $tmpa = 1;
     $pagenumb = int( ( $max - 1 ) / $maxmessagedisplay ) + 1;
   
     if ( $start >= ( ( $postdisplaynum - 1 ) * $maxmessagedisplay ) ) {
         $startpage = $start - ( ( $postdisplaynum - 1 ) * $maxmessagedisplay );
         $tmpa = int( $startpage / $maxmessagedisplay ) + 1;
     }
     if ( $max >= $start + ( $postdisplaynum * $maxmessagedisplay ) ) {
         $endpage = $start + ( $postdisplaynum * $maxmessagedisplay );
     }
     else { $endpage = $max; }
     $lastpn  = int( $mreplies / $maxmessagedisplay ) + 1;
     $lastptn = ( $lastpn - 1 ) * $maxmessagedisplay;
     $pageindex1 =
  qq~<span class="small pgindex"><img src="$index_togl{'index_togl'}" alt="$display_txt{'19'}" title="$display_txt{'19'}" /> $display_txt{'139'}: $pagenumb</span>~;
     $pageindex2 = $pageindex1;
     if ( $pagenumb > 1 || $all ) {
         if ( $userthreadpage == 1 || $iamguest ) {
             $pagetxtindexst = q~<span class="small pgindex">~;
             if ( !$iamguest ) {
                 $pagetxtindexst .=
                     qq~<a href="$scripturl?num=$viewnum;start=~
                   . ( !$ttsreverse ? $start : $mreplies - $start )
                   . qq~;action=threadpagedrop"><img src="$index_togl{'index_togl'}" alt="$display_txt{'19'}" title="$display_txt{'19'}" /></a> $display_txt{'139'}: ~;
             }
             else {
                 $pagetxtindexst .=
  qq~<img src="$index_togl{'index_togl'}" alt="$display_txt{'19'}" title="$display_txt{'19'}" /> $display_txt{'139'}: ~;
             }
             if ( $startpage > 0 ) {
                 $pagetxtindex =
                     qq~<a href="$scripturl?num=$viewnum/~
                   . ( !$ttsreverse ? 0 : $mreplies )
                   . qq~"><span class="small">1</span></a>&nbsp;<a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>&nbsp;~;
             }
             if ( $startpage == $maxmessagedisplay ) {
                 $pagetxtindex =
                     qq~<a href="$scripturl?num=$viewnum/~
                   . ( !$ttsreverse ? 0 : $mreplies )
                   . q~"><span class="small">1</span></a>&nbsp;~;
             }
             foreach my $counter ( $startpage .. ( $endpage - 1 ) ) {
                 if ( $counter % $maxmessagedisplay == 0 ) {
                     $pagetxtindex .=
                       $start == $counter
                       ? qq~<b>[$tmpa]</b>&nbsp;~
                       : qq~<a href="$scripturl?num=$viewnum/~
                       . ( !$ttsreverse ? $counter : ( $mreplies - $counter ) )
                       . qq~"><span class="small">$tmpa</span></a>&nbsp;~;
                     $tmpa++;
                 }
             }
             if ( $endpage < $max - ($maxmessagedisplay) ) {
                 $pageindexadd =
  qq~<a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>&nbsp;~;
             }
             if ( $endpage != $max ) {
                 $pageindexadd .=
                     qq~<a href="$scripturl?num=$viewnum/~
                   . ( !$ttsreverse ? $lastptn : $mreplies - $lastptn )
                   . qq~"><span class="small">$lastpn</span></a>~;
             }
             $pagetxtindex .= qq~$pageindexadd~;
             $pageindex1 = qq~$pagetxtindexst$pagetxtindex</span>~;
             $pageindex2 = $pageindex1;
   
         }
         else {
             $pagedropindex1 = q~<span class="pagedropindex">~;
             $pagedropindex1 .=
  qq~<span class="pagedropindex_inner"><a href="$scripturl?num=$viewnum;start=~
               . ( !$ttsreverse ? $start : $mreplies - $start )
               . qq~;action=threadpagetext"><img src="$index_togl{'index_togl'}" alt="$display_txt{'19'}" title="$display_txt{'19'}" /></a></span>~;
             $pagedropindex2 = $pagedropindex1;
             $tstart         = $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 / $maxmessagedisplay ) / $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 =
                   !$ttsreverse
                   ? ( $i * $dropdisplaynum * $maxmessagedisplay )
                   : (
                     $mreplies - ( $i * $dropdisplaynum * $maxmessagedisplay ) );
                 $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|$maxmessagedisplay|$indexpage~;
                 }
                 if ( $pagenumb > $dropdisplaynum ) {
                     $pagedropindex1 .=
  qq~<option value="$indexstart|$indexend|$maxmessagedisplay|$indexpage"$selected>$indxoption</option>\n~;
                     $pagedropindex2 .=
  qq~<option value="$indexstart|$indexend|$maxmessagedisplay|$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>~;
             $tmpmaxmessagedisplay = $maxmessagedisplay;
             $prevpage =
                !$ttsreverse
               ? $start - $tmpmaxmessagedisplay
               : $mreplies - $start + $tmpmaxmessagedisplay;
             $nextpage =
                !$ttsreverse
               ? $start + $maxmessagedisplay
               : $mreplies - $start - $maxmessagedisplay;
             $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 (   ( !$ttsreverse && $start < $maxmessagedisplay )
                 or ( $ttsreverse && $prevpage > $mreplies ) )
             {
                 $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" onclick="location.href=\\'$scripturl?num=$viewnum/$prevpage\\'" ondblclick="location.href=\\'$scripturl?num=$viewnum/~
                   . ( !$ttsreverse ? 0 : $mreplies )
                   . q~\\'" />~;
             }
             if (   ( !$ttsreverse && $nextpage > $lastptn )
                 or ( $ttsreverse && $nextpage < $mreplies - $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" onclick="location.href=\\'$scripturl?num=$viewnum/$nextpage\\'" ondblclick="location.href=\\'$scripturl?num=$viewnum/~
                   . ( !$ttsreverse ? $lastptn : $mreplies - $lastptn )
                   . q~\\'" />~;
             }
             $pageindex1 = qq~$pagedropindex1</span>~;
             $pageindex2 = qq~$pagedropindex2</span>~;
   
             $pageindexjs = qq~
     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?num=$viewnum/' + pagstart + '">' + i + '</a>$visel_1b';
             pagstart ~ . ( !$ttsreverse ? q{+} : q{-} ) . q~= maxpag;
         }
         ~;
             if ($showpageall) {
                 $pageindexjs .= qq~
             if (vistart != viend) {
                 if(visel == 'all') pagedropindex += '$visel_1a<b>$pidtxt{'01'}</b>$visel_1b';
                 else pagedropindex += '$visel_2a<a href="$scripturl?num=$viewnum/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~
     }
     SelDec('$pagejsindex', '~
               . ( !$ttsreverse ? $tstart : ( $mreplies - $tstart ) ) . q~');
~; ~;
       }        }
   }    }
   
   if (!$iamguest) {    if ( !$iamguest ) {
       $yyjavascript .= qq~         my $addnotlink = $img{'add_notify'}; 
       var addnotlink = '$img{'add_notify'}';         my $remnotlink = $img{'del_notify'}; 
       var remnotlink = '$img{'del_notify'}';         if ($useThreadtools) { 
       ~;             $addnotlink =~ s/\[tool=(.+?)\](.+?)\[\/tool\]/$2/gsm; 
       if (${$uid.$username}{'thread_notifications'} =~ /\b$viewnum\b/) {             $remnotlink =~ s/\[tool=(.+?)\](.+?)\[\/tool\]/$2/gsm; 
           $notify = qq~$menusep<a href="javascript:Notify('$scripturl?action=notify3;num=$viewnum/~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~','$imagesdir')" name="notifylink">$img{'del_notify'}</a>~;         } 
       } else {         $yyjavascript .= qq~ 
           $notify = qq~$menusep<a href="javascript:Notify('$scripturl?action=notify2;num=$viewnum/~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~','$imagesdir')" name="notifylink">$img{'add_notify'}</a>~;         var addnotlink = '$addnotlink'; 
       }         var remnotlink = '$remnotlink'; 
   }         ~; 
   
   $yymain .= qq~         if ( 
   <script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script>             ${ $uid . $username }{'thread_notifications'} =~ /\b$viewnum\b/xsm ) 
   <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>         { 
   ~;             $notify = 
  qq~$menusep<a href="javascript:Notify('$scripturl?action=notify3;num=$viewnum/~
   # update the .ctb file START               . ( !$ttsreverse ? $start : $mreplies - $start ) 
   &MessageTotals("load", $viewnum);               . qq~','$imagesdir')" id="notifylink">$img{'del_notify'}</a>~; 
   if ($username ne "Guest") {             $notify2 = 
       my (%viewer,@tmprepliers,$isrep);  qq~$menusep<a href="javascript:Notify('$scripturl?action=notify3;num=$viewnum/~ 
       foreach (@logentries) { # @logentries already loaded in YaBB.pl => &WriteLog;               . ( !$ttsreverse ? $start : $mreplies - $start ) 
           $viewer{(split(/\|/, $_, 2))[0]} = 1;               . qq~','$imagesdir')" id="notifylink2">$img{'del_notify'}</a>~; 
       }        }
         else {
       my $j = 0;             $notify = 
       foreach (@repliers) {  qq~$menusep<a href="javascript:Notify('$scripturl?action=notify2;num=$viewnum/~ 
           my ($reptime, $repuser, $isreplying) = split(/\|/, $_);               . ( !$ttsreverse ? $start : $mreplies - $start ) 
           next if $date - $reptime > 600 || !exists $viewer{$repuser};               . qq~','$imagesdir')" id="notifylink">$img{'add_notify'}</a>~; 
           if ($repuser eq $username) { $tmprepliers[$j] = qq~$date|$repuser|0~; $isrep = 1; }             $notify2 = 
           else { $tmprepliers[$j] = qq~$reptime|$repuser|$isreplying~; }  qq~$menusep<a href="javascript:Notify('$scripturl?action=notify2;num=$viewnum/~ 
           $j++;               . ( !$ttsreverse ? $start : $mreplies - $start ) 
       }               . qq~','$imagesdir')" id="notifylink2">$img{'add_notify'}</a>~; 
       push(@tmprepliers, qq~$date|$username|0~) if !$isrep;  
       @repliers = @tmprepliers;         } 
     }
       ${$viewnum}{'views'}++; # Add 1 to the number of views of this thread.  
       &MessageTotals("update", $viewnum);  
   } else {     # update the .ctb file START 
       &MessageTotals("incview", $viewnum); # Add 1 to the number of views of this thread.     MessageTotals( 'load', $viewnum ); 
   }     if ( $username ne 'Guest' ) { 
   # update the .ctb file END         my ( %viewer, @tmprepliers, $isrep ); 
         foreach (@logentries)
   # Mark current board as read if no other new threads are in         {    # @logentries already loaded in YaBB.pl => &WriteLog; 
   &getlog;             $viewer{ ( split /\|/xsm, $_, 2 )[0] } = 1; 
   # &NextPrev => Insert Navigation Bit and get info about number of threads newer than last visit         } 
   if (&NextPrev($viewnum, $yyuserlog{$currentboard}) < 2) { $yyuserlog{$currentboard} = $date; }  
   # Mark current thread as read. Save thread and board Mark.         my $j = 0; 
   delete $yyuserlog{"$mnum--unread"};         foreach (@repliers) { 
   &dumplog($mnum);             my ( $reptime, $repuser, $isreplying ) = split /\|/xsm, $_; 
             next if $date - $reptime > 600 || !exists $viewer{$repuser};
   $template_home = qq~<a href="$scripturl" class="nav">$mbname</a>~;             if ( $repuser eq $username ) { 
   $topviewers = 0;                 $tmprepliers[$j] = qq~$date|$repuser|0~; 
   if (${$uid.$currentboard}{'ann'} == 1) {                 $isrep = 1; 
       if ($vircurrentboard) {             } 
           $template_cat = qq~<a href="$scripturl?catselect=$vircurcat">$vircat</a>~;             else { $tmprepliers[$j] = qq~$reptime|$repuser|$isreplying~; } 
           $template_board = qq~<a href="$scripturl?board=$vircurrentboard">$virboardname</a>~;             $j++; 
           $navback = qq~<a href="$scripturl?board=$vircurrentboard">&lsaquo; $maintxt{'board'}</a>~;         } 
           $template_mods = qq~$showmods$showmodgroups~;         if ( !$isrep ) { push @tmprepliers, qq~$date|$username|0~; } 
       } elsif ($iamadmin || $iamgmod) {         @repliers = @tmprepliers; 
           $template_cat = qq~<a href="$scripturl?catselect=$curcat">$cat</a>~;  
           $template_board = qq~<a href="$scripturl?board=$currentboard">$boardname</a>~;         ${$viewnum}{'views'}++;   # Add 1 to the number of views of this thread. 
           $navback = qq~<a href="$scripturl?board=$currentboard">&lsaquo; $maintxt{'board'}</a>~;         MessageTotals( 'update', $viewnum ); 
           $template_mods = qq~$showmods$showmodgroups~;     } 
       } else {    else {
           $template_cat = $maintxt{'418'};         MessageTotals( 'incview', $viewnum ); 
           $template_board = $display_txt{'999'};  
           $template_mods = '';         # Add 1 to the number of views of this thread. 
       }    }
   } else {  
       $template_cat = qq~<a href="$scripturl?catselect=$curcat">$cat</a>~;     # update the .ctb file END 
       $template_board = qq~<a href="$scripturl?board=$currentboard">$boardname</a>~;  
       $navback = qq~<a href="$scripturl?board=$currentboard">&lsaquo; $maintxt{'board'}</a>~;     # Mark current board as read if no other new threads are in 
       $template_mods  = qq~$showmods$showmodgroups~;     getlog(); 
   }  
   if ($showtopicviewers && ($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {  # &NextPrev => Insert Navigation Bit and get info about number of threads newer than last visit 
       my ($mrepuser, $misreplying, $replying);     if ( NextPrev( $viewnum, $yyuserlog{$currentboard} ) < 2 ) { 
       foreach (@repliers) {         $yyuserlog{$currentboard} = $date; 
           (undef, $mrepuser, $misreplying) = split(/\|/, $_);     } 
           &LoadUser($mrepuser);  
           $replying = $misreplying ? qq~ <span class="small">($display_txt{'645'})</span>~ : '';     # Mark current thread as read. Save thread and board Mark. 
           $template_viewers .= qq~$link{$mrepuser}$replying, ~;     delete $yyuserlog{"$mnum--unread"}; 
           $topviewers++;     dumplog($mnum); 
       }  
       $template_viewers =~ s/\, \Z/\./;     $template_home = qq~<a href="$scripturl" class="nav">$mbname</a>~; 
   }     $topviewers    = 0; 
     if ( ${ $uid . $currentboard }{'ann'}