############################################################################### # MessageIndex.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Project started by Zef Hemel (zef@zefnet.com) # # Software Version: YaBB 1 Gold - Release # # =========================================================================== # # Software Distributed by: http://yabb.xnull.com # # Support, News, Updates at: http://yabb.xnull.com/community/ # # =========================================================================== # # Copyright (c) 2000-2001 X-Null - All Rights Reserved # # Software by: The YaBB Development Team # ############################################################################### $messageindexplver="1 Gold - Release"; sub MessageIndex { my $start = int( $INFO{'start'} ) || 0; my( $bdescrip, $counter, $buffer, $pages, $showmods, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $dlp, $threadlength, $threaddate ); my( @boardinfo, @threads ); my( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($currentboard); my $maxindex = $INFO{'view'} eq 'all' ? $threadcount : $maxdisplay; # Make sure the starting place makes sense. if( $start > $threadcount ) { $start = int( $threadcount % $maxindex ) * $maxindex; } elsif( $start < 0 ) { $start = 0; } # Construct the page links for this board. $tmpa = $start - $maxindex; $pageindex .= $start == 0 ? qq~ ~ : qq~« ~; $tmpa = 1; for( $counter = 0; $counter < $threadcount; $counter += $maxindex ) { $pageindex .= $start == $counter ? qq~$tmpa ~ : qq~$tmpa ~; ++$tmpa; } $tmpa = $start + $maxindex; $tmpa = $tmpa > $threadcount ? $threadcount : $tmpa; if($start != $counter-$threadcount) { $pageindex .= $tmpa > $counter-$maxindex ? qq~ ~ : qq~» ~; } # Determine what category we are in. fopen(FILE, "$boardsdir/$currentboard.ctb") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.ctb"); $cat = ; fclose(FILE); fopen(FILE, "$boardsdir/$cat.cat") || &fatal_error("300 $txt{'106'}: $txt{'23'} $cat.cat"); $currcat = $cat; $cat = ; fclose(FILE); #$counter = 0; #while($counter == 0) { $cat = $temp; } # Get the board's description fopen(FILE, "$boardsdir/$currentboard.dat") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.dat"); @boardinfo = ; fclose(FILE); chomp @boardinfo; $bdescrip = $boardinfo[1]; # Open and quickly read the current board thread list. # Skip past threads until we reach the "page" we want. fopen(FILE, "$boardsdir/$currentboard.txt") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.txt"); $counter = 0; $tmpa = ''; if( $counter < $start && ( $buffer = ) ) { $tmpa = $buffer; $counter++; } while( $counter < $start && ( $buffer = ) ) { $counter++; } $#threads = $maxindex - 1; $counter = 0; while( $counter < $maxindex && ( $buffer = ) ) { chomp $buffer; $threads[$counter] = $buffer; $counter++; } fclose(FILE); $#threads = $counter - 1; # Let's get the info for the first thread in this forum. $tmpa ||= $threads[0]; ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split( /\|/, $tmpa ); # Mark current board as seen. &dumplog($currentboard); # Build a list of the board's moderators. if( scalar keys %moderators > 0 ) { if( scalar keys %moderators == 1 ) { $showmods = qq~($txt{'298'}: ~; } else { $showmods = qq~($txt{'299'}: ~; } while( $_ = each(%moderators) ) { &FormatUserName($_); $showmods .= qq~$moderators{$_}, ~; } $showmods =~ s/, \Z/)/; } # Load censor list. fopen(FILE,"$vardir/censor.txt"); while( chomp( $buffer = ) ) { ($tmpa,$tmpb) = split(/=/,$buffer); push(@censored,[$tmpa,$tmpb]); } fclose(FILE); # Print the header and board info. $yytitle = $boardname; &header; $curboardurl = $curposlinks ? qq~$boardname~ : $boardname; print << "EOT";
   $mbname
   $cat
   $curboardurl
$showmods
EOT if($ShowBDescrip) { print <
$bdescrip
EOT } print <
$txt{'139'}: $pageindex EOT if ($username ne 'Guest') { if($showmarkread) { print qq~ $img{'markboardread'}~; } } print << "EOT"; $menusep$img{'newthread'} 
EOT # Begin printing the message index for current board. $counter = $start; foreach( @threads ) { ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split( /\|/, $_ ); # Set thread class depending on locked status and number of replies. if( $mstate == 1 ) { $threadclass = 'locked'; } elsif( $mreplies > 24 ) { $threadclass = 'veryhotthread'; } elsif( $mreplies > 14 ) { $threadclass = 'hotthread'; } elsif( $mstate == 0 ) { $threadclass = 'thread'; } # Decide if thread should have the "NEW" indicator next to it. # Do this by reading the user's log for last read time on thread, # and compare to the last post time on the thread. $dlp = &getlog($mnum); $threaddate = stringtotime($mdate); if( $max_log_days_old && $dlp != $threaddate && $username ne 'Guest' && &getlog("$currentboard--mark") < $threaddate ) { $new = qq~$txt{'302'}~; } else { $new = ''; } # Load the current nickname of the account name of the thread starter. if( $musername ne 'Guest' && -e "$memberdir/$musername.dat" ) { &LoadUser($musername); $mname = $userprofile{$musername}->[1] || $mname || $txt{'470'}; $mname = qq~$mname~; } else { $mname ||= $txt{'470'}; } # Censor the subject of the thread. foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } # Decide how many pages the thread should have. $threadlength = $mreplies + 1; $pages = ''; if( $threadlength > $maxmessagedisplay ) { $tmpa = 1; for( $tmpb = 0; $tmpb < $threadlength; $tmpb += $maxmessagedisplay ) { $pages .= qq~$tmpa\n~; ++$tmpa; } $pages =~ s/\n\Z//; $pages = qq~« $pages »~; } if( fopen(FILE, "$datadir/$mnum.data") ) { $tmpa = ; fclose(FILE); } elsif( -e "$datadir/$mnum.data" ) { &fatal_error("301 $txt{'106'}: $txt{'23'} $mnum.data"); } else { $tmpa = '0'; } ($views, $lastposter) = split(/\|/, $tmpa); if( $lastposter =~ m~\AGuest-(.*)~ ) { $lastposter = $1; } else { unless( $lastposter eq $txt{'470'} ) { $lastposterid = $lastposter; &LoadUser($lastposterid); if($userprofile{$lastposter}->[1]) { $lastposter = qq~$userprofile{$lastposter}->[1]~; } } &LoadUser($lastposter); } $lastpostername = $lastposter || $txt{'470'}; $views = $views ? $views - 1 : 0; # Print the thread info. $mydate = &timeformat($mdate); print << "EOT"; EOT ++$counter; } print << "EOT";
  $txt{'70'} $txt{'109'} $txt{'110'} $txt{'301'} $txt{'111'}
$msub $new $pages $mname $mreplies $views $mydate
$txt{'525'} $lastpostername
$txt{'139'}: $pageindex EOT if ($username ne 'Guest') { if($showmarkread) { print qq~$img{'markboardread'}~; } } &jumpto; print << "EOT"; $menusep$img{'newthread'} 
$txt{'454'}
$txt{'455'}
$txt{'456'}
$txt{'457'}
$txt{'160'}:
EOT &footer; exit; } sub MarkRead { # Mark all threads in this board as read. &dumplog("$currentboard--mark"); &MessageIndex; } 1;