D:\WEBSITES\testbed\252_zip\sources\Display_08_27\Display.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Sources\Display.pl
############################################################################### ###############################################################################
# Display.pl                                                                  # # Display.pl                                                                  #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.5.2                                                  #
# Packaged:       September 30, 2012                                          # # Packaged:       September 30, 2012                                          #
# 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-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
   
$displayplver = 'YaBB 2.5.2 $Revision: 1.2 $'; $displayplver = 'YaBB 2.5.2 $Revision: 1.2 $';
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"; require "$templatesdir/$usedisplay/Display.template";
if ($iamgmod) { require "$vardir/gmodsettings.txt"; } if ($iamgmod) { require "$vardir/gmodsettings.txt"; }
   
sub Display { sub Display {
   # Check if board was 'shown to all' - and whether they can view the topic    # Check if board was 'shown to all' - and whether they can view the topic
   if (&AccessCheck($currentboard, '', $boardperms) ne "granted") { &fatal_error("no_access"); }    if (&AccessCheck($currentboard, '', $boardperms) ne "granted") { &fatal_error("no_access"); }
   
   # Get the "NEW"est Post for this user.    # Get the "NEW"est Post for this user.
   my $newestpost;    my $newestpost;
   if (!$iamguest && $max_log_days_old && $INFO{'start'} eq "new") {    if (!$iamguest && $max_log_days_old && $INFO{'start'} eq "new") {
       # This decides which messages were already read in the thread to        # This decides which messages were already read in the thread to
       # determing where the redirect should go. It is done by        # determing where the redirect should go. It is done by
       # comparing times in the username.log and the boardnumber.txt files.        # comparing times in the username.log and the boardnumber.txt files.
       &getlog;        &getlog;
       my $mnum = $INFO{'num'};        my $mnum = $INFO{'num'};
       my $dlp = int($yyuserlog{$mnum}) > int($yyuserlog{"$currentboard--mark"}) ? int($yyuserlog{$mnum}) : int($yyuserlog{"$currentboard--mark"});        my $dlp = int($yyuserlog{$mnum}) > int($yyuserlog{"$currentboard--mark"}) ? int($yyuserlog{$mnum}) : int($yyuserlog{"$currentboard--mark"});
       $dlp = $dlp > $date - ($max_log_days_old * 86400) ? $dlp : $date - ($max_log_days_old * 86400);        $dlp = $dlp > $date - ($max_log_days_old * 86400) ? $dlp : $date - ($max_log_days_old * 86400);
   
       unless (ref($thread_arrayref{$mnum})) {        unless (ref($thread_arrayref{$mnum})) {
           fopen(MNUM, "$datadir/$mnum.txt");            fopen(MNUM, "$datadir/$mnum.txt");
           @{$thread_arrayref{$mnum}} = <MNUM>;            @{$thread_arrayref{$mnum}} = <MNUM>;
           fclose(MNUM);            fclose(MNUM);
       }        }
       my $i = -1;        my $i = -1;
       foreach (@{$thread_arrayref{$mnum}}) {        foreach (@{$thread_arrayref{$mnum}}) {
           $i++;            $i++;
           last if (split(/\|/, $_))[3] > $dlp;            last if (split(/\|/, $_))[3] > $dlp;
       }        }
   
       $newestpost = $INFO{'start'} = $i;        $newestpost = $INFO{'start'} = $i;
   }    }
   
   if ($buddyListEnabled) { &loadMyBuddy; }    if ($buddyListEnabled) { &loadMyBuddy; }
   my $viewnum = $INFO{'num'};    my $viewnum = $INFO{'num'};
   
   # strip off any non numeric values to avoid exploitation    # strip off any non numeric values to avoid exploitation
   $maxmessagedisplay ||= 10;    $maxmessagedisplay ||= 10;
   my ($msubthread, $mnum, $mstate, $mdate, $msub, $mname, $memail, $mreplies, $musername, $micon, $mip, $mlm, $mlmb);    my ($msubthread, $mnum, $mstate, $mdate, $msub, $mname, $memail, $mreplies, $musername, $micon, $mip, $mlm, $mlmb);
   my ($counter, $counterwords, $threadclass, $notify, $max, $start, $windowbg, $mattach, $pagedropindex, $template_viewers, $template_favorite, $template_pollmain, $navback, $mark_unread, $pollbutton, $icanbypass, $replybutton, $bypassReplyButton);    my ($counter, $counterwords, $threadclass, $notify, $max, $start, $windowbg, $mattach, $pagedropindex, $template_viewers, $template_favorite, $template_pollmain, $navback, $mark_unread, $pollbutton, $icanbypass, $replybutton, $bypassReplyButton);
   
   &LoadCensorList;    &LoadCensorList;
   
   # Determine category    # Determine category
   $curcat = ${$uid.$currentboard}{'cat'};    $curcat = ${$uid.$currentboard}{'cat'};
   
   # Figure out the name of the category    # Figure out the name of the category
   unless ($mloaded == 1) { require "$boardsdir/forum.master"; }    unless ($mloaded == 1) { require "$boardsdir/forum.master"; }
   
   if ($currentboard eq $annboard) {    if ($currentboard eq $annboard) {
       $vircurrentboard = $INFO{'virboard'};        $vircurrentboard = $INFO{'virboard'};
       $vircurcat = ${$uid.$vircurrentboard}{'cat'};        $vircurcat = ${$uid.$vircurrentboard}{'cat'};
       ($vircat, undef) = split(/\|/, $catinfo{$vircurcat});        ($vircat, undef) = split(/\|/, $catinfo{$vircurcat});
       ($virboardname, undef) = split(/\|/, $board{$vircurrentboard},2);        ($virboardname, undef) = split(/\|/, $board{$vircurrentboard},2);
       &ToChars($virboardname);        &ToChars($virboardname);
   }    }
   
   ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});    ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});
   &ToChars($cat);    &ToChars($cat);
   
   ($boardname, $boardperms, $boardview) = split(/\|/, $board{$currentboard});    ($boardname, $boardperms, $boardview) = split(/\|/, $board{$currentboard});
   
   &ToChars($boardname);    &ToChars($boardname);
   
   # Check to make sure this thread isn't locked.    # Check to make sure this thread isn't locked.
   ($mnum, $msubthread, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);    ($mnum, $msubthread, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);
   
   if ($mstate =~ /m/) {    if ($mstate =~ /m/) {
       $msubthread =~ / dest=(\d+)\]/;        $msubthread =~ / dest=(\d+)\]/;
       my $newnum = $1;        my $newnum = $1;
       if (-e "$datadir/$newnum.txt") {        if (-e "$datadir/$newnum.txt") {
           $yySetLocation = "$scripturl?num=$newnum";            $yySetLocation = "$scripturl?num=$newnum";
           &redirectexit;            &redirectexit;
       }        }
       eval { require "$datadir/movedthreads.cgi" };        eval { require "$datadir/movedthreads.cgi" };
       while (exists $moved_file{$newnum}) {        while (exists $moved_file{$newnum}) {
           $newnum = $moved_file{$newnum};            $newnum = $moved_file{$newnum};
           next if exists $moved_file{$newnum};            next if exists $moved_file{$newnum};
           if (-e "$datadir/$newnum.txt") {            if (-e "$datadir/$newnum.txt") {
               $yySetLocation = "$scripturl?num=$newnum";                $yySetLocation = "$scripturl?num=$newnum";
               &redirectexit;                &redirectexit;
           }            }
       }        }
   }    }
   
   ($msubthread, undef) = &Split_Splice_Move($msubthread,0);    ($msubthread, undef) = &Split_Splice_Move($msubthread,0);
   &ToChars($msubthread);    &ToChars($msubthread);
   $msubthread = &Censor($msubthread);    $msubthread = &Censor($msubthread);
   
   # Build a list of this board's moderators.    # Build a list of this board's moderators.
   if (keys %moderators > 0) {    if (keys %moderators > 0) {
       if (keys %moderators == 1) { $showmods = qq~($display_txt{'298'}: ~; }        if (keys %moderators == 1) { $showmods = qq~($display_txt{'298'}: ~; }
       else { $showmods = qq~($display_txt{'63'}: ~; }        else { $showmods = qq~($display_txt{'63'}: ~; }
   
       while ($_ = each(%moderators)) {        while ($_ = each(%moderators)) {
           &FormatUserName($_);            &FormatUserName($_);
           $showmods .= &QuickLinks($_,1) . ", ";            $showmods .= &QuickLinks($_,1) . ", ";
       }        }
       $showmods =~ s/, \Z/)/;        $showmods =~ s/, \Z/)/;
   }    }
   if (keys %moderatorgroups > 0) {    if (keys %moderatorgroups > 0) {
       if (keys %moderatorgroups == 1) { $showmodgroups = qq~($display_txt{'298a'}: ~; }        if (keys %moderatorgroups == 1) { $showmodgroups = qq~($display_txt{'298a'}: ~; }
       else { $showmodgroups = qq~($display_txt{'63a'}: ~; }        else { $showmodgroups = qq~($display_txt{'63a'}: ~; }
   
       my ($tmpmodgrp,$thismodgrp);        my ($tmpmodgrp,$thismodgrp);
       while ($_ = each(%moderatorgroups)) {        while ($_ = each(%moderatorgroups)) {
           $tmpmodgrp = $moderatorgroups{$_};            $tmpmodgrp = $moderatorgroups{$_};
           ($thismodgrp, undef) = split(/\|/, $NoPost{$tmpmodgrp}, 2);            ($thismodgrp, undef) = split(/\|/, $NoPost{$tmpmodgrp}, 2);
           $showmodgroups .= qq~$thismodgrp, ~;            $showmodgroups .= qq~$thismodgrp, ~;
       }        }
       $showmodgroups =~ s/, \Z/)/;        $showmodgroups =~ s/, \Z/)/;
   }    }
   
   ## now we have established credentials,    ## now we have established credentials,
   ## can this user bypass locks?    ## can this user bypass locks?
   ## work out who can bypass locked thread post only if bypass switched on    ## work out who can bypass locked thread post only if bypass switched on
   if ($mstate =~ /l/i) {    if ($mstate =~ /l/i) {
       if ($bypass_lock_perm) { $icanbypass = &checkUserLockBypass; }        if ($bypass_lock_perm) { $icanbypass = &checkUserLockBypass; }
       $enable_quickreply = 0;        $enable_quickreply = 0;
   }    }
   
   my $permdate = &permtimer($mnum);    my $permdate = &permtimer($mnum);
   my $display_permalink = qq~<a href="http://$perm_domain/$symlink$permdate/$currentboard/$mnum">$display_txt{'10'}</a>~;    my $display_permalink = qq~<a href="http://$perm_domain/$symlink$permdate/$currentboard/$mnum">$display_txt{'10'}</a>~;
   
   # Look for a poll file for this thread.    # Look for a poll file for this thread.
   if (&AccessCheck($currentboard, 3) eq 'granted') {    if (&AccessCheck($currentboard, 3) eq 'granted') {
       $pollbutton = qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=AddPoll">$img{'addpoll'}</a>~;        $pollbutton = qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=AddPoll">$img{'addpoll'}</a>~;
   }    }
   if (-e "$datadir/$viewnum.poll") {    if (-e "$datadir/$viewnum.poll") {
       $has_poll = 1;        $has_poll = 1;
       $pollbutton = '';        $pollbutton = '';
   } else {    } else {
       $has_poll = 0;        $has_poll = 0;
       if ($useraddpoll == 0) { $pollbutton = ''; }        if ($useraddpoll == 0) { $pollbutton = ''; }
   }    }
   
   # Get the class of this thread, based on lock status and number of replies.    # Get the class of this thread, based on lock status and number of replies.
   if ((!$iamguest || $enable_guestposting) && &AccessCheck($currentboard, 2) eq 'granted') {    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~);        $replybutton = qq~$menusep<a href="~ . ($enable_quickreply && $enable_quickjump ? 'javascript:document.postmodify.message.focus();' : qq~$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=PostReply~);
       $bypassReplyButton = $replybutton . qq~" onclick="return confirm('$display_txt{'posttolocked'}');">$img{'reply'}</a> ~;        $bypassReplyButton = $replybutton . qq~" onclick="return confirm('$display_txt{'posttolocked'}');">$img{'reply'}</a> ~;
       $replybutton .= qq~">$img{'reply'}</a> ~; #" make my text-editor happy;        $replybutton .= qq~">$img{'reply'}</a> ~; #" make my text-editor happy;
   }    }
   
   $threadclass = 'thread';    $threadclass = 'thread';
   ## hidden threads    ## hidden threads
   if ($mstate =~ /h/i) {    if ($mstate =~ /h/i) {
       $threadclass = 'hide';        $threadclass = 'hide';
       if (!$iamadmin && !$iamgmod && !$iammod) { &fatal_error('no_access'); }        if (!$iamadmin && !$iamgmod && !$iammod) { &fatal_error('no_access'); }
   }    }
   ## locked thread    ## locked thread
   elsif ($mstate =~ /l/i) {    elsif ($mstate =~ /l/i) {
       $threadclass = 'locked';  ## same icon regardless        $threadclass = 'locked';  ## same icon regardless
       $pollbutton = '';        $pollbutton = '';
       if   ($icanbypass) { $replybutton = $bypassReplyButton; }        if   ($icanbypass) { $replybutton = $bypassReplyButton; }
       else { $replybutton = ''; } # squish        else { $replybutton = ''; } # squish
   }    }
   elsif ($mreplies >= $VeryHotTopic) { $threadclass = 'veryhotthread'; }    elsif ($mreplies >= $VeryHotTopic) { $threadclass = 'veryhotthread'; }
   elsif ($mreplies >= $HotTopic) { $threadclass = 'hotthread'; }    elsif ($mreplies >= $HotTopic) { $threadclass = 'hotthread'; }
   elsif ($mstate eq '') { $threadclass = 'thread'; }    elsif ($mstate eq '') { $threadclass = 'thread'; }
   
   if ($threadclass eq 'hide') { ##  hidden    if ($threadclass eq 'hide') { ##  hidden
       if ($mstate =~ /s/i && $mstate !~ /l/i) { $threadclass = 'hidesticky'; }        if ($mstate =~ /s/i && $mstate !~ /l/i) { $threadclass = 'hidesticky'; }
       elsif ($mstate =~ /l/i && $mstate !~ /s/i) {        elsif ($mstate =~ /l/i && $mstate !~ /s/i) {
           $threadclass = 'hidelock'; $pollbutton = '';            $threadclass = 'hidelock'; $pollbutton = '';
           if ($icanbypass) { $replybutton = $bypassReplyButton; }            if ($icanbypass) { $replybutton = $bypassReplyButton; }
           else { $replybutton = ''; } # squish            else { $replybutton = ''; } # squish
       }        }
       elsif ($mstate =~ /s/i && $mstate =~ /l/i) {        elsif ($mstate =~ /s/i && $mstate =~ /l/i) {
           $threadclass = 'hidestickylock'; $pollbutton  = '';            $threadclass = 'hidestickylock'; $pollbutton  = '';
           if ($icanbypass) { $replybutton = $bypassReplyButton; }            if ($icanbypass) { $replybutton = $bypassReplyButton; }
           else { $replybutton = ''; } # squish            else { $replybutton = ''; } # squish
       }        }
   }    }
   elsif ($threadclass eq 'locked' && $mstate =~ /s/i) {    elsif ($threadclass eq 'locked' && $mstate =~ /s/i) {
       $threadclass = 'stickylock';        $threadclass = 'stickylock';
       if ($icanbypass) { $replybutton = $bypassReplyButton; }        if ($icanbypass) { $replybutton = $bypassReplyButton; }
       else { $replybutton = ''; } # squish        else { $replybutton = ''; } # squish
   }    }
   elsif ($mstate =~ /s/i) { $threadclass = 'sticky'; }    elsif ($mstate =~ /s/i) { $threadclass = 'sticky'; }
   elsif (${$mnum}{'board'} eq $annboard) { $threadclass = $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; }    elsif (${$mnum}{'board'} eq $annboard) { $threadclass = $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; }
   
   if (-e "$datadir/$mnum.mail" && !$iamguest) {    if (-e "$datadir/$mnum.mail" && !$iamguest) {
       require "$sourcedir/Notify.pl";        require "$sourcedir/Notify.pl";
       &ManageThreadNotify("update", $mnum, $username, '', '', '1');        &ManageThreadNotify("update", $mnum, $username, '', '', '1');
   }    }
   
   if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~ - ~; }    if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~ - ~; }
   
   # Build the page links list.    # Build the page links list.
   if (!$iamguest) {    if (!$iamguest) {
       (undef, $userthreadpage, undef,undef) = split(/\|/, ${$uid.$username}{'pageindex'});        (undef, $userthreadpage, undef,undef) = split(/\|/, ${$uid.$username}{'pageindex'});
   }    }
   my ($pagetxtindex, $pagetextindex, $pagedropindex1, $pagedropindex2, $all, $allselected);    my ($pagetxtindex, $pagetextindex, $pagedropindex1, $pagedropindex2, $all, $allselected);
   $postdisplaynum = 3; # max number of pages to display    $postdisplaynum = 3; # max number of pages to display
   $dropdisplaynum = 10;    $dropdisplaynum = 10;
   $startpage = 0;    $startpage = 0;
   $max = $mreplies + 1;    $max = $mreplies + 1;
   if (substr($INFO{'start'}, 0, 3) eq 'all' && $showpageall != 0) { $maxmessagedisplay = $max; $all = 1; $allselected = qq~ selected="selected"~; $start = !$ttsreverse ? 0 : $mreplies; }    if (substr($INFO{'start'}, 0, 3) eq 'all' && $showpageall != 0) { $maxmessagedisplay = $max; $all = 1; $allselected = qq~ selected="selected"~; $start = !$ttsreverse ? 0 : $mreplies; }
   else { $start = $INFO{'start'} !~ /\d/ ? (!$ttsreverse ? 0 : $mreplies) : $INFO{'start'}; }    else { $start = $INFO{'start'} !~ /\d/ ? (!$ttsreverse ? 0 : $mreplies) : $INFO{'start'}; }
   $start = $start > $mreplies ? $mreplies : $start;    $start = $start > $mreplies ? $mreplies : $start;
   $start = !$ttsreverse ? (int($start / $maxmessagedisplay) * $maxmessagedisplay) : (int(($mreplies - $start) / $maxmessagedisplay) * $maxmessagedisplay);    $start = !$ttsreverse ? (int($start / $maxmessagedisplay) * $maxmessagedisplay) : (int(($mreplies - $start) / $maxmessagedisplay) * $maxmessagedisplay);
   $tmpa = 1;    $tmpa = 1;
   $pagenumb = int(($max - 1) / $maxmessagedisplay) + 1;    $pagenumb = int(($max - 1) / $maxmessagedisplay) + 1;
   
   if ($start >= (($postdisplaynum - 1) * $maxmessagedisplay)) {    if ($start >= (($postdisplaynum - 1) * $maxmessagedisplay)) {
       $startpage = $start - (($postdisplaynum - 1) * $maxmessagedisplay);        $startpage = $start - (($postdisplaynum - 1) * $maxmessagedisplay);
       $tmpa = int($startpage / $maxmessagedisplay) + 1;        $tmpa = int($startpage / $maxmessagedisplay) + 1;
   }    }
   if ($max >= $start + ($postdisplaynum * $maxmessagedisplay)) { $endpage = $start + ($postdisplaynum * $maxmessagedisplay); }    if ($max >= $start + ($postdisplaynum * $maxmessagedisplay)) { $endpage = $start + ($postdisplaynum * $maxmessagedisplay); }
   else { $endpage = $max; }    else { $endpage = $max; }
   $lastpn = int($mreplies / $maxmessagedisplay) + 1;    $lastpn = int($mreplies / $maxmessagedisplay) + 1;
   $lastptn = ($lastpn - 1) * $maxmessagedisplay;    $lastptn = ($lastpn - 1) * $maxmessagedisplay;
   $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>~;    $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>~;
   $pageindex2 = $pageindex1;    $pageindex2 = $pageindex1;
   if ($pagenumb > 1 || $all) {    if ($pagenumb > 1 || $all) {
       if ($userthreadpage == 1 || $iamguest) {        if ($userthreadpage == 1 || $iamguest) {
           $pagetxtindexst = qq~<span class="small" style="float: left; height: 21px; margin: 0px; margin-top: 2px;">~;            $pagetxtindexst = qq~<span class="small" style="float: left; height: 21px; margin: 0px; margin-top: 2px;">~;
           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'}: ~; }            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'}: ~; }            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;~; }            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;~; }
           if ($startpage == $maxmessagedisplay) { $pagetxtindex = qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? 0 : $mreplies) . qq~" style="font-weight: normal;">1</a>&nbsp;~; }            if ($startpage == $maxmessagedisplay) { $pagetxtindex = qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? 0 : $mreplies) . qq~" style="font-weight: normal;">1</a>&nbsp;~; }
           for ($counter = $startpage; $counter < $endpage; $counter += $maxmessagedisplay) {            for ($counter = $startpage; $counter < $endpage; $counter += $maxmessagedisplay) {
               $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;~;                $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++;                $tmpa++;
           }            }
           if ($endpage < $max - ($maxmessagedisplay)) { $pageindexadd = qq~<a href="javascript:void(0);" onclick="ListPages($mnum);">...</a>&nbsp;~; }            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~" style="font-weight: normal;">$lastpn</a>~; }            if ($endpage != $max) { $pageindexadd .= qq~<a href="$scripturl?num=$viewnum/~ . (!$ttsreverse ? $lastptn : $mreplies - $lastptn) . qq~" style="font-weight: normal;">$lastpn</a>~; }
           $pagetxtindex .= qq~$pageindexadd~;            $pagetxtindex .= qq~$pageindexadd~;
           $pageindex1 = qq~$pagetxtindexst$pagetxtindex</span>~;            $pageindex1 = qq~$pagetxtindexst$pagetxtindex</span>~;
           $pageindex2 = $pageindex1;            $pageindex2 = $pageindex1;
   
       } else {        } else {
           $pagedropindex1 = qq~<span style="float: left; width: 350px; margin: 0px; margin-top: 2px; border: 0px;">~;            $pagedropindex1 = qq~<span style="float: left; width: 350px; margin: 0px; margin-top: 2px; border: 0px;">~;
           $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>~;            $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>~;
           $pagedropindex2 = $pagedropindex1;            $pagedropindex2 = $pagedropindex1;
           $tstart = $start;            $tstart = $start;
           #if (substr($INFO{'start'}, 0, 3) eq "all") { ($tstart, $start) = split(/\-/, $INFO{'start'}); }            #if (substr($INFO{'start'}, 0, 3) eq "all") { ($tstart, $start) = split(/\-/, $INFO{'start'}); }
           $d_indexpages = $pagenumb / $dropdisplaynum;            $d_indexpages = $pagenumb / $dropdisplaynum;
           $i_indexpages = int($pagenumb / $dropdisplaynum);            $i_indexpages = int($pagenumb / $dropdisplaynum);
           if ($d_indexpages > $i_indexpages) { $indexpages = int($pagenumb / $dropdisplaynum) + 1; }            if ($d_indexpages > $i_indexpages) { $indexpages = int($pagenumb / $dropdisplaynum) + 1; }
           else { $indexpages = int($pagenumb / $dropdisplaynum) }            else { $indexpages = int($pagenumb / $dropdisplaynum) }
           $selectedindex = int(($start / $maxmessagedisplay) / $dropdisplaynum);            $selectedindex = int(($start / $maxmessagedisplay) / $dropdisplaynum);
   
           if ($pagenumb > $dropdisplaynum) {            if ($pagenumb > $dropdisplaynum) {
               $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~;                $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~;
               $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~;                $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~;
           }            }
   
           for ($i = 0; $i < $indexpages; $i++) {            for ($i = 0; $i < $indexpages; $i++) {
               $indexpage = !$ttsreverse ? ($i * $dropdisplaynum * $maxmessagedisplay) : ($mreplies - ($i * $dropdisplaynum * $maxmessagedisplay));                $indexpage = !$ttsreverse ? ($i * $dropdisplaynum * $maxmessagedisplay) : ($mreplies - ($i * $dropdisplaynum * $maxmessagedisplay));
               $indexstart = ($i * $dropdisplaynum) + 1;                $indexstart = ($i * $dropdisplaynum) + 1;
               $indexend = $indexstart + ($dropdisplaynum - 1);                $indexend = $indexstart + ($dropdisplaynum - 1);
               if ($indexend > $pagenumb)    { $indexend   = $pagenumb; }                if ($indexend > $pagenumb)    { $indexend   = $pagenumb; }
               if ($indexstart == $indexend) { $indxoption = qq~$indexstart~; }                if ($indexstart == $indexend) { $indxoption = qq~$indexstart~; }
               else { $indxoption = qq~$indexstart-$indexend~; }                else { $indxoption = qq~$indexstart-$indexend~; }
               $selected = "";                $selected = "";
               if ($i == $selectedindex) {                if ($i == $selectedindex) {
                   $selected    = qq~ selected="selected"~;                    $selected    = qq~ selected="selected"~;
                   $pagejsindex = qq~$indexstart|$indexend|$maxmessagedisplay|$indexpage~;                    $pagejsindex = qq~$indexstart|$indexend|$maxmessagedisplay|$indexpage~;
               }                }
               if ($pagenumb > $dropdisplaynum) {                if ($pagenumb > $dropdisplaynum) {
                   $pagedropindex1 .= qq~<option value="$indexstart|$indexend|$maxmessagedisplay|$indexpage"$selected>$indxoption</option>\n~;                    $pagedropindex1 .= qq~<option value="$indexstart|$indexend|$maxmessagedisplay|$indexpage"$selected>$indxoption</option>\n~;
                   $pagedropindex2 .= 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) {            if ($pagenumb > $dropdisplaynum) {
               $pagedropindex1 .= qq~</select>\n</span>~;                $pagedropindex1 .= qq~</select>\n</span>~;
               $pagedropindex2 .= qq~</select>\n</span>~;                $pagedropindex2 .= qq~</select>\n</span>~;
           }            }
           $pagedropindex1 .= qq~<span id="ViewIndex1" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;            $pagedropindex1 .= qq~<span id="ViewIndex1" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;
           $pagedropindex2 .= qq~<span id="ViewIndex2" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;            $pagedropindex2 .= qq~<span id="ViewIndex2" class="droppageindex" style="height: 14px; visibility: hidden">&nbsp;</span>~;
           $tmpmaxmessagedisplay = $maxmessagedisplay;            $tmpmaxmessagedisplay = $maxmessagedisplay;
           $prevpage = !$ttsreverse ? $start - $tmpmaxmessagedisplay : $mreplies - $start + $tmpmaxmessagedisplay;            $prevpage = !$ttsreverse ? $start - $tmpmaxmessagedisplay : $mreplies - $start + $tmpmaxmessagedisplay;
           $nextpage = !$ttsreverse ? $start + $maxmessagedisplay : $mreplies - $start - $maxmessagedisplay;            $nextpage = !$ttsreverse ? $start + $maxmessagedisplay : $mreplies - $start - $maxmessagedisplay;
           $pagedropindexpvbl = qq~<img src="$imagesdir/index_left0.gif" height="14" width="13" border="0" alt="" style="margin: 0px; display: inline; vertical-align: middle;" />~;            $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;" />~;            $pagedropindexnxbl = qq~<img src="$imagesdir/index_right0.gif" height="14" width="13" border="0" alt="" style="margin: 0px; display: inline; vertical-align: middle;" />~;
           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;" />~; }            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;" />~; }
           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~\\'" />~; }            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;" />~; }            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~\\'" />~; }            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~\\'" />~; }
           $pageindex1 = qq~$pagedropindex1</span>~;            $pageindex1 = qq~$pagedropindex1</span>~;
           $pageindex2 = qq~$pagedropindex2</span>~;            $pageindex2 = qq~$pagedropindex2</span>~;
   
           $pageindexjs = qq~            $pageindexjs = qq~
   function SelDec(decparam, visel) {    function SelDec(decparam, visel) {
       splitparam = decparam.split("|");        splitparam = decparam.split("|");
       var vistart = parseInt(splitparam[0]);        var vistart = parseInt(splitparam[0]);
       var viend = parseInt(splitparam[1]);        var viend = parseInt(splitparam[1]);
       var maxpag = parseInt(splitparam[2]);        var maxpag = parseInt(splitparam[2]);
       var pagstart = parseInt(splitparam[3]);        var pagstart = parseInt(splitparam[3]);
       //var allpagstart = parseInt(splitparam[3]);        //var allpagstart = parseInt(splitparam[3]);
       if(visel == 'xx' && decparam == '$pagejsindex') visel = '$tstart';        if(visel == 'xx' && decparam == '$pagejsindex') visel = '$tstart';
       var pagedropindex = '<table border="0" cellpadding="0" cellspacing="0"><tr>';        var pagedropindex = '<table border="0" cellpadding="0" cellspacing="0"><tr>';
       for(i=vistart; i<=viend; i++) {        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>';            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>';
           else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?num=$viewnum/' + pagstart + '">' + i + '</a></td>';            else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?num=$viewnum/' + pagstart + '">' + i + '</a></td>';
           pagstart ~ . (!$ttsreverse ? '+' : '-') . qq~= maxpag;            pagstart ~ . (!$ttsreverse ? '+' : '-') . qq~= maxpag;
       }        }
       ~;        ~;
       if ($showpageall) {        if ($showpageall) {
           $pageindexjs .= qq~            $pageindexjs .= qq~
           if (vistart != viend) {            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(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>';
               else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?num=$viewnum/all">$pidtxt{'01'}</a></td>';                else pagedropindex += '<td height="14" class="droppages"><a href="$scripturl?num=$viewnum/all">$pidtxt{'01'}</a></td>';
           }            }
           ~;            ~;
       }        }
       $pageindexjs .= qq~        $pageindexjs .= qq~
       if(visel != 'xx') pagedropindex += '<td height="14" class="small" style="height: 14px; padding-left: 4px;">$pagedropindexpv$pagedropindexnx</td>';        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>';        else pagedropindex += '<td height="14" class="small" style="height: 14px; padding-left: 4px;">$pagedropindexpvbl$pagedropindexnxbl</td>';
       pagedropindex += '</tr></table>';        pagedropindex += '</tr></table>';
       document.getElementById("ViewIndex1").innerHTML=pagedropindex;        document.getElementById("ViewIndex1").innerHTML=pagedropindex;
       document.getElementById("ViewIndex1").style.visibility = "visible";        document.getElementById("ViewIndex1").style.visibility = "visible";
       document.getElementById("ViewIndex2").innerHTML=pagedropindex;        document.getElementById("ViewIndex2").innerHTML=pagedropindex;
       document.getElementById("ViewIndex2").style.visibility = "visible";        document.getElementById("ViewIndex2").style.visibility = "visible";
       ~;        ~;
           if ($pagenumb > $dropdisplaynum) {            if ($pagenumb > $dropdisplaynum) {
               $pageindexjs .= qq~                $pageindexjs .= qq~
       document.getElementById("decselector1").value = decparam;        document.getElementById("decselector1").value = decparam;
       document.getElementById("decselector2").value = decparam;        document.getElementById("decselector2").value = decparam;
       ~;        ~;
           }            }
           $pageindexjs .= qq~            $pageindexjs .= qq~
   }    }
   SelDec('$pagejsindex', '~ . (!$ttsreverse ? $tstart : ($mreplies - $tstart)) . qq~');    SelDec('$pagejsindex', '~ . (!$ttsreverse ? $tstart : ($mreplies - $tstart)) . qq~');
~; ~;
       }        }
   }    }
   
   if (!$iamguest) {    if (!$iamguest) {
       $yyjavascript .= qq~        $yyjavascript .= qq~
       var addnotlink = '$img{'add_notify'}';        var addnotlink = '$img{'add_notify'}';
       var remnotlink = '$img{'del_notify'}';        var remnotlink = '$img{'del_notify'}';
       ~;        ~;
       if (${$uid.$username}{'thread_notifications'} =~ /\b$viewnum\b/) {        if (${$uid.$username}{'thread_notifications'} =~ /\b$viewnum\b/) {
           $notify = qq~$menusep<a href="javascript:Notify('$scripturl?action=notify3;num=$viewnum/~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~','$imagesdir')" name="notifylink">$img{'del_notify'}</a>~;            $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 {        } else {
           $notify = qq~$menusep<a href="javascript:Notify('$scripturl?action=notify2;num=$viewnum/~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~','$imagesdir')" name="notifylink">$img{'add_notify'}</a>~;            $notify = qq~$menusep<a href="javascript:Notify('$scripturl?action=notify2;num=$viewnum/~ . (!$ttsreverse ? $start : $mreplies - $start) . qq~','$imagesdir')" name="notifylink">$img{'add_notify'}</a>~;
       }        }
   }    }
   
   $yymain .= qq~    $yymain .= qq~
   <script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script>    <script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script>
   <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>    <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>
   ~;    ~;
   
   # update the .ctb file START    # update the .ctb file START
   &MessageTotals("load", $viewnum);    &MessageTotals("load", $viewnum);
   if ($username ne "Guest") {    if ($username ne "Guest") {
       my (%viewer,@tmprepliers,$isrep);        my (%viewer,@tmprepliers,$isrep);
       foreach (@logentries) { # @logentries already loaded in YaBB.pl => &WriteLog;        foreach (@logentries) { # @logentries already loaded in YaBB.pl => &WriteLog;
           $viewer{(split(/\|/, $_, 2))[0]} = 1;            $viewer{(split(/\|/, $_, 2))[0]} = 1;
       }        }
   
       my $j = 0;        my $j = 0;
       foreach (@repliers) {        foreach (@repliers) {
           my ($reptime, $repuser, $isreplying) = split(/\|/, $_);            my ($reptime, $repuser, $isreplying) = split(/\|/, $_);
           next if $date - $reptime > 600 || !exists $viewer{$repuser};            next if $date - $reptime > 600 || !exists $viewer{$repuser};
           if ($repuser eq $username) { $tmprepliers[$j] = qq~$date|$repuser|0~; $isrep = 1; }            if ($repuser eq $username) { $tmprepliers[$j] = qq~$date|$repuser|0~; $isrep = 1; }
           else { $tmprepliers[$j] = qq~$reptime|$repuser|$isreplying~; }            else { $tmprepliers[$j] = qq~$reptime|$repuser|$isreplying~; }
           $j++;            $j++;
       }        }
       push(@tmprepliers, qq~$date|$username|0~) if !$isrep;        push(@tmprepliers, qq~$date|$username|0~) if !$isrep;
       @repliers = @tmprepliers;        @repliers = @tmprepliers;
   
       ${$viewnum}{'views'}++; # Add 1 to the number of views of this thread.        ${$viewnum}{'views'}++; # Add 1 to the number of views of this thread.
       &MessageTotals("update", $viewnum);        &MessageTotals("update", $viewnum);
   } else {    } else {
       &MessageTotals("incview", $viewnum); # Add 1 to the number of views of this thread.        &MessageTotals("incview", $viewnum); # Add 1 to the number of views of this thread.
   }    }
   # update the .ctb file END    # update the .ctb file END
   
   # Mark current board as read if no other new threads are in    # Mark current board as read if no other new threads are in
   &getlog;    &getlog;
   # &NextPrev => Insert Navigation Bit and get info about number of threads newer than last visit    # &NextPrev => Insert Navigation Bit and get info about number of threads newer than last visit
   if (&NextPrev($viewnum, $yyuserlog{$currentboard}) < 2) { $yyuserlog{$currentboard} = $date; }    if (&NextPrev($viewnum, $yyuserlog{$currentboard}) < 2) { $yyuserlog{$currentboard} = $date; }
   # Mark current thread as read. Save thread and board Mark.    # Mark current thread as read. Save thread and board Mark.
   delete $yyuserlog{"$mnum--unread"};    delete $yyuserlog{"$mnum--unread"};
   &dumplog($mnum);    &dumplog($mnum);
   
   $template_home = qq~<a href="$scripturl" class="nav">$mbname</a>~;    $template_home = qq~<a href="$scripturl" class="nav">$mbname</a>~;
   $topviewers = 0;    $topviewers = 0;
   if (${$uid.$currentboard}{'ann'} == 1) {    if (${$uid.$currentboard}{'ann'} == 1) {
       if ($vircurrentboard) {        if ($vircurrentboard) {
           $template_cat = qq~<a href="$scripturl?catselect=$vircurcat">$vircat</a>~;            $template_cat = qq~<a href="$scripturl?catselect=$vircurcat">$vircat</a>~;
           $template_board = qq~<a href="$scripturl?board=$vircurrentboard">$virboardname</a>~;            $template_board = qq~<a href="$scripturl?board=$vircurrentboard">$virboardname</a>~;
           $navback = qq~<a href="$scripturl?board=$vircurrentboard">&lsaquo; $maintxt{'board'}</a>~;            $navback = qq~<a href="$scripturl?board=$vircurrentboard">&lsaquo; $maintxt{'board'}</a>~;
           $template_mods = qq~$showmods$showmodgroups~;            $template_mods = qq~$showmods$showmodgroups~;
       } elsif ($iamadmin || $iamgmod) {        } elsif ($iamadmin || $iamgmod) {
           $template_cat = qq~<a href="$scripturl?catselect=$curcat">$cat</a>~;            $template_cat = qq~<a href="$scripturl?catselect=$curcat">$cat</a>~;
           $template_board = qq~<a href="$scripturl?board=$currentboard">$boardname</a>~;            $template_board = qq~<a href="$scripturl?board=$currentboard">$boardname</a>~;
           $navback = qq~<a href="$scripturl?board=$currentboard">&lsaquo; $maintxt{'board'}</a>~;            $navback = qq~<a href="$scripturl?board=$currentboard">&lsaquo; $maintxt{'board'}</a>~;
           $template_mods = qq~$showmods$showmodgroups~;            $template_mods = qq~$showmods$showmodgroups~;
       } else {        } else {
           $template_cat = $maintxt{'418'};            $template_cat = $maintxt{'418'};
           $template_board = $display_txt{'999'};            $template_board = $display_txt{'999'};
           $template_mods = '';            $template_mods = '';
       }        }
   } else {    } else {
       $template_cat = qq~<a href="$scripturl?catselect=$curcat">$cat</a>~;        $template_cat = qq~<a href="$scripturl?catselect=$curcat">$cat</a>~;
       $template_board = qq~<a href="$scripturl?board=$currentboard">$boardname</a>~;        $template_board = qq~<a href="$scripturl?board=$currentboard">$boardname</a>~;
       $navback = qq~<a href="$scripturl?board=$currentboard">&lsaquo; $maintxt{'board'}</a>~;        $navback = qq~<a href="$scripturl?board=$currentboard">&lsaquo; $maintxt{'board'}</a>~;
       $template_mods  = qq~$showmods$showmodgroups~;        $template_mods  = qq~$showmods$showmodgroups~;
   }    }
   if ($showtopicviewers && ($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {    if ($showtopicviewers && ($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {
       my ($mrepuser, $misreplying, $replying);        my ($mrepuser, $misreplying, $replying);
       foreach (@repliers) {        foreach (@repliers) {
           (undef, $mrepuser, $misreplying) = split(/\|/, $_);            (undef, $mrepuser, $misreplying) = split(/\|/, $_);
           &LoadUser($mrepuser);            &LoadUser($mrepuser);
           $replying = $misreplying ? qq~ <span class="small">($display_txt{'645'})</span>~ : '';            $replying = $misreplying ? qq~ <span class="small">($display_txt{'645'})</span>~ : '';
           $template_viewers .= qq~$link{$mrepuser}$replying, ~;            $template_viewers .= qq~$link{$mrepuser}$replying, ~;
           $topviewers++;            $topviewers++;
       }        }
       $template_viewers =~ s/\, \Z/\./;        $template_viewers =~ s/\, \Z/\./;
   }    }
   
   $yyjavascript .= qq~    $yyjavascript .= qq~
       var addfavlang = '$display_txt{'526'}';        var addfavlang = '$display_txt{'526'}';
       var remfavlang = '$display_txt{'527'}';        var remfavlang = '$display_txt{'527'}';
       var remnotelang = '$display_txt{'530'}';        var remnotelang = '$display_txt{'530'}';
       var addnotelang = '$display_txt{'529'}';        var addnotelang = '$display_txt{'529'}';
       var markfinishedlang = '$display_txt{'528'}';~;        var markfinishedlang = '$display_txt{'528'}';~;
   
   if (!$iamguest && $currentboard ne $annboard) {    if (!$iamguest && $currentboard ne $annboard) {
       require "$sourcedir/Favorites.pl";        require "$sourcedir/Favorites.pl";
       $template_favorite = &IsFav($viewnum, (!$ttsreverse ? $start : $mreplies - $start));        $template_favorite = &IsFav($viewnum, (!$ttsreverse ? $start : $mreplies - $start));
   }    }
   $template_threadimage = qq~<a name="top"><img src="$imagesdir/$threadclass.gif" style="vertical-align: middle;" alt="" /></a>~;    $template_threadimage = qq~<a name="top"><img src="$imagesdir/$threadclass.gif" style="vertical-align: middle;" alt="" /></a>~;
   $template_sendtopic = $sendtopicmail ? qq~$menusep<a href="javascript:sendtopicmail($sendtopicmail);">$img{'sendtopic'}</a>~ : '';    $template_sendtopic = $sendtopicmail ? qq~$menusep<a href="javascript:sendtopicmail($sendtopicmail);">$img{'sendtopic'}</a>~ : '';
   $template_print = qq~$menusep<a href="$scripturl?action=print;num=$viewnum" target="_blank">$img{'print'}</a>~;    $template_print = qq~$menusep<a href="$scripturl?action=print;num=$viewnum" target="_blank">$img{'print'}</a>~;
   if ($has_poll) { require "$sourcedir/Poll.pl"; &display_poll($viewnum); $template_pollmain = qq~$pollmain<br />~; }    if ($has_poll) { require "$sourcedir/Poll.pl"; &display_poll($viewnum); $template_pollmain = qq~$pollmain<br />~; }
   
   # Load background color list.    # Load background color list.
   @cssvalues = ('windowbg', 'windowbg2');    @cssvalues = ('windowbg', 'windowbg2');
   $cssnum = @cssvalues;    $cssnum = @cssvalues;
   
   if (!$UseMenuType) { $sm = 1; }    if (!$UseMenuType) { $sm = 1; }
   
   unless (ref($thread_arrayref{$viewnum})) {    unless (ref($thread_arrayref{$viewnum})) {
       fopen(MSGTXT, "$datadir/$viewnum.txt") || &fatal_error("cannot_open","$datadir/$viewnum.txt", 1);        fopen(MSGTXT, "$datadir/$viewnum.txt") || &fatal_error("cannot_open","$datadir/$viewnum.txt", 1);
       @{$thread_arrayref{$viewnum}} = <MSGTXT>;        @{$thread_arrayref{$viewnum}} = <MSGTXT>;
       fclose(MSGTXT);        fclose(MSGTXT);
   }    }
   $counter = 0;    $counter = 0;
   my @messages;    my @messages;
   # Skip the posts in this thread until we reach $start.    # Skip the posts in this thread until we reach $start.
   if (!$ttsreverse) {    if (!$ttsreverse) {
       foreach (@{$thread_arrayref{$viewnum}}) {        foreach (@{$thread_arrayref{$viewnum}}) {
           if ($counter >= $start and $counter < ($start + $maxmessagedisplay)) { push(@messages, $_); }            if ($counter >= $start and $counter < ($start + $maxmessagedisplay)) { push(@messages, $_); }
           $counter++;            $counter++;
       }        }
       $counter = $start;        $counter = $start;
   
   } else {    } else {
       foreach (@{$thread_arrayref{$viewnum}}) {        foreach (@{$thread_arrayref{$viewnum}}) {
           if ($counter > ($mreplies - $start - $maxmessagedisplay) and $counter <= ($mreplies - $start)) { push(@messages, $_); }            if ($counter > ($mreplies - $start - $maxmessagedisplay) and $counter <= ($mreplies - $start)) { push(@messages, $_); }
           $counter++;            $counter++;
       }        }
       $counter = $mreplies - $start;        $counter = $mreplies - $start;
       @messages = reverse(@messages);        @messages = reverse(@messages);
   }    }
   
   # For each post in this thread:    # For each post in this thread:
   my (%attach_gif,%attach_count,$movedflag);    my (%attach_gif,%attach_count,$movedflag);
   foreach (@messages) {    foreach (@messages) {
       my ($userlocation, $aimad, $yimad, $msnad, $gtalkad, $skypead, $myspacead, $facebookad, $icqad, $buddyad, $addbuddy, $isbuddy, $addbuddylink, $userOnline, $signature_hr, $lastmodified, $memberinfo, $template_postinfo, $template_ext_prof, $template_profile, $template_quote, $template_email, $template_www, $template_pm);        my ($userlocation, $aimad, $yimad, $msnad, $gtalkad, $skypead, $myspacead, $facebookad, $icqad, $buddyad, $addbuddy, $isbuddy, $addbuddylink, $userOnline, $signature_hr, $lastmodified, $memberinfo, $template_postinfo, $template_ext_prof, $template_profile, $template_quote, $template_email, $template_www, $template_pm);
   
       $css = $cssvalues[($counter % $cssnum)];        $css = $cssvalues[($counter % $cssnum)];
       ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $postmessage, $ns, $mlm, $mlmb, $mfn) = split(/[\|]/, $_);        ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $postmessage, $ns, $mlm, $mlmb, $mfn) = split(/[\|]/, $_);
   
       # If the user isn't a guest, load their info.        # If the user isn't a guest, load their info.
       if ($musername ne 'Guest' && !$yyUDLoaded{$musername} && -e ("$memberdir/$musername.vars")) {        if ($musername ne 'Guest' && !$yyUDLoaded{$musername} && -e ("$memberdir/$musername.vars")) {
           my $tmpns = $ns;            my $tmpns = $ns;
           $ns = "";            $ns = "";
           &LoadUserDisplay($musername);            &LoadUserDisplay($musername);
           $ns = $tmpns;            $ns = $tmpns;
       }        }
       $messagedate = $mdate;        $messagedate = $mdate;
       if (${$uid.$musername}{'regtime'}) {        if (${$uid.$musername}{'regtime'}) {
           $registrationdate = ${$uid.$musername}{'regtime'};            $registrationdate = ${$uid.$musername}{'regtime'};
       } else {        } else {
           $registrationdate = $date;            $registrationdate = $date;
       }        }
   
       # Do we have an attachment file?        # Do we have an attachment file?
       chomp $mfn;        chomp $mfn;
       $attachment = '';        $attachment = '';
       $showattach = '';        $showattach = '';
       $showattachhr = '';        $showattachhr = '';
       if ($mfn ne '') {        if ($mfn ne '') {
           # store all downloadcounts in variable            # store all downloadcounts in variable
           if (!%attach_count) {            if (!%attach_count) {
               my ($atfile,$atcount);                my ($atfile,$atcount);
               fopen(ATM, "$vardir/attachments.txt");                fopen(ATM, "$vardir/attachments.txt");
               while (<ATM>) {                while (<ATM>) {
                   (undef, undef, undef, undef, undef, undef, undef, $atfile, $atcount) =split(/\|/, $_);                    (undef, undef, undef, undef, undef, undef, undef, $atfile, $atcount) =split(/\|/, $_);
                   $attach_count{$atfile} = $atcount;                    $attach_count{$atfile} = $atcount;
               }                }
               fclose(ATM);                fclose(ATM);
               $attach_count{'no_attachments'} = 1 if !%attach_count;                $attach_count{'no_attachments'} = 1 if !%attach_count;
           }            }
   
           foreach (split(/,/, $mfn)) {            foreach (split(/,/, $mfn)) {
               $_ =~ /\.(.+?)$/;                $_ =~ /\.(.+?)$/;
               my $ext = lc($1);                my $ext = lc($1);
               unless (exists $attach_gif{$ext}) {                unless (exists $attach_gif{$ext}) {
                   $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif";                    $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif";
               }                }
               my $filesize = -s "$uploaddir/$_";                my $filesize = -s "$uploaddir/$_";
               $urlname = $_;                $urlname = $_;
               $urlname =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;                $urlname =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
               if ($filesize) {                if ($filesize) {
                   if ($_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/i && $amdisplaypics == 1) {                    if ($_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/i && $amdisplaypics == 1) {
                       $showattach .= qq~<div class="small" style="float:left; margin:8px;"><a href="$scripturl?action=downloadfile;file=$urlname" target="_blank"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> $_</a> (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )<br />~ . ($img_greybox ? ($img_greybox == 2 ? qq~<a href="$scripturl?action=downloadfile;file=$urlname" rel="gb_imageset[nice_pics]" title="$_">~ : qq~<a href="$scripturl?action=downloadfile;file=$urlname" rel="gb_image[nice_pics]" title="$_">~) : qq~<a href="$scripturl?action=downloadfile;file=$urlname" target="_blank">~) . qq~<img src="$uploadurl/$_" name="attach_img_resize" alt="$_" title="$_" border="0" style="display:none" /></a></div>\n~;                        $showattach .= qq~<div class="small" style="float:left; margin:8px;"><a href="$scripturl?action=downloadfile;file=$urlname" target="_blank"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> $_</a> (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )<br />~ . ($img_greybox ? ($img_greybox == 2 ? qq~<a href="$scripturl?action=downloadfile;file=$urlname" rel="gb_imageset[nice_pics]" title="$_">~ : qq~<a href="$scripturl?action=downloadfile;file=$urlname" rel="gb_image[nice_pics]" title="$_">~) : qq~<a href="$scripturl?action=downloadfile;file=$urlname" target="_blank">~) . qq~<img src="$uploadurl/$_" name="attach_img_resize" alt="$_" title="$_" border="0" style="display:none" /></a></div>\n~;
                   } else {                    } else {
                       $attachment .= qq~<div class="small"><a href="$scripturl?action=downloadfile;file=$urlname"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> $_</a> (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )</div>~;                        $attachment .= qq~<div class="small"><a href="$scripturl?action=downloadfile;file=$urlname"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" /> $_</a> (~ . int($filesize / 1024) . qq~ KB | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> )</div>~;
                   }                    }
               } else {                } else {
                   $attachment .= qq~<div class="small"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" />  $_ ($fatxt{'1'}~ . (exists $attach_count{$_} ? qq~ | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> ~ : '') . qq~)</div>~;                    $attachment .= qq~<div class="small"><img src="$imagesdir/$attach_gif{$ext}" border="0" align="bottom" alt="" />  $_ ($fatxt{'1'}~ . (exists $attach_count{$_} ? qq~ | <acronym title='$attach_count{$_} $fatxt{'41a'}' class="small">$attach_count{$_}</acronym> ~ : '') . qq~)</div>~;
               }                }
           }            }
           $showattachhr = qq~<hr width="100%" size="1" class="hr" style="margin: 0; margin-top: 5px; margin-bottom: 5px; padding: 0;" />~;            $showattachhr = qq~<hr width="100%" size="1" class="hr" style="margin: 0; margin-top: 5px; margin-bottom: 5px; padding: 0;" />~;
           if ($showattach && $attachment) {            if ($showattach && $attachment) {
               $attachment =~ s/<div class="small">/<div class="small" style="margin:8px;">/g;                $attachment =~ s/<div class="small">/<div class="small" style="margin:8px;">/g;
           }            }
       }        }
   
       # Should we show "last modified by?"        # Should we show "last modified by?"
       if ($showmodify && $mlm ne '' && $mlmb ne '' && (!$tllastmodflag || ($mdate + ($tllastmodtime * 60)) < $mlm)) {        if ($showmodify && $mlm ne '' && $mlmb ne '' && (!$tllastmodflag || ($mdate + ($tllastmodtime * 60)) < $mlm)) {
           &LoadUser($mlmb);            &LoadUser($mlmb);
           $mlmb = ${$uid.$mlmb}{'realname'} || $display_txt{'470'};            $mlmb = ${$uid.$mlmb}{'realname'} || $display_txt{'470'};
           $lastmodified = qq~&#171; <i>$display_txt{'211'}: ~ . &timeformat($mlm) . qq~ $display_txt{'525'} $mlmb</i> &#187;~;            $lastmodified = qq~&#171; <i>$display_txt{'211'}: ~ . &timeformat($mlm) . qq~ $display_txt{'525'} $mlmb</i> &#187;~;
       }        }
   
       $messdate = &timeformat($mdate);        $messdate = &timeformat($mdate);
       if ($iamadmin || $iamgmod && $gmod_access2{'ipban2'} eq "on") { $mip = $mip }        if ($iamadmin || $iamgmod && $gmod_access2{'ipban2'} eq "on") { $mip = $mip }
       else { $mip = $display_txt{'511'}; }        else { $mip = $display_txt{'511'}; }
   
       ## moderator alert button!        ## moderator alert button!
       if ($PMenableAlertButton && $PM_level && !$iamadmin && !$iamgmod && !$iammod && (!$iamguest || ($iamguest && $PMAlertButtonGuests))) {        if ($PMenableAlertButton && $PM_level && !$iamadmin && !$iamgmod && !$iammod && (!$iamguest || ($iamguest && $PMAlertButtonGuests))) {
           $PMAlertButton = qq~$menusep<a href="$scripturl?action=modalert;num=$viewnum;title=PostReply;quote=$counter" onclick="return confirm('$display_txt{'alertmod_confirm'}');">$img{'alertmod'}</a>~;            $PMAlertButton = qq~$menusep<a href="$scripturl?action=modalert;num=$viewnum;title=PostReply;quote=$counter" onclick="return confirm('$display_txt{'alertmod_confirm'}');">$img{'alertmod'}</a>~;
       }        }
       ## is member a buddy of mine?        ## is member a buddy of mine?
       if ($buddyListEnabled && !$iamguest && $musername ne $username) {        if ($buddyListEnabled && !$iamguest && $musername ne $username) {
           $isbuddy = qq~<br /><img src="$imagesdir/buddylist.gif" border="0" align="middle" alt="$display_txt{'isbuddy'}" title="$display_txt{'isbuddy'}" /> <br />$display_txt{'isbuddy'}~;            $isbuddy = qq~<br /><img src="$imagesdir/buddylist.gif" border="0" align="middle" alt="$display_txt{'isbuddy'}" title="$display_txt{'isbuddy'}" /> <br />$display_txt{'isbuddy'}~;
           $addbuddylink = qq~$menusep<a href="$scripturl?num=$viewnum;action=addbuddy;name=$useraccount{$musername};vpost=$counter">$img{'addbuddy'}</a>~;            $addbuddylink = qq~$menusep<a href="$scripturl?num=$viewnum;action=addbuddy;name=$useraccount{$musername};vpost=$counter">$img{'addbuddy'}</a>~;
       }        }
   
       # user is current / admin / gmod        # user is current / admin / gmod
       if ((${$uid.$musername}{'regdate'} && $messagedate > $registrationdate) || ${$uid.$musername}{'position'} eq 'Administrator' || ${$uid.$musername}{'position'} eq 'Global Moderator') {        if ((${$uid.$musername}{'regdate'} && $messagedate > $registrationdate) || ${$uid.$musername}{'position'} eq 'Administrator' || ${$uid.$musername}{'position'} eq 'Global Moderator') {
           if (!$iamguest && $musername ne $username) {            if (!$iamguest && $musername ne $username) {
               ## check whether user is a buddy                ## check whether user is a buddy
               if ($mybuddie{$musername}) { $buddyad = $isbuddy; }                if ($mybuddie{$musername}) { $buddyad = $isbuddy; }
               else { $addbuddy = $addbuddylink; }                else { $addbuddy = $addbuddylink; }
               # Allow instant message sending if current user is a member.                # Allow instant message sending if current user is a member.
               &CheckUserPM_Level($musername);                &CheckUserPM_Level($musername);
               if ($PM_level == 1 || ($PM_level == 2 && $UserPM_Level{$musername} > 1 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && $UserPM_Level{$musername} == 3 && ($iamadmin || $iamgmod))) {                if ($PM_level == 1 || ($PM_level == 2 && $UserPM_Level{$musername} > 1 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && $UserPM_Level{$musername} == 3 && ($iamadmin || $iamgmod))) {
                   $template_pm = qq~$menusep<a href="$scripturl?action=imsend;to=$useraccount{$musername}">$img{'message_sm'}</a>~;                    $template_pm = qq~$menusep<a href="$scripturl?action=imsend;to=$useraccount{$musername}">$img{'message_sm'}</a>~;
               }                }
           }            }
   
           $tmppostcount = &NumberFormat(${$uid.$musername}{'postcount'});            $tmppostcount = &NumberFormat(${$uid.$musername}{'postcount'});
           $template_postinfo = qq~$display_txt{'21'}: $tmppostcount<br />~;            $template_postinfo = qq~$display_txt{'21'}: $tmppostcount<br />~;
           $template_profile = ($profilebutton && !$iamguest) ? qq~$menusep<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}">$img{'viewprofile_sm'}</a>~ : '';            $template_profile = ($profilebutton && !$iamguest) ? qq~$menusep<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}">$img{'viewprofile_sm'}</a>~ : '';
           $template_www = ${$uid.$musername}{'weburl'} ? qq~$menusep${$uid.$musername}{'weburl'}~ : '';            $template_www = ${$uid.$musername}{'weburl'} ? qq~$menusep${$uid.$musername}{'weburl'}~ : '';
   
           $userOnline = &userOnLineStatus($musername) . "<br />";            $userOnline = &userOnLineStatus($musername) . "<br />";
           $displayname = ${$uid.$musername}{'realname'};            $displayname = ${$uid.$musername}{'realname'};
           if (${$uid.$musername}{'location'}) {            if (${$uid.$musername}{'location'}) {
               $userlocation = ${$uid.$musername}{'location'} . "<br />";                $userlocation = ${$uid.$musername}{'location'} . "<br />";
           }            }
           $signature_hr = qq~<hr width="100%" size="1" class="hr" style="margin: 0; margin-top: 5px; margin-bottom: 5px; padding: 0;" />~ if ${$uid.$musername}{'signature'};            $signature_hr = qq~<hr width="100%" size="1" class="hr" style="margin: 0; margin-top: 5px; margin-bottom: 5px; padding: 0;" />~ if ${$uid.$musername}{'signature'};
           $memberinfo = "$memberinfo{$musername}$addmembergroup{$musername}";            $memberinfo = "$memberinfo{$musername}$addmembergroup{$musername}";
   
           $aimad = ${$uid.$musername}{'aim'} ? qq~$menusep${$uid.$musername}{'aim'}~ : '';            $aimad = ${$uid.$musername}{'aim'} ? qq~$menusep${$uid.$musername}{'aim'}~ : '';
           $memailad = ${ $uid . $musername }{'email'} ? qq~$menusep${$uid.$musername}{'email'}~ : q{};            $memailad = ${ $uid . $musername }{'email'} ? qq~$menusep${$uid.$musername}{'email'}~ : q{};
           $icqad = ${$uid.$musername}{'icq'} ? qq~$menusep${$uid.$musername}{'icq'}~ : '';            $icqad = ${$uid.$musername}{'icq'} ? qq~$menusep${$uid.$musername}{'icq'}~ : '';
           $yimad = ${$uid.$musername}{'yim'} ? qq~$menusep${$uid.$musername}{'yim'}~ : '';            $yimad = ${$uid.$musername}{'yim'} ? qq~$menusep${$uid.$musername}{'yim'}~ : '';
           $msnad = ${$uid.$musername}{'msn'} ? qq~$menusep${$uid.$musername}{'msn'}~ : '';            $msnad = ${$uid.$musername}{'msn'} ? qq~$menusep${$uid.$musername}{'msn'}~ : '';
           $gtalkad = ${$uid.$musername}{'gtalk'} ? qq~$menusep${$uid.$musername}{'gtalk'}~ : '';            $gtalkad = ${$uid.$musername}{'gtalk'} ? qq~$menusep${$uid.$musername}{'gtalk'}~ : '';
           $skypead = ${$uid.$musername}{'skype'} ? qq~$menusep${$uid.$musername}{'skype'}~ : '';            $skypead = ${$uid.$musername}{'skype'} ? qq~$menusep${$uid.$musername}{'skype'}~ : '';
           $myspacead = ${$uid.$musername}{'myspace'} ? qq~$menusep${$uid.$musername}{'myspace'}~ : '';            $myspacead = ${$uid.$musername}{'myspace'} ? qq~$menusep${$uid.$musername}{'myspace'}~ : '';
           $facebookad = ${$uid.$musername}{'facebook'} ? qq~$menusep${$uid.$musername}{'facebook'}~ : '';            $facebookad = ${$uid.$musername}{'facebook'} ? qq~$menusep${$uid.$musername}{'facebook'}~ : '';
   
           $usernamelink = &QuickLinks($musername);            $usernamelink = &QuickLinks($musername);
           if ($extendedprofiles) {            if ($extendedprofiles) {
               require "$sourcedir/ExtendedProfiles.pl";                require "$sourcedir/ExtendedProfiles.pl";
               $usernamelink = &ext_viewinposts_popup($musername,$usernamelink);                $usernamelink = &ext_viewinposts_popup($musername,$usernamelink);
           }            }
       } elsif ($musername !~ m~Guest~ && $messagedate < $registrationdate) {        } elsif ($musername !~ m~Guest~ && $messagedate < $registrationdate) {
           $exmem = 1;            $exmem = 1;
           $memberinfo = $display_txt{'470a'};            $memberinfo = $display_txt{'470a'};
           $usernamelink = qq~<b>$mname</b>~;            $usernamelink = qq~<b>$mname</b>~;
           $displayname = $display_txt{'470a'};            $displayname = $display_txt{'470a'};
       } else {        } else {
           require "$sourcedir/Decoder.pl";            require "$sourcedir/Decoder.pl";
           $musername = 'Guest';            $musername = 'Guest';
           $memberinfo = $display_txt{'28'};            $memberinfo = $display_txt{'28'};
           $usernamelink = qq~<b>$mname</b>~;            $usernamelink = qq~<b>$mname</b>~;
           $displayname = $mname;            $displayname = $mname;
           $cryptmail = &scramble($memailad, $musername);            $cryptmail = &scramble($memailad, $musername);
       }        }
       $usernames_life_quote{$useraccount{$musername}} = $displayname; # for display names in Quotes in LivePreview        $usernames_life_quote{$useraccount{$musername}} = $displayname; # for display names in Quotes in LivePreview
   
       # Insert 2        # Insert 2
       if ((!${$uid.$musername}{'hidemail'} || $iamadmin || $allow_hide_email != 1 || $musername eq 'Guest') && !$exmem) {        if ((!${$uid.$musername}{'hidemail'} || $iamadmin || $allow_hide_email != 1 || $musername eq 'Guest') && !$exmem) {
           $template_email = $menusep . &enc_eMail($img{'email_sm'},$memailad,'','');            $template_email = $menusep . &enc_eMail($img{'email_sm'},$memailad,'','');
           if ($iamadmin) { $template_email =~ s~title=\\"$img_txt{'69'}\\"~title=\\"$memailad\\"~; }            if ($iamadmin) { $template_email =~ s~title=\\"$img_txt{'69'}\\"~title=\\"$memailad\\"~; }
       }        }
       if ($iamguest) { $template_email = ''; }        if ($iamguest) { $template_email = ''; }
   
       $counterwords = $counter != 0 ? "$display_txt{'146'} #$counter - " : "";        $counterwords = $counter != 0 ? "$display_txt{'146'} #$counter - " : "";
   
       # Print the post and user info for the poster.        # Print the post and user info for the poster.
       my $outblock = $messageblock;        my $outblock = $messageblock;
       my $posthandelblock = $posthandellist;        my $posthandelblock = $posthandellist;
       my $contactblock = $contactlist;        my $contactblock = $contactlist;
   
       ($msub, undef) = &Split_Splice_Move($msub,0);        ($msub, undef) = &Split_Splice_Move($msub,0);
       $msub ||= $display_txt{'24'};        $msub ||= $display_txt{'24'};
       &ToChars($msub);        &ToChars($msub);
       $msub = &Censor($msub);        $msub = &Censor($msub);
   
       $message = &Censor($postmessage);        $message = &Censor($postmessage);
       &wrap;        &wrap;
       ($message,$movedflag) = &Split_Splice_Move($message,$viewnum);        ($message,$movedflag) = &Split_Splice_Move($message,$viewnum);
       if ($enable_ubbc) {        if ($enable_ubbc) {
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }            if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }
           &DoUBBC;            &DoUBBC;
       }        }
       &wrap2;        &wrap2;
       &ToChars($message);        &ToChars($message);
   
       if ($icanbypass) { $template_modify = qq~$menusep<a href="$scripturl?board=$currentboard;action=modify;message=$counter;thread=$viewnum" onclick="return confirm('$display_txt{'modifyinlocked'}');">$img{'modify'}</a> ~; }        if ($icanbypass) { $template_modify = qq~$menusep<a href="$scripturl?board=$currentboard;action=modify;message=$counter;thread=$viewnum" onclick="return confirm('$display_txt{'modifyinlocked'}');">$img{'modify'}</a> ~; }
   
       if ($mstate !~ /l/i) {        if ($mstate !~ /l/i) {
           if ($replybutton) {            if ($replybutton) {
               my $quote_mname = $displayname;                my $quote_mname = $displayname;
               $quote_mname =~ s/'/\\'/g;                $quote_mname =~ s/'/\\'/g;
               $usernamelink = qq~<a href="javascript:void(AddText('[color=$quoteuser_color]@[/color] [b]$quote_mname\[/b]\\r\\n\\r\\n'))"><img src="$imagesdir/qquname.gif" border="0" alt="$display_txt{'146n'}" title="$display_txt{'146n'}" /></a> $usernamelink~ if $enable_quickreply && $enable_quoteuser && (!$iamguest || $enable_guestposting);                $usernamelink = qq~<a href="javascript:void(AddText('[color=$quoteuser_color]@[/color] [b]$quote_mname\[/b]\\r\\n\\r\\n'))"><img src="$imagesdir/qquname.gif" border="0" alt="$display_txt{'146n'}" title="$display_txt{'146n'}" /></a> $usernamelink~ if $enable_quickreply && $enable_quoteuser && (!$iamguest || $enable_guestposting);
   
               if (!$movedflag || $iamadmin || $iamgmod || $iammod) {                if (!$movedflag || $iamadmin || $iamgmod || $iammod) {
                   if ($enable_quickreply) {                    if ($enable_quickreply) {
                       $quote_mname = $useraccount{$musername};                        $quote_mname = $useraccount{$musername};
                       $quote_mname =~ s/'/\\'/g;                        $quote_mname =~ s/'/\\'/g;
                       if ($enable_markquote) {                        if ($enable_markquote) {
                           $outblock =~ s/(<div)( class="$messageclass" style="float: left; width: 99%; overflow: auto;">)/$1 onmouseup="get_selection($counter);"$2/i;                            $outblock =~ s/(<div)( class="$messageclass" style="float: left; width: 99%; overflow: auto;">)/$1 onmouseup="get_selection($counter);"$2/i;
                           $template_quote = qq~$menusep<a href="javascript:void(quoteSelection('$quote_mname',$viewnum,$counter,$mdate,''))">$img{'mquote'}</a>~;                            $template_quote = qq~$menusep<a href="javascript:void(quoteSelection('$quote_mname',$viewnum,$counter,$mdate,''))">$img{'mquote'}</a>~;
                       } else {                        } else {
                           $template_quote = '';                            $template_quote = '';
                       }                        }
                       if ($enable_quickjump) {                        if ($enable_quickjump) {
                           if (length($postmessage) <= $quick_quotelength) {                            if (length($postmessage) <= $quick_quotelength) {
                               my $quickmessage = $postmessage;                                my $quickmessage = $postmessage;
                               if (!$nestedquotes) {                                if (!$nestedquotes) {
                                   $quickmessage =~ s~(<(br|p).*?>){0,1}\[quote([^\]]*)\](.*?)\[/quote([^\]]*)\](<(br|p).*?>){0,1}~<br />~ig;                                    $quickmessage =~ s~(<(br|p).*?>){0,1}\[quote([^\]]*)\](.*?)\[/quote([^\]]*)\](<(br|p).*?>){0,1}~<br />~ig;
                               }                                }
                               $quickmessage =~ s/<(br|p).*?>/\\r\\n/ig;                                $quickmessage =~ s/<(br|p).*?>/\\r\\n/ig;
                               $quickmessage =~ s/'/\\'/g;                                $quickmessage =~ s/'/\\'/g;
                               $template_quote .= qq~$menusep<a href="javascript:void(quoteSelection('$quote_mname',$viewnum,$counter,$mdate,'$quickmessage'))">$img{'quote'}</a>~;                                $template_quote .= qq~$menusep<a href="javascript:void(quoteSelection('$quote_mname',$viewnum,$counter,$mdate,'$quickmessage'))">$img{'quote'}</a>~;
                           } else {                            } else {
                               $template_quote .= qq~$menusep<a href="javascript:void(quick_quote_confirm('$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;quote=$counter;title=PostReply'))">$img{'quote'}</a>~;                                $template_quote .= qq~$menusep<a href="javascript:void(quick_quote_confirm('$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;quote=$counter;title=PostReply'))">$img{'quote'}</a>~;
                           }                            }
                       } else {                        } else {
                           $template_quote .= qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;quote=$counter;title=PostReply">$img{'quote'}</a>~;                            $template_quote .= qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;quote=$counter;title=PostReply">$img{'quote'}</a>~;
                       }                        }
                   } else {                    } else {
                       $template_quote = qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;quote=$counter;title=PostReply">$img{'quote'}</a>~;                        $template_quote = qq~$menusep<a href="$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;quote=$counter;title=PostReply">$img{'quote'}</a>~;
                   }                    }
               }                }
           }            }
           if ($sessionvalid == 1 && ($iamadmin || $iamgmod || $iammod || ($username eq $musername && !$exmem && (!$tlnomodflag || $date < $mdate + ($tlnomodtime * 3600 * 24))))) {            if ($sessionvalid == 1 && ($iamadmin || $iamgmod || $iammod || ($username eq $musername && (!$tlnomodflag || $date < $mdate + ($tlnomodtime * 3600 * 24))))) {
               $template_modify = qq~$menusep<a href="$scripturl?board=$currentboard;action=modify;message=$counter;thread=$viewnum">$img{'modify'}</a>~;                $template_modify = qq~$menusep<a href="$scripturl?board=$currentboard;action=modify;message=$counter;thread=$viewnum">$img{'modify'}</a>~;
           } else {            } else {
               $template_modify = '';                $template_modify = '';
           }            }
           if ($counter > 0 && ($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {            if ($counter > 0 && ($iamadmin || $iamgmod || $iammod) && $sessionvalid == 1) {
               $template_split = qq~$menusep<a href="$scripturl?action=split_splice;board=$currentboard;thread=$viewnum;oldposts=~ . join(',%20', ($counter .. $mreplies)) . qq~;leave=0;newcat=$curcat;newboard=$currentboard;newthread=new;ss_submit=1" onclick="return confirm('$display_txt{'split_confirm'}');">$img{'admin_split'}</a>~;                $template_split = qq~$menusep<a href="$scripturl?action=split_splice;board=$currentboard;thread=$viewnum;oldposts=~ . join(',%20', ($counter .. $mreplies)) . qq~;leave=0;newcat=$curcat;newboard=$currentboard;newthread=new;ss_submit=1" onclick="return confirm('$display_txt{'split_confirm'}');">$img{'admin_split'}</a>~;
           }            }
           if ($sessionvalid == 1 && ($iamadmin || $iamgmod || $iammod || ($username eq $musername && !$exmem && (!$tlnodelflag || $date < $mdate + ($tlnodeltime * 3600 * 24))))) {            if ($sessionvalid == 1 && ($iamadmin || $iamgmod || $iammod || ($username eq $musername && (!$tlnodelflag || $date < $mdate + ($tlnodeltime * 3600 * 24))))) {
               $template_delete = qq~$menusep<span style="cursor: pointer; cursor: hand;" onclick="if(confirm('$display_txt{'rempost'}')) {uncheckAllBut($counter);}">$img{'delete'}</span>~;                $template_delete = qq~$menusep<span style="cursor: pointer; cursor: hand;" onclick="if(confirm('$display_txt{'rempost'}')) {uncheckAllBut($counter);}">$img{'delete'}</span>~;
               if ((($iammod && $mdmod == 1) || ($iamadmin && $mdadmin == 1) || ($iamgmod && $mdglobal == 1)) && $sessionvalid == 1) {                if ((($iammod && $mdmod == 1) || ($iamadmin && $mdadmin == 1) || ($iamgmod && $mdglobal == 1)) && $sessionvalid == 1) {
                   $template_admin = qq~<input type="checkbox" class="$css" style="border: 0px;" name="del$counter" value="$counter" />~;                    $template_admin = qq~<input type="checkbox" class="$css" style="border: 0px;" name="del$counter" value="$counter" />~;
               } else {                } else {
                   # need to set visibility to hidden - used for regular users to delete their posts too,                    # need to set visibility to hidden - used for regular users to delete their posts too,
                   $template_admin = qq~ <input type="checkbox" class="$css" style="border: 0px; visibility: hidden; display: none;" name="del$counter" value="$counter" />~;                    $template_admin = qq~ <input type="checkbox" class="$css" style="border: 0px; visibility: hidden; display: none;" name="del$counter" value="$counter" />~;
               }                }
           } else {            } else {
               $template_delete = '';                $template_delete = '';
               $template_admin = qq~ <input type="checkbox" class="$css" style="border: 0px; visibility: hidden; display: none;" name="del$counter" value="$counter" />~;                $template_admin = qq~ <input type="checkbox" class="$css" style="border: 0px; visibility: hidden; display: none;" name="del$counter" value="$counter" />~;
           }            }
       }        }
   
       $msgimg = qq~<a href="$scripturl?num=$viewnum/$counter#$counter"><img src="$imagesdir/$micon.gif" alt="" border="0" style="vertical-align: middle;" /></a>~;        $msgimg = qq~<a href="$scripturl?num=$viewnum/$counter#$counter"><img src="$imagesdir/$micon.gif" alt="" border="0" style="vertical-align: middle;" /></a>~;
       $ipimg = qq~<img src="$imagesdir/ip.gif" alt="" border="0" style="vertical-align: middle;" />~;        $ipimg = qq~<img src="$imagesdir/ip.gif" alt="" border="0" style="vertical-align: middle;" />~;
       if ($extendedprofiles) {        if ($extendedprofiles) {
           require "$sourcedir/ExtendedProfiles.pl";            require "$sourcedir/ExtendedProfiles.pl";
           $template_ext_prof = &ext_viewinposts($musername);            $template_ext_prof = &ext_viewinposts($musername);
       }        }
   
       # Jump to the "NEW" Post.        # Jump to the "NEW" Post.
       $usernamelink = qq~<a name="new"></a>$usernamelink~ if $newestpost && $newestpost == $counter;        $usernamelink = qq~<a name="new"></a>$usernamelink~ if $newestpost && $newestpost == $counter;
   
       $posthandelblock =~ s/({|<)yabb quote(}|>)/$template_quote/g;        $posthandelblock =~ s/({|<)yabb quote(}|>)/$template_quote/g;
       $posthandelblock =~ s/({|<)yabb modify(}|>)/$template_modify/g;        $posthandelblock =~ s/({|<)yabb modify(}|>)/$template_modify/g;
       $posthandelblock =~ s/({|<)yabb split(}|>)/$template_split/g;        $posthandelblock =~ s/({|<)yabb split(}|>)/$template_split/g;
       $posthandelblock =~ s/({|<)yabb delete(}|>)/$template_delete/g;        $posthandelblock =~ s/({|<)yabb delete(}|>)/$template_delete/g;
       $posthandelblock =~ s/({|<)yabb admin(}|>)/$template_admin/g;        $posthandelblock =~ s/({|<)yabb admin(}|>)/$template_admin/g;
       $posthandelblock =~ s/({|<)yabb modalert(}|>)/$PMAlertButton/g;        $posthandelblock =~ s/({|<)yabb modalert(}|>)/$PMAlertButton/g;
       $posthandelblock =~ s/\Q$menusep//i;        $posthandelblock =~ s/\Q$menusep//i;
   
       $contactblock =~ s/({|<)yabb email(}|>)/$template_email/g;        $contactblock =~ s/({|<)yabb email(}|>)/$template_email/g;
       $contactblock =~ s/({|<)yabb profile(}|>)/$template_profile/g;        $contactblock =~ s/({|<)yabb profile(}|>)/$template_profile/g;
       $contactblock =~ s/({|<)yabb pm(}|>)/$template_pm/g;        $contactblock =~ s/({|<)yabb pm(}|>)/$template_pm/g;
       $contactblock =~ s/({|<)yabb www(}|>)/$template_www/g;        $contactblock =~ s/({|<)yabb www(}|>)/$template_www/g;
       $contactblock =~ s/({|<)yabb aim(}|>)/$aimad/g;        $contactblock =~ s/({|<)yabb aim(}|>)/$aimad/g;
       $contactblock =~ s/({|<)yabb yim(}|>)/$yimad/g;        $contactblock =~ s/({|<)yabb yim(}|>)/$yimad/g;
       $contactblock =~ s/({|<)yabb icq(}|>)/$icqad/g;        $contactblock =~ s/({|<)yabb icq(}|>)/$icqad/g;
       $contactblock =~ s/({|<)yabb msn(}|>)/$msnad/g;        $contactblock =~ s/({|<)yabb msn(}|>)/$msnad/g;
       $contactblock =~ s/({|<)yabb gtalk(}|>)/$gtalkad/g;        $contactblock =~ s/({|<)yabb gtalk(}|>)/$gtalkad/g;
       $contactblock =~ s/({|<)yabb skype(}|>)/$skypead/g;        $contactblock =~ s/({|<)yabb skype(}|>)/$skypead/g;
       $contactblock =~ s/({|<)yabb myspace(}|>)/$myspacead/g;        $contactblock =~ s/({|<)yabb myspace(}|>)/$myspacead/g;
       $contactblock =~ s/({|<)yabb facebook(}|>)/$facebookad/g;        $contactblock =~ s/({|<)yabb facebook(}|>)/$facebookad/g;
       $contactblock =~ s/({|<)yabb addbuddy(}|>)/$addbuddy/g;        $contactblock =~ s/({|<)yabb addbuddy(}|>)/$addbuddy/g;
       $contactblock =~ s/\Q$menusep//i;        $contactblock =~ s/\Q$menusep//i;
   
       $outblock =~ s/({|<)yabb images(}|>)/$imagesdir/g;        $outblock =~ s/({|<)yabb images(}|>)/$imagesdir/g;
       $outblock =~ s/({|<)yabb messageoptions(}|>)/$msgcontrol/g;        $outblock =~ s/({|<)yabb messageoptions(}|>)/$msgcontrol/g;
       $outblock =~ s/({|<)yabb memberinfo(}|>)/$memberinfo/g;        $outblock =~ s/({|<)yabb memberinfo(}|>)/$memberinfo/g;
       $outblock =~ s/({|<)yabb userlink(}|>)/$usernamelink/g;        $outblock =~ s/({|<)yabb userlink(}|>)/$usernamelink/g;
       $outblock =~ s/({|<)yabb location(}|>)/$userlocation/g;        $outblock =~ s/({|<)yabb location(}|>)/$userlocation/g;
       $outblock =~ s/({|<)yabb stars(}|>)/$memberstar{$musername}/g;        $outblock =~ s/({|<)yabb stars(}|>)/$memberstar{$musername}/g;
       $outblock =~ s/({|<)yabb subject(}|>)/$msub/g;        $outblock =~ s/({|<)yabb subject(}|>)/$msub/g;
       $outblock =~ s/({|<)yabb msgimg(}|>)/$msgimg/g;        $outblock =~ s/({|<)yabb msgimg(}|>)/$msgimg/g;
       $outblock =~ s/({|<)yabb msgdate(}|>)/$messdate/g;        $outblock =~ s/({|<)yabb msgdate(}|>)/$messdate/g;
       $outblock =~ s/({|<)yabb replycount(}|>)/$counterwords/g;        $outblock =~ s/({|<)yabb replycount(}|>)/$counterwords/g;
       $outblock =~ s/({|<)yabb count(}|>)/$counter/g;        $outblock =~ s/({|<)yabb count(}|>)/$counter/g;
       $outblock =~ s/({|<)yabb att(}|>)/$attachment/g;        $outblock =~ s/({|<)yabb att(}|>)/$attachment/g;
       $outblock =~ s/({|<)yabb css(}|>)/$css/g;        $outblock =~ s/({|<)yabb css(}|>)/$css/g;
       $outblock =~ s/({|<)yabb gender(}|>)/${$uid.$musername}{'gender'}/g;        $outblock =~ s/({|<)yabb gender(}|>)/${$uid.$musername}{'gender'}/g;
       $outblock =~ s/({|<)yabb ext_prof(}|>)/$template_ext_prof/g;        $outblock =~ s/({|<)yabb ext_prof(}|>)/$template_ext_prof/g;
       $outblock =~ s/({|<)yabb postinfo(}|>)/$template_postinfo/g;        $outblock =~ s/({|<)yabb postinfo(}|>)/$template_postinfo/g;
       $outblock =~ s/({|<)yabb usertext(}|>)/${$uid.$musername}{'usertext'}/g;        $outblock =~ s/({|<)yabb usertext(}|>)/${$uid.$musername}{'usertext'}/g;
       $outblock =~ s/({|<)yabb userpic(}|>)/${$uid.$musername}{'userpic'}/g;        $outblock =~ s/({|<)yabb userpic(}|>)/${$uid.$musername}{'userpic'}/g;
       $outblock =~ s/({|<)yabb message(}|>)/$message/g;        $outblock =~ s/({|<)yabb message(}|>)/$message/g;
       $outblock =~ s/({|<)yabb showatt(}|>)/$showattach/g;        $outblock =~ s/({|<)yabb showatt(}|>)/$showattach/g;
       $outblock =~ s/({|<)yabb showatthr(}|>)/$showattachhr/g;        $outblock =~ s/({|<)yabb showatthr(}|>)/$showattachhr/g;
       $outblock =~ s/({|<)yabb modified(}|>)/$lastmodified/g;        $outblock =~ s/({|<)yabb modified(}|>)/$lastmodified/g;
       $outblock =~ s/({|<)yabb signature(}|>)/${$uid.$musername}{'signature'}/g;        $outblock =~ s/({|<)yabb signature(}|>)/${$uid.$musername}{'signature'}/g;
       $outblock =~ s/({|<)yabb signaturehr(}|>)/$signature_hr/g;        $outblock =~ s/({|<)yabb signaturehr(}|>)/$signature_hr/g;
       $outblock =~ s/({|<)yabb ipimg(}|>)/$ipimg/g;        $outblock =~ s/({|<)yabb ipimg(}|>)/$ipimg/g;
       $outblock =~ s/({|<)yabb ip(}|>)/$mip/g;        $outblock =~ s/({|<)yabb ip(}|>)/$mip/g;
       $outblock =~ s/({|<)yabb posthandellist(}|>)/$posthandelblock/g;        $outblock =~ s/({|<)yabb posthandellist(}|>)/$posthandelblock/g;
       $outblock =~ s/({|<)yabb contactlist(}|>)/$contactblock/g;        $outblock =~ s/({|<)yabb contactlist(}|>)/$contactblock/g;
       if ($accept_permalink == 1){        if ($accept_permalink == 1){
           $outblock =~ s/({|<)yabb permalink(}|>)/$display_permalink/g;            $outblock =~ s/({|<)yabb permalink(}|>)/$display_permalink/g;
       } else {        } else {
           $outblock =~ s/({|<)yabb permalink(}|>)//g;            $outblock =~ s/({|<)yabb permalink(}|>)//g;
       }        }
       $outblock =~ s/({|<)yabb useronline(}|>)/$userOnline/g;        $outblock =~ s/({|<)yabb useronline(}|>)/$userOnline/g;
       $outblock  =~ s/({|<)yabb isbuddy(}|>)/$buddyad/g;        $outblock  =~ s/({|<)yabb isbuddy(}|>)/$buddyad/g;
   
       $tmpoutblock .= $outblock;        $tmpoutblock .= $outblock;
   
       $counter += !$ttsreverse ? 1 : -1;        $counter += !$ttsreverse ? 1 : -1;
   }    }
   undef %UserPM_Level;    undef %UserPM_Level;
   # Insert 4    # Insert 4
   
   # Insert 5    # Insert 5
   my ($template_remove, $template_splice, $template_lock, $template_hide, $template_sticky, $template_multidelete);    my ($template_remove, $template_splice, $template_lock, $template_hide, $template_sticky, $template_multidelete);
   if (($iammod || $iamadmin || $iamgmod) && $sessionvalid == 1) {    if (($iammod || $iamadmin || $iamgmod) && $sessionvalid == 1) {
       $template_remove = qq~$menusep<a href="javascript:document.removethread.submit();" onclick="return confirm('$display_txt{'162'}')"> $img{'admin_rem'}</a>~;        $template_remove = qq~$menusep<a href="javascript:document.removethread.submit();" onclick="return confirm('$display_txt{'162'}')"> $img{'admin_rem'}</a>~;
   
       $template_splice = qq~$menusep<a href="javascript:void(window.open('$scripturl?action=split_splice;board=$currentboard;thread=$viewnum;oldposts=all;leave=0;newcat=$curcat;newboard=$currentboard;position=end','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))">$img{'admin_move_split_splice'}</a>~;        $template_splice = qq~$menusep<a href="javascript:void(window.open('$scripturl?action=split_splice;board=$currentboard;thread=$viewnum;oldposts=all;leave=0;newcat=$curcat;newboard=$currentboard;position=end','_blank','width=800,height=650,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,top=150,left=150'))">$img{'admin_move_split_splice'}</a>~;
   
       $template_lock = qq~$menusep<a href="$scripturl?action=lock;thread=$viewnum">$img{'admin_lock'}</a>~;        $template_lock = qq~$menusep<a href="$scripturl?action=lock;thread=$viewnum">$img{'admin_lock'}</a>~;
       $template_hide = qq~$menusep<a href="$scripturl?action=hide;thread=$viewnum">$img{'hide'}</a>~;        $template_hide = qq~$menusep<a href="$scripturl?action=hide;thread=$viewnum">$img{'hide'}</a>~;
       $template_sticky = qq~$menusep<a href="$scripturl?action=sticky;thread=$viewnum">$img{'admin_sticky'}</a>~;        $template_sticky