F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\BoardIndex.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\BoardIndex.pm
############################################################################### ###############################################################################
# BoardIndex.pl                                                               # # BoardIndex.pm                                                               #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
  # use strict;
  # use warnings;
  no warnings qw(uninitialized once redefine);
  use CGI::Carp qw(fatalsToBrowser);
  use English '-no_match_vars';
  our $VERSION = '2.6.12';
   
$boardindexplver = 'YaBB 2.5.2 $Revision: 1.0 $'; $boardindexpmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ( $action eq 'detailedversion' ) { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
&LoadLanguage('BoardIndex');  LoadLanguage('BoardIndex'); 
require "$templatesdir/$useboard/BoardIndex.template";  get_micon(); 
   
sub BoardIndex { sub BoardIndex {
   my (    my (
       $users,          $lspostid,   $lspostbd,   $lssub,         $users,   $lspostid,   $lspostbd,   $lssub,      $lsposter, 
       $lsposttime,     $lsposter,   $lsreply,    $lsdatetime,         $lsreply, $lsdatetime, @goodboards, @loadboards, $guestlist 
       $lastthreadtime, @goodboards, @loadboards, $guestlist  
   );    );
   my ( $memcount, $latestmember ) = &MembershipGet;     get_forum_master(); 
     my @brd_img_id = sort ( keys %board);
     my %brd_img_id = ();
     my $brdimgcnt = 0;
     for ( @brd_img_id ) {
         $brd_img_id{$_} = $brdimgcnt;
         $brdimgcnt++;
     }
   
     my ( $memcount, $latestmember ) = MembershipGet();
   chomp $latestmember;    chomp $latestmember;
   $totalm         = 0;    $totalm       = 0;
   $totalt         = 0;    $totalt       = 0;
   $lastposttime   = 0;    $lastposttime = 0;
   $lastthreadtime = 0;    my $lastthreadtime = 0;
   &GetBotlist;  
     if ( $INFO{'boardselect'} ) { $subboard_sel = $INFO{'boardselect'}; }
   
     # if sub board is selected but none exists with that name, show everything
     if ( $subboard_sel && !$subboard{$subboard_sel} ) {
         $subboard_sel = 0;
     }
   
     get_template('BoardIndex');
   
   my ( $numusers, $guests, $numbots, $user_in_log, $guest_in_log ) =    my ( $numusers, $guests, $numbots, $user_in_log, $guest_in_log ) =
     ( 0, 0, 0, 0, 0 );      ( 0, 0, 0, 0, 0 );
   my $lastonline = $date - ( $OnlineLogTime * 60 );     my %bvusers = (); 
   foreach (@logentries) {  
       ( $name, $date1, $last_ip, $last_host ) = split( /\|/, $_ );     # do not do this stuff when we're calling for sub board display 
       if ( !$last_ip ) {    if ( !$subboard_sel ) {
           $last_ip =         GetBotlist(); 
   
         my $lastonline = $date - ( $OnlineLogTime * 60 );
         foreach (@logentries) {
             ( $name, $date1, $last_ip, $last_host, undef, $boardv, undef ) =
               split /\|/xsm, $_, 7;
             if ( !$last_ip ) {
                 $last_ip =
qq~</i></span><span class="error">$boardindex_txt{'no_ip'}</span><span class="small"><i>~; qq~</i></span><span class="error">$boardindex_txt{'no_ip'}</span><span class="small"><i>~;
       }            }
       my $is_a_bot = &Is_Bot($last_host);             my $lookupIP = 
       if ($is_a_bot) {               ( $ipLookup && $last_ip ) 
           $numbots++;               ? qq~<a href="$scripturl?action=iplookup;ip=$last_ip">$last_ip</a>~ 
           $bot_count{$is_a_bot}++;               : qq~$last_ip~; 
       }  
       elsif ($name) {             my $is_a_bot = Is_Bot($last_host); 
           if ( &LoadUser($name) ) {            if ($is_a_bot) {
               if ( $name eq $username ) { $user_in_log = 1; }                 $numbots++; 
               elsif ( ${ $uid . $name }{'lastonline'} < $lastonline ) {                 $bot_count{$is_a_bot}++; 
                   next;             } 
               }             elsif ($name) { 
               if ( $iamadmin || $iamgmod ) {                if ( -e "$memberdir/$name.vars" ) {
                   $numusers++;                     LoadUser( $name, 'vars'); 
                   $users .= &QuickLinks($name);                     if ( $name eq $username ) { $user_in_log = 1; } 
                   $users .= ( ${ $uid . $name }{'stealth'} ? "*" : "" )                     elsif ( ${ $uid . $name }{'lastonline'} < $lastonline ) { 
                     . (                         next; 
                       (                     } 
                                ( $iamadmin && $show_online_ip_admin )                     if ( $iamadmin || $iamgmod || $iamfmod ) { 
                             || ( $iamgmod && $show_online_ip_gmod )                         $numusers++; 
                       ) ? "&nbsp;<i>($last_ip)</i>, " : ", "                         $bvusers{$boardv}++; 
                     );                         $users .= QuickLinks($name); 
                         $users .= ( ${ $uid . $name }{'stealth'} ? q{*} : q{} )
                           . (
                             (
                                      ( $iamadmin && $show_online_ip_admin )
                                   || ( $iamgmod && $show_online_ip_gmod )
                                   || ( $iamfmod && $show_online_ip_fmod )
                             ) ? qq~&nbsp;<i>($lookupIP)</i>, ~ : q{, }
                           );
   
                     }
                     elsif ( !${ $uid . $name }{'stealth'} ) {
                         $numusers++;
                         $users .= QuickLinks($name) . q{, };
                     }
               }                }
               elsif ( !${ $uid . $name }{'stealth'} ) {                else {
                   $numusers++;                     if ( $name eq $user_ip ) { $guest_in_log = 1; } 
                   $users .= &QuickLinks($name) . ", ";                     $guests++; 
                     $bvusers{$boardv}++;
                     if (   ( $iamadmin && $show_online_ip_admin )
                         || ( $iamgmod && $show_online_ip_gmod )
                         || ( $iamfmod && $show_online_ip_fmod ) )
                     {
                         $guestlist .= qq~<i>$lookupIP</i>, ~;
                     }
               }                }
           }            }
           else {         } 
               if ( $name eq $user_ip ) { $guest_in_log = 1; }         if ( !$iamguest && !$user_in_log ) { 
               $guests++;             if ($guests) { $guests--; } 
             $numusers++;
             $bvusers{$boardv}++;
             $users .= QuickLinks($username);
             if ( $iamadmin || $iamgmod || $iamfmod ) {
                 $users .= ${ $uid . $username }{'stealth'} ? q{*} : q{};
               if (   ( $iamadmin && $show_online_ip_admin )                if (   ( $iamadmin && $show_online_ip_admin )
                   || ( $iamgmod && $show_online_ip_gmod ) )                     || ( $iamgmod && $show_online_ip_gmod ) 
                     || ( $iamfmod && $show_online_ip_fmod ) )
               {                {
                   $guestlist .= qq~<i>$last_ip</i>, ~;                     $users .= "&nbsp;<i>($user_ip)</i>"; 
                     $guestlist =~ s/<i>$lookupIP<\/i>, //osm;
               }                }
           }            }
       }        }
   }         elsif ( $iamguest && !$is_a_bot && !$guest_in_log ) { 
   if ( !$iamguest && !$user_in_log ) {             $guests++; 
       $guests-- if $guests;             $bvusers{$boardv}++; 
       $numusers++;         } 
       $users .= &QuickLinks($username);  
       if ( $iamadmin || $iamgmod ) {        if ($numusers) {
           $users .= ${ $uid . $username }{'stealth'} ? "*" : "";             $users =~ s/, \Z//sm; 
           if (   ( $iamadmin && $show_online_ip_admin )             $users .= q~<br />~; 
               || ( $iamgmod && $show_online_ip_gmod ) )         } 
           {         if ($guestlist) {    # build the guest list 
               $users .= "&nbsp;<i>($user_ip)</i>";             $guestlist =~ s/, $//sm; 
               $guestlist =~ s|<i>$last_ip</i>, ||o;             $guestlist = qq~<span class="small">$guestlist</span><br />~; 
         }
         if ($numbots) {      # build the bot list
             foreach ( sort keys %bot_count ) {
                 $botlist .= qq~$_&nbsp;($bot_count{$_}), ~;
           }            }
             $botlist =~ s/, $//sm;
             $botlist = qq~<span class="small">$botlist</span>~;
       }        }
   }  
   elsif ( $iamguest && !$guest_in_log ) {  
       $guests++;  
   }  
   
   if ($numusers) {        if ( !$INFO{'catselect'} ) {
       $users =~ s~, \Z~~;             $yytitle = $boardindex_txt{'18'}; 
       $users .= qq~<br />~;         } 
   }         else { 
   if ($guestlist) {    # build the guest list             ( $tmpcat, $tmpmod, $tmpcol ) = 
       $guestlist =~ s/, $//;               split /\|/xsm, $catinfo{ $INFO{'catselect'} }; 
       $guestlist = qq~<span class="small">$guestlist</span><br />~;             ToChars($tmpcat); 
             $yytitle      = qq~$tmpcat~;
             $yynavigation = qq~&rsaquo; $tmpcat~;
         }
   
         if ( !$iamguest ) { Collapse_Load(); }
   }    }
   if ($numbots) {      # build the bot list  
       foreach ( sort keys(%bot_count) ) {    else {
           $botlist .= qq~$_&nbsp;($bot_count{$_}), ~;         foreach (@logentries) { 
             ( $name, $date1, $last_ip, $last_host, undef, $boardv, undef ) =
               split /\|/xsm, $_, 7;
             if ($name) {
                 if ( -e "$memberdir/$name.vars" ) {
                     LoadUser( $name, 'vars');
                     if ( $iamadmin || $iamgmod || $iamfmod ) {
                         $numusers++;
                         $bvusers{$boardv}++;
                     }
                 }
                 else {
                     if ( $name eq $user_ip ) { $guest_in_log = 1; }
                     $guests++;
                     $bvusers{$boardv}++;
                 }
             }
       }        }
       $botlist =~ s/, $//;  
       $botlist = qq~<span class="small">$botlist</span>~;  
   }    }
   
   if ( !$INFO{'catselect'} ) {     my @tmplist; 
       $yytitle = $boardindex_txt{'18'};     if ($subboard_sel) { 
         push @tmplist, $subboard_sel;
   }    }
   else {    else {
       ( $tmpcat, $tmpmod, $tmpcol ) =         push @tmplist, @categoryorder; 
         split( /\|/, $catinfo{ $INFO{'catselect'} } );  
       &ToChars($tmpcat);  
       $yytitle      = qq~$tmpcat~;  
       $yynavigation = qq~&rsaquo; $tmpcat~;  
   }    }
   
   if ( !$iamguest ) { &Collapse_Load; }  # first get all the boards based on the categories found in forum.master or the provided sub board 
     foreach my $catid (@tmplist) {
   # first get all the boards based on the categories found in forum.master         if (   $INFO{'catselect'} ne $catid 
   foreach $catid (@categoryorder) {             && $INFO{'catselect'} 
       if ( $INFO{'catselect'} ne $catid && $INFO{'catselect'} ) { next; }             && !$subboard_sel ) 
       $boardlist = $cat{$catid};         { 
       (@bdlist) = split( /\,/, $boardlist );             next; 
       my ( $catname, $catperms, $catallowcol ) =         } 
         split( /\|/, $catinfo{"$catid"} );  
   
       # Category Permissions Check  
       my $access = &CatAccess($catperms);  
       if ( !$access ) { next; }  
       $cat_boardcnt{$catid} = 0;  
   
       # next determine all the boards a user has access to         # get boards in category if we're not looking for subboards 
       foreach $curboard (@bdlist) {        if ( !$subboard_sel ) {
             (@bdlist) = split /\,/xsm, $cat{$catid};
             my ( $catname, $catperms, $catallowcol ) =
               split /\|/xsm, $catinfo{$catid};
   
             # Category Permissions Check
             my $access = CatAccess($catperms);
             if ( !$access ) { next; }
             $cat_boardcnt{$catid} = 0;
         }
         else {
             (@bdlist) = split /\|/xsm, $subboard{$catid};
         }
   
           # now fill all the neccesary hashes to show all board index stuff         foreach my $curboard (@bdlist) { 
           if ( !exists $board{$curboard} ) {            if ( !exists $board{$curboard} ) {
               &gostRemove( $catid, $curboard );                gostRemove( $catid, $curboard );
               next;                next;
           }            }
   
# hide the actual global announcement board for all normal users but admins and gmods # hide the actual global announcement board for all normal users but admins and gmods
           if ( $annboard eq $curboard && !$iamadmin && !$iamgmod ) { next; }             if (   $annboard eq $curboard 
                 && !$iamadmin
                 && !$iamgmod
                 && !$iamfmod )
             {
                 next;
             }
           my ( $boardname, $boardperms, $boardview ) =            my ( $boardname, $boardperms, $boardview ) =
             split( /\|/, $board{"$curboard"} );               split /\|/xsm, $board{$curboard}; 
           my $access = &AccessCheck( $curboard, '', $boardperms );            my $access = AccessCheck( $curboard, q{}, $boardperms );
           if ( !$iamadmin && $access ne "granted" && $boardview != 1 ) {            if ( !$iamadmin && $access ne 'granted' && $boardview != 1 ) {
               next;                next;
           }            }
           push( @goodboards, "$catid|$curboard" );  
           push( @loadboards, $curboard );      # Now check subboards that won't be displayed but we need their latest info 
           $cat_boardcnt{$catid}++;             if ( $subboard{$curboard} ) { 
   
          # recursively check access to all sub boards then add them to load list
                 *recursive_boards = sub {
                     foreach my $childbd (@_) {
   
                # now fill all the necessary hashes to show all board index stuff
                         if ( !exists $board{$childbd} ) {
                             gostRemove( $catid, $childbd );
                             next;
                         }
   
  # hide the actual global announcement board for all normal users but admins and gmods
                         if (   $annboard eq $childbd
                             && !$iamadmin
                             && !$iamgmod
                             && !$iamfmod )
                         {
                             next;
                         }
                         ( $boardname, $boardperms, $boardview ) =
                           split /\|/xsm, $board{$childbd};
                         $access = AccessCheck( $childbd, q{}, $boardperms );
                         if (  !$iamadmin
                             && $access ne 'granted' 
                             && $boardview != 1 )
                         {
                             next;
                         }
   
                         # add it to list of boards to load data
                         push @loadboards, $childbd;
   
                         # make recursive call if this board has more children
                         if ( $subboard{$childbd} ) {
                             recursive_boards( split /\|/xsm,
                                 $subboard{$childbd} );
                         }
                     }
                 };
                 recursive_boards( split /\|/xsm, $subboard{$curboard} );
             }
   
             # if it's a sub board don't add to category count
             if ( !${ $uid . $curboard }{'parent'} ) {
                 $cat_boardcnt{$catid}++;
             }
   
             push @goodboards, "$catid|$curboard";
             push @loadboards, $curboard;
       }        }
   }    }
   
   &BoardTotals( "load", @loadboards );    BoardTotals( 'load', @loadboards );
   &getlog;     getlog(); 
   my $dmax = $date - ( $max_log_days_old * 86400 );    my $dmax = $date - ( $max_log_days_old * 86400 );
   
   # showcase poll start  # if loading subboard list by ajax we don't need this (Ajax showcasepoll load does not work, assume this is mistake. DAR) 
   
   my $polltemp;    my $polltemp;
   if ( -e "$datadir/showcase.poll" ) {    if ( -e "$datadir/showcase.poll" ) {
       fopen( SCPOLLFILE, "$datadir/showcase.poll" );        fopen( SCPOLLFILE, "$datadir/showcase.poll" );
       my $scthreadnum = <SCPOLLFILE>;        my $scthreadnum = <SCPOLLFILE>;
       fclose(SCPOLLFILE);        fclose(SCPOLLFILE);
   
       # Look for a valid poll file.        # Look for a valid poll file.
       my $pollthread;        my $pollthread;
       if ( -e "$datadir/$scthreadnum.poll" ) {        if ( -e "$datadir/$scthreadnum.poll" ) {
           &MessageTotals( "load", $scthreadnum );            MessageTotals( 'load', $scthreadnum );
           if ( $iamadmin || $iamgmod ) {            if ( $iamadmin || $iamgmod || $iamfmod ) {
               $pollthread = 1;                $pollthread = 1;
           }            }
           else {            else {
               my $curcat = ${ $uid . ${$scthreadnum}{'board'} }{'cat'};                my $curcat = ${ $uid . ${$scthreadnum}{'board'} }{'cat'};
               my $catperms = ( split /\|/, $catinfo{$curcat} )[1];                my $catperms = ( split /\|/xsm, $catinfo{$curcat} )[1];
               $pollthread = 1 if &CatAccess($catperms);                 if ( CatAccess($catperms) ) { $pollthread = 1; } 
               my $boardperms =                my $boardperms =
                 ( split /\|/, $board{ ${$scthreadnum}{'board'} } )[1];                  ( split /\|/xsm, $board{ ${$scthreadnum}{'board'} } )[1];
               $pollthread =                $pollthread =
                 &AccessCheck( ${$scthreadnum}{'board'}, '', $boardperms ) eq                  AccessCheck( ${$scthreadnum}{'board'}, q{}, $boardperms ) eq
                 'granted' ? $pollthread : 0;                  'granted' ? $pollthread : 0;
           }            }
             if ( ${ $uid . $scboard }{'brdpasswr'} && !$iamadmin && !$iamgmod )
             {
                 my $pswiammod = 0;
                 my $bdmods    = ${ $uid . $curboard }{'mods'};
                 $bdmods =~ s/\, /\,/gsm;
                 $bdmods =~ s/\ /\,/gsm;
                 foreach my $curuser ( split /\,/xsm, $bdmods ) {
                     if ( $username eq $curuser ) { $pswiammod = 1; last; }
                 }
                 my $bdmodgroups = ${ $uid . $scboard }{'modgroups'};
                 $bdmodgroups =~ s/\, /\,/gsm;
                 foreach my $curgroup ( split /\,/xsm, $bdmodgroups ) {
                     if ( ${ $uid . $username }{'position'} eq $curgroup ) {
                         $pswiammod = 1;
                         last;
                     }
                     foreach my $memberaddgroups ( split /\, /xsm,
                         ${ $uid . $username }{'addgroups'} )
                     {
                         chomp $memberaddgroups;
                         if ( $memberaddgroups eq $curgroup ) {
                             $pswiammod = 1;
                             last;
                         }
                     }
                 }
                 my $bpasscookie =
                   "$cookiepassword$scboard$username$cookieother_name";
                 my $crypass = ${ $uid . $scboard }{'brdpassw'};
                 if ( !$pswiammod && $yyCookies{$bpasscookie} ne $crypass ) {
                     $pollthread = 0;
                 }
             }
       }        }
   
       if ($pollthread) {        if ($pollthread) {
           my $tempcurrentboard = $currentboard;            my $tempcurrentboard = $currentboard;
           $currentboard = ${$scthreadnum}{'board'};            $currentboard = ${$scthreadnum}{'board'};
           my $tempmod = $iammod;             my $tempstaff = $staff; 
           $iammod = 0;             if ( !$iamadmin && !$iamgmod && !$iamfmod ) { $staff = 0; } 
           require "$sourcedir/Poll.pl";             require Sources::Poll; 
           &display_poll( $scthreadnum, 1 );            display_poll( $scthreadnum, 1 );
           $iammod = $tempmod;             $staff        = $tempstaff; 
           $polltemp =             $polltemp     = $pollmain . '<br />'; 
qq~<script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>~  
             . $pollmain  
             . '<br />';  
           $currentboard = $tempcurrentboard;            $currentboard = $tempcurrentboard;
       }        }
   }    }
   
   # showcase poll end    # showcase poll end
   
   foreach $curboard (@loadboards) {    foreach my $curboard (@loadboards) {
       chomp $curboard;        chomp $curboard;
       $lastposttime = ${ $uid . $curboard }{'lastposttime'};  
       ${ $uid . $curboard }{'lastposttime'} =  
         ( ${ $uid . $curboard }{'lastposttime'} eq 'N/A'   
             || !${ $uid . $curboard }{'lastposttime'} )  
         ? $boardindex_txt{'470'}  
         : ${ $uid . $curboard }{'lastposttime'};  
       if ( ${ $uid . $curboard }{'lastposttime'} > 0 ) {  
           $lastposttime{$curboard} =  
             &timeformat( ${ $uid . $curboard }{'lastposttime'} );  
       }  
       else { $lastposttime{$curboard} = $boardindex_txt{'470'}; }  
       $lastpostrealtime{$curboard} =  
         ( ${ $uid . $curboard }{'lastposttime'} eq 'N/A'   
             || !${ $uid . $curboard }{'lastposttime'} )  
         ? 0  
         : ${ $uid . $curboard }{'lastposttime'};  
       $lsreply{$curboard} = ${ $uid . $curboard }{'lastreply'} + 1;  
       if ( ${ $uid . $curboard }{'lastposter'} =~ m~\AGuest-(.*)~ ) {  
           ${ $uid . $curboard }{'lastposter'} = $1 . " ($maintxt{'28'})";  
           $lastposterguest{$curboard} = 1;  
       }  
       ${ $uid . $curboard }{'lastposter'} =  
         ${ $uid . $curboard }{'lastposter'} eq 'N/A'   
         || !${ $uid . $curboard }{'lastposter'}  
         ? $boardindex_txt{'470'}  
         : ${ $uid . $curboard }{'lastposter'};  
       ${ $uid . $curboard }{'messagecount'} =  
         ${ $uid . $curboard }{'messagecount'} || 0;  
       ${ $uid . $curboard }{'threadcount'} =  
         ${ $uid . $curboard }{'threadcount'} || 0;  
       $totalm += ${ $uid . $curboard }{'messagecount'};  
       $totalt += ${ $uid . $curboard }{'threadcount'};  
   
       # hide hidden threads for ordinary members and guests         my $iammodhere = q{}; 
       my $iammodhere = '';         foreach my $curuser ( split /, ?/sm, ${ $uid . $curboard }{'mods'} ) { 
       foreach my $curuser ( split( /, ?/, ${ $uid . $curboard }{'mods'} ) ) {  
           if ( $username eq $curuser ) { $iammodhere = 1; }            if ( $username eq $curuser ) { $iammodhere = 1; }
       }        }
       foreach        foreach
         my $curgroup ( split( /, /, ${ $uid . $curboard }{'modgroups'} ) )           my $curgroup ( split /, /sm, ${ $uid . $curboard }{'modgroups'} ) 
       {        {
           if ( ${ $uid . $username }{'position'} eq $curgroup ) {            if ( ${ $uid . $username }{'position'} eq $curgroup ) {
               $iammodhere = 1;                $iammodhere = 1;
           }            }
           foreach ( split( /,/, ${ $uid . $username }{'addgroups'} ) ) {            foreach ( split /,/xsm, ${ $uid . $username }{'addgroups'} ) {
               if ( $_ eq $curgroup ) { $iammodhere = 1; last; }                if ( $_ eq $curgroup ) { $iammodhere = 1; last; }
           }            }
       }        }
   
  # if this is a parent board and it can't be posted in, set lastposttime to 0 so subboards will show latest data
         if ( $subboard{$curboard} && !${ $uid . $curboard }{'canpost'} ) {
             ${ $uid . $curboard }{'lastposttime'} = 0;
         }
   
         $lastposttime = ${ $uid . $curboard }{'lastposttime'};
   
       # hide hidden threads for ordinary members and guests in all loaded boards
       if (   !$iammodhere        if (   !$iammodhere
           && !$iamadmin            && !$iamadmin
           && !$iamgmod            && !$iamgmod
           && ${ $uid . $curboard }{'lasttopicstate'} =~ /h/i )             && !$iamfmod 
             && ${ $uid . $curboard }{'lasttopicstate'} =~ /h/ism )
       {        {
           ${ $uid . $curboard }{'lastpostid'}   = '';             ${ $uid . $curboard }{'lastpostid'}   = q{}; 
           ${ $uid . $curboard }{'lastsubject'}  = '';             ${ $uid . $curboard }{'lastsubject'}  = q{}; 
           ${ $uid . $curboard }{'lastreply'}    = '';             ${ $uid . $curboard }{'lastreply'}    = q{}; 
           ${ $uid . $curboard }{'lastposter'}   = $boardindex_txt{'470'};            ${ $uid . $curboard }{'lastposter'}   = $boardindex_txt{'470'};
           ${ $uid . $curboard }{'lastposttime'} = '';             ${ $uid . $curboard }{'lastposttime'} = q{}; 
           $lastposttime{$curboard} = $boardindex_txt{'470'};            $lastposttime{$curboard} = $boardindex_txt{'470'};
             my ( $messageid, $messagestate );
           fopen( MNUM, "$boardsdir/$curboard.txt" );            fopen( MNUM, "$boardsdir/$curboard.txt" );
           my @threadlist = <MNUM>;            my @threadlist = <MNUM>;
           fclose(MNUM);            fclose(MNUM);
           my ( $messageid, $messagestate );  
   
           foreach (@threadlist) {            foreach (@threadlist) {
               (                (
                   $messageid, undef, undef, undef, undef,                    $messageid, undef, undef, undef, undef,
                   undef,      undef, undef, $messagestate                    undef,      undef, undef, $messagestate
               ) = split( /\|/, $_ );                 ) = split /\|/xsm, $_; 
               if ( $messagestate !~ /h/i ) {                if ( $messagestate !~ /h/ism ) {
                   fopen( FILE, "$datadir/$messageid.txt" ) || next;                    fopen( FILE, "$datadir/$messageid.txt" ) || next;
                   my @lastthreadmessages = <FILE>;                    my @lastthreadmessages = <FILE>;
                   fclose(FILE);                    fclose(FILE);
                   my @lastmessage =                     my @lastmessage = split /\|/xsm, $lastthreadmessages[-1], 6; 
                     split( /\|/, $lastthreadmessages[$#lastthreadmessages],  
                       6 );  
                   ${ $uid . $curboard }{'lastpostid'}  = $messageid;                    ${ $uid . $curboard }{'lastpostid'}  = $messageid;
                   ${ $uid . $curboard }{'lastsubject'} = $lastmessage[0];                    ${ $uid . $curboard }{'lastsubject'} = $lastmessage[0];
                   ${ $uid . $curboard }{'lastreply'}   = $#lastthreadmessages;                    ${ $uid . $curboard }{'lastreply'}   = $#lastthreadmessages;
                   ${ $uid . $curboard }{'lastposter'} =                    ${ $uid . $curboard }{'lastposter'} =
                     $lastmessage[4] eq "Guest"                       $lastmessage[4] eq 'Guest' 
                     ? qq~Guest-$lastmessage[1]~                      ? qq~Guest-$lastmessage[1]~
                     : $lastmessage[4];                      : $lastmessage[4];
                   ${ $uid . $curboard }{'lastposttime'} = $lastmessage[3];                    ${ $uid . $curboard }{'lastposttime'} = $lastmessage[3];
                   $lastposttime{$curboard} = &timeformat( $lastmessage[3] );                    $lastposttime{$curboard} = timeformat( $lastmessage[3] );
                     $lastposttime{$curboard2} = timeformat( $lastmessage[3],0,0,0,1 );
                   last;                    last;
               }                }
           }            }
       }        }
   
         ${ $uid . $curboard }{'lastposttime'} =
           ( ${ $uid . $curboard }{'lastposttime'} eq 'N/A' 
               || !${ $uid . $curboard }{'lastposttime'} )
           ? $boardindex_txt{'470'}
           : ${ $uid . $curboard }{'lastposttime'};
         if (   ${ $uid . $curboard }{'lastposttime'} ne 'N/A' 
             && ${ $uid . $curboard }{'lastposttime'} > 0 )
         {
             $lastposttime{$curboard} =
               timeformat( ${ $uid . $curboard }{'lastposttime'} );
             $lastposttime{$curboard2} =
               timeformat( ${ $uid . $curboard }{'lastposttime'},0,0,0,1 );
         }
         else { $lastposttime{$curboard} = $boardindex_txt{'470'}; }
   
         $lastpostrealtime{$curboard} =
           ( ${ $uid . $curboard }{'lastposttime'} eq 'N/A' 
               || !${ $uid . $curboard }{'lastposttime'} )
           ? 0
           : ${ $uid . $curboard }{'lastposttime'};
   
         $lsreply{$curboard} = ${ $uid . $curboard }{'lastreply'} + 1;
         if ( ${ $uid . $curboard }{'lastposter'} =~ m{\AGuest-(.*)}xsm ) {
             ${ $uid . $curboard }{'lastposter'} = $1 . " ($maintxt{'28'})";
             $lastposterguest{$curboard} = 1;
         }
   
         ${ $uid . $curboard }{'lastposter'} =
           ${ $uid . $curboard }{'lastposter'} eq 'N/A' 
           || !${ $uid . $curboard }{'lastposter'}
           ? $boardindex_txt{'470'}
           : ${ $uid . $curboard }{'lastposter'};
   
         ${ $uid . $curboard }{'messagecount'} =
           ${ $uid . $curboard }{'messagecount'} || 0;
   
         ${ $uid . $curboard }{'threadcount'} =
           ${ $uid . $curboard }{'threadcount'} || 0;
   
         $totalm += ${ $uid . $curboard }{'messagecount'};
         $totalt += ${ $uid . $curboard }{'threadcount'};
   
         if (
               !$iamguest
             && $max_log_days_old
             && $lastpostrealtime{$curboard}
             && (
                 (
                       !$yyuserlog{$curboard}
                     && $lastpostrealtime{$curboard} > $dmax
                 )
                 || (   $yyuserlog{$curboard} > $dmax
                     && $yyuserlog{$curboard} < $lastpostrealtime{$curboard} )
             )
           )
         {
             $new_boards{$curboard} = 1;
         }
   
       # determine the true last post on all the boards a user has access to        # determine the true last post on all the boards a user has access to
       if ( ${ $uid . $curboard }{'lastposttime'} > $lastthreadtime        if ( ${ $uid . $curboard }{'lastposttime'} > $lastthreadtime
           && $lastposttime{$curboard} ne $boardindex_txt{'470'} )            && $lastposttime{$curboard} ne $boardindex_txt{'470'} )
       {        {
           $lsdatetime     = $lastposttime{$curboard};             my $cookiename = "$cookiepassword$curboard$username"; 
           $lsposter       = ${ $uid . $curboard }{'lastposter'};             my $crypass    = ${ $uid . $curboard }{'brdpassw'}; 
           $lssub          = ${ $uid . $curboard }{'lastsubject'};             if ( !${ $uid . $curboard }{'brdpasswr'} ) { 
           $lspostid       = ${ $uid . $curboard }{'lastpostid'};                 $lsdatetime     = $lastposttime{$curboard2}; 
           $lsreply        = ${ $uid . $curboard }{'lastreply'};                 $lsposter       = ${ $uid . $curboard }{'lastposter'}; 
           $lastthreadtime = ${ $uid . $curboard }{'lastposttime'};                 $lssub          = ${ $uid . $curboard }{'lastsubject'}; 
           $lspostbd       = $curboard;                 $lspostid       = ${ $uid . $curboard }{'lastpostid'}; 
                 $lsreply        = ${ $uid . $curboard }{'lastreply'};
                 $lastthreadtime = ${ $uid . $curboard }{'lastposttime'};
                 $lspostbd       = $curboard;
             }
             elsif ( $yyCookies{$cookiename} eq $crypass || $staff ) {
                 $lsdatetime     = $lastposttime{$curboard2};
                 $lsposter       = ${ $uid . $curboard }{'lastposter'};
                 $lssub          = ${ $uid . $curboard }{'lastsubject'};
                 $lspostid       = ${ $uid . $curboard }{'lastpostid'};
                 $lsreply        = ${ $uid . $curboard }{'lastreply'};
                 $lastthreadtime = ${ $uid . $curboard }{'lastposttime'};
                 $lspostbd       = $curboard;
             }
       }        }
   }    }
   
   &LoadCensorList;  # make a copy of new boards has to update the tree if a sub board has a new post, but keep original so we know which individual boards are new 
   foreach $catid (@categoryorder) {     my %new_icon = %new_boards; 
       if ( $INFO{'catselect'} ne $catid && $INFO{'catselect'} ) { next; }  
       my ( $catname, $catperms, $catallowcol, $catimage ) =     # count boards to see if we print anything when we're looking for subboards 
         split( /\|/, $catinfo{"$catid"} );     my $brd_count; 
       &ToChars($catname);     LoadCensorList(); 
     foreach my $catid (@tmplist) {
         if (   $INFO{'catselect'} ne $catid
             && $INFO{'catselect'}
             && !$subboard_sel )
         {
             next;
         }
   
       $cataccess = &CatAccess($catperms);         my ( $catname, $catperms, $catallowcol, $catimage, $catrss ); 
       if ( !$cataccess ) { next; }  
         # get boards in category if we're not looking for subboards
         if ( !$subboard_sel ) {
             (@bdlist) = split /\,/xsm, $cat{$catid};
             ( $catname, $catperms, $catallowcol, $catimage, $catrss ) =
               split /\|/xsm, $catinfo{$catid};
             ToChars($catname);
   
             # Category Permissions Check
             $cataccess = CatAccess($catperms);
             if ( !$cataccess ) { next; }
         }
         else {
             (@bdlist) = split /\|/xsm, $subboard{$catid};
             my ( $boardname, $boardperms, $boardview ) =
               split /\|/xsm, $board{$catid};
             ToChars($boardname);
             ( $catname, $catperms, $catallowcol, $catimage ) =
               ( qq~$boardindex_txt{'65'} '$boardname'~, 0, 0, q{} );
         }
   
       # Skip any empty categories.        # Skip any empty categories.
       if ( $cat_boardcnt{$catid} == 0 ) { next; }        if ( $cat_boardcnt{$catid} == 0 && !$subboard_sel ) { next; }
   
       if ( !$iamguest ) {        if ( !$iamguest ) {
           my $newmsg = 0;            my $newmsg = 0;
           $newms{$catname}       = '';             $newms{$catname}       = q{}; 
           $newrowicon{$catname}  = '';             $newrowicon{$catname}  = q{}; 
           $newrowstart{$catname} = '';             $newrowstart{$catname} = q{}; 
           $newrowend{$catname}   = '';             $newrowend{$catname}   = q{}; 
           $collapse_link         = '';             $collapse_link         = q{}; 
             $mnew                  = q{};
   
           if ($catallowcol) {            if ($catallowcol) {
               $collapse_link =                $collapse_link =
qq~<a href="javascript:SendRequest('$scripturl?action=collapse_cat;cat=$catid','$catid','$imagesdir','$boardindex_exptxt{'2'}','$boardindex_exptxt{'1'}')">~; qq~<a href="javascript:SendRequest('$scripturl?action=collapse_cat;cat=$catid','$catid','$imagesdir','$boardindex_exptxt{'2'}','$boardindex_exptxt{'1'}')">~;
           }            }
   
         # Moved this out of for loop. Gets the latest data for sub boards
# loop through any collapsed boards to find new posts in it and change the image to match # loop through any collapsed boards to find new posts in it and change the image to match
# Now shows this whether minimized or not, for Javascript hiding/showing. (Unilat) # Now shows this whether minimized or not, for Javascript hiding/showing. (Unilat)
           if ( $INFO{'catselect'} eq '' ) {            if ( $INFO{'catselect'} eq q{} ) {
               foreach my $boardinfo (@goodboards) {                foreach my $boardinfo (@goodboards) {
                   my $testcat;                    my $testcat;
                   ( $testcat, $curboard ) = split( /\|/, $boardinfo );                     ( $testcat, $curboard ) = split /\|/xsm, $boardinfo; 
                   if ( $testcat ne $catid ) { next; }                    if ( $testcat ne $catid ) { next; }
                     else { find_latest_data( $curboard, split /\|/xsm,
                         $subboard{$curboard} );
                     }
   
# as we fill the vars based on all boards we need to skip any cat already shown before # as we fill the vars based on all boards we need to skip any cat already shown before
                   if (                     if ( $new_icon{$curboard} ) { 
                         !$iamguest  
                       && $max_log_days_old  
                       && $lastpostrealtime{$curboard}  
                       && (  
                           (  
                                 !$yyuserlog{$curboard}  
                               && $lastpostrealtime{$curboard} > $dmax  
                           )  
                           || (   $yyuserlog{$curboard} > $dmax  
                               && $yyuserlog{$curboard} <  
                               $lastpostrealtime{$curboard} )  
                       )  
                     )  
                   {  
                       my ( undef, $boardperms, $boardview ) =                        my ( undef, $boardperms, $boardview ) =
                         split( /\|/, $board{"$curboard"} );                           split /\|/xsm, $board{$curboard}; 
                       if ( &AccessCheck( $curboard, '', $boardperms ) eq                        if ( AccessCheck( $curboard, q{}, $boardperms ) eq
                           "granted" )                            'granted' )
                       {                        {
                           $newmsg = 1;                            $newmsg = 1;
                       }                        }
                   }                    }
               }                }
   
               if ($catallowcol) {                if ($catallowcol) {
                   $template_catnames .= qq~"$catid",~;                    $template_catnames .= qq~"$catid",~;
                   $newrowend{$catname} = qq~</span></td></tr>~;                     $newrowend{$catname} = $brd_newrowend; 
                   if ( $catcol{$catid} ) {                    if ( $catcol{$catid} ) {
                       $newrowstart{$catname} =                         $my_brdrow = $brd_newrow; 
qq~<tr id="col$catid" style="display:none;"><td colspan="5" class="$new_msg_bg" height="18"><span class="$new_msg_class">~;                         $my_brdrow =~ s/{yabb new_msg_bg}/$new_msg_bg/sm; 
                         $my_brdrow =~ s/{yabb new_msg_class}/$new_msg_class/sm;
                         $newrowstart{$catname} = $my_brdrow;
                       $template_boardtable = qq~id="$catid"~;                        $template_boardtable = qq~id="$catid"~;
                         $template_colboardtable =
                           qq~id="col$catid" style="display:none"~;
                   }                    }
                   else {                    else {
                       $newrowstart{$catname} =                         $my_brdrow = $brd_newrow; 
qq~<tr id="col$catid"><td colspan="5" class="$new_msg_bg" height="18"><span class="$new_msg_class">~;                         $my_brdrow =~ s/{yabb new_msg_bg}/$new_msg_bg/sm; 
                         $my_brdrow =~ s/{yabb new_msg_class}/$new_msg_class/sm;
                         $newrowstart{$catname} = $my_brdrow;
                       $template_boardtable =                        $template_boardtable =
                         qq~id="$catid" style="display:none;"~;                          qq~id="$catid" style="display:none;"~;
                         $template_colboardtable = qq~id="col$catid"~;
                   }                    }
                   if ($newmsg) {                    if ($newmsg) {
                         $mnew = q{new_} . $curboard;
                       $newrowicon{$catname} =                        $newrowicon{$catname} =
qq~<img src="$imagesdir/on.gif" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" border="0" style="margin-left: 4px; margin-right: 6px; vertical-align: middle;" />~; qq~<img src="$imagesdir/$newload{'brd_new'}" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" class="ongif" id="$mnew" />~;
                       $newms{$catname} = $boardindex_exptxt{'5'};                        $newms{$catname} = $boardindex_exptxt{'5'};
                   }                    }
                   else {                    else {
                       $newrowicon{$catname} =                        $newrowicon{$catname} =
qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="margin-left: 4px; margin-right: 6px; vertical-align: middle;" />~; qq~<img src="$imagesdir/$newload{'brd_old'}" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" class="ongif" />~;
                       $newms{$catname} = $boardindex_exptxt{'6'};                        $newms{$catname} = $boardindex_exptxt{'6'};
                   }                    }
                   if ( $catcol{$catid} ) {                    if ( $catcol{$catid} ) {
                       $hash{$catname} =                        $hash{$catname} =
qq~<img src="$imagesdir/cat_collapse.gif" id="img$catid" alt="$boardindex_exptxt{'2'}" title="$boardindex_exptxt{'2'}" border="0" /></a>~; qq~<img src="$imagesdir/$newload{'brd_col'}" id="img$catid" alt="$boardindex_exptxt{'2'}" title="$boardindex_exptxt{'2'}" /></a>~;
                   }                    }
                   else {                    else {
                       $hash{$catname} =                        $hash{$catname} =
qq~ <img src="$imagesdir/cat_expand.gif" id="img$catid" alt="$boardindex_exptxt{'1'}" title="$boardindex_exptxt{'1'}" border="0" /></a>~; qq~<img src="$imagesdir/$newload{'brd_exp'}" id="img$catid" alt="$boardindex_exptxt{'1'}" title="$boardindex_exptxt{'1'}" /></a>~;
                   }                    }
   
               }                }
               else {                else {
                   $template_boardtable = qq~id="$catid"~;                    $template_boardtable = qq~id="$catid"~;
                     $template_colboardtable =
                       qq~id="col$catid" style="display:none;"~;
               }                }
   
           }            }
           else {            else {
               $collapse_link       = '';                 $collapse_link       = q{}; 
               $hash{$catname}      = '';                 $hash{$catname}      = q{}; 
               $template_boardtable = qq~id="$catid"~;                $template_boardtable = qq~id="$catid"~;
                 $template_colboardtable =
                   qq~id="col$catid" style="display:none;"~;
           }            }
   
             if ( $cat{$catid} && !$INFO{'board'} ) { $my_cat = 'catselect'; }
             else                                   { $my_cat = 'boardselect'; }
           $catlink =            $catlink =
qq~$collapse_link $hash{$catname} <a href="$scripturl?catselect=$catid" title="$boardindex_txt{'797'} $catname">$catname</a>~; qq~$collapse_link $hash{$catname} <a href="$scripturl?$my_cat=$catid" title="$boardindex_txt{'797'} $catname">$catname</a>~;
       }        }
       else {        else {
           $template_boardtable = qq~id="$catid"~;             if ( $cat{$catid} && !$INFO{'board'} ) { $my_cat = 'catselect'; } 
           $catlink = qq~<a href="$scripturl?catselect=$catid">$catname</a>~;             else                                   { $my_cat = 'boardselect'; } 
             $template_boardtable    = qq~id="$catid"~;
             $template_colboardtable = qq~id="col$catid" style="display:none;"~;
             $catlink = qq~<a href="$scripturl?$my_cat=$catid">$catname</a>~;
         }
   
         # Don't need the category headers if we're loading ajax subboards
         if ( !$INFO{'a'} ) {
             if ( !$rss_disabled && $catrss ) {
                 $rss_catlink =
  qq~<a href="$scripturl?action=RSSrecent;catselect=$catid" target="_blank"><img src="$micon_bg{'boardrss'}" alt="$maintxt{'rssfeed'} - $catname" title="$maintxt{'rssfeed'} - $catname" /></a>~;
             }
             else {
                 $rss_catlink = q{};
             }
             $templatecat = $catheader;
             $tmpcatimg   = q{};
             $imgid = $brd_img_id{$catid};
             if ( $catimage ne q{} ) {
                 if ( $catimage =~ /\//ism ) {
                     $catimage = qq~<img src="$catimage" alt="" id="brd_id_$imgid" onload="resize_brd_images(this);" />~;
                 }
                 elsif ($catimage) {
                     $catimage = qq~<img src="$imagesdir/$catimage" alt="" id="brd_id_$imgid" onload="resize_brd_images(this);" />~;
                 }
                 $tmpcatimg = qq~$catimage~;
             }
             $templatecat =~ s/{yabb catimage}/$tmpcatimg/gsm;
             $templatecat =~ s/{yabb catrss}/$rss_catlink/gsm;
             $templatecat =~ s/{yabb catlink}/$catlink/gsm;
             $templatecat =~ s/{yabb newmsg start}/$newrowstart{$catname}/gsm;
             $templatecat =~ s/{yabb newmsg icon}/$newrowicon{$catname}/gsm;
             $templatecat =~ s/{yabb newmsg}/$newms{$catname}/gsm;
             $templatecat =~ s/{yabb newmsg end}/$newrowend{$catname}/gsm;
             $templatecat =~ s/{yabb boardtable}/$template_boardtable/gsm;
             $templatecat =~ s/{yabb colboardtable}/$template_colboardtable/gsm;
             $tmptemplateblock .= $templatecat;
       }        }
   
       $templatecat = $catheader;         my $alternateboardcolor = 0; 
       $tmpcatimg   = "";  
       if ( $catimage ne '' ) {  
           if ( $catimage =~ /\//i ) {  
               $catimage =  
qq~<img src="$catimage" alt="" border="0" style="vertical-align: middle;" />~;  
           }  
           elsif ($catimage) {  
               $catimage =  
qq~<img src="$imagesdir/$catimage" alt="" border="0" style="vertical-align: middle;" />~;  
           }  
           $tmpcatimg = qq~$catimage~;  
       }  
       $templatecat =~ s/({|<)yabb catimage(}|>)/$tmpcatimg/g;  
       $templatecat =~ s/({|<)yabb catlink(}|>)/$catlink/g;  
       $templatecat =~ s/({|<)yabb newmsg start(}|>)/$newrowstart{$catname}/g;  
       $templatecat =~ s/({|<)yabb newmsg icon(}|>)/$newrowicon{$catname}/g;  
       $templatecat =~ s/({|<)yabb newmsg(}|>)/$newms{$catname}/g;  
       $templatecat =~ s/({|<)yabb newmsg end(}|>)/$newrowend{$catname}/g;  
       $templatecat =~ s/({|<)yabb boardtable(}|>)/$template_boardtable/g;  
       $tmptemplateblock .= $templatecat;  
   
       ## loop through any non collapsed boards to show the board index  
       ## Also shows whether collapsed or not due to QuickCollapse (Unilat)  
#if (($catcol{$catid} || !$catcol{$catid})|| $INFO{'catselect'} ne '' || $iamguest) {  <= Unilat  
       if (  !$INFO{'oldcollapse'}        if (  !$INFO{'oldcollapse'}
           || $catcol{$catid}            || $catcol{$catid}
           || $INFO{'catselect'} ne ''             || $INFO{'catselect'} ne q{} 
           || $iamguest )            || $iamguest )
       {    # deti        {    # deti
           foreach my $boardinfo (@goodboards) {            foreach my $boardinfo (@goodboards) {
               my $testcat;                my $testcat;
               ( $testcat, $curboard ) = split( /\|/, $boardinfo );                 ( $testcat, $curboard ) = split /\|/xsm, $boardinfo; 
               if ( $testcat ne $catid ) { next; }                if ( $testcat ne $catid ) { next; }
   
# as we fill the vars based on all boards we need to skip any cat already shown before                 $brd_count++; 
   
                 # let's add this to javascript array of good boards.
                 $template_boardnames .= qq~"$curboard",~;
   
  # first off, lets find the most recent post data and total sub board posts/threads
                 if ( $subboard{$curboard} ) {
   
  # if its a parent board that cant be posted in, don't count its threads/posts towards total
                     if ( !${ $uid . $curboard }{'canpost'} ) {
                         ${ $uid . $curboard }{'threadcount'}  = 0;
                         ${ $uid . $curboard }{'messagecount'} = 0;
                     }
   
                     find_latest_data( $curboard, split /\|/xsm,
                         $subboard{$curboard} );
                 }
   
                 ( $boardname, $boardperms, $boardview ) =
                   split /\|/xsm, $board{$curboard};
                 ToChars($boardname);
                 $INFO{'zeropost'} = 0;
                 $zero             = q{};
                 $bdpic = qq~$imagesdir/boards.$bdpicExt~;
                 fopen( BRDPIC, "<$boardsdir/brdpics.db" );
                 my @brdpics = <BRDPIC>;
                 fclose( BRDPIC);
                 chomp @brdpics;
                 for (@brdpics) {
                     my ( $brdnm, $style, $brdpic ) = split /[|]/xsm, $_;
                     if ( $brdnm eq $curboard && $template eq $style ) {
                         if ( $brdpic =~ /\//ism ) {
                             $bdpic = $brdpic;
                             last;
                         }
                         else {
                             if ( -e "$htmldir/Templates/Forum/$useimages/Boards/$brdpic" ) {
                                 $bdpic = qq~$imagesdir/Boards/$brdpic~;
                             }
                             else { $bdpic = qq~$imagesdir/boards.$bdpicExt~; }
                             last;
                         }
                     }
                     else {
                         if ( $boardname =~ m/[ht|f]tp[s]{0,1}:\/\//sm  ) {
                             $bdpic = qq~$imagesdir/$extern~;
                         }
                         else {$bdpic = qq~$imagesdir/boards.$bdpicExt~; }
                     }
                 }
   
               if ( ${ $uid . $curboard }{'ann'} == 1 ) {                if ( ${ $uid . $curboard }{'ann'} == 1 ) {
                   ${ $uid . $curboard }{'pic'} = 'ann.gif';                     $bdpic = qq~$imagesdir/ann.$bdpicExt~; 
               }                }
               if ( ${ $uid . $curboard }{'rbin'} == 1 ) {                if ( ${ $uid . $curboard }{'rbin'} == 1 ) {
                   ${ $uid . $curboard }{'pic'} = 'recycle.gif';                     $bdpic = qq~$imagesdir/recycle.$bdpicExt~; 
               }                }
               ( $boardname, $boardperms, $boardview ) =  
                 split( /\|/, $board{$curboard} );  
               &ToChars($boardname);  
               $INFO{'zeropost'} = 0;  
               $zero             = '';  
               $bdpic            = ${ $uid . $curboard }{'pic'};  
               $bddescr          = ${ $uid . $curboard }{'description'};                $bddescr          = ${ $uid . $curboard }{'description'};
               &ToChars($bddescr);                 ToChars($bddescr); 
               $iammod     = '';                 $iammod     = q{}; 
               %moderators = ();                %moderators = ();
                 my $curmods = ${ $uid . $curboard }{'mods'};
   
               foreach                 foreach my $curuser ( split /, ?/sm, $curmods ) { 
                 my $curuser ( split( /, ?/, ${ $uid . $curboard }{'mods'} ) )  
               {  
                   if ( $username eq $curuser ) { $iammod = 1; }                    if ( $username eq $curuser ) { $iammod = 1; }
                   &LoadUser($curuser);                     LoadUser($curuser); 
                   $moderators{$curuser} = ${ $uid . $curuser }{'realname'};                    $moderators{$curuser} = ${ $uid . $curuser }{'realname'};
               }                }
               $showmods = '';                 $showmods = q{}; 
               if ( keys %moderators == 1 ) {                if ( keys %moderators == 1 ) {
                   $showmods = qq~$boardindex_txt{'298'}: ~;                    $showmods = qq~$boardindex_txt{'298'}: ~;
               }                }
               elsif ( keys %moderators != 0 ) {                elsif ( keys %moderators != 0 ) {
                   $showmods = qq~$boardindex_txt{'63'}: ~;                    $showmods = qq~$boardindex_txt{'63'}: ~;
               }                }
               while ( $tmpa = each(%moderators) ) {                while ( $tmpa = each %moderators ) {
                   &FormatUserName($tmpa);                     FormatUserName($tmpa); 
                   $showmods .= &QuickLinks( $tmpa, 1 ) . ", ";                     $showmods .= QuickLinks( $tmpa, 1 ) . q{, }; 
               }                }
               $showmods =~ s/, \Z//;                 $showmods =~ s/, \Z//sm; 
   
               &LoadUser($username);                 LoadUser($username); 
               %moderatorgroups = ();                %moderatorgroups = ();
               foreach my $curgroup (                 foreach my $curgroup ( split /, /sm, 
                   split( /, /, ${ $uid . $curboard }{'modgroups'} ) )                     ${ $uid . $curboard }{'modgroups'} ) 
               {                {
                   if ( ${ $uid . $username }{'position'} eq $curgroup ) {                    if ( ${ $uid . $username }{'position'} eq $curgroup ) {
                       $iammod = 1;                        $iammod = 1;
                   }                    }
                   foreach ( split( /,/, ${ $uid . $username }{'addgroups'} ) )                     foreach ( split /,/xsm, ${ $uid . $username }{'addgroups'} ) 
                   {                    {
                       if ( $_ eq $curgroup ) { $iammod = 1; last; }                        if ( $_ eq $curgroup ) { $iammod = 1; last; }
                   }                    }
                   ( $thismodgrp, undef ) =                    ( $thismodgrp, undef ) =
                     split( /\|/, $NoPost{$curgroup}, 2 );                       split /\|/xsm, $NoPost{$curgroup}, 2; 
                   $moderatorgroups{$curgroup} = $thismodgrp;                    $moderatorgroups{$curgroup} = $thismodgrp;
               }                }
   
               $showmodgroups = '';                 $showmodgroups = q{}; 
               if ( scalar keys %moderatorgroups == 1 ) {                if ( scalar keys %moderatorgroups == 1 ) {
                   $showmodgroups = qq~$boardindex_txt{'298a'}: ~;                    $showmodgroups = qq~$boardindex_txt{'298a'}: ~;
               }                }
               elsif ( scalar keys %moderatorgroups != 0 ) {                elsif ( scalar keys %moderatorgroups != 0 ) {
                   $showmodgroups = qq~$boardindex_txt{'63a'}: ~;                    $showmodgroups = qq~$boardindex_txt{'63a'}: ~;
               }                }
               while ( $tmpa = each(%moderatorgroups) ) {                while ( $tmpa = each %moderatorgroups ) {
                   $showmodgroups .= qq~$moderatorgroups{$tmpa}, ~;                    $showmodgroups .= qq~$moderatorgroups{$tmpa}, ~;
               }                }
               $showmodgroups =~ s/, \Z//;                 $showmodgroups =~ s/, \Z//sm; 
               if ( $showmodgroups eq "" && $showmods eq "" ) {                if ( $showmodgroups eq q{} && $showmods eq q{} ) {
                   $showmodgroups = qq~<br />~;                    $showmodgroups = q~<br />~;
               }                }
               if ( $showmodgroups ne "" && $showmods ne "" ) {                if ( $showmodgroups ne q{} && $showmods ne q{} ) {
                   $showmods .= qq~<br />~;                    $showmods .= q~<br />~;
               }                }
   
               if ($iamguest) {                if ($iamguest) {
                   $new = '';                     $new  = q{}; 
                     $new2 = q{};
               }                }
               elsif (                 elsif ( $new_icon{$curboard} ) { 
                      $max_log_days_old  
                   && $lastpostrealtime{$curboard}  
                   && (  
                       (  
                             !$yyuserlog{$curboard}  
                           && $lastpostrealtime{$curboard} > $dmax  
                       )  
                       || (   $yyuserlog{$curboard} > $dmax  
                           && $yyuserlog{$curboard} <  
                           $lastpostrealtime{$curboard} )  
                   )  
                 )  
               {  
                   my ( undef, $boardperms, $boardview ) =                    my ( undef, $boardperms, $boardview ) =
                     split( /\|/, $board{"$curboard"} );                       split /\|/xsm, $board{$curboard}; 
                   if ( &AccessCheck( $curboard, '', $boardperms ) eq                    if ( AccessCheck( $curboard, q{}, $boardperms ) eq
                       "granted" )                        'granted' )
                   {                    {
                         $mnew = q{new_} . $curboard;
                       $new =                        $new =
qq~<img src="$imagesdir/on.gif" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" border="0" style="vertical-align: middle;" />~; qq~<img src="$imagesdir/$newload{'brd_new'}" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" class="img_new" id="$mnew" />~;
                         $new2 =
  qq~<img src="$imagesdir/$newload{'sub_brd_new'}" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" class="img_new" id="$mnew" />~;
   
                   }                    }
                   else {                    else {
                       $new =                        $new =
qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="vertical-align: middle;" />~; qq~<img src="$imagesdir/$newload{'brd_old'}" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" class="img_new" />~;
                   }                    }
   
               }                }
               else {                else {
                   $new =                    $new =
qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="vertical-align: middle;" />~; qq~<img src="$imagesdir/$newload{'brd_old'}" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" />~;
               }                }
               if ( !$bdpic ) { $bdpic = 'boards.gif'; }  
   
               $lastposter = ${ $uid . $curboard }{'lastposter'};                $lastposter = ${ $uid . $curboard }{'lastposter'};
               $lastposter =~ s~\AGuest-(.*)~$1 ($maintxt{'28'})~i;                 $lastposter =~ s/\AGuest-(.*)/$1 ($maintxt{'28'})/ism; 
   
               unless ( $lastposterguest{$curboard}                 if ( !$lastposterguest{$curboard} 
                   || ${ $uid . $curboard }{'lastposter'} eq                     && ${ $uid . $curboard }{'lastposter'} ne 
                   $boardindex_txt{'470'} )                    $boardindex_txt{'470'} )
               {                {
                   &LoadUser($lastposter);                     LoadUser($lastposter); 
                   if (                    if (
                       (                        (
                              ${ $uid . $lastposter }{'regdate'}                               ${ $uid . $lastposter }{'regdate'}
                           && ${ $uid . $curboard }{'lastposttime'} >                            && ${ $uid . $curboard }{'lastposttime'} >
                           ${ $uid . $lastposter }{'regtime'}                            ${ $uid . $lastposter }{'regtime'}
                       )                        )
                       || ${ $uid . $lastposter }{'position'} eq                        || ${ $uid . $lastposter }{'position'} eq
                       "Administrator"                         'Administrator' 
                       || ${ $uid . $lastposter }{'position'} eq                        || ${ $uid . $lastposter }{'position'} eq
                       "Global Moderator"                         'Global Moderator' 
                     )                      )
                   {                    {
                       $lastposter =                         if ( $iamguest ) { 
qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$lastposter}">${$uid.$lastposter}{'realname'}</a>~;                             $lastposter = qq~$format_unbold{$lastposter}~; 
                         }
                         else {
                             $lastposter =
  qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$lastposter}" rel="nofollow">$format_unbold{$lastposter}</a>~;
                         }
                   }                    }
                   else {                    else {
   
           # Need to load thread to see lastposters DISPLAYname if is Ex-Member            # Need to load thread to see lastposters DISPLAYname if is Ex-Member
                       fopen( EXMEMBERTHREAD,                        fopen( EXMEMBERTHREAD,
                           "$datadir/${$uid.$curboard}{'lastpostid'}.txt" )                            "$datadir/${$uid.$curboard}{'lastpostid'}.txt" )
                         || &fatal_error( 'cannot_open',                          or fatal_error( 'cannot_open',
                           "$datadir/${$uid.$curboard}{'lastpostid'}.txt", 1 );                            "$datadir/${$uid.$curboard}{'lastpostid'}.txt", 1 );
                       my @x = <EXMEMBERTHREAD>;                        my @x = <EXMEMBERTHREAD>;
                       fclose(EXMEMBERTHREAD);                        fclose(EXMEMBERTHREAD);
                       $lastposter =                         @lstp = split /\|/xsm, $x[-1]; 
                         ( split( /\|/, $x[$#x], 3 ) )[1]                         if ( $lstp[4] eq 'Guest') { 
                         . " - $boardindex_txt{'470a'}";                             $lastposter = qq~$lstp[1] ($maintxt{'28'})~; 
                   }                        }
               }                        else { $lastposter = qq~$lstp[1] - $boardindex_txt{'470a'}~; }
               ${ $uid . $curboard }{'lastposter'} ||= $boardindex_txt{'470'};                     } 
               ${ $uid . $curboard }{'lastposttime'} ||=  
                 $boardindex_txt{'470'};  
   
               if ( $bdpic =~ /\//i ) {  
                   $bdpic =  
qq~ <img src="$bdpic" alt="$boardname" title="$boardname" border="0" align="middle" /> ~;  
               }  
               elsif ($bdpic) {  
                   $bdpic =  
qq~ <img src="$imagesdir/$bdpic" alt="$boardname" title="$boardname" border="0" /> ~;  
               }                }
                 ${ $uid . $curboard }{'lastposter'} = isempty( ${ $uid . $curboard }{'lastposter'}, $boardindex_txt{'470'} );
                 ${ $uid . $curboard }{'lastposttime'} = isempty( ${ $uid . $curboard }{'lastposttime'}, $boardindex_txt{'470'} );
   
               my $templateblock = $boardblock;                my $templateblock = $boardblock;
   
                 # if we can't post in this parent board, change the layout
                 if ( $subboard{$curboard} && !${ $uid . $curboard }{'canpost'} )
                 {
                     $templateblock = $nopost_boardblock;
                 }
   
               my $lasttopictxt = ${ $uid . $curboard }{'lastsubject'};                my $lasttopictxt = ${ $uid . $curboard }{'lastsubject'};
               ( $lasttopictxt, undef ) =                ( $lasttopictxt, undef ) =
                 &Split_Splice_Move( $lasttopictxt, 0 );                  Split_Splice_Move( $lasttopictxt, 0 );
               my $fulltopictext = $lasttopictxt;                my $fulltopictext = $lasttopictxt;
   
               $convertstr = $lasttopictxt;                $convertstr = $lasttopictxt;
               $convertcut = $topiccut ? $topiccut : 15;                $convertcut = $topiccut ? $topiccut : 15;
               &CountChars;                 CountChars(); 
               $lasttopictxt = $convertstr;                $lasttopictxt = $convertstr;
               if ($cliped) { $lasttopictxt .= "..."; }                if ($cliped) { $lasttopictxt .= q{...}; }
   
               &ToChars($lasttopictxt);                 ToChars($lasttopictxt); 
               $lasttopictxt = &Censor($lasttopictxt);                 $lasttopictxt = Censor($lasttopictxt); 
   
               &ToChars($fulltopictext);                 ToChars($fulltopictext); 
               $fulltopictext = &Censor($fulltopictext);                 $fulltopictext = Censor($fulltopictext); 
   
               if ( ${ $uid . $curboard }{'lastreply'} ne "" ) {                if ( ${ $uid . $curboard }{'lastreply'} ne q{} ) {
                   $lastpostlink =                    $lastpostlink =
qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}">$img{'lastpost'}</a> $lastposttime{$curboard}~; qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}" title="$boardindex_txt{'22'}">$img{'lastpost'}</a> $lastposttime{$curboard}~;
               }                }
               else {                else {
                   $lastpostlink = qq~$img{'lastpost'} $boardindex_txt{'470'}~;                    $lastpostlink = qq~$img{'lastpost'} $boardindex_txt{'470'}~;
               }                }
   
                 if ( !$rss_disabled ) {
                     my ( undef, $boardperms, $boardview ) = split /\|/xsm,
                       $board{"$curboard"};
                     if ( AccessCheck( $curboard, q{}, $boardperms ) eq 'granted' 
                         && ${ $uid . $curboard }{'brdrss'} == 1 )
                     {
                         $rss_boardlink =
  qq~<a href="$scripturl?action=RSSboard;board=$curboard" target="_blank"><img src="$micon_bg{'boardrss'}" alt="$maintxt{'rssfeed'} - $boardname" title="$maintxt{'rssfeed'} - $boardname" /></a>~;
                     }
                     else {
                         $rss_boardlink = q{};
                     }
                 }
   
     # if we have subboards, check to see if there's something new and print name
                 my $template_subboards;
                 my $tmp_sublist = q{};
                 my $sub_count;
                 if ( $subboard{$curboard} ) {
                     my @childboards = split /\|/xsm, $subboard{$curboard};
                     $tmp_sublist = $subboard_list;
                     foreach my $childbd (@childboards) {
                         my $tmp_sublinks = $subboard_links_ext;
                         my ( $chldboardname, $chldboardperms, $chldboardview ) =
                           split /\|/xsm, $board{$childbd};
                         my $access =
                           AccessCheck( $childbd, q{}, $chldboardperms );
                         if (  !$iamadmin
                             && $access ne 'granted' 
                             && $chldboardview != 1 )
                         {
                             next;
                         }
                         ToChars($chldboardname);
                         $sub_count++;
   
                         $cookiename = "$cookiepassword$childbd$username";
                         $crypass    = ${ $uid . $childbd }{'brdpassw'};
                         $sub_lock   = q{};
                         if ($crypass) {
                             if ( $staff || $yyCookies{$cookiename} eq $crypass )
                             {
                                 $sub_lock = qq~ $micon{'lockopen_sub'}~;
                             }
                             else {
                                 $sub_lock = qq~ $micon{'lockimg_sub'}~;
                             }
                         }
   
                         # get new icon
                         if ($iamguest) {
                             $sub_new = q{};
                         }
                         elsif ( $new_icon{$childbd} ) {
                             $mnew = q{new_} . $childbd . q{_sub};
                             $sub_new =
  qq~<img src="$imagesdir/$newload{'sub_brd_new'}" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" id="$mnew" />~;
                         }
                         else {
                             $sub_new =
  qq~<img src="$imagesdir/$newload{'sub_brd_old'}" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" />~;
                         }
   
                         my $boardinfotxt =
                             $new_boards{$childbd}
                           ? $boardindex_txt{'67'}
                           : $boardindex_txt{'68'};
                         if ( $subboard{$childbd} ) {
                             if ( $childcnt{$childbd} > 1 ) {
                                 $boardinfotxt .=
  qq~ $sub_new_cnt{$childbd} $boardindex_txt{'69'} $childcnt{$childbd} $boardindex_txt{'70'}~;
                             }
                             else {
                                 if ( $sub_new_cnt{$childbd} ) {
                                     $boardinfotxt .=
  qq~ $childcnt{$childbd} $boardindex_txt{'71'}~;
                                 }
                                 else {
                                     $boardinfotxt .=
  qq~ $childcnt{$childbd} $boardindex_txt{'72'}~;
                                 }
                             }
                         }
   
                         if ( $chldboardname =~ m/[ht|f]tp[s]{0,1}:\/\//sm ) {
                             $tmp_sublinks = $subboard_links_ext;
                             $bdd          = q{};
                             $my_bddescr   = ${ $uid . $childbd }{'description'};
                             my @bname = split /<br \/>/sm, $my_bddescr;
                             ToChars($bname[0]);
                             $boardname = qq~$scripturl\?action\=showexternal;exboard\=$childbd~;
                             $tmp_sublinks =~ s/{yabb boardurl}/$boardname/gsm;
                             $tmp_sublinks =~ s/{yabb new}/$new/gsm;
                             $tmp_sublinks =~ s/{yabb boardname}/$bname[0]/gsm;
                             $tmp_sublinks =~ s/{yabb sub_lock}/$sub_lock/gsm;
                         }
                         else {
                             $tmp_sublinks = $subboard_links;
                             $tmp_sublinks =~ s/{yabb boardname}/$chldboardname/gsm;
                             $tmp_sublinks =~ s/{yabb boardurl}/$scripturl\?board\=$childbd/gsm;
                             $tmp_sublinks =~ s/{yabb new}/$sub_new/gsm;
                             $tmp_sublinks =~ s/{yabb sub_lock}/$sub_lock/gsm;
                             $tmp_sublinks =~ s/{yabb boardinfo}/$boardinfotxt/gsm;
                         }
                         $template_subboards .= qq~$tmp_sublinks, ~;
                     }
                     $template_subboards =~ s/, $//gsm;
   
                     my $sub_txt = $boardindex_txt{'64'};
   
                     if ( $sub_count == 1 ) { $sub_txt = $boardindex_txt{'66'}; }
                     elsif ( $sub_count == 0 ) {
                         $sub_txt     = q{};
                         $tmp_sublist = q{};
                     }
   
  # drop down arrow for expanding sub boards
  # only do this if 1 or more sub boards and if this is an ajax call we do not want infinite levels of subboards
                     my $subdropdown;
                     if ( $sub_count > 0 ) {
   
                      # do not make an ajax dropdown if we are calling from ajax.
                         if ( $INFO{'a'} ) {
                             $subdropdown = qq~$sub_txt~;
                         }
                         else {
                             $subdropdown =
  qq~<a href="javascript:void(0)" id="subdropa_$curboard" style="font-weight:bold" onclick="SubBoardList('$scripturl?board=$curboard','$curboard','$catid',$sub_count,$alternateboardcolor)"><img src="$imagesdir/$sub_arrow_dn" id="subdropbutton_$curboard" class="sub_drop" alt="" />&nbsp;$sub_txt</a>~;
                         }
                     }
                     $tmp_sublist =~
                       s/{yabb subboardlinks}/$template_subboards/gsm;
                     $tmp_sublist =~ s/{yabb subdropdown}/$subdropdown/gsm;
                 }
   
                 my $altbrdcolor =
                   ( ( $alternateboardcolor % 2 ) == 1 )
                   ? 'windowbg' 
                   : 'windowbg2';
               my $boardanchor = $curboard;                my $boardanchor = $curboard;
               if ( $boardanchor =~ m~\A[^az]~i ) {                if ( $boardanchor =~ m{\A[^az]}ism ) {
                   $boardanchor =~ s~(.*?)~b$1~;                     $boardanchor =~ s/(.*?)/b$1/xsm; 
               }                }
               my $lasttopiclink =                my $lasttopiclink =
qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}" title="$fulltopictext">$lasttopictxt</a>~; qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}" title="$fulltopictext">$lasttopictxt</a>~;
                 my $boardpwpic = q{};
                 my $crypass;
                 if ( ${ $uid . $curboard }{'brdpasswr'} ) {
                     my $cookiename = "$cookiepassword$curboard$username";
                     $crypass = ${ $uid . $curboard }{'brdpassw'};
                     if (  !$staff
                         && $yyCookies{$cookiename} ne $crypass )
                     {
                         $boardpwpic    = qq~$micon{'lockimg'}~;
                         $lastpostlink  = qq~$maintxt{'900pr'}~;
                         $lasttopiclink = q~~;
                         $lastposter    = q~~;
                         $templateblock = $boardblockpw;
                     }
                     else {
                         $boardpwpic = qq~$micon{'lockopen'}~;
                     }
                 }
               if ( ${ $uid . $curboard }{'threadcount'} < 0 ) {                if ( ${ $uid . $curboard }{'threadcount'} < 0 ) {
                   ${ $uid . $curboard }{'threadcount'} = 0;                    ${ $uid . $curboard }{'threadcount'} = 0;
               }                }
               if ( ${ $uid . $curboard }{'messagecount'} < 0 ) {                if ( ${ $uid . $curboard }{'messagecount'} < 0 ) {
                   ${ $uid . $curboard }{'messagecount'} = 0;                    ${ $uid . $curboard }{'messagecount'} = 0;
               }                }
               ${ $uid . $curboard }{'threadcount'} =                ${ $uid . $curboard }{'threadcount'} =
                 &NumberFormat( ${ $uid . $curboard }{'threadcount'} );                  NumberFormat( ${ $uid . $curboard }{'threadcount'} );
               ${ $uid . $curboard }{'messagecount'} =                ${ $uid . $curboard }{'messagecount'} =
                 &NumberFormat( ${ $uid . $curboard }{'messagecount'} );                  NumberFormat( ${ $uid . $curboard }{'messagecount'} );
               $templateblock =~ s/({|<)yabb boardanchor(}|>)/$boardanchor/g;  
               $templateblock =~  # if it's a parent board that cannot be posted in, just show sub board list when clicked vs. message index 
                 s/({|<)yabb boardurl(}|>)/$scripturl\?board\=$curboard/g;                 if ( $subboard{$curboard} && !${ $uid . $curboard }{'canpost'} ) 
               $templateblock =~ s/({|<)yabb new(}|>)/$new/g;                 { 
               $templateblock =~ s/({|<)yabb boardpic(}|>)/$bdpic/g;                     $templateblock =~ s/{yabb boardurl}/$scripturl\?boardselect\=$curboard/gsm; 
               $templateblock =~ s/({|<)yabb boardname(}|>)/$boardname/g;                 } 
               $templateblock =~ s/({|<)yabb boarddesc(}|>)/$bddescr/g;                 else { 
               $templateblock =~                     $templateblock =~ s/{yabb boardurl}/$scripturl\?board\=$curboard/gsm; 
                 s/({|<)yabb moderators(}|>)/$showmods$showmodgroups/g;                 } 
               $templateblock =~  
s/({|<)yabb threadcount(}|>)/${$uid.$curboard}{'threadcount'}/g;                 # Make hidden table rows for drop down message list 
               $templateblock =~                 $expandmessages = $brd_expandmessages; 
s/({|<)yabb messagecount(}|>)/${$uid.$curboard}{'messagecount'}/g;                 $expandmessages =~ s/{yabb curboard}/$curboard/gsm; 
               $templateblock =~ s/({|<)yabb lastpostlink(}|>)/$lastpostlink/g;                 $messagedropdown; 
               $templateblock =~ s/({|<)yabb lastposter(}|>)/$lastposter/g;                 ( $boardname, $boardperms, $boardview ) = 
               $templateblock =~                   split /\|/xsm, $board{$curboard}; 
                 s/({|<)yabb lasttopiclink(}|>)/$lasttopiclink/g;                 $access = AccessCheck( $curboard, q{}, $boardperms ); 
                 if (   ( $boardperms eq q{} && !$crypass )
                     || ( !$iamguest && $access eq 'granted' ) )
                 {
                     $messagedropdown =
  qq~    <img src="$imagesdir/$brd_dropdown" onclick="MessageList('$scripturl\?board\=$curboard;messagelist=1','$yyhtml_root','$curboard', 0)" id="dropbutton_$curboard" class="cursor" alt="" />~;
                 }
                 else { $messagedropdown = q{}; }
   
                 $imgid = $brd_img_id{$curboard};
                 $bdpic =
  qq~ <img src="$bdpic" alt="$boardname" title="$boardname" id="brd_id_$imgid" onload="resize_brd_images(this);" /> ~;
   
                 if ( $boardname !~ m/[ht|f]tp[s]{0,1}:\/\//sm ) {
                     $templateblock =~ s/{yabb expandmessages}/$expandmessages/gsm;
                     $templateblock =~ s/{yabb messagedropdown}/$messagedropdown/gsm;
                     ToChars($boardname);
                     $templateblock =~ s/{yabb boardanchor}/$boardanchor/gsm;
                     $templateblock =~ s/{yabb new}/$new/gsm;
                     $templateblock =~ s/{yabb boardrss}/$rss_boardlink/gsm;
                     $templateblock =~ s/{yabb newsm}/$new2/gsm;
                     $templateblock =~ s/{yabb boardpic}/$bdpic/gsm;
                     $templateblock =~ s/{yabb boardname}/$boardname $boardpwpic/gsm;
                     $templateblock =~ s/{yabb boarddesc}/$bddescr/gsm;
                     my $boardviewers;
   
                     if ( $bvusers{$curboard} ) {
                         $tmpboardviewers = NumberFormat($bvusers{$curboard});
                         $boardviewers = qq~&nbsp;($tmpboardviewers&nbsp;$boardindex_txt{'bviews'})~;
                     }
                     $templateblock =~ s/{yabb boardviewers}/$boardviewers/gsm;
                     $templateblock =~ s/{yabb moderators}/$showmods$showmodgroups/gsm;
                     $templateblock =~ s/{yabb threadcount}/${$uid.$curboard}{'threadcount'}/gsm;
                     $templateblock =~ s/{yabb messagecount}/${$uid.$curboard}{'messagecount'}/gsm;
                     $templateblock =~ s/{yabb lastpostlink}/$lastpostlink/gsm;
                     $templateblock =~ s/{yabb lastposter}/$lastposter/gsm;
                     $templateblock =~ s/{yabb lasttopiclink}/$lasttopiclink/gsm;
                     $templateblock =~ s/{yabb altbrdcolor}/$altbrdcolor/gsm;
                     $templateblock =~ s/{yabb subboardlist}/$tmp_sublist/gsm;
                 }
                 else {
                     $templateblock = $boardblockext;
                     $bdd           = q{};
                     my @bname = split /<br \/>/sm, $bddescr;
                     for my $i ( 1 .. $#bname ) {
                         $bdd .= $bname[$i] . '<br />';
                     }
                     $boardname =
                       qq~$scripturl\?action\=showexternal;exboard\=$curboard~;
                     ToChars($bname[0]);
                     ToChars($bdd);
                     $my_blankext = q{--};
                     $templateblock =~ s/{yabb boardurl}/$boardname/gsm;
                     $templateblock =~ s/{yabb boardpic}/$bdpic/gsm;
                     $templateblock =~ s/{yabb boardname}/$bname[0]/gsm;
                     $templateblock =~ s/{yabb boarddesc}/$bdd/gsm;
                     $templateblock =~ s/{yabb threadcount}/$my_blankext/gsm;
                     $templateblock =~ s/{yabb messagecount}/$my_blankext/gsm;
                     $lastpostlink = RedirectExternalShow() || 0;
                     $templateblock =~ s/{yabb lastpostlink}/$lastpostlink/gsm;
                     $templateblock =~ s/{yabb altbrdcolor}/$altbrdcolor/gsm;
                     $templateblock =~ s/{yabb subboardlist}/$tmp_sublist/gsm;
                     $templateblock =~ s/{yabb boardanchor}/$curboard/gsm;
                 }
   
               $tmptemplateblock .= $templateblock;                $tmptemplateblock .= $templateblock;
   
                 $alternateboardcolor++;
           }            }
       }        }
       $tmptemplateblock .= $catfooter;        $tmptemplateblock .= $INFO{'a'} ? q{} : $catfooter;
       ++$catcount;        ++$catcount;
   }    }
   
   if ( !$iamguest ) {    if ( !$iamguest && !$subboard_sel ) {
       if ( ${ $uid . $username }{'im_imspop'} ) {        if ( ${ $uid . $username }{'im_imspop'} ) {
           $yymain .=             $yymain .= qq~\n\n<script type="text/javascript"> 
             qq~\n\n<script language="JavaScript1.2" type="text/javascript">     function viewIM() { window.open("$scripturl?action=im"); } 
<!--    function viewIMOUT() { window.open("$scripturl?action=imoutbox"); } 
   function viewIM() { window.open("$scripturl?action=im"); }    function viewIMSTORE() { window.open("$scripturl?action=imstorage"); }
   function viewIMOUT() { window.open("$scripturl?action=imoutbox"); }  
   function viewIMSTORE() { window.open("$scripturl?action=imstorage"); }  
// -->  
</script>~; </script>~;
       }        }
       else {        else {
           $yymain .=             $yymain .= qq~\n\n<script type="text/javascript"> 
             qq~\n\n<script language="JavaScript1.2" type="text/javascript">     function viewIM() { location.href = ("$scripturl?action=im"); } 
<!--    function viewIMOUT() { location.href = ("$scripturl?action=imoutbox"); } 
   function viewIM() { location.href = ("$scripturl?action=im"); }    function viewIMSTORE() { location.href = ("$scripturl?action=imstorage"); }
   function viewIMOUT() { location.href = ("$scripturl?action=imoutbox"); }  
   function viewIMSTORE() { location.href = ("$scripturl?action=imstorage"); }  
// -->  
</script>~; </script>~;
       }        }
       my $imsweredeleted = 0;        my $imsweredeleted = 0;
       if ( ${$username}{'PMmnum'} > $numibox && $numibox && $enable_imlimit )        if ( ${$username}{'PMmnum'} > $numibox && $numibox && $enable_imlimit )
       {        {
           &Del_Max_IM( 'msg', $numibox );            Del_Max_IM( 'msg', $numibox );
           $imsweredeleted = ${$username}{'PMmnum'} - $numibox;            $imsweredeleted = ${$username}{'PMmnum'} - $numibox;
           $yymain .=             $yymain .= qq~\n<script type="text/javascript"> 
             qq~\n<script language="JavaScript1.2" type="text/javascript">     if (confirm('$boardindex_imtxt{'11'} ${$username}{'PMmnum'} $boardindex_imtxt{'12'} $boardindex_txt{'316'}, $boardindex_imtxt{'16'} $numibox $boardindex_imtxt{'18'}. $boardindex_imtxt{'19'} $imsweredeleted $boardindex_imtxt{'20'} $boardindex_txt{'316'} $boardindex_imtxt{'21'}')) viewIM(); 
<!--  
   if (confirm('$boardindex_imtxt{'11'} ${$username}{'PMmnum'} $boardindex_imtxt{'12'} $boardindex_txt{'316'}, $boardindex_imtxt{'16'} $numibox $boardindex_imtxt{'18'}. $boardindex_imtxt{'19'} $imsweredeleted $boardindex_imtxt{'20'} $boardindex_txt{'316'} $boardindex_imtxt{'21'}')) viewIM();  
// -->  
</script>~; </script>~;
           ${$username}{'PMmnum'} = $numibox;            ${$username}{'PMmnum'} = $numibox;
       }        }
       if (   ${$username}{'PMmoutnum'} > $numobox        if (   ${$username}{'PMmoutnum'} > $numobox
           && $numobox            && $numobox
           && $enable_imlimit )            && $enable_imlimit )
       {        {
           &Del_Max_IM( 'outbox', $numobox );            Del_Max_IM( 'outbox', $numobox );
           $imsweredeleted = ${$username}{'PMmoutnum'} - $numobox;            $imsweredeleted = ${$username}{'PMmoutnum'} - $numobox;
           $yymain .=             $yymain .= qq~\n<script type="text/javascript"> 
             qq~\n<script language="JavaScript1.2" type="text/javascript">     if (confirm('$boardindex_imtxt{'11'} ${$username}{'PMmoutnum'} $boardindex_imtxt{'12'} $boardindex_txt{'320'}, $boardindex_imtxt{'16'} $numobox $boardindex_imtxt{'18'}. $boardindex_imtxt{'19'} $imsweredeleted $boardindex_imtxt{'20'} $boardindex_txt{'320'} $boardindex_imtxt{'21'}')) viewIMOUT(); 
<!--  
   if (confirm('$boardindex_imtxt{'11'} ${$username}{'PMmoutnum'} $boardindex_imtxt{'12'} $boardindex_txt{'320'}, $boardindex_imtxt{'16'} $numobox $boardindex_imtxt{'18'}. $boardindex_imtxt{'19'} $imsweredeleted $boardindex_imtxt{'20'} $boardindex_txt{'320'} $boardindex_imtxt{'21'}')) viewIMOUT();  
// -->  
</script>~; </script>~;
           ${$username}{'PMmoutnum'} = $numobox;            ${$username}{'PMmoutnum'} = $numobox;
       }        }
       if (   ${$username}{'PMstorenum'} > $numstore        if (   ${$username}{'PMstorenum'} > $numstore
           && $numstore            && $numstore
           && $enable_imlimit )            && $enable_imlimit )
       {        {
           &Del_Max_IM( 'imstore', $numstore );            Del_Max_IM( 'imstore', $numstore );
           $imsweredeleted = ${$username}{'PMstorenum'} - $numstore;            $imsweredeleted = ${$username}{'PMstorenum'} - $numstore;
           $yymain .=             $yymain .= qq~\n<script type="text/javascript"> 
             qq~\n<script language="JavaScript1.2" type="text/javascript">  
<!--  
if (confirm('$boardindex_imtxt{'11'} ${$username}{'PMstorenum'} $boardindex_imtxt{'12'} $boardindex_imtxt{'46'}, $boardindex_imtxt{'16'} $numstore $boardindex_imtxt{'18'}. $boardindex_imtxt{'19'} $imsweredeleted $boardindex_imtxt{'20'} $boardindex_imtxt{'46'} $boardindex_imtxt{'21'}')) viewIMSTORE(); if (confirm('$boardindex_imtxt{'11'} ${$username}{'PMstorenum'} $boardindex_imtxt{'12'} $boardindex_imtxt{'46'}, $boardindex_imtxt{'16'} $numstore $boardindex_imtxt{'18'}. $boardindex_imtxt{'19'} $imsweredeleted $boardindex_imtxt{'20'} $boardindex_imtxt{'46'} $boardindex_imtxt{'21'}')) viewIMSTORE();
// -->  
</script>~; </script>~;
           ${$username}{'PMstorenum'} = $numstore;            ${$username}{'PMstorenum'} = $numstore;
       }        }
       if ($imsweredeleted) {        if ($imsweredeleted) {
           &buildIMS( $username, 'update' );            buildIMS( $username, 'update' );
           &LoadIMs();             LoadIMs(); 
       }        }
   
       $ims = '';         $ims    = q{}; 
       if (   $PM_level == 1         $pm_lev = PMlev(); 
           || ( $PM_level == 2 && ( $iamadmin || $iamgmod || $iammod ) )         if ( $pm_lev == 1 ) { 
           || ( $PM_level == 3 && ( $iamadmin || $iamgmod ) ) )  
       {  
           $ims =            $ims =
qq~$boardindex_txt{'795'} <a href="$scripturl?action=im"><b>${$username}{'PMmnum'}</b></a> $boardindex_txt{'796'}~; qq~$boardindex_txt{'795'} <a href="$scripturl?action=im"><b>${$username}{'PMmnum'}</b></a> $boardindex_txt{'796'}~;
           if ( ${$username}{'PMmnum'} > 0 ) {            if ( ${$username}{'PMmnum'} > 0 ) {
               if ( ${$username}{'PMimnewcount'} == 1 ) {                if ( ${$username}{'PMimnewcount'} == 1 ) {
                   $ims .=                    $ims .=
qq~ $boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'25'}.~;  qq~ <span class="newPM">$boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'25'}.</span>~; 
               }                }
               else {                else {
                   $ims .=                    $ims .=
qq~ $boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'26'}.~;  qq~ <span class="newPM">$boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'26'}.</span>~; 
               }                }
           }            }
           else {            else {
               $ims .= qq~.~;                 $ims .= q~.~; 
           }            }
       }        }
   
       if ( $INFO{'catselect'} eq '' ) {        if ( $INFO{'catselect'} eq q{} ) {
           if   ($colbutton) { $col_vis = ""; }            if   ($colbutton) { $col_vis = q{}; }
           else              { $col_vis = " style='display:none;'"; }            else              { $col_vis = q{ style="display:none;"}; }
           if ( ${ $uid . $username }{'cathide'} ) { $exp_vis = ""; }            if ( ${ $uid . $username }{'cathide'} ) { $exp_vis = q{}; }
           else { $exp_vis = " style='display:none;'"; }            else { $exp_vis = q{ style="display:none;"}; }
   
           $expandlink =            $expandlink =
qq~<span id="expandall" $exp_vis><a href="javascript:Collapse_All('$scripturl?action=collapse_all;status=1',1,'$imagesdir','$boardindex_exptxt{'2'}')">$img{'expand'}</a>$menusep</span>~; qq~<span id="expandall" $exp_vis><a href="javascript:Collapse_All('$scripturl?action=collapse_all;status=1',1,'$imagesdir','$boardindex_exptxt{'2'}')">$img{'expand'}</a>$menusep</span>~;
           $collapselink =            $collapselink =
qq~<span id="collapseall" $col_vis><a href="javascript:Collapse_All('$scripturl?action=collapse_all;status=0',0,'$imagesdir','$boardindex_exptxt{'1'}')">$img{'collapse'}</a>$menusep</span>~; qq~<span id="collapseall" $col_vis><a href="javascript:Collapse_All('$scripturl?action=collapse_all;status=0',0,'$imagesdir','$boardindex_exptxt{'1'}')">$img{'collapse'}</a>$menusep</span>~;
           $markalllink =            $markalllink =
qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread','$imagesdir')">$img{'markallread'}</a>~;  qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread','$imagesdir','0','1')">$img{'markallread'}</a>~; 
   
       }        }
       else {        else {
           $markalllink =            $markalllink =
qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread;cat=$INFO{'catselect'}','$imagesdir')">$img{'markallread'}</a>~; qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread;cat=$INFO{'catselect'}','$imagesdir')">$img{'markallread'}</a>~;
           $collapselink = '';             $collapselink = q{}; 
           $expandlink   = '';             $expandlink   = q{}; 
       }        }
   }    }
   
   if ( $totalt < 0 ) { $totalt = 0; }    if ( $totalt < 0 ) { $totalt = 0; }
   if ( $totalm < 0 ) { $totalm = 0; }    if ( $totalm < 0 ) { $totalm = 0; }
   $totalt = &NumberFormat($totalt);     $totalt = NumberFormat($totalt); 
   $totalm = &NumberFormat($totalm);     $totalm = NumberFormat($totalm); 
   
   $guestson =     # Template some stuff for sub boards before the rest 
     qq~<span class="small">$boardindex_txt{'141'}: <b>$guests</b></span>~;     $boardindex_template =~ s/{yabb catsblock}/$tmptemplateblock/gsm; 
   $userson =  
     qq~<span class="small">$boardindex_txt{'142'}: <b>$numusers</b></span>~;  # no matter if this is ajax subboards, subboards at top of messageindex, or regular boardindex we need these vars now 
   $botson =     $brd_img_idw       = isempty( $max_brd_img_width, 50 ); 
     qq~<span class="small">$boardindex_txt{'143'}: <b>$numbots</b></span>~;     $brd_img_idh       = isempty( $max_brd_img_height, 50 ); 
     $fix_brd_img_size  = isempty( $fix_brd_img_size, 0 );
   $totalusers = $numusers + $guests;     $template_catnames =~ s/,\Z//xsm; 
     $template_boardnames =~ s/,\Z//xsm;
   if ( !-e ("$vardir/mostlog.txt") ) {     $yymain .= qq~ 
       fopen( MOSTUSERS, ">$vardir/mostlog.txt" );  <script type="text/javascript">//<![CDATA[ 
       print MOSTUSERS "$numusers|$date\n";     var catNames = [$template_catnames]; 
       print MOSTUSERS "$guests|$date\n";     var boardNames = [$template_boardnames]; 
       print MOSTUSERS "$totalusers|$date\n";     var boardOpen = ""; 
       print MOSTUSERS "$numbots|$date\n";     var subboardOpen = ""; 
       fclose(MOSTUSERS);     var arrowup = '<img src="$imagesdir/$brd_arrowup" class="brd_arrow" alt="$boardindex_txt{'643'}" />'; 
   }     var openbutton = "$imagesdir/$brd_dropdown"; 
   fopen( MOSTUSERS, "$vardir/mostlog.txt" );     var closebutton = "$imagesdir/$brd_dropup"; 
   @mostentries = <MOSTUSERS>;     var opensubbutton = "$imagesdir/$sub_arrow_dn"; 
   fclose(MOSTUSERS);     var closesubbutton = "$imagesdir/$sub_arrow_up"; 
   ( $mostmemb,  $datememb )  = split( /\|/, $mostentries[0] );     var loadimg = "$imagesdir/$brd_loadbar"; 
   ( $mostguest, $dateguest ) = split( /\|/, $mostentries[1] );     var cachedBoards = new Object(); 
   ( $mostusers, $dateusers ) = split( /\|/, $mostentries[2] );     var cachedSubBoards = new Object(); 
   ( $mostbots,  $datebots )  = split( /\|/, $mostentries[3] );     var curboard = ""; 
   chomp( $datememb, $dateguest, $dateusers, $datebots );     var insertindex; 
     var insertcat;
   if (   $numusers > $mostmemb     var prev_subcount; 
       || $guests > $mostguest     var markallreadlang = '$boardindex_txt{'500'}'; 
       || $numbots > $mostbots     var markfinishedlang = '$boardindex_txt{'500a'}'; 
       || $totalusers > $mostusers )     var markthreadslang = '$boardindex_txt{'500b'}'; 
   {     var brd_img_idw = $brd_img_idw; 
       fopen( MOSTUSERS, ">$vardir/mostlog.txt" );     var brd_img_idh = $brd_img_idh; 
       if ( $numusers > $mostmemb ) {     var fix_brd_size = $fix_brd_img_size; 
           $mostmemb = $numusers;  //]]></script>~; 
           $datememb = $date;  
       }     # don't show info center, login, etc. if we're calling from sub boards 
       if ( $guests > $mostguest ) {    if ( !$subboard_sel ) {
           $mostguest = $guests;         $guestson = 
           $dateguest = $date;           qq~<span class="small">$boardindex_txt{'141'}: <b>$guests</b></span>~; 
       }         $userson = 
       if ( $totalusers > $mostusers ) {  qq~<span class="small">$boardindex_txt{'142'}: <b>$numusers</b></span>~; 
           $mostusers = $totalusers;         $botson = 
           $dateusers = $date;  qq~<span class="small">$boardindex_txt{'143'}: <b>$numbots</b></span>~; 
       }  
       if ( $numbots > $mostbots ) { $mostbots = $numbots; $datebots = $date; }         $totalusers = $numusers + $guests; 
       print MOSTUSERS "$mostmemb|$datememb\n";  
       print MOSTUSERS "$mostguest|$dateguest\n";         if ( !-e ("$vardir/mostlog.txt") ) { 
       print MOSTUSERS "$mostusers|$dateusers\n";             fopen( MOSTUSERS, ">$vardir/mostlog.txt" ); 
       print MOSTUSERS "$mostbots|$datebots\n";             print {MOSTUSERS} "$numusers|$date\n" 
               or croak "$croak{'print'} MOSTUSERS";
             print {MOSTUSERS} "$guests|$date\n" 
               or croak "$croak{'print'} MOSTUSERS";
             print {MOSTUSERS} "$totalusers|$date\n" 
               or croak "$croak{'print'} MOSTUSERS";
             print {MOSTUSERS} "$numbots|$date\n" 
               or croak "$croak{'print'} MOSTUSERS";
             fclose(MOSTUSERS);
         }
         fopen( MOSTUSERS, "$vardir/mostlog.txt" );
         @mostentries = <MOSTUSERS>;
       fclose(MOSTUSERS);        fclose(MOSTUSERS);
   }         ( $mostmemb,  $datememb )  = split /\|/xsm, $mostentries[0]; 
   $themostmembdate  = &timeformat($datememb);         ( $mostguest, $dateguest ) = split /\|/xsm, $mostentries[1]; 
   $themostguestdate = &timeformat($dateguest);         ( $mostusers, $dateusers ) = split /\|/xsm, $mostentries[2]; 
   $themostuserdate  = &timeformat($dateusers);         ( $mostbots,  $datebots )  = split /\|/xsm, $mostentries[3]; 
   $themostbotsdate  = &timeformat($datebots);         $mostmemb  = ( $mostmemb  || 0 ); 
   $mostmemb         = &NumberFormat($mostmemb);         $datememb  = ( $datememb  || 0 ); 
   $mostguest        = &NumberFormat($mostguest);         $mostguest = ( $mostguest || 0 ); 
   $mostusers        = &NumberFormat($mostusers);         $dateguest = ( $dateguest || 0 ); 
   $mostbots         = &NumberFormat($mostbots);         $mostusers = ( $mostusers || 0 ); 
         $dateusers = ( $dateusers || 0 );
   my $shared_login;         $mostbots  = ( $mostbots  || 0 ); 
   if ($iamguest) {         $datebots  = ( $datebots  || 0 ); 
       require "$sourcedir/LogInOut.pl";  
       $sharedLogin_title = '';         chomp $datememb; 
       $shared_login      = &sharedLogin;         chomp $dateguest; 
   }         chomp $dateusers; 
         chomp $datebots;
   my %tmpcolors;  
   $tmpcnt    = 0;         if (   $numusers > $mostmemb 
   $grpcolors = '';             || $guests > $mostguest 
   ( $title, undef, undef, $color, $noshow, undef ) =             || $numbots > $mostbots 
     split( /\|/, $Group{'Administrator'}, 6 );             || $totalusers > $mostusers ) 
   if ( $color && $noshow != 1 ) {        {
       $tmpcnt++;             fopen( MOSTUSERS, ">$vardir/mostlog.txt" ); 
       $tmpcolors{$tmpcnt} =             if ( $numusers > $mostmemb ) { 
qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;                 $mostmemb = $numusers; 
   }                 $datememb = $date; 
   ( $title, undef, undef, $color, $noshow, undef ) =             } 
     split( /\|/, $Group{'Global Moderator'}, 6 );             if ( $guests > $mostguest ) { 
   if ( $color && $noshow != 1 ) {                 $mostguest = $guests; 
       $tmpcnt++;                 $dateguest = $date; 
       $tmpcolors{$tmpcnt} =             } 
qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;             if ( $totalusers > $mostusers ) { 
   }                 $mostusers = $totalusers; 
   foreach (@nopostorder) {                 $dateusers = $date; 
       ( $title, undef, undef, $color, $noshow, undef ) =             } 
         split( /\|/, $NoPost{$_}, 6 );             if ( $numbots > $mostbots ) { 
       if ( $color && $noshow != 1 ) {                 $mostbots = $numbots; 
           $tmpcnt++;                 $datebots = $date; 
           $tmpcolors{$tmpcnt} =             } 
qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;             print {MOSTUSERS} "$mostmemb|$datememb\n" 
       }               or croak "$croak{'print'} MOSTUSERS"; 
   }             print {MOSTUSERS} "$mostguest|$dateguest\n" 
   foreach $postamount ( sort { $b <=> $a } keys %Post ) {               or croak "$croak{'print'} MOSTUSERS"; 
       ( $title, undef, undef, $color, $noshow, undef ) =             print {MOSTUSERS} "$mostusers|$dateusers\n" 
         split( /\|/, $Post{$postamount}, 6 );               or croak "$croak{'print'} MOSTUSERS"; 
       if ( $color && $noshow != 1 ) {             print {MOSTUSERS} "$mostbots|$datebots\n" 
           $tmpcnt++;               or croak "$croak{'print'} MOSTUSERS"; 
           $tmpcolors{$tmpcnt} =             fclose(MOSTUSERS); 
qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;         } 
       }         $themostmembdate  = timeformat($datememb,0,0,0,1); 
   }         $themostguestdate = timeformat($dateguest,0,0,0,1); 
   $rows = int( ( $tmpcnt / 2 ) + 0.5 );         $themostuserdate  = timeformat($dateusers,0,0,0,1); 
   $col1 = 1;         $themostbotsdate  = timeformat($datebots,0,0,0,1); 
   for ( 1 .. $rows ) {         $mostmemb         = NumberFormat($mostmemb); 
       $col2 = $rows + $col1;         $mostguest        = NumberFormat($mostguest); 
       if ( $tmpcolors{$col1} ) { $grpcolors .= qq~$tmpcolors{$col1}~; }         $mostusers        = NumberFormat($mostusers); 
       if ( $tmpcolors{$col2} ) { $grpcolors .= qq~$tmpcolors{$col2}~; }         $mostbots         = NumberFormat($mostbots); 
       $col1++;  
   }         my $shared_login; 
   undef %tmpcolors;         if ($iamguest) { 
             require Sources::LogInOut;
   # Template it             $sharedLogin_title = q{}; 
   my ( $rss_link, $rss_text );             $shared_login      = sharedLogin(); 
   if ( !$rss_disabled ) {         } 
       $rss_link =  
qq~<a href="$scripturl?action=RSSrecent" target="_blank"><img src="$imagesdir/rss.png" border="0" alt="$maintxt{'rssfeed'}" title="$maintxt{'rssfeed'}" style="vertical-align: middle;" /></a>~;         my %tmpcolors; 
       $rss_link =         $tmpcnt    = 0; 
qq~<a href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" target="_blank"><img src="$imagesdir/rss.png" border="0" alt="$maintxt{'rssfeed'}" title="$maintxt{'rssfeed'}" style="vertical-align: middle;" /></a>~         $grpcolors = q{}; 
         if $INFO{'catselect'};  
       $rss_text =         foreach my $stafgrp ( sort keys %Group ) { 
             ( $title, undef, undef, $color, $noshow, undef ) =
               split /\|/xsm, $Group{$stafgrp}, 6;
             if ( $color && $noshow != 1 ) {
                 $tmpcnt++;
                 $tmpcolors{$tmpcnt} =
  qq~<div class="grpcolors"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
             }
         }
         foreach (@nopostorder) {
             ( $title, undef, undef, $color, $noshow, undef ) =
               split /\|/xsm, $NoPost{$_}, 6;
             if ( $color && $noshow != 1 ) {
                 $tmpcnt++;
                 $tmpcolors{$tmpcnt} =
  qq~<div class="grpcolors"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
             }
         }
         foreach my $postamount ( reverse sort { $a <=> $b } keys %Post ) {
             ( $title, undef, undef, $color, $noshow, undef ) =
               split /\|/xsm, $Post{$postamount}, 6;
             if ( $color && $noshow != 1 ) {
                 $tmpcnt++;
                 $tmpcolors{$tmpcnt} =
  qq~<div class="grpcolors"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
             }
         }
         $rows = int( ( $tmpcnt / 2 ) + 0.5 );
         $col1 = 1;
         for ( 1 .. $rows ) {
             $col2 = $rows + $col1;
             if ( $tmpcolors{$col1} ) { $grpcolors .= qq~$tmpcolors{$col1}~; }
             if ( $tmpcolors{$col2} ) { $grpcolors .= qq~$tmpcolors{$col2}~; }
             $col1++;
         }
         undef %tmpcolors;
   
         # Template it
         my ( $rss_link, $rss_text );
         if ( !$rss_disabled ) {
             $rss_link =
  qq~<a href="$scripturl?action=RSSrecent" target="_blank"><img src="$micon_bg{'rss'}" alt="$maintxt{'rssfeed'}" title="$maintxt{'rssfeed'}" /></a>~;
             if ( $INFO{'catselect'} ) {
                 $rss_link =
  qq~<a href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" target="_blank"><img src="$micon_bg{'rss'}" alt="$maintxt{'rssfeed'}" title="$maintxt{'rssfeed'}" /></a>~;
             }
             $rss_text =
qq~<a href="$scripturl?action=RSSrecent" target="_blank">$boardindex_txt{'792'}</a>~; qq~<a href="$scripturl?action=RSSrecent" target="_blank">$boardindex_txt{'792'}</a>~;
       $rss_text =             if ( $INFO{'catselect'} ) { 
qq~<a href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" target="_blank">$boardindex_txt{'792'}</a>~                 $rss_text = 
         if $INFO{'catselect'};  qq~<a href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" target="_blank">$boardindex_txt{'792'}</a>~; 
   }            }
   $yyrssfeed = $rss_text;         } 
   $yyrss     = $rss_link;         $yyrssfeed = $rss_text; 
   $boardindex_template =~ s/({|<)yabb rssfeed(}|>)/$rss_text/g;         $yyrss     = $rss_link; 
   $boardindex_template =~ s/({|<)yabb rss(}|>)/$rss_link/g;         $boardindex_template =~ s/{yabb rssfeed}/$rss_text/gsm; 
         $boardindex_template =~ s/{yabb rss}/$rss_link/gsm;
   $boardindex_template =~ s/({|<)yabb navigation(}|>)/&nbsp;/g;  
   $boardindex_template =~ s/({|<)yabb pollshowcase(}|>)/$polltemp/g;         $boardindex_template =~ s/{yabb navigation}/&nbsp;/gsm; 
   $boardindex_template =~ s/({|<)yabb selecthtml(}|>)//g;         $boardindex_template =~ s/{yabb pollshowcase}/$polltemp/gsm; 
   $boardindex_template =~ s/({|<)yabb catsblock(}|>)/$tmptemplateblock/g;         $boardindex_template =~ s/{yabb selecthtml}//gsm; 
   
   $boardhandellist =~ s/({|<)yabb collapse(}|>)/$collapselink/g;         $boardhandellist =~ s/{yabb collapse}/$collapselink/gsm; 
   $boardhandellist =~ s/({|<)yabb expand(}|>)/$expandlink/g;         $boardhandellist =~ s/{yabb expand}/$expandlink/gsm; 
   $boardhandellist =~ s/({|<)yabb markallread(}|>)/$markalllink/g;         $boardhandellist =~ s/{yabb markallread}/$markalllink/gsm; 
   
   $boardindex_template =~ s/({|<)yabb boardhandellist(}|>)/$boardhandellist/g;         $boardindex_template =~ s/{yabb boardhandellist}/$boardhandellist/gsm; 
   $boardindex_template =~ s/({|<)yabb totaltopics(}|>)/$totalt/g;         $boardindex_template =~ s/{yabb totaltopics}/$totalt/gsm; 
   $boardindex_template =~ s/({|<)yabb totalmessages(}|>)/$totalm/g;         $boardindex_template =~ s/{yabb totalmessages}/$totalm/gsm; 
   
   if ($Show_RecentBar) {  ### recent/recentopics?## 
       ( $lssub, undef ) = &Split_Splice_Move( $lssub, 0 );         if ($Show_RecentBar) { 
       &ToChars($lssub);             ( $lssub, undef ) = Split_Splice_Move( $lssub, 0 ); 
       $lssub        = &Censor($lssub);             ToChars($lssub); 
       $tmlsdatetime = qq~($lsdatetime).<br />~;             $lssub        = Censor($lssub); 
       $lastpostlink =             $tmlsdatetime = qq~($lsdatetime).<br />~; 
             $lastpostlink =
qq~$boardindex_txt{'236'} <b><a href="$scripturl?num=$lspostid/$lsreply#$lsreply"><b>$lssub</b></a></b>~; qq~$boardindex_txt{'236'} <b><a href="$scripturl?num=$lspostid/$lsreply#$lsreply"><b>$lssub</b></a></b>~;
             if ( $Show_RecentBar == 1 || $Show_RecentBar == 3 ) {
       if ( $maxrecentdisplay > 0 ) {                 $recentl   = 'recent'; 
           $recentpostslink =                 $recenttxt = "$boardindex_txt{'792'}"; 
qq~$boardindex_txt{'791'} <form method="post" action="$scripturl?action=recent" name="recent" style="display: inline"><select size="1" name="display" onchange="submit()"><option value="">&nbsp;</option>~;                 if ( $maxrecentdisplay > 0 ) { 
           my ( $x, $y ) = ( int( $maxrecentdisplay / 5 ), 0 );                     $recentpostslink = 
           if ($x) {  qq~$boardindex_txt{'791'} <form method="post" action="$scripturl?action=$recentl" name="$recentl" style="display: inline"><select size="1" name="display" onchange="submit()"><option value="">&nbsp;</option>~; 
               for ( my $i = 1 ; $i <= 5 ; $i++ ) {                     my ( $x, $y ) = ( int( $maxrecentdisplay / 5 ), 0 ); 
                   $y = $i * $x;                     if ($x) { 
                   $recentpostslink .= qq~<option value="$y">$y</option>~;                         foreach my $i ( 1 .. 5 ) { 
               }                             $y = $i * $x; 
           }                             $recentpostslink .= 
           $recentpostslink .=                               qq~<option value="$y">$y</option>~; 
             qq~<option value="$maxrecentdisplay">$maxrecentdisplay</option>~                         } 
             if $maxrecentdisplay > $y;                     } 
           $recentpostslink .=                     if ( $maxrecentdisplay > $y ) { 
qq~</select> </form> $boardindex_txt{'792'} $boardindex_txt{'793'}~;                         $recentpostslink .= 
       }  qq~<option value="$maxrecentdisplay">$maxrecentdisplay</option>~; 
                     }
       $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)/$lastpostlink/g;                     $recentpostslink .= 
       $boardindex_template =~ s/({|<)yabb recentposts(}|>)/$recentpostslink/g;  qq~</select> <input type="submit" style="display:none" /></form> $recenttxt $boardindex_txt{'793'}~; 
       $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)/$tmlsdatetime/g;                 } 
   }            }
   else {            if ( $Show_RecentBar == 2 || $Show_RecentBar == 3 ) {
       $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)//g;                 $recentl_t   = 'recenttopics'; 
       $boardindex_template =~ s/({|<)yabb recentposts(}|>)//g;                 $recenttxt_t = "$boardindex_txt{'792a'}"; 
       $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)//g;                 if ( $maxrecentdisplay_t > 0 ) { 
   }                     $recenttopicslink = 
   $memcount        = &NumberFormat($memcount);  qq~$boardindex_txt{'791'} <form method="post" action="$scripturl?action=$recentl_t" name="$recentl_t" style="display: inline"><select size="1" name="display" onchange="submit()"><option value="">&nbsp;</option>~; 
   $membercountlink = qq~<a href="$scripturl?action=ml"><b>$memcount</b></a>~;                     my ( $x, $y ) = ( int( $maxrecentdisplay_t / 5 ), 0 ); 
   $boardindex_template =~ s/({|<)yabb membercount(}|>)/$membercountlink/g;                     if ($x) { 
   if ($showlatestmember) {                        foreach my $i ( 1 .. 5 ) {
       &LoadUser($latestmember);                             $y = $i * $x; 
       $latestmemberlink =                             $recenttopicslink .= 
           qq~$boardindex_txt{'201'} ~                               qq~<option value="$y">$y</option>~; 
         . &QuickLinks($latestmember)                         } 
         . qq~.<br />~;                     } 
       $boardindex_template =~                     if ( $maxrecentdisplay > $y ) { 
         s/({|<)yabb latestmember(}|>)/$latestmemberlink/g;  qq~<option value="$maxrecentdisplay_t">$maxrecentdisplay_t</option>~; 
   }                    }
   else {                     $recenttopicslink .= 
       $boardindex_template =~ s/({|<)yabb latestmember(}|>)//g;  qq~</select> <input type="submit" style="display:none" /></form> $recenttxt_t $boardindex_txt{'793'}~; 
   }                }
   $boardindex_template =~ s/({|<)yabb ims(}|>)/$ims/g;             } 
   $boardindex_template =~ s/({|<)yabb guests(}|>)/$guestson/g;             if ( $Show_RecentBar == 3 && $maxrecentdisplay_t > 0 ) { 
   $boardindex_template =~ s/({|<)yabb users(}|>)/$userson/g;                 $spc = q~<br />~; 
   $boardindex_template =~ s/({|<)yabb bots(}|>)/$botson/g;             } 
   $boardindex_template =~ s/({|<)yabb onlineusers(}|>)/$users/g;             $boardindex_template =~ s/{yabb lastpostlink}/$lastpostlink/gsm; 
   $boardindex_template =~ s/({|<)yabb onlineguests(}|>)/$guestlist/g;             $boardindex_template =~ s/{yabb recentposts}/$recentpostslink/gsm; 
   $boardindex_template =~ s/({|<)yabb onlinebots(}|>)/$botlist/g;             $boardindex_template =~ s/{yabb spc}/$spc/sm; 
   $boardindex_template =~ s/({|<)yabb mostmembers(}|>)/$mostmemb/g;             $boardindex_template =~ s/{yabb recenttopics}/$recenttopicslink/gsm; 
   $boardindex_template =~ s/({|<)yabb mostguests(}|>)/$mostguest/g;             $boardindex_template =~ s/{yabb lastpostdate}/$tmlsdatetime/gsm; 
   $boardindex_template =~ s/({|<)yabb mostbots(}|>)/$mostbots/g;         } 
   $boardindex_template =~ s/({|<)yabb mostusers(}|>)/$mostusers/g;         else { 
   $boardindex_template =~ s/({|<)yabb mostmembersdate(}|>)/$themostmembdate/g;             $boardindex_template =~ s/{yabb lastpostlink}//gsm; 
   $boardindex_template =~ s/({|<)yabb mostguestsdate(}|>)/$themostguestdate/g;             $boardindex_template =~ s/{yabb recentposts}//gsm; 
   $boardindex_template =~ s/({|<)yabb mostbotsdate(}|>)/$themostbotsdate/g;             $boardindex_template =~ s/{yabb recenttopics}//gsm; 
   $boardindex_template =~ s/({|<)yabb mostusersdate(}|>)/$themostuserdate/g;             $boardindex_template =~ s/{yabb lastpostdate}//gsm; 
   $boardindex_template =~ s/({|<)yabb groupcolors(}|>)/$grpcolors/g;         } 
   $boardindex_template =~ s/({|<)yabb sharedlogin(}|>)/$shared_login/g;         $memcount = NumberFormat($memcount); 
         $membercountlink =
   chop($template_catnames);           qq~<a href="$scripturl?action=ml"><b>$memcount</b></a>~; 
   $yyjavascript .=         if ( $iamguest && $ML_Allowed ) { 
qq~\nvar markallreadlang = '$boardindex_txt{'500'}';\nvar markfinishedlang = '$boardindex_txt{'500a'}';~;             $membercountlink = qq~<b>$memcount</b>~; 
   $yymain .= qq~\n         } 
<script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script>         $boardindex_template =~ s/{yabb membercount}/$membercountlink/gsm; 
<script language="JavaScript1.2" type="text/javascript">         if ($showlatestmember) { 
<!--             LoadUser($latestmember); 
   var catNames = [$template_catnames];             $latestmemberlink = 
//-->                 qq~$boardindex_txt{'201'} ~ 
</script>               . QuickLinks($latestmember) 
$boardindex_template~;               . q~.<br />~; 
             $boardindex_template =~ s/{yabb latestmember}/$latestmemberlink/gsm;
   if ( ${$username}{'PMimnewcount'} > 0 ) {         } 
       if ( ${$username}{'PMimnewcount'} > 1 ) {        else {
           $en  = 's';             $boardindex_template =~ s/{yabb latestmember}//gsm; 
           $en2 = $boardindex_imtxt{'47'};         } 
         $boardindex_template =~ s/{yabb ims}/$ims/gsm;
         $boardindex_template =~ s/{yabb guests}/$guestson/gsm;
         $boardindex_template =~ s/{yabb users}/$userson/gsm;
         $boardindex_template =~ s/{yabb bots}/$botson/gsm;
         $boardindex_template =~ s/{yabb onlineusers}/$users/gsm;
         $boardindex_template =~ s/{yabb onlineguests}/$guestlist/gsm;
         $boardindex_template =~ s/{yabb onlinebots}/$botlist/gsm;
         $boardindex_template =~ s/{yabb mostmembers}/$mostmemb/gsm;
         $boardindex_template =~ s/{yabb mostguests}/$mostguest/gsm;
         $boardindex_template =~ s/{yabb mostbots}/$mostbots/gsm;
         $boardindex_template =~ s/{yabb mostusers}/$mostusers/gsm;
         $boardindex_template =~ s/{yabb mostmembersdate}/$themostmembdate/gsm;
         $boardindex_template =~ s/{yabb mostguestsdate}/$themostguestdate/gsm;
         $boardindex_template =~ s/{yabb mostbotsdate}/$themostbotsdate/gsm;
         $boardindex_template =~ s/{yabb mostusersdate}/$themostuserdate/gsm;
         $boardindex_template =~ s/{yabb groupcolors}/$grpcolors/gsm;
         $boardindex_template =~ s/{yabb sharedlogin}/$shared_login/gsm;
         $boardindex_template =~ s/{yabb new_load}/$newload/gsm;
   
         # EventCal START
         my $cal_display;
         if ( $Show_EventCal == 2 || ( !$iamguest && $Show_EventCal == 1 ) ) {
             require Sources::EventCal;
             $cal_display = eventcal();
         }
         $boardindex_template =~ s/{yabb caldisplay}/$cal_display/gsm;
   
         # EventCal END
   
         chop $template_catnames;
         chop $template_boardnames;
         $yymain .= qq~$boardindex_template~;
   
         $yymain .= qq~
  <script type="text/javascript">
     function ListPages(tid) { window.open('$scripturl?action=pages;num='+tid, '', 'menubar=no,toolbar=no,top=50,left=50,scrollbars=yes,resizable=no,width=400,height=300'); }
     function ListPages2(bid,cid) { window.open('$scripturl?action=pages;board='+bid+';count='+cid, '', 'menubar=no,toolbar=no,top=50,left=50,scrollbars=yes,resizable=no,width=400,height=300'); }
             </script>
         ~;
   
         if ( ${$username}{'PMimnewcount'} > 0 ) {
             if ( ${$username}{'PMimnewcount'} > 1 ) {
                 $en  = 's';
                 $en2 = $boardindex_imtxt{'47'};
             }
             else { $en = q{}; $en2 = $boardindex_imtxt{'48'}; }
   
             if ( ${ $uid . $username }{'im_popup'} ) {
                 if ( ${ $uid . $username }{'im_imspop'} ) {
                     $yymain .= qq~
  <script type="text/javascript">
     if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) window.open("$scripturl?action=im","_blank");
  </script>~;
                 }
                 else {
                     $yymain .= qq~
  <script type="text/javascript">
     if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) location.href = ("$scripturl?action=im");
  </script>~;
                 }
             }
       }        }
       else { $en = ''; $en2 = $boardindex_imtxt{'48'}; }  
   
       if ( ${ $uid . $username }{'im_popup'} ) {         LoadBroadcastMessages($username); 
   
         # look for new BM
         if ($BCnewMessage) {
           if ( ${ $uid . $username }{'im_imspop'} ) {            if ( ${ $uid . $username }{'im_imspop'} ) {
               $yymain .= qq~                $yymain .= qq~
<script language="JavaScript1.2" type="text/javascript"> <script type="text/javascript">
<!--    if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) window.open("$scripturl?action=im;focus=bmess","_blank"); 
   if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) window.open("$scripturl?action=im","_blank");  
// -->  
</script>~; </script>~;
           }            }
           else {            else {
               $yymain .= qq~                $yymain .= qq~
<script language="JavaScript1.2" type="text/javascript"> <script type="text/javascript">
<!--    if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) location.href = ("$scripturl?action=im;focus=bmess"); 
   if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) location.href = ("$scripturl?action=im");  
// -->  
</script>~; </script>~;
           }            }
       }        }
   }  
   
   &LoadBroadcastMessages($username);    # look for new BM         # Make browsers aware of our RSS 
   if ($BCnewMessage) {        if ( !$rss_disabled ) {
       if ( ${ $uid . $username }{'im_imspop'} ) {             if ( $INFO{'catselect'} ) {    # Handle categories properly 
           $yymain .= qq~                 $yyinlinestyle .= 
<script language="JavaScript1.2" type="text/javascript">  qq~    <link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" />~; 
<!--             } 
   if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) window.open("$scripturl?action=im;focus=bmess","_blank");             else { 
// -->                 $yyinlinestyle .= 
</script>~;  qq~    <link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent" />~; 
       }            }
       else {  
           $yymain .= qq~  
<script language="JavaScript1.2" type="text/javascript">  
<!--  
   if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) location.href = ("$scripturl?action=im;focus=bmess");  
// -->  
</script>~;  
       }        }
         template();
   }    }
   
   # Make browsers aware of our RSS     # end info center, login, etc. 
   if ( !$rss_disabled ) {  
       if ( $INFO{'catselect'} ) {    # Handle categories properly     if ( !$INFO{'a'} ) { 
           $yyinlinestyle .=         if ( $INFO{'boardselect'} ) { 
qq~<link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" />\n~;             $yymain .= $boardindex_template; 
       }  
       else {             my $boardtree = q{}; 
           $yyinlinestyle .=             $mycat = ${ $uid . $subboard_sel }{'cat'}; 
qq~<link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent" />\n~;             ( $mynamecat, undef ) = split /\|/xsm, $catinfo{$mycat}; 
             ToChars($mynamecat);
             my $catlinkb =
               qq~<a href="$scripturl?catselect=$mycat">$mynamecat</a>~;
             my $parentboard = $subboard_sel;
   
             while ($parentboard) {
                 my ( $pboardname, undef, undef ) =
                   split /\|/xsm, $board{$parentboard};
                 ToChars($pboardname);
                 $yytitle = $pboardname;
                 if ( ${ $uid . $parentboard }{'canpost'}
                     || !$subboard{$parentboard} )
                 {
                     $pboardname =
  qq~<a href="$scripturl?board=$parentboard" class="a"><b>$pboardname</b></a>~;
                 }
                 else {
                     $pboardname =
  qq~<a href="$scripturl?boardselect=$parentboard;subboards=1" class="a"><b>$pboardname</b></a>~;
                 }
                 $boardtree =
                   qq~ &rsaquo; $catlinkb &rsaquo; $pboardname$boardtree~;
                 $parentboard = ${ $uid . $parentboard }{'parent'};
             }
   
             $yynavigation .= qq~$boardtree~;
             template();
         }
         elsif ($subboard_sel) {
             if ($brd_count) {
                 $boardindex_template = qq~
                     <script type="text/javascript">//<![CDATA[
                         var catNames = [$template_catnames];
                         var boardNames = [$template_boardnames];
                         var boardOpen = "";
                         var subboardOpen = "";
                         var arrowup = '<img src="$imagesdir/$brd_arrowup" class="brd_arrow" alt="$boardindex_txt{'643'}" />';
                         var openbutton = "$imagesdir/$brd_dropdown";
                         var closebutton = "$imagesdir/$brd_dropup";
                         var loadimg = "$imagesdir/$brd_loadbar";
                         var cachedBoards = new Object();
                         var cachedSubBoards = new Object();
                         var curboard = "";
                         var insertindex;
                         var insertcat;
                         var prev_subcount;
                         //]]></script>
                         $boardindex_template
  ~;
             }
       }        }
   }    }
     else {
         print "Content-type: text/html; charset=$yymycharset\n\n" 
           or croak "$croak{'print'} charset";
         print qq~
             <table id="subloaded_$INFO{'board'}" style="display:none">
             $boardindex_template
             </table>
         ~ or croak "$croak{'print'} table";
         CORE::exit;    # This is here only to avoid server error log entries!
     }
   
   &template;     # cannot have return here - breaks subboard display; 
} }
   
sub GetBotlist { sub GetBotlist {
   if ( -e "$vardir/bots.hosts" ) {    if ( -e "$vardir/bots.hosts" ) {
       fopen( BOTS, "$vardir/bots.hosts" )        fopen( BOTS, "$vardir/bots.hosts" )
         || &fatal_error( "cannot_open", "$vardir/bots.hosts", 1 );          or fatal_error( 'cannot_open', "$vardir/bots.hosts", 1 );
       my @botlist = <BOTS>;        my @botlist = <BOTS>;
       fclose(BOTS);        fclose(BOTS);
       chomp(@botlist);         chomp @botlist; 
       foreach (@botlist) {        foreach (@botlist) {
           $_ =~ /(.*?)\|(.*)/;             if ( $_ =~ /(.*?)\|(.*)/xsm ) { 
           push( @all_bots, $1 );                 push @all_bots, $1; 
           $bot_name{$1} = $2;                $bot_name{$1} = $2;
             }
       }        }
   }    }
     return;
} }
   
sub Is_Bot { sub Is_Bot {
   my $bothost = $_[0];     my ($bothost) = @_; 
   foreach (@all_bots) { return $bot_name{$_} if $bothost =~ /$_/i; }    foreach (@all_bots) { return $bot_name{$_} if $bothost =~ /$_/ism; }
     return;
} }
   
sub Collapse_Write { sub Collapse_Write {
   my @userhide;    my @userhide;
   
   # rewrite the category hash for the user    # rewrite the category hash for the user
   foreach my $key (@categoryorder) {    foreach my $key (@categoryorder) {
       my ( $catname, $catperms, $catallowcol ) =        my ( $catname, $catperms, $catallowcol ) =
         split( /\|/, $catinfo{$key} );           split /\|/xsm, $catinfo{$key}; 
       $access = &CatAccess($catperms);         $access = CatAccess($catperms); 
       if ( $catcol{$key} == 0 && $access ) { push( @userhide, $key ); }        if ( $catcol{$key} == 0 && $access ) { push @userhide, $key; }
   }    }
   ${ $uid . $username }{'cathide'} = join( ",", @userhide );     ${ $uid . $username }{'cathide'} = join q{,}, @userhide; 
   &UserAccount( $username, "update" );    UserAccount( $username, 'update' );
   if ( -e "$memberdir/$username.cat" ) { unlink "$memberdir/$username.cat"; }     if ( -e "$memberdir/$username.cat" ) { 
         unlink "$memberdir/$username.cat";
     }
     return;
} }
   
sub Collapse_Cat { sub Collapse_Cat {
   if ($iamguest) { &fatal_error("collapse_no_member"); }    if ($iamguest) { fatal_error('collapse_no_member'); }
   my $changecat = $INFO{'cat'};    my $changecat = $INFO{'cat'};
   unless ($colloaded) { &Collapse_Load; }    if ( !$colloaded ) { Collapse_Load(); }
   
   if ( $catcol{$changecat} eq 1 ) {    if ( $catcol{$changecat} == 1 ) {
       $catcol{$changecat} = 0;        $catcol{$changecat} = 0;
   }    }
   else {    else {
       $catcol{$changecat} = 1;        $catcol{$changecat} = 1;
   }    }
   &Collapse_Write;     Collapse_Write(); 
   if ( $INFO{'oldcollapse'} ) {    if ( $INFO{'oldcollapse'} ) {
       $yySetLocation = $scripturl;        $yySetLocation = $scripturl;
       &redirectexit;         redirectexit(); 
   }    }
   $elenable = 0;    $elenable = 0;
   die "";    # This is here only to avoid server error log entries!    croak q{};    # This is here only to avoid server error log entries!
} }
   
sub Collapse_All { sub Collapse_All {
   my ( $state, @catstatus );     my $state = $INFO{'status'}; 
   $state = $INFO{'status'};  
   
   if ($iamguest) { &fatal_error("collapse_no_member"); }    if ($iamguest) { fatal_error('collapse_no_member'); }
   if ( $state != 1 && $state != 0 ) {    if ( $state != 1 && $state != 0 ) {
       &fatal_error("collapse_invalid_state");         fatal_error('collapse_invalid_state'); 
   }    }
   
   foreach my $key (@categoryorder) {    foreach my $key (@categoryorder) {
       my ( $catname, $catperms, $catallowcol ) =        my ( $catname, $catperms, $catallowcol ) =
         split( /\|/, $catinfo{$key} );           split /\|/xsm, $catinfo{$key}; 
       if ( $catallowcol eq '1' ) {        if ( $catallowcol eq '1' ) {
           $catcol{$key} = $state;            $catcol{$key} = $state;
       }        }
       else {        else {
           $catcol{$key} = 1;            $catcol{$key} = 1;
       }        }
   }    }
   &Collapse_Write;     Collapse_Write(); 
   if ( $INFO{'oldcollapse'} ) {    if ( $INFO{'oldcollapse'} ) {
       $yySetLocation = $scripturl;        $yySetLocation = $scripturl;
       &redirectexit;         redirectexit(); 
   }    }
   $elenable = 0;    $elenable = 0;
   die "";    # This is here only to avoid server error log entries!    croak q{};    # This is here only to avoid server error log entries!
} }
   
sub MarkAllRead {    # Mark all boards as read. sub MarkAllRead {    # Mark all boards as read.
   unless ( $mloaded == 1 ) { require "$boardsdir/forum.master"; }     get_forum_master(); 
   
   my @cats = ();    my @cats = ();
   if ( $INFO{'cat'} ) {    if ( $INFO{'cat'} ) {
       @cats = ( $INFO{'cat'} );        @cats = ( $INFO{'cat'} );
       $INFO{'catselect'} = $INFO{'cat'};        $INFO{'catselect'} = $INFO{'cat'};
   }    }
   else { @cats = @categoryorder; }    else { @cats = @categoryorder; }
   
   # Load the whole log    # Load the whole log
   &getlog;     getlog(); 
   
   foreach my $catid (@cats) {    *recursive_mark = sub {
         my @x = @_;
       # Security check         foreach my $board (@x) { 
       unless ( &CatAccess( ( split /\|/, $catinfo{$catid} )[1] ) ) {  
           foreach my $board ( split( /\,/, $cat{$catid} ) ) {  
               delete $yyuserlog{"$board--mark"};  
               delete $yyuserlog{$board};  
           }  
           next;  
       }  
   
       foreach my $board ( split( /\,/, $cat{$catid} ) ) {  
   
           # Security check            # Security check
           if (            if (
               &AccessCheck( $board, '', ( split /\|/, $board{$board} )[1] ) ne                 AccessCheck( 
               'granted' )                     $board, q{}, ( split /\|/xsm, $board{$board} )[1] 
                 ) ne 'granted' 
               )
           {            {
               delete $yyuserlog{"$board--mark"};                delete $yyuserlog{"$board--mark"};
               delete $yyuserlog{$board};                delete $yyuserlog{$board};
           }            }
           else {            else {
   
               # Mark it                # Mark it
               $yyuserlog{"$board--mark"} = $date;                $yyuserlog{"$board--mark"} = $date;
               $yyuserlog{$board} = $date;                $yyuserlog{$board} = $date;
           }            }
   
             # make recursive call if this board has more children
             if ( $subboard{$board} ) {
                 recursive_mark( split /\|/xsm, $subboard{$board} );
             }
       }        }
     };
   
     foreach my $catid (@cats) {
   
         # Security check
         if ( !CatAccess( ( split /\|/xsm, $catinfo{$catid} )[1] ) ) {
             foreach my $board ( split /\,/xsm, $cat{$catid} ) {
                 delete $yyuserlog{"$board--mark"};
                 delete $yyuserlog{$board};
             }
             next;
         }
   
         recursive_mark( split /\,/xsm, $cat{$catid} );
   }    }
   
   # Write it out    # Write it out
   &dumplog();     dumplog(); 
   
   if ( $INFO{'oldmarkread'} ) {    if ( $INFO{'oldmarkread'} ) {
       &redirectinternal;         redirectinternal(); 
   }    }
   $elenable = 0;    $elenable = 0;
   die "";    # This is here only to avoid server error log entries!    croak q{};    # This is here only to avoid server error log entries!
} }
   
sub gostRemove { sub gostRemove {
   $thecat    = $_[0];     my ( $thecat, $gostboard ) = @_; 
   $gostboard = $_[1];     get_forum_master(); 
   unless ( $mloaded == 1 ) { require "$boardsdir/forum.master"; }     (@gbdlist) = split /\,/xsm, $cat{$thecat}; 
   (@gbdlist) = split( /\,/, $cat{$thecat} );     $tmp_master = q{}; 
   $tmp_master = '';     foreach my $item (@gbdlist) { 
   foreach $item (@gbdlist) {  
       if ( $item ne $gostboard ) {        if ( $item ne $gostboard ) {
           $tmp_master .= qq~$item,~;            $tmp_master .= qq~$item,~;
       }        }
   }    }
   $tmp_master =~ s/,\Z//;     $tmp_master =~ s/,\Z//xsm; 
   $cat{$thecat} = $tmp_master;    $cat{$thecat} = $tmp_master;
   &Write_ForumMaster;     Write_ForumMaster(); 
     return;
} }
   
sub Del_Max_IM { sub Del_Max_IM {
   my ( $ext, $max ) = @_;    my ( $ext, $max ) = @_;
   fopen( DELMAXIM, "+<$memberdir/$username.$ext" );    fopen( DELMAXIM, "<$memberdir/$username.$ext" );
   seek DELMAXIM, 0, 0;  
   my @IMmessages = <DELMAXIM>;    my @IMmessages = <DELMAXIM>;
   seek DELMAXIM, 0, 0;     fclose(DELMAXIM); 
   truncate DELMAXIM, 0;     splice @IMmessages, $max; 
   
   splice( @IMmessages, $max );  
   
   print DELMAXIM @IMmessages;     fopen( DELMAXIM, ">$memberdir/$username.$ext" ); 
     print {DELMAXIM} @IMmessages or croak "$croak{'print'} DELMAXIM";
   fclose(DELMAXIM);    fclose(DELMAXIM);
     return;
} }
   
  sub RedirectExternalShow {
     my $exboard = $INFO{'exboard'} || $curboard;
     fopen( COUNT, "$boardsdir/$exboard.exhits" );
     $excount = <COUNT>;
     chomp $excount;
     fclose(COUNT);
   
     if ( $INFO{'action'} eq 'showexternal' ) {
         my $link = ( split /\|/xsm, $board{$exboard} )[0];
         if   ($excount) { $excount++; }
         else            { $excount = 1; }
         fopen( COUNT, ">$boardsdir/$exboard.exhits" );
         seek COUNT, 0, 0;
         print {COUNT} "$excount" or croak "$croak{'print'} COUNT";
         fclose(COUNT);
         print "Content-type: text/html\n" or croak "$croak{'print'} top";
         print "Location: $link\n\n"       or croak "$croak{'print'} link";
         exit;
     }
     else {
         return $excount;
     }
  }
   
  sub find_latest_data  {
             my ( $parentbd, @children ) = @_;
             $childcnt{$parentbd}    = 0;
             $sub_new_cnt{$parentbd} = 0;
             foreach my $childbd (@children) {
   
  # make recursive call first so we can get latest post data working from bottom up.
                 if ( $subboard{$childbd} ) {
                     find_latest_data( $childbd, split /\|/xsm,
                         $subboard{$childbd} );
                 }
   
                 # don't check sub board if its lastposttime is N/A
                 if ( ${ $uid . $childbd }{'lastposttime'} ne
                     $boardindex_txt{'470'} )
                 {
   
                   # update parent board last data if this child's is more recent
                     if ( $lastpostrealtime{$childbd} >
                         $lastpostrealtime{$parentbd} )
                     {
                         $lastposttime{$parentbd} = $lastposttime{$childbd};
                         $lastpostrealtime{$parentbd} =
                           $lastpostrealtime{$childbd};
                         ${ $uid . $parentbd }{'lastposttime'} =
                           ${ $uid . $childbd }{'lastposttime'};
                         ${ $uid . $parentbd }{'lastposter'} =
                           ${ $uid . $childbd }{'lastposter'};
                         ${ $uid . $parentbd }{'lastpostid'} =
                           ${ $uid . $childbd }{'lastpostid'};
                         ${ $uid . $parentbd }{'lastreply'} =
                           ${ $uid . $childbd }{'lastreply'};
                         ${ $uid . $parentbd }{'lastsubject'} =
                           ${ $uid . $childbd }{'lastsubject'};
                         ${ $uid . $parentbd }{'lasticon'} =
                           ${ $uid . $childbd }{'lasticon'};
                         ${ $uid . $parentbd }{'lasttopicstate'} =
                           ${ $uid . $childbd }{'lasttopicstate'};
                     }
                 }
   
                 # Add to totals
                 ${ $uid . $parentbd }{'threadcount'} +=
                   ${ $uid . $childbd }{'threadcount'};
                 ${ $uid . $parentbd }{'messagecount'} +=
                   ${ $uid . $childbd }{'messagecount'};
   
       # but if it's a parent board that can't be posted in, don't add to totals.
                 if ( $subboard{$childbd} && !${ $uid . $childbd }{'canpost'} ) {
                     ${ $uid . $parentbd }{'threadcount'} -=
                       ${ $uid . $childbd }{'threadcount'};
                     ${ $uid . $parentbd }{'messagecount'} -=
                       ${ $uid . $childbd }{'messagecount'};
                 }
                 if ( $new_icon{$childbd} ) {
   
                     # parent board gets new status if child has something new
                     $new_icon{$parentbd} = $new_icon{$childbd};
   
                     # count sub boards with new posts
                     $sub_new_cnt{$parentbd}++;
                 }
   
                 $childcnt{$parentbd}++;
             }
         };
   
1; 1;