D:\my docs\My Received Files\Yabb\Yabb\YaBB_2.5_AEB\cgi-bin\yabb2_old\Sources\BoardIndex.pl D:\WEBSITES\testbed\cgi-bin\yabb252\Sources\BoardIndex.pl
############################################################################### ###############################################################################
# BoardIndex.pl                                                               # # BoardIndex.pl                                                               #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5 Anniversary Edition                                # # Version:        YaBB 2.5.2                                                  #
# Packaged:       July 04, 2010                                               # # Packaged:       September 30, 2012                                          #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #    
#               Your source for web hosting, web design, and domains.         #    
############################################################################### ###############################################################################
   
$boardindexplver = 'YaBB 2.5 AE $Revision: 1.41 $'; $boardindexplver = 'YaBB 2.5.2 $Revision: 1.0 $';
if ($action eq 'detailedversion') { return 1; } if ($action eq 'detailedversion') { return 1; }
   
&LoadLanguage('BoardIndex'); &LoadLanguage('BoardIndex');
require "$templatesdir/$useboard/BoardIndex.template"; require "$templatesdir/$useboard/BoardIndex.template";
   
sub BoardIndex { sub BoardIndex {
   my ($users, $lspostid, $lspostbd, $lssub, $lsposttime, $lsposter, $lsreply, $lsdatetime, $lastthreadtime, @goodboards, @loadboards, $guestlist);    my ($users, $lspostid, $lspostbd, $lssub, $lsposttime, $lsposter, $lsreply, $lsdatetime, $lastthreadtime, @goodboards, @loadboards, $guestlist);
   my ($memcount, $latestmember) = &MembershipGet;    my ($memcount, $latestmember) = &MembershipGet;
   chomp $latestmember;    chomp $latestmember;
   $totalm = 0;    $totalm = 0;
   $totalt = 0;    $totalt = 0;
   $lastposttime   = 0;    $lastposttime   = 0;
   $lastthreadtime = 0;    $lastthreadtime = 0;
   &GetBotlist;    &GetBotlist;
   
   my ($numusers, $guests, $numbots, $user_in_log, $guest_in_log) = (0,0,0,0,0);    my ($numusers, $guests, $numbots, $user_in_log, $guest_in_log) = (0,0,0,0,0);
   my $lastonline = $date - ($OnlineLogTime * 60);    my $lastonline = $date - ($OnlineLogTime * 60);
   foreach (@logentries) {    foreach (@logentries) {
       ($name, $date1, $last_ip, $last_host) = split(/\|/, $_);        ($name, $date1, $last_ip, $last_host) = split(/\|/, $_);
       if (!$last_ip) { $last_ip = qq~</i></span><span class="error">$boardindex_txt{'no_ip'}</span><span class="small"><i>~; }        if (!$last_ip) { $last_ip = qq~</i></span><span class="error">$boardindex_txt{'no_ip'}</span><span class="small"><i>~; }
       my $is_a_bot = &Is_Bot($last_host);        my $is_a_bot = &Is_Bot($last_host);
       if ($is_a_bot){        if ($is_a_bot){
           $numbots++;            $numbots++;
           $bot_count{$is_a_bot}++;            $bot_count{$is_a_bot}++;
       } elsif ($name) {        } elsif ($name) {
           if (&LoadUser($name)) {            if (&LoadUser($name)) {
               if ($name eq $username) { $user_in_log = 1; }                if ($name eq $username) { $user_in_log = 1; }
               elsif (${$uid.$name}{'lastonline'} < $lastonline) { next; }                elsif (${$uid.$name}{'lastonline'} < $lastonline) { next; }
               if ($iamadmin || $iamgmod) {                if ($iamadmin || $iamgmod) {
                   $numusers++;                    $numusers++;
                   $users .= &QuickLinks($name);                    $users .= &QuickLinks($name);
                   $users .= (${$uid.$name}{'stealth'} ? "*" : "") .                    $users .= (${$uid.$name}{'stealth'} ? "*" : "") .
                             ((($iamadmin && $show_online_ip_admin) || ($iamgmod && $show_online_ip_gmod)) ? "&nbsp;<i>($last_ip)</i>, " : ", ");                              ((($iamadmin && $show_online_ip_admin) || ($iamgmod && $show_online_ip_gmod)) ? "&nbsp;<i>($last_ip)</i>, " : ", ");
   
               } elsif (!${$uid.$name}{'stealth'}) {                } elsif (!${$uid.$name}{'stealth'}) {
                   $numusers++;                    $numusers++;
                   $users .= &QuickLinks($name) . ", ";                    $users .= &QuickLinks($name) . ", ";
               }                }
           } else {            } else {
               if ($name eq $user_ip) { $guest_in_log = 1; }                if ($name eq $user_ip) { $guest_in_log = 1; }
               $guests++;                $guests++;
               if (($iamadmin && $show_online_ip_admin) || ($iamgmod && $show_online_ip_gmod)) {                if (($iamadmin && $show_online_ip_admin) || ($iamgmod && $show_online_ip_gmod)) {
                   $guestlist .= qq~<i>$last_ip</i>, ~;                    $guestlist .= qq~<i>$last_ip</i>, ~;
               }                }
           }            }
       }        }
   }    }
   if (!$iamguest && !$user_in_log) {    if (!$iamguest && !$user_in_log) {
       $guests-- if $guests;        $guests-- if $guests;
       $numusers++;        $numusers++;
       $users .= &QuickLinks($username);        $users .= &QuickLinks($username);
       if ($iamadmin || $iamgmod) {        if ($iamadmin || $iamgmod) {
           $users .= ${$uid.$username}{'stealth'} ? "*" : "";            $users .= ${$uid.$username}{'stealth'} ? "*" : "";
           if (($iamadmin && $show_online_ip_admin) || ($iamgmod && $show_online_ip_gmod)) {            if (($iamadmin && $show_online_ip_admin) || ($iamgmod && $show_online_ip_gmod)) {
               $users .= "&nbsp;<i>($user_ip)</i>";                $users .= "&nbsp;<i>($user_ip)</i>";
               $guestlist =~ s|<i>$last_ip</i>, ||o;                $guestlist =~ s|<i>$last_ip</i>, ||o;
           }            }
       }        }
   } elsif ($iamguest && !$guest_in_log) {    } elsif ($iamguest && !$guest_in_log) {
       $guests++;        $guests++;
   }    }
   
   if ($numusers) {    if ($numusers) {
       $users =~ s~, \Z~~;        $users =~ s~, \Z~~;
       $users .= qq~<br />~;        $users .= qq~<br />~;
   }    }
   if ($guestlist) { # build the guest list    if ($guestlist) { # build the guest list
       $guestlist =~ s/, $//;        $guestlist =~ s/, $//;
       $guestlist = qq~<span class="small">$guestlist</span><br />~;        $guestlist = qq~<span class="small">$guestlist</span><br />~;
   }    }
   if ($numbots) { # build the bot list    if ($numbots) { # build the bot list
       foreach (sort keys(%bot_count)) { $botlist .= qq~$_&nbsp;($bot_count{$_}), ~; }        foreach (sort keys(%bot_count)) { $botlist .= qq~$_&nbsp;($bot_count{$_}), ~; }
       $botlist =~ s/, $//;        $botlist =~ s/, $//;
       $botlist = qq~<span class="small">$botlist</span>~;        $botlist = qq~<span class="small">$botlist</span>~;
   }    }
   
   if (!$INFO{'catselect'}) {    if (!$INFO{'catselect'}) {
       $yytitle = $boardindex_txt{'18'};        $yytitle = $boardindex_txt{'18'};
   } else {    } else {
       ($tmpcat, $tmpmod, $tmpcol) = split(/\|/, $catinfo{ $INFO{'catselect'} });        ($tmpcat, $tmpmod, $tmpcol) = split(/\|/, $catinfo{ $INFO{'catselect'} });
       &ToChars($tmpcat);        &ToChars($tmpcat);
       $yytitle = qq~$tmpcat~;        $yytitle = qq~$tmpcat~;
       $yynavigation = qq~&rsaquo; $tmpcat~;        $yynavigation = qq~&rsaquo; $tmpcat~;
   }    }
   
   if (!$iamguest) { &Collapse_Load; }    if (!$iamguest) { &Collapse_Load; }
   
   # first get all the boards based on the categories found in forum.master    # first get all the boards based on the categories found in forum.master
   foreach $catid (@categoryorder) {    foreach $catid (@categoryorder) {
       if ($INFO{'catselect'} ne $catid && $INFO{'catselect'}) { next; }        if ($INFO{'catselect'} ne $catid && $INFO{'catselect'}) { next; }
       $boardlist = $cat{$catid};        $boardlist = $cat{$catid};
       (@bdlist) = split(/\,/, $boardlist);        (@bdlist) = split(/\,/, $boardlist);
       my ($catname, $catperms, $catallowcol) = split(/\|/, $catinfo{"$catid"});        my ($catname, $catperms, $catallowcol) = split(/\|/, $catinfo{"$catid"});
   
       # Category Permissions Check        # Category Permissions Check
       my $access = &CatAccess($catperms);        my $access = &CatAccess($catperms);
       if (!$access) { next; }        if (!$access) { next; }
       $cat_boardcnt{$catid} = 0;        $cat_boardcnt{$catid} = 0;
   
       # next determine all the boards a user has access to        # next determine all the boards a user has access to
       foreach $curboard (@bdlist) {        foreach $curboard (@bdlist) {
           # now fill all the neccesary hashes to show all board index stuff            # now fill all the neccesary hashes to show all board index stuff
           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) { next; }
           my ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$curboard"});            my ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$curboard"});
           my $access = &AccessCheck($curboard, '', $boardperms);            my $access = &AccessCheck($curboard, '', $boardperms);
           if (!$iamadmin && $access ne "granted" && $boardview != 1) { next; }            if (!$iamadmin && $access ne "granted" && $boardview != 1) { next; }
           push(@goodboards, "$catid|$curboard");            push(@goodboards, "$catid|$curboard");
           push(@loadboards, $curboard);            push(@loadboards, $curboard);
           $cat_boardcnt{$catid}++;            $cat_boardcnt{$catid}++;
       }        }
   }    }
   
   &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    # showcase poll start
   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) {
               $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 /\|/,$catinfo{$curcat})[1];
               $pollthread = 1 if &CatAccess($catperms);                $pollthread = 1 if &CatAccess($catperms);
               my $boardperms = (split /\|/,$board{${$scthreadnum}{'board'}})[1];                my $boardperms = (split /\|/,$board{${$scthreadnum}{'board'}})[1];
               $pollthread = &AccessCheck(${$scthreadnum}{'board'}, '', $boardperms) eq 'granted' ? $pollthread : 0;                $pollthread = &AccessCheck(${$scthreadnum}{'board'}, '', $boardperms) eq 'granted' ? $pollthread : 0;
           }            }
       }        }
   
       if ($pollthread) {        if ($pollthread) {
           my $tempcurrentboard = $currentboard;            my $tempcurrentboard = $currentboard;
           $currentboard = ${$scthreadnum}{'board'};            $currentboard = ${$scthreadnum}{'board'};
           my $tempmod = $iammod;            my $tempmod = $iammod;
           $iammod = 0;            $iammod = 0;
           require "$sourcedir/Poll.pl";            require "$sourcedir/Poll.pl";
           &display_poll($scthreadnum,1);            &display_poll($scthreadnum,1);
           $iammod = $tempmod;            $iammod = $tempmod;
           $polltemp = qq~<script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>~ . $pollmain . '<br />';            $polltemp = 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 $curboard (@loadboards) {
       chomp $curboard;        chomp $curboard;
       $lastposttime = ${$uid.$curboard}{'lastposttime'};        $lastposttime = ${$uid.$curboard}{'lastposttime'};
       ${$uid.$curboard}{'lastposttime'} = (${$uid.$curboard}{'lastposttime'} eq 'N/A' || !${$uid.$curboard}{'lastposttime'}) ? $boardindex_txt{'470'} : ${$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'}); }        if (${$uid.$curboard}{'lastposttime'} > 0) { $lastposttime{$curboard} = &timeformat(${$uid.$curboard}{'lastposttime'}); }
       else { $lastposttime{$curboard} = $boardindex_txt{'470'}; }        else { $lastposttime{$curboard} = $boardindex_txt{'470'}; }
       $lastpostrealtime{$curboard} = (${$uid.$curboard}{'lastposttime'} eq 'N/A' || !${$uid.$curboard}{'lastposttime'}) ? 0 : ${$uid.$curboard}{'lastposttime'};        $lastpostrealtime{$curboard} = (${$uid.$curboard}{'lastposttime'} eq 'N/A' || !${$uid.$curboard}{'lastposttime'}) ? 0 : ${$uid.$curboard}{'lastposttime'};
       $lsreply{$curboard} = ${$uid.$curboard}{'lastreply'} + 1;        $lsreply{$curboard} = ${$uid.$curboard}{'lastreply'} + 1;
       if (${$uid.$curboard}{'lastposter'} =~ m~\AGuest-(.*)~) {        if (${$uid.$curboard}{'lastposter'} =~ m~\AGuest-(.*)~) {
           ${$uid.$curboard}{'lastposter'} = $1 . " ($maintxt{'28'})";            ${$uid.$curboard}{'lastposter'} = $1 . " ($maintxt{'28'})";
           $lastposterguest{$curboard} = 1;            $lastposterguest{$curboard} = 1;
       }        }
       ${$uid.$curboard}{'lastposter'} = ${$uid.$curboard}{'lastposter'} eq 'N/A' || !${$uid.$curboard}{'lastposter'} ? $boardindex_txt{'470'} : ${$uid.$curboard}{'lastposter'};        ${$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}{'messagecount'} = ${$uid.$curboard}{'messagecount'} || 0;
       ${$uid.$curboard}{'threadcount'} = ${$uid.$curboard}{'threadcount'} || 0;        ${$uid.$curboard}{'threadcount'} = ${$uid.$curboard}{'threadcount'} || 0;
       $totalm += ${$uid.$curboard}{'messagecount'};        $totalm += ${$uid.$curboard}{'messagecount'};
       $totalt += ${$uid.$curboard}{'threadcount'};        $totalt += ${$uid.$curboard}{'threadcount'};
   
       # hide hidden threads for ordinary members and guests        # hide hidden threads for ordinary members and guests
       my $iammodhere = '';        my $iammodhere = '';
       foreach my $curuser (split(/, ?/, ${$uid.$curboard}{'mods'})) {        foreach my $curuser (split(/, ?/, ${$uid.$curboard}{'mods'})) {
           if ($username eq $curuser) { $iammodhere = 1; }            if ($username eq $curuser) { $iammodhere = 1; }
       }        }
       foreach my $curgroup (split(/, /, ${$uid.$curboard}{'modgroups'})) {        foreach my $curgroup (split(/, /, ${$uid.$curboard}{'modgroups'})) {
           if (${$uid.$username}{'position'} eq $curgroup) { $iammodhere = 1; }            if (${$uid.$username}{'position'} eq $curgroup) { $iammodhere = 1; }
           foreach (split(/,/, ${$uid.$username}{'addgroups'})) {            foreach (split(/,/, ${$uid.$username}{'addgroups'})) {
               if ($_ eq $curgroup) { $iammodhere = 1; last; }                if ($_ eq $curgroup) { $iammodhere = 1; last; }
           }            }
       }        }
   
       if (!$iammodhere && !$iamadmin && !$iamgmod && ${$uid.$curboard}{'lasttopicstate'} =~ /h/i) {        if (!$iammodhere && !$iamadmin && !$iamgmod && ${$uid.$curboard}{'lasttopicstate'} =~ /h/i) {
           ${$uid.$curboard}{'lastpostid'} = '';            ${$uid.$curboard}{'lastpostid'} = '';
           ${$uid.$curboard}{'lastsubject'} = '';            ${$uid.$curboard}{'lastsubject'} = '';
           ${$uid.$curboard}{'lastreply'} = '';            ${$uid.$curboard}{'lastreply'} = '';
           ${$uid.$curboard}{'lastposter'} = $boardindex_txt{'470'};            ${$uid.$curboard}{'lastposter'} = $boardindex_txt{'470'};
           ${$uid.$curboard}{'lastposttime'} = '';            ${$uid.$curboard}{'lastposttime'} = '';
           $lastposttime{$curboard} = $boardindex_txt{'470'};            $lastposttime{$curboard} = $boardindex_txt{'470'};
           fopen(MNUM, "$boardsdir/$curboard.txt");            fopen(MNUM, "$boardsdir/$curboard.txt");
           my @threadlist = <MNUM>;            my @threadlist = <MNUM>;
           fclose(MNUM);            fclose(MNUM);
           my ($messageid, $messagestate);            my ($messageid, $messagestate);
           foreach (@threadlist) {            foreach (@threadlist) {
               ($messageid, undef, undef, undef, undef, undef, undef, undef, $messagestate) = split(/\|/, $_);                ($messageid, undef, undef, undef, undef, undef, undef, undef, $messagestate) = split(/\|/, $_);
               if ($messagestate !~ /h/i) {                if ($messagestate !~ /h/i) {
                   fopen(FILE, "$datadir/$messageid.txt") || next;                    fopen(FILE, "$datadir/$messageid.txt") || next;
                   my @lastthreadmessages = <FILE>;                    my @lastthreadmessages = <FILE>;
                   fclose(FILE);                    fclose(FILE);
                   my @lastmessage = split(/\|/, $lastthreadmessages[$#lastthreadmessages], 6);                    my @lastmessage = 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'} = $lastmessage[4] eq "Guest" ? qq~Guest-$lastmessage[1]~ : $lastmessage[4];                    ${$uid.$curboard}{'lastposter'} = $lastmessage[4] eq "Guest" ? qq~Guest-$lastmessage[1]~ : $lastmessage[4];
                   ${$uid.$curboard}{'lastposttime'} = $lastmessage[3];                    ${$uid.$curboard}{'lastposttime'} = $lastmessage[3];
                   $lastposttime{$curboard} = &timeformat($lastmessage[3]);                    $lastposttime{$curboard} = &timeformat($lastmessage[3]);
                   last;                    last;
               }                }
           }            }
       }        }
   
       # 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 && $lastposttime{$curboard} ne $boardindex_txt{'470'}) {        if (${$uid.$curboard}{'lastposttime'} > $lastthreadtime && $lastposttime{$curboard} ne $boardindex_txt{'470'}) {
           $lsdatetime = $lastposttime{$curboard};            $lsdatetime = $lastposttime{$curboard};
           $lsposter = ${$uid.$curboard}{'lastposter'};            $lsposter = ${$uid.$curboard}{'lastposter'};
           $lssub = ${$uid.$curboard}{'lastsubject'};            $lssub = ${$uid.$curboard}{'lastsubject'};
           $lspostid = ${$uid.$curboard}{'lastpostid'};            $lspostid = ${$uid.$curboard}{'lastpostid'};
           $lsreply = ${$uid.$curboard}{'lastreply'};            $lsreply = ${$uid.$curboard}{'lastreply'};
           $lastthreadtime = ${$uid.$curboard}{'lastposttime'};            $lastthreadtime = ${$uid.$curboard}{'lastposttime'};
           $lspostbd = $curboard;            $lspostbd = $curboard;
       }        }
   }    }
   
   &LoadCensorList;    &LoadCensorList;
   foreach $catid (@categoryorder) {    foreach $catid (@categoryorder) {
       if ($INFO{'catselect'} ne $catid && $INFO{'catselect'}) { next; }        if ($INFO{'catselect'} ne $catid && $INFO{'catselect'}) { next; }
       my ($catname, $catperms, $catallowcol, $catimage) = split(/\|/, $catinfo{"$catid"});        my ($catname, $catperms, $catallowcol, $catimage) = split(/\|/, $catinfo{"$catid"});
       &ToChars($catname);        &ToChars($catname);
   
       $cataccess = &CatAccess($catperms);        $cataccess = &CatAccess($catperms);
       if (!$cataccess) { next; }        if (!$cataccess) { next; }
   
       # Skip any empty categories.        # Skip any empty categories.
       if ($cat_boardcnt{$catid} == 0) { next; }        if ($cat_boardcnt{$catid} == 0) { next; }
   
       if (!$iamguest) {        if (!$iamguest) {
           my $newmsg = 0;            my $newmsg = 0;
           $newms{$catname} = '';            $newms{$catname} = '';
           $newrowicon{$catname} = '';            $newrowicon{$catname} = '';
           $newrowstart{$catname} = '';            $newrowstart{$catname} = '';
           $newrowend{$catname} = '';            $newrowend{$catname} = '';
           $collapse_link = '';            $collapse_link = '';
                         
           if ($catallowcol) {            if ($catallowcol) {
               $collapse_link = qq~<a href="javascript:SendRequest('$scripturl?action=collapse_cat;cat=$catid','$catid','$imagesdir','$boardindex_exptxt{'2'}','$boardindex_exptxt{'1'}')">~;                $collapse_link = qq~<a href="javascript:SendRequest('$scripturl?action=collapse_cat;cat=$catid','$catid','$imagesdir','$boardindex_exptxt{'2'}','$boardindex_exptxt{'1'}')">~;
           }            }
   
           # 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 '') {
               foreach my $boardinfo (@goodboards) {                foreach my $boardinfo (@goodboards) {
                   my $testcat;                    my $testcat;
                   ($testcat, $curboard) = split(/\|/, $boardinfo);                    ($testcat, $curboard) = split(/\|/, $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                    # as we fill the vars based on all boards we need to skip any cat already shown before
                   if (!$iamguest && $max_log_days_old && $lastpostrealtime{$curboard} && ((!$yyuserlog{$curboard} && $lastpostrealtime{$curboard} > $dmax) || ($yyuserlog{$curboard} > $dmax && $yyuserlog{$curboard} < $lastpostrealtime{$curboard}))) {                    if (!$iamguest && $max_log_days_old && $lastpostrealtime{$curboard} && ((!$yyuserlog{$curboard} && $lastpostrealtime{$curboard} > $dmax) || ($yyuserlog{$curboard} > $dmax && $yyuserlog{$curboard} < $lastpostrealtime{$curboard}))) {
                       my (undef, $boardperms, $boardview) = split(/\|/, $board{"$curboard"});                        my (undef, $boardperms, $boardview) = split(/\|/, $board{"$curboard"});
                       if (&AccessCheck($curboard, '', $boardperms) eq "granted") { $newmsg = 1; }                        if (&AccessCheck($curboard, '', $boardperms) eq "granted") { $newmsg = 1; }
                   }                    }
               }                }
   
               if ($catallowcol) {                if ($catallowcol) {
                   $template_catnames .= qq~"$catid",~;                    $template_catnames .= qq~"$catid",~;
                   $newrowend{$catname}   = qq~</span></td></tr>~;                    $newrowend{$catname}   = qq~</span></td></tr>~;
                   if ($catcol{$catid}) {                    if ($catcol{$catid}) {
                       $newrowstart{$catname} = qq~<tr id="col$catid" style="display:none;"><td colspan="5" class="$new_msg_bg" height="18"><span class="$new_msg_class">~;                        $newrowstart{$catname} = qq~<tr id="col$catid" style="display:none;"><td colspan="5" class="$new_msg_bg" height="18"><span class="$new_msg_class">~;
                       $template_boardtable = qq~id="$catid"~;                        $template_boardtable = qq~id="$catid"~;
                   } else {                    } else {
                       $newrowstart{$catname} = qq~<tr id="col$catid"><td colspan="5" class="$new_msg_bg" height="18"><span class="$new_msg_class">~;                        $newrowstart{$catname} = qq~<tr id="col$catid"><td colspan="5" class="$new_msg_bg" height="18"><span class="$new_msg_class">~;
                       $template_boardtable = qq~id="$catid" style="display:none;"~;                        $template_boardtable = qq~id="$catid" style="display:none;"~;
                   }                    }
                   if ($newmsg) {                    if ($newmsg) {
                       $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;" />~;                        $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;" />~;
                       $newms{$catname} = $boardindex_exptxt{'5'};                        $newms{$catname} = $boardindex_exptxt{'5'};
                   } else {                    } else {
                       $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;" />~;                        $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;" />~;
                       $newms{$catname} = $boardindex_exptxt{'6'};                        $newms{$catname} = $boardindex_exptxt{'6'};
                   }                    }
                   if ($catcol{$catid}) {                    if ($catcol{$catid}) {
                       $hash{$catname} = qq~<img src="$imagesdir/cat_collapse.gif" id="img$catid" alt="$boardindex_exptxt{'2'}" title="$boardindex_exptxt{'2'}" border="0" /></a>~;                        $hash{$catname} = qq~<img src="$imagesdir/cat_collapse.gif" id="img$catid" alt="$boardindex_exptxt{'2'}" title="$boardindex_exptxt{'2'}" border="0" /></a>~;
                   } else {                    } else {
                       $hash{$catname} = qq~ <img src="$imagesdir/cat_expand.gif" id="img$catid" alt="$boardindex_exptxt{'1'}" title="$boardindex_exptxt{'1'}" border="0" /></a>~;                        $hash{$catname} = qq~ <img src="$imagesdir/cat_expand.gif" id="img$catid" alt="$boardindex_exptxt{'1'}" title="$boardindex_exptxt{'1'}" border="0" /></a>~;
                   }                    }
   
               } else {                } else {
                   $template_boardtable = qq~id="$catid"~;                    $template_boardtable = qq~id="$catid"~;
               }                }
   
           } else {            } else {
               $collapse_link = ''; $hash{$catname} = '';                $collapse_link = ''; $hash{$catname} = '';
               $template_boardtable = qq~id="$catid"~;                $template_boardtable = qq~id="$catid"~;
           }            }
   
           $catlink = qq~$collapse_link $hash{$catname} <a href="$scripturl?catselect=$catid" title="$boardindex_txt{'797'} $catname">$catname</a>~;            $catlink = qq~$collapse_link $hash{$catname} <a href="$scripturl?catselect=$catid" title="$boardindex_txt{'797'} $catname">$catname</a>~;
       } else {        } else {
           $template_boardtable = qq~id="$catid"~;            $template_boardtable = qq~id="$catid"~;
           $catlink = qq~<a href="$scripturl?catselect=$catid">$catname</a>~;            $catlink = qq~<a href="$scripturl?catselect=$catid">$catname</a>~;
       }        }
   
       $templatecat = $catheader;        $templatecat = $catheader;
       $tmpcatimg = "";        $tmpcatimg = "";
       if ($catimage ne '') {        if ($catimage ne '') {
           if ($catimage =~ /\//i) { $catimage = qq~<img src="$catimage" alt="" border="0" style="vertical-align: middle;" />~; }            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;" />~; }            elsif ($catimage) { $catimage = qq~<img src="$imagesdir/$catimage" alt="" border="0" style="vertical-align: middle;" />~; }
           $tmpcatimg = qq~$catimage~;            $tmpcatimg = qq~$catimage~;
       }        }
       $templatecat =~ s/({|<)yabb catimage(}|>)/$tmpcatimg/g;        $templatecat =~ s/({|<)yabb catimage(}|>)/$tmpcatimg/g;
       $templatecat =~ s/({|<)yabb catlink(}|>)/$catlink/g;        $templatecat =~ s/({|<)yabb catlink(}|>)/$catlink/g;
       $templatecat =~ s/({|<)yabb newmsg start(}|>)/$newrowstart{$catname}/g;        $templatecat =~ s/({|<)yabb newmsg start(}|>)/$newrowstart{$catname}/g;
       $templatecat =~ s/({|<)yabb newmsg icon(}|>)/$newrowicon{$catname}/g;        $templatecat =~ s/({|<)yabb newmsg icon(}|>)/$newrowicon{$catname}/g;
       $templatecat =~ s/({|<)yabb newmsg(}|>)/$newms{$catname}/g;        $templatecat =~ s/({|<)yabb newmsg(}|>)/$newms{$catname}/g;
       $templatecat =~ s/({|<)yabb newmsg end(}|>)/$newrowend{$catname}/g;        $templatecat =~ s/({|<)yabb newmsg end(}|>)/$newrowend{$catname}/g;
       $templatecat =~ s/({|<)yabb boardtable(}|>)/$template_boardtable/g;        $templatecat =~ s/({|<)yabb boardtable(}|>)/$template_boardtable/g;
       $tmptemplateblock .= $templatecat;        $tmptemplateblock .= $templatecat;
   
       ## loop through any non collapsed boards to show the board index        ## loop through any non collapsed boards to show the board index
       ## Also shows whether collapsed or not due to QuickCollapse (Unilat)        ## Also shows whether collapsed or not due to QuickCollapse (Unilat)
       #if (($catcol{$catid} || !$catcol{$catid})|| $INFO{'catselect'} ne '' || $iamguest) {  <= Unilat        #if (($catcol{$catid} || !$catcol{$catid})|| $INFO{'catselect'} ne '' || $iamguest) {  <= Unilat
       if (!$INFO{'oldcollapse'} || $catcol{$catid} || $INFO{'catselect'} ne '' || $iamguest) { # deti        if (!$INFO{'oldcollapse'} || $catcol{$catid} || $INFO{'catselect'} ne '' || $iamguest) { # deti
           foreach my $boardinfo (@goodboards) {            foreach my $boardinfo (@goodboards) {
               my $testcat;                my $testcat;
               ($testcat, $curboard) = split(/\|/, $boardinfo);                ($testcat, $curboard) = split(/\|/, $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                # as we fill the vars based on all boards we need to skip any cat already shown before
               if (${$uid.$curboard}{'ann'} == 1) { ${$uid.$curboard}{'pic'} = 'ann.gif'; }                if (${$uid.$curboard}{'ann'} == 1) { ${$uid.$curboard}{'pic'} = 'ann.gif'; }
               if (${$uid.$curboard}{'rbin'} == 1) { ${$uid.$curboard}{'pic'} = 'recycle.gif'; }                if (${$uid.$curboard}{'rbin'} == 1) { ${$uid.$curboard}{'pic'} = 'recycle.gif'; }
               ($boardname, $boardperms, $boardview) = split(/\|/, $board{$curboard});                ($boardname, $boardperms, $boardview) = split(/\|/, $board{$curboard});
               &ToChars($boardname);                &ToChars($boardname);
               $INFO{'zeropost'} = 0;                $INFO{'zeropost'} = 0;
               $zero = '';                $zero = '';
               $bdpic = ${$uid.$curboard}{'pic'};                $bdpic = ${$uid.$curboard}{'pic'};
               $bddescr = ${$uid.$curboard}{'description'};                $bddescr = ${$uid.$curboard}{'description'};
               &ToChars($bddescr);                &ToChars($bddescr);
               $iammod = '';                $iammod = '';
               %moderators = ();                %moderators = ();
               foreach my $curuser (split(/, ?/, ${$uid.$curboard}{'mods'})) {                foreach 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 = '';
               if (keys %moderators == 1) { $showmods = qq~$boardindex_txt{'298'}: ~; }                if (keys %moderators == 1) { $showmods = qq~$boardindex_txt{'298'}: ~; }
               elsif (keys %moderators != 0) { $showmods = qq~$boardindex_txt{'63'}: ~; }                elsif (keys %moderators != 0) { $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) . ", ";
               }                }
               $showmods =~ s/, \Z//;                $showmods =~ s/, \Z//;
   
               &LoadUser($username);                &LoadUser($username);
               %moderatorgroups = ();                %moderatorgroups = ();
               foreach my $curgroup (split(/, /, ${$uid.$curboard}{'modgroups'})) {                foreach my $curgroup (split(/, /, ${$uid.$curboard}{'modgroups'})) {
                   if (${$uid.$username}{'position'} eq $curgroup) { $iammod = 1; }                    if (${$uid.$username}{'position'} eq $curgroup) { $iammod = 1; }
                   foreach (split(/,/, ${$uid.$username}{'addgroups'})) {                    foreach (split(/,/, ${$uid.$username}{'addgroups'})) {
                       if ($_ eq $curgroup) { $iammod = 1; last; }                        if ($_ eq $curgroup) { $iammod = 1; last; }
                   }                    }
                   ($thismodgrp, undef) = split(/\|/, $NoPost{$curgroup}, 2);                    ($thismodgrp, undef) = split(/\|/, $NoPost{$curgroup}, 2);
                   $moderatorgroups{$curgroup} = $thismodgrp;                    $moderatorgroups{$curgroup} = $thismodgrp;
               }                }
   
               $showmodgroups = '';                $showmodgroups = '';
               if (scalar keys %moderatorgroups == 1) { $showmodgroups = qq~$boardindex_txt{'298a'}: ~; }                if (scalar keys %moderatorgroups == 1) { $showmodgroups = qq~$boardindex_txt{'298a'}: ~; }
               elsif (scalar keys %moderatorgroups != 0) { $showmodgroups = qq~$boardindex_txt{'63a'}: ~; }                elsif (scalar keys %moderatorgroups != 0) { $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//;
               if ($showmodgroups eq "" && $showmods eq "") { $showmodgroups = qq~<br />~; }                if ($showmodgroups eq "" && $showmods eq "") { $showmodgroups = qq~<br />~; }
               if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~<br />~; }                if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~<br />~; }
   
               if ($iamguest) {                if ($iamguest) {
                   $new = '';                    $new = '';
   
               } elsif ($max_log_days_old && $lastpostrealtime{$curboard} && ((!$yyuserlog{$curboard} && $lastpostrealtime{$curboard} > $dmax) || ($yyuserlog{$curboard} > $dmax && $yyuserlog{$curboard} < $lastpostrealtime{$curboard}))) {                } elsif ($max_log_days_old && $lastpostrealtime{$curboard} && ((!$yyuserlog{$curboard} && $lastpostrealtime{$curboard} > $dmax) || ($yyuserlog{$curboard} > $dmax && $yyuserlog{$curboard} < $lastpostrealtime{$curboard}))) {
                   my (undef, $boardperms, $boardview) = split(/\|/, $board{"$curboard"});                    my (undef, $boardperms, $boardview) = split(/\|/, $board{"$curboard"});
                   if (&AccessCheck($curboard, '', $boardperms) eq "granted") {                    if (&AccessCheck($curboard, '', $boardperms) eq "granted") {
                       $new = qq~<img src="$imagesdir/on.gif" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" border="0" style="vertical-align: middle;" />~;                        $new = qq~<img src="$imagesdir/on.gif" alt="$boardindex_txt{'333'}" title="$boardindex_txt{'333'}" border="0" style="vertical-align: middle;" />~;
                   } else {                    } else {
                       $new = qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="vertical-align: middle;" />~;                        $new = qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="vertical-align: middle;" />~;
                   }                    }
   
               } else {                } else {
                   $new = qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="vertical-align: middle;" />~;                    $new = qq~<img src="$imagesdir/off.gif" alt="$boardindex_txt{'334'}" title="$boardindex_txt{'334'}" border="0" style="vertical-align: middle;" />~;
               }                }
               if (!$bdpic) { $bdpic = 'boards.gif'; }                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'})~i;
   
               unless ($lastposterguest{$curboard} || ${$uid.$curboard}{'lastposter'} eq $boardindex_txt{'470'}) {                unless ($lastposterguest{$curboard} || ${$uid.$curboard}{'lastposter'} eq $boardindex_txt{'470'}) {
                   &LoadUser($lastposter);                    &LoadUser($lastposter);
                   if ((${$uid.$lastposter}{'regdate'} && ${$uid.$curboard}{'lastposttime'} > ${$uid.$lastposter}{'regtime'}) || ${$uid.$lastposter}{'position'} eq "Administrator" || ${$uid.$lastposter}{'position'} eq "Global Moderator") {                    if ((${$uid.$lastposter}{'regdate'} && ${$uid.$curboard}{'lastposttime'} > ${$uid.$lastposter}{'regtime'}) || ${$uid.$lastposter}{'position'} eq "Administrator" || ${$uid.$lastposter}{'position'} eq "Global Moderator") {
                       $lastposter = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$lastposter}">${$uid.$lastposter}{'realname'}</a>~;                        $lastposter = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$lastposter}">${$uid.$lastposter}{'realname'}</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, "$datadir/${$uid.$curboard}{'lastpostid'}.txt") || &fatal_error('cannot_open', "$datadir/${$uid.$curboard}{'lastpostid'}.txt", 1);                        fopen(EXMEMBERTHREAD, "$datadir/${$uid.$curboard}{'lastpostid'}.txt") || &fatal_error('cannot_open', "$datadir/${$uid.$curboard}{'lastpostid'}.txt", 1);
                       my @x = <EXMEMBERTHREAD>;                        my @x = <EXMEMBERTHREAD>;
                       fclose(EXMEMBERTHREAD);                        fclose(EXMEMBERTHREAD);
                       $lastposter = (split(/\|/, $x[$#x], 3))[1] . " - $boardindex_txt{'470a'}";                        $lastposter = (split(/\|/, $x[$#x], 3))[1] . " - $boardindex_txt{'470a'}";
                   }                    }
               }                }
               ${$uid.$curboard}{'lastposter'} ||= $boardindex_txt{'470'};                ${$uid.$curboard}{'lastposter'} ||= $boardindex_txt{'470'};
               ${$uid.$curboard}{'lastposttime'} ||= $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" /> ~; }                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" /> ~; }                elsif ($bdpic) { $bdpic = qq~ <img src="$imagesdir/$bdpic" alt="$boardname" title="$boardname" border="0" /> ~; }
   
               my $templateblock = $boardblock;                my $templateblock = $boardblock;
   
               my $lasttopictxt = ${$uid.$curboard}{'lastsubject'};                my $lasttopictxt = ${$uid.$curboard}{'lastsubject'};
               ($lasttopictxt, undef) = &Split_Splice_Move($lasttopictxt,0);                ($lasttopictxt, undef) = &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 .= "..."; }
   
               &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 "") {
                   $lastpostlink = qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}">$img{'lastpost'}</a> $lastposttime{$curboard}~;                    $lastpostlink = qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}">$img{'lastpost'}</a> $lastposttime{$curboard}~;
               } else {                } else {
                   $lastpostlink = qq~$img{'lastpost'} $boardindex_txt{'470'}~;                    $lastpostlink = qq~$img{'lastpost'} $boardindex_txt{'470'}~;
               }                }
   
               my $boardanchor = $curboard;                my $boardanchor = $curboard;
               if($boardanchor =~ m~\A[^az]~i) {$boardanchor =~ s~(.*?)~b$1~;}                if($boardanchor =~ m~\A[^az]~i) {$boardanchor =~ s~(.*?)~b$1~;}
               my $lasttopiclink = qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}" title="$fulltopictext">$lasttopictxt</a>~;                my $lasttopiclink = qq~<a href="$scripturl?num=${$uid.$curboard}{'lastpostid'}/${$uid.$curboard}{'lastreply'}#${$uid.$curboard}{'lastreply'}" title="$fulltopictext">$lasttopictxt</a>~;
               if (${$uid.$curboard}{'threadcount'} < 0)  { ${$uid.$curboard}{'threadcount'}  = 0; }                if (${$uid.$curboard}{'threadcount'} < 0)  { ${$uid.$curboard}{'threadcount'}  = 0; }
               if (${$uid.$curboard}{'messagecount'} < 0) { ${$uid.$curboard}{'messagecount'} = 0; }                if (${$uid.$curboard}{'messagecount'} < 0) { ${$uid.$curboard}{'messagecount'} = 0; }
               ${$uid.$curboard}{'threadcount'} = &NumberFormat(${$uid.$curboard}{'threadcount'});                ${$uid.$curboard}{'threadcount'} = &NumberFormat(${$uid.$curboard}{'threadcount'});
               ${$uid.$curboard}{'messagecount'} = &NumberFormat(${$uid.$curboard}{'messagecount'});                ${$uid.$curboard}{'messagecount'} = &NumberFormat(${$uid.$curboard}{'messagecount'});
               $templateblock =~ s/({|<)yabb boardanchor(}|>)/$boardanchor/g;                $templateblock =~ s/({|<)yabb boardanchor(}|>)/$boardanchor/g;
               $templateblock =~ s/({|<)yabb boardurl(}|>)/$scripturl\?board\=$curboard/g;                $templateblock =~ s/({|<)yabb boardurl(}|>)/$scripturl\?board\=$curboard/g;
               $templateblock =~ s/({|<)yabb new(}|>)/$new/g;                $templateblock =~ s/({|<)yabb new(}|>)/$new/g;
               $templateblock =~ s/({|<)yabb boardpic(}|>)/$bdpic/g;                $templateblock =~ s/({|<)yabb boardpic(}|>)/$bdpic/g;
               $templateblock =~ s/({|<)yabb boardname(}|>)/$boardname/g;                $templateblock =~ s/({|<)yabb boardname(}|>)/$boardname/g;
               $templateblock =~ s/({|<)yabb boarddesc(}|>)/$bddescr/g;                $templateblock =~ s/({|<)yabb boarddesc(}|>)/$bddescr/g;
               $templateblock =~ s/({|<)yabb moderators(}|>)/$showmods$showmodgroups/g;                $templateblock =~ s/({|<)yabb moderators(}|>)/$showmods$showmodgroups/g;
               $templateblock =~ s/({|<)yabb threadcount(}|>)/${$uid.$curboard}{'threadcount'}/g;                $templateblock =~ s/({|<)yabb threadcount(}|>)/${$uid.$curboard}{'threadcount'}/g;
               $templateblock =~ s/({|<)yabb messagecount(}|>)/${$uid.$curboard}{'messagecount'}/g;                $templateblock =~ s/({|<)yabb messagecount(}|>)/${$uid.$curboard}{'messagecount'}/g;
               $templateblock =~ s/({|<)yabb lastpostlink(}|>)/$lastpostlink/g;                $templateblock =~ s/({|<)yabb lastpostlink(}|>)/$lastpostlink/g;
               $templateblock =~ s/({|<)yabb lastposter(}|>)/$lastposter/g;                $templateblock =~ s/({|<)yabb lastposter(}|>)/$lastposter/g;
               $templateblock =~ s/({|<)yabb lasttopiclink(}|>)/$lasttopiclink/g;                $templateblock =~ s/({|<)yabb lasttopiclink(}|>)/$lasttopiclink/g;
               $tmptemplateblock .= $templateblock;                $tmptemplateblock .= $templateblock;
           }            }
       }        }
       $tmptemplateblock .= $catfooter;        $tmptemplateblock .= $catfooter;
       ++$catcount;        ++$catcount;
   }    }
   
   if (!$iamguest) {    if (!$iamguest) {
       if (${$uid.$username}{'im_imspop'}) {        if (${$uid.$username}{'im_imspop'}) {
           $yymain .= qq~\n\n<script language="JavaScript1.2" type="text/javascript">            $yymain .= qq~\n\n<script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   function viewIM() { window.open("$scripturl?action=im"); }    function viewIM() { window.open("$scripturl?action=im"); }
   function viewIMOUT() { window.open("$scripturl?action=imoutbox"); }    function viewIMOUT() { window.open("$scripturl?action=imoutbox"); }
   function viewIMSTORE() { window.open("$scripturl?action=imstorage"); }    function viewIMSTORE() { window.open("$scripturl?action=imstorage"); }
// --> // -->
</script>~; </script>~;
       } else {        } else {
           $yymain .= qq~\n\n<script language="JavaScript1.2" type="text/javascript">            $yymain .= qq~\n\n<script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   function viewIM() { location.href = ("$scripturl?action=im"); }    function viewIM() { location.href = ("$scripturl?action=im"); }
   function viewIMOUT() { location.href = ("$scripturl?action=imoutbox"); }    function viewIMOUT() { location.href = ("$scripturl?action=imoutbox"); }
   function viewIMSTORE() { location.href = ("$scripturl?action=imstorage"); }    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 .= qq~\n<script language="JavaScript1.2" type="text/javascript">            $yymain .= 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 && $numobox && $enable_imlimit) {        if (${$username}{'PMmoutnum'} > $numobox && $numobox && $enable_imlimit) {
           &Del_Max_IM('outbox',$numobox);            &Del_Max_IM('outbox',$numobox);
           $imsweredeleted = ${$username}{'PMmoutnum'} - $numobox;            $imsweredeleted = ${$username}{'PMmoutnum'} - $numobox;
           $yymain .= qq~\n<script language="JavaScript1.2" type="text/javascript">            $yymain .= 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 && $numstore && $enable_imlimit) {        if (${$username}{'PMstorenum'} > $numstore && $numstore && $enable_imlimit) {
           &Del_Max_IM('imstore',$numstore);            &Del_Max_IM('imstore',$numstore);
           $imsweredeleted = ${$username}{'PMstorenum'} - $numstore;            $imsweredeleted = ${$username}{'PMstorenum'} - $numstore;
           $yymain .= qq~\n<script language="JavaScript1.2" type="text/javascript">            $yymain .= 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 = '';
       if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))){        if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))){
           $ims = qq~$boardindex_txt{'795'} <a href="$scripturl?action=im"><b>${$username}{'PMmnum'}</b></a> $boardindex_txt{'796'}~;            $ims = 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 .= qq~ $boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'25'}.~;                    $ims .= qq~ $boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'25'}.~;
               } else {                } else {
                   $ims .= qq~ $boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'26'}.~;                    $ims .= qq~ $boardindex_imtxt{'24'} <a href="$scripturl?action=im"><b>${$username}{'PMimnewcount'}</b></a> $boardindex_imtxt{'26'}.~;
               }                }
           } else {            } else {
               $ims .= qq~.~;                $ims .= qq~.~;
           }            }
       }        }
   
       if ($INFO{'catselect'} eq '') {        if ($INFO{'catselect'} eq '') {
           if ($colbutton) { $col_vis = ""; }            if ($colbutton) { $col_vis = ""; }
           else { $col_vis = " style='display:none;'"; }            else { $col_vis = " style='display:none;'"; }
           if (${$uid.$username}{'cathide'}) { $exp_vis = ""; }            if (${$uid.$username}{'cathide'}) { $exp_vis = ""; }
           else { $exp_vis = " style='display:none;'"; }            else { $exp_vis = " style='display:none;'"; }
   
           $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>~;            $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>~;
           $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>~;            $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>~;
           $markalllink = qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread','$imagesdir')">$img{'markallread'}</a>~;            $markalllink = qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread','$imagesdir')">$img{'markallread'}</a>~;
   
       } else {        } else {
           $markalllink  = qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread;cat=$INFO{'catselect'}','$imagesdir')">$img{'markallread'}</a>~;            $markalllink  = qq~<a href="javascript:MarkAllAsRead('$scripturl?action=markallasread;cat=$INFO{'catselect'}','$imagesdir')">$img{'markallread'}</a>~;
           $collapselink = '';            $collapselink = '';
           $expandlink   = '';            $expandlink   = '';
       }        }
   }    }
   
   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 = qq~<span class="small">$boardindex_txt{'141'}: <b>$guests</b></span>~;    $guestson = qq~<span class="small">$boardindex_txt{'141'}: <b>$guests</b></span>~;
   $userson = qq~<span class="small">$boardindex_txt{'142'}: <b>$numusers</b></span>~;    $userson = qq~<span class="small">$boardindex_txt{'142'}: <b>$numusers</b></span>~;
   $botson = qq~<span class="small">$boardindex_txt{'143'}: <b>$numbots</b></span>~;    $botson = qq~<span class="small">$boardindex_txt{'143'}: <b>$numbots</b></span>~;
   
   $totalusers = $numusers + $guests;    $totalusers = $numusers + $guests;
   
   if (!-e ("$vardir/mostlog.txt")) {    if (!-e ("$vardir/mostlog.txt")) {
       fopen(MOSTUSERS, ">$vardir/mostlog.txt");        fopen(MOSTUSERS, ">$vardir/mostlog.txt");
       print MOSTUSERS "$numusers|$date\n";        print MOSTUSERS "$numusers|$date\n";
       print MOSTUSERS "$guests|$date\n";        print MOSTUSERS "$guests|$date\n";
       print MOSTUSERS "$totalusers|$date\n";        print MOSTUSERS "$totalusers|$date\n";
       print MOSTUSERS "$numbots|$date\n";        print MOSTUSERS "$numbots|$date\n";
       fclose(MOSTUSERS);        fclose(MOSTUSERS);
   }    }
   fopen(MOSTUSERS, "$vardir/mostlog.txt");    fopen(MOSTUSERS, "$vardir/mostlog.txt");
   @mostentries = <MOSTUSERS>;    @mostentries = <MOSTUSERS>;
   fclose(MOSTUSERS);    fclose(MOSTUSERS);
   ($mostmemb, $datememb) = split(/\|/, $mostentries[0]);    ($mostmemb, $datememb) = split(/\|/, $mostentries[0]);
   ($mostguest, $dateguest) = split(/\|/, $mostentries[1]);    ($mostguest, $dateguest) = split(/\|/, $mostentries[1]);
   ($mostusers, $dateusers) = split(/\|/, $mostentries[2]);    ($mostusers, $dateusers) = split(/\|/, $mostentries[2]);
   ($mostbots, $datebots) = split(/\|/, $mostentries[3]);    ($mostbots, $datebots) = split(/\|/, $mostentries[3]);
   chomp ($datememb, $dateguest, $dateusers, $datebots);    chomp ($datememb, $dateguest, $dateusers, $datebots);
   if ($numusers > $mostmemb || $guests > $mostguest || $numbots > $mostbots || $totalusers > $mostusers) {    if ($numusers > $mostmemb || $guests > $mostguest || $numbots > $mostbots || $totalusers > $mostusers) {
       fopen(MOSTUSERS, ">$vardir/mostlog.txt");        fopen(MOSTUSERS, ">$vardir/mostlog.txt");
       if ($numusers > $mostmemb) { $mostmemb = $numusers; $datememb = $date; }        if ($numusers > $mostmemb) { $mostmemb = $numusers; $datememb = $date; }
       if ($guests > $mostguest) { $mostguest = $guests; $dateguest = $date; }        if ($guests > $mostguest) { $mostguest = $guests; $dateguest = $date; }
       if ($totalusers > $mostusers) { $mostusers = $totalusers; $dateusers = $date; }        if ($totalusers > $mostusers) { $mostusers = $totalusers; $dateusers = $date; }
       if ($numbots > $mostbots) { $mostbots  = $numbots; $datebots = $date; }        if ($numbots > $mostbots) { $mostbots  = $numbots; $datebots = $date; }
       print MOSTUSERS "$mostmemb|$datememb\n";        print MOSTUSERS "$mostmemb|$datememb\n";
       print MOSTUSERS "$mostguest|$dateguest\n";        print MOSTUSERS "$mostguest|$dateguest\n";
       print MOSTUSERS "$mostusers|$dateusers\n";        print MOSTUSERS "$mostusers|$dateusers\n";
       print MOSTUSERS "$mostbots|$datebots\n";        print MOSTUSERS "$mostbots|$datebots\n";
       fclose(MOSTUSERS);        fclose(MOSTUSERS);
   }    }
   $themostmembdate = &timeformat($datememb);    $themostmembdate = &timeformat($datememb);
   $themostguestdate = &timeformat($dateguest);    $themostguestdate = &timeformat($dateguest);
   $themostuserdate = &timeformat($dateusers);    $themostuserdate = &timeformat($dateusers);
   $themostbotsdate = &timeformat($datebots);    $themostbotsdate = &timeformat($datebots);
   $mostmemb = &NumberFormat($mostmemb);    $mostmemb = &NumberFormat($mostmemb);
   $mostguest = &NumberFormat($mostguest);    $mostguest = &NumberFormat($mostguest);
   $mostusers = &NumberFormat($mostusers);    $mostusers = &NumberFormat($mostusers);
   $mostbots = &NumberFormat($mostbots);    $mostbots = &NumberFormat($mostbots);
   
   my $shared_login;    my $shared_login;
   if ($iamguest) {    if ($iamguest) {
       require "$sourcedir/LogInOut.pl";        require "$sourcedir/LogInOut.pl";
       $sharedLogin_title = '';        $sharedLogin_title = '';
       $shared_login = &sharedLogin;        $shared_login = &sharedLogin;
   }    }
   
   my %tmpcolors;    my %tmpcolors;
   $tmpcnt = 0;    $tmpcnt = 0;
   $grpcolors = '';    $grpcolors = '';
   ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $Group{'Administrator'}, 6);    ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $Group{'Administrator'}, 6);
   if ($color && $noshow != 1) {    if ($color && $noshow != 1) {
       $tmpcnt++;        $tmpcnt++;
       $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;        $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
   }    }
   ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $Group{'Global Moderator'}, 6);    ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $Group{'Global Moderator'}, 6);
   if ($color && $noshow != 1) {    if ($color && $noshow != 1) {
       $tmpcnt++;        $tmpcnt++;
       $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;        $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
   }    }
   foreach (@nopostorder) {    foreach (@nopostorder) {
       ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $NoPost{$_}, 6);        ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $NoPost{$_}, 6);
       if ($color && $noshow != 1) {        if ($color && $noshow != 1) {
           $tmpcnt++;            $tmpcnt++;
           $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;            $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
       }        }
   }    }
   foreach $postamount (sort { $b <=> $a } keys %Post) {    foreach $postamount (sort { $b <=> $a } keys %Post) {
       ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $Post{$postamount}, 6);        ($title, undef, undef, $color, $noshow, undef) = split(/\|/, $Post{$postamount}, 6);
       if ($color && $noshow != 1) {        if ($color && $noshow != 1) {
           $tmpcnt++;            $tmpcnt++;
           $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;            $tmpcolors{$tmpcnt} = qq~<div class="small" style="float: left; width: 49%;"><span style="color: $color;"><b>lllll</b></span> $title</div>~;
       }        }
   }    }
   $rows = int(($tmpcnt / 2) + 0.5);    $rows = int(($tmpcnt / 2) + 0.5);
   $col1 = 1;    $col1 = 1;
   for(1..$rows) {    for(1..$rows) {
       $col2 = $rows + $col1;        $col2 = $rows + $col1;
       if($tmpcolors{$col1}) { $grpcolors .= qq~$tmpcolors{$col1}~; }        if($tmpcolors{$col1}) { $grpcolors .= qq~$tmpcolors{$col1}~; }
       if($tmpcolors{$col2}) { $grpcolors .= qq~$tmpcolors{$col2}~; }        if($tmpcolors{$col2}) { $grpcolors .= qq~$tmpcolors{$col2}~; }
       $col1++;        $col1++;
   }    }
   undef %tmpcolors;    undef %tmpcolors;
   
   # Template it    # Template it
   my ($rss_link, $rss_text);    my ($rss_link, $rss_text);
   if (!$rss_disabled) {    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>~;        $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>~;
       $rss_link = 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>~ if $INFO{'catselect'};        $rss_link = 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>~ if $INFO{'catselect'};
       $rss_text = qq~<a href="$scripturl?action=RSSrecent" target="_blank">$boardindex_txt{'792'}</a>~;        $rss_text = qq~<a href="$scripturl?action=RSSrecent" target="_blank">$boardindex_txt{'792'}</a>~;
       $rss_text = qq~<a href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" target="_blank">$boardindex_txt{'792'}</a>~ if $INFO{'catselect'};        $rss_text = qq~<a href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" target="_blank">$boardindex_txt{'792'}</a>~ if $INFO{'catselect'};
   }    }
   $yyrssfeed = $rss_text;    $yyrssfeed = $rss_text;
   $yyrss = $rss_link;    $yyrss = $rss_link;
   $boardindex_template =~ s/({|<)yabb rssfeed(}|>)/$rss_text/g;    $boardindex_template =~ s/({|<)yabb rssfeed(}|>)/$rss_text/g;
   $boardindex_template =~ s/({|<)yabb rss(}|>)/$rss_link/g;    $boardindex_template =~ s/({|<)yabb rss(}|>)/$rss_link/g;
   
   $boardindex_template =~ s/({|<)yabb navigation(}|>)/&nbsp;/g;    $boardindex_template =~ s/({|<)yabb navigation(}|>)/&nbsp;/g;
   $boardindex_template =~ s/({|<)yabb pollshowcase(}|>)/$polltemp/g;    $boardindex_template =~ s/({|<)yabb pollshowcase(}|>)/$polltemp/g;
   $boardindex_template =~ s/({|<)yabb selecthtml(}|>)//g;    $boardindex_template =~ s/({|<)yabb selecthtml(}|>)//g;
   $boardindex_template =~ s/({|<)yabb catsblock(}|>)/$tmptemplateblock/g;    $boardindex_template =~ s/({|<)yabb catsblock(}|>)/$tmptemplateblock/g;
   
   $boardhandellist     =~ s/({|<)yabb collapse(}|>)/$collapselink/g;    $boardhandellist     =~ s/({|<)yabb collapse(}|>)/$collapselink/g;
   $boardhandellist     =~ s/({|<)yabb expand(}|>)/$expandlink/g;    $boardhandellist     =~ s/({|<)yabb expand(}|>)/$expandlink/g;
   $boardhandellist     =~ s/({|<)yabb markallread(}|>)/$markalllink/g;    $boardhandellist     =~ s/({|<)yabb markallread(}|>)/$markalllink/g;
   
   $boardindex_template =~ s/({|<)yabb boardhandellist(}|>)/$boardhandellist/g;    $boardindex_template =~ s/({|<)yabb boardhandellist(}|>)/$boardhandellist/g;
   $boardindex_template =~ s/({|<)yabb totaltopics(}|>)/$totalt/g;    $boardindex_template =~ s/({|<)yabb totaltopics(}|>)/$totalt/g;
   $boardindex_template =~ s/({|<)yabb totalmessages(}|>)/$totalm/g;    $boardindex_template =~ s/({|<)yabb totalmessages(}|>)/$totalm/g;
   
   if ($Show_RecentBar) {    if ($Show_RecentBar) {
       ($lssub, undef) = &Split_Splice_Move($lssub,0);        ($lssub, undef) = &Split_Splice_Move($lssub,0);
       &ToChars($lssub);        &ToChars($lssub);
       $lssub = &Censor($lssub);        $lssub = &Censor($lssub);
       $tmlsdatetime    = qq~($lsdatetime).<br />~;        $tmlsdatetime    = qq~($lsdatetime).<br />~;
       $lastpostlink    = qq~$boardindex_txt{'236'} <b><a href="$scripturl?num=$lspostid/$lsreply#$lsreply"><b>$lssub</b></a></b>~;        $lastpostlink    = qq~$boardindex_txt{'236'} <b><a href="$scripturl?num=$lspostid/$lsreply#$lsreply"><b>$lssub</b></a></b>~;
   
       if ($maxrecentdisplay > 0) {        if ($maxrecentdisplay > 0) {
           $recentpostslink = 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>~;            $recentpostslink = 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>~;
           my ($x,$y) = (int($maxrecentdisplay/5),0);            my ($x,$y) = (int($maxrecentdisplay/5),0);
           if ($x) {            if ($x) {
               for (my $i = 1; $i <= 5; $i++) {                for (my $i = 1; $i <= 5; $i++) {
                   $y = $i * $x;                    $y = $i * $x;
                   $recentpostslink .= qq~<option value="$y">$y</option>~;                    $recentpostslink .= qq~<option value="$y">$y</option>~;
               }                }
           }            }
           $recentpostslink .= qq~<option value="$maxrecentdisplay">$maxrecentdisplay</option>~ if $maxrecentdisplay > $y;            $recentpostslink .= qq~<option value="$maxrecentdisplay">$maxrecentdisplay</option>~ if $maxrecentdisplay > $y;
           $recentpostslink .= qq~</select> </form> $boardindex_txt{'792'} $boardindex_txt{'793'}~;            $recentpostslink .= qq~</select> </form> $boardindex_txt{'792'} $boardindex_txt{'793'}~;
       }        }
   
       $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)/$lastpostlink/g;        $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)/$lastpostlink/g;
       $boardindex_template =~ s/({|<)yabb recentposts(}|>)/$recentpostslink/g;        $boardindex_template =~ s/({|<)yabb recentposts(}|>)/$recentpostslink/g;
       $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)/$tmlsdatetime/g;        $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)/$tmlsdatetime/g;
   } else {    } else {
       $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)//g;        $boardindex_template =~ s/({|<)yabb lastpostlink(}|>)//g;
       $boardindex_template =~ s/({|<)yabb recentposts(}|>)//g;        $boardindex_template =~ s/({|<)yabb recentposts(}|>)//g;
       $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)//g;        $boardindex_template =~ s/({|<)yabb lastpostdate(}|>)//g;
   }    }
   $memcount = &NumberFormat($memcount);    $memcount = &NumberFormat($memcount);
   $membercountlink = qq~<a href="$scripturl?action=ml"><b>$memcount</b></a>~;    $membercountlink = qq~<a href="$scripturl?action=ml"><b>$memcount</b></a>~;
   $boardindex_template =~ s/({|<)yabb membercount(}|>)/$membercountlink/g;    $boardindex_template =~ s/({|<)yabb membercount(}|>)/$membercountlink/g;
   if ($showlatestmember) {    if ($showlatestmember) {
       &LoadUser($latestmember);        &LoadUser($latestmember);
       $latestmemberlink = qq~$boardindex_txt{'201'} ~ . &QuickLinks($latestmember) . qq~.<br />~;        $latestmemberlink = qq~$boardindex_txt{'201'} ~ . &QuickLinks($latestmember) . qq~.<br />~;
       $boardindex_template =~ s/({|<)yabb latestmember(}|>)/$latestmemberlink/g;        $boardindex_template =~ s/({|<)yabb latestmember(}|>)/$latestmemberlink/g;
   } else {    } else {
       $boardindex_template =~ s/({|<)yabb latestmember(}|>)//g;        $boardindex_template =~ s/({|<)yabb latestmember(}|>)//g;
   }    }
   $boardindex_template =~ s/({|<)yabb ims(}|>)/$ims/g;    $boardindex_template =~ s/({|<)yabb ims(}|>)/$ims/g;
   $boardindex_template =~ s/({|<)yabb guests(}|>)/$guestson/g;    $boardindex_template =~ s/({|<)yabb guests(}|>)/$guestson/g;
   $boardindex_template =~ s/({|<)yabb users(}|>)/$userson/g;    $boardindex_template =~ s/({|<)yabb users(}|>)/$userson/g;
   $boardindex_template =~ s/({|<)yabb bots(}|>)/$botson/g;    $boardindex_template =~ s/({|<)yabb bots(}|>)/$botson/g;
   $boardindex_template =~ s/({|<)yabb onlineusers(}|>)/$users/g;    $boardindex_template =~ s/({|<)yabb onlineusers(}|>)/$users/g;
   $boardindex_template =~ s/({|<)yabb onlineguests(}|>)/$guestlist/g;    $boardindex_template =~ s/({|<)yabb onlineguests(}|>)/$guestlist/g;
   $boardindex_template =~ s/({|<)yabb onlinebots(}|>)/$botlist/g;    $boardindex_template =~ s/({|<)yabb onlinebots(}|>)/$botlist/g;
   $boardindex_template =~ s/({|<)yabb mostmembers(}|>)/$mostmemb/g;    $boardindex_template =~ s/({|<)yabb mostmembers(}|>)/$mostmemb/g;
   $boardindex_template =~ s/({|<)yabb mostguests(}|>)/$mostguest/g;    $boardindex_template =~ s/({|<)yabb mostguests(}|>)/$mostguest/g;
   $boardindex_template =~ s/({|<)yabb mostbots(}|>)/$mostbots/g;    $boardindex_template =~ s/({|<)yabb mostbots(}|>)/$mostbots/g;
   $boardindex_template =~ s/({|<)yabb mostusers(}|>)/$mostusers/g;    $boardindex_template =~ s/({|<)yabb mostusers(}|>)/$mostusers/g;
   $boardindex_template =~ s/({|<)yabb mostmembersdate(}|>)/$themostmembdate/g;    $boardindex_template =~ s/({|<)yabb mostmembersdate(}|>)/$themostmembdate/g;
   $boardindex_template =~ s/({|<)yabb mostguestsdate(}|>)/$themostguestdate/g;    $boardindex_template =~ s/({|<)yabb mostguestsdate(}|>)/$themostguestdate/g;
   $boardindex_template =~ s/({|<)yabb mostbotsdate(}|>)/$themostbotsdate/g;    $boardindex_template =~ s/({|<)yabb mostbotsdate(}|>)/$themostbotsdate/g;
   $boardindex_template =~ s/({|<)yabb mostusersdate(}|>)/$themostuserdate/g;    $boardindex_template =~ s/({|<)yabb mostusersdate(}|>)/$themostuserdate/g;
   $boardindex_template =~ s/({|<)yabb groupcolors(}|>)/$grpcolors/g;    $boardindex_template =~ s/({|<)yabb groupcolors(}|>)/$grpcolors/g;
   $boardindex_template =~ s/({|<)yabb sharedlogin(}|>)/$shared_login/g;    $boardindex_template =~ s/({|<)yabb sharedlogin(}|>)/$shared_login/g;
   
   chop($template_catnames);    chop($template_catnames);
   $yyjavascript .= qq~\nvar markallreadlang = '$boardindex_txt{'500'}';\nvar markfinishedlang = '$boardindex_txt{'500a'}';~;    $yyjavascript .= qq~\nvar markallreadlang = '$boardindex_txt{'500'}';\nvar markfinishedlang = '$boardindex_txt{'500a'}';~;
   $yymain .= qq~\n    $yymain .= qq~\n
<script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script> <script language="JavaScript1.2" src="$yyhtml_root/ajax.js" type="text/javascript"></script>
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   var catNames = [$template_catnames];    var catNames = [$template_catnames];
//--> //-->
</script> </script>
$boardindex_template~; $boardindex_template~;
   
   if (${$username}{'PMimnewcount'} > 0) {    if (${$username}{'PMimnewcount'} > 0) {
       if (${$username}{'PMimnewcount'} > 1) { $en = 's'; $en2 = $boardindex_imtxt{'47'}; }        if (${$username}{'PMimnewcount'} > 1) { $en = 's'; $en2 = $boardindex_imtxt{'47'}; }
       else { $en = ''; $en2 = $boardindex_imtxt{'48'}; }        else { $en = ''; $en2 = $boardindex_imtxt{'48'}; }
   
       if (${$uid.$username}{'im_popup'}) {        if (${$uid.$username}{'im_popup'}) {
           if (${$uid.$username}{'im_imspop'}) {            if (${$uid.$username}{'im_imspop'}) {
               $yymain .= qq~                $yymain .= qq~
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) window.open("$scripturl?action=im","_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 language="JavaScript1.2" type="text/javascript">
<!-- <!--
   if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) location.href = ("$scripturl?action=im");    if (confirm("$boardindex_imtxt{'14'} ${$username}{'PMimnewcount'}$boardindex_imtxt{'15'}?")) location.href = ("$scripturl?action=im");
// --> // -->
</script>~; </script>~;
           }            }
       }        }
   }    }
   
   &LoadBroadcastMessages($username); # look for new BM    &LoadBroadcastMessages($username); # look for new BM
   if ($BCnewMessage) {    if ($BCnewMessage) {
       if (${$uid.$username}{'im_imspop'}) {        if (${$uid.$username}{'im_imspop'}) {
           $yymain .= qq~            $yymain .= qq~
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) window.open("$scripturl?action=im;focus=bmess","_blank");    if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) window.open("$scripturl?action=im;focus=bmess","_blank");
// --> // -->
</script>~; </script>~;
       } else {        } else {
               $yymain .= qq~                $yymain .= qq~
<script language="JavaScript1.2" type="text/javascript"> <script language="JavaScript1.2" type="text/javascript">
<!-- <!--
   if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) location.href = ("$scripturl?action=im;focus=bmess");    if (confirm("$boardindex_imtxt{'50'}$boardindex_imtxt{'51'}?")) location.href = ("$scripturl?action=im;focus=bmess");
// --> // -->
</script>~; </script>~;
       }        }
   }    }
   
   # Make browsers aware of our RSS    # Make browsers aware of our RSS
   if (!$rss_disabled) {    if (!$rss_disabled) {
       if ($INFO{'catselect'}) { # Handle categories properly        if ($INFO{'catselect'}) { # Handle categories properly
           $yyinlinestyle .= qq~<link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" />\n~;            $yyinlinestyle .= qq~<link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent;catselect=$INFO{'catselect'}" />\n~;
       } else {        } else {
           $yyinlinestyle .= qq~<link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent" />\n~;            $yyinlinestyle .= qq~<link rel="alternate" type="application/rss+xml" title="$boardindex_txt{'792'}" href="$scripturl?action=RSSrecent" />\n~;
       }        }
   }    }
   
   &template;    &template;
} }
   
sub GetBotlist { sub GetBotlist {
   if (-e "$vardir/bots.hosts") {    if (-e "$vardir/bots.hosts") {
       fopen(BOTS, "$vardir/bots.hosts") || &fatal_error("cannot_open","$vardir/bots.hosts", 1);        fopen(BOTS, "$vardir/bots.hosts") || &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) {
           $_ =~ /(.*?)\|(.*)/;            $_ =~ /(.*?)\|(.*)/;
           push(@all_bots, $1);            push(@all_bots, $1);
           $bot_name{$1} = $2;            $bot_name{$1} = $2;
       }        }
   }    }
} }
   
sub Is_Bot { sub Is_Bot {
   my $bothost = $_[0];    my $bothost = $_[0];
   foreach (@all_bots){ return $bot_name{$_} if $bothost =~ /$_/i; }    foreach (@all_bots){ return $bot_name{$_} if $bothost =~ /$_/i; }
} }
   
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) = split(/\|/, $catinfo{$key});        my ($catname, $catperms, $catallowcol) = split(/\|/, $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(",", @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"; }
} }
   
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; }    unless ($colloaded) { &Collapse_Load; }
   
   if ($catcol{$changecat} eq 1) {    if ($catcol{$changecat} eq 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;
   }