############################################################################### # MessageIndex.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.1 # # Released: December 2001; Updated March 22, 2002 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2002 Xnull (www.xnull.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $messageindexplver = "1 Gold - SP 1.1"; 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, $startdate ); my( @boardinfo, @threads ); my( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($currentboard); my $maxindex = $INFO{'view'} eq 'all' ? $threadcount : $maxdisplay; # 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"); @threadlist = ; @threadlist2 = ''; fclose(FILE); # Get sort order and date mask $default_sort = ""; $default_mask = ""; if (-e "$boardsdir/$currentboard.opt" ) { require "$boardsdir/$currentboard.opt"; } my $sortmode = $INFO{'sort'} || $default_sort; my $datemask = $INFO{'date'} || $default_mask; if ($FORM{'sortmode'}) { $sortmode = $FORM{'sortmode'}; } if ($FORM{'datemask'}) { $datemask = $FORM{'datemask'}; } if ($sortmode eq "rating" && $enable_topicrating != 1) { $sortmode = "";} # Highlight current sort order and date mask my ( $sort1, $sort2, $sort3, $sort4, $sort5, $sort6, $sort7, $sort8 )= (); if ($sortmode eq "subject") { $sort2 = " selected" } elsif ($sortmode eq "created") { $sort3 = " selected" } elsif ($sortmode eq "author") { $sort4 = " selected" } elsif ($sortmode eq "last") { $sort5 = " selected" } elsif ($sortmode eq "replies") { $sort6 = " selected" } elsif ($sortmode eq "views") { $sort7 = " selected" } elsif ($sortmode eq "rating") { $sort8 = " selected" } elsif ($sortmode eq "none") { $sort1 = " selected" } else { $sort1 = " selected"; $sortmode = ""; } my ( $mask1, $mask2, $mask3, $mask4, $mask5, $mask6, $mask7 )= (); if ($datemask eq "today") { $mask1 = " selected" } elsif ($datemask eq "2") { $mask2 = " selected" } elsif ($datemask eq "5") { $mask3 = " selected" } elsif ($datemask eq "10") { $mask4 = " selected" } elsif ($datemask eq "20") { $mask5 = " selected" } elsif ($datemask eq "30") { $mask6 = " selected" } elsif ($datemask eq "all") { $mask7 = " selected" } else { $mask7 = " selected"; $datemask = ""; } # Mask Old Threads my @tmplist = (); if ( $datemask ne "" && $datemask ne "all") { $date2 = $date; if ($datemask == "today") {$days = "0";} else {$days = $datemask; } for($i=0;$i<$threadcount;$i++) { ($dummy, $dummy, $dummy, $dummy, $date1, $dummy) = split( /\|/, $threadlist[$i], 6 ); &calcdifference; if ($result <= $days) {$tmplist[++$#tmplist] = $threadlist[$i];} } @threadlist = @tmplist; $threadcount = $#threadlist + 1; } # Sort list if ($sortmode ne "" && $sortmode ne "none" && $threadcount > 0) { @tmplist = @threadlist; $date2 = $date; for($i=0;$i<$threadcount;$i++) { ($mnum, $msub, $mname, $dummy, $mdate, $mreplies, $dummy) = split( /\|/, $threadlist[$i], 7 ); if ($sortmode eq "subject") { $tmplist[$i] = $msub."|".$threadlist[$i]; } elsif ($sortmode eq "created") { fopen(FILE, "$datadir/$mnum.txt"); $tmpa = ; fclose(FILE); ($dummy, $dummy, $dummy, $date1, $dummy) = split(/\|/, $tmpa, 5); &calcdifference; $tmplist[$i] = $result."|".$threadlist[$i]; } elsif ($sortmode eq "author") { $tmplist[$i] = $mname."|".$threadlist[$i]; } elsif ($sortmode eq "last") { $date1 = $mdate; &calcdifference; $tmplist[$i] = $result."|".$threadlist[$i]; } elsif ($sortmode eq "replies") { $tmplist[$i] = $mreplies."|".$threadlist[$i]; } elsif ($sortmode eq "views") { if( -e "$datadir/$mnum.data" ) { fopen(FILE, "$datadir/$mnum.data"); $tmpa = ; fclose(FILE); ($views, $dummy) = split(/\|/, $tmpa, 2); $views = $views ? $views - 1 : 0; } else { $views = "0"; } $tmplist[$i] = $views."|".$threadlist[$i]; } elsif ($sortmode eq "rating") { if( -e "$datadir/$mnum.data" ) { fopen(FILE, "$datadir/$mnum.data"); $tmpa = ; fclose(FILE); ($dummy, $dummy, $rate, $dummy) = split( /\|/, $tmpa, 4 ); if ($rate eq "") { $rate = "0"; } } else { $rate = "0"; } $tmplist[$i] = $rate."|".$threadlist[$i]; } } if ($sortmode eq "subject" || $sortmode eq "author") { @sortlist = sort{uc($a) cmp uc($b)} (@tmplist); } elsif ($sortmode eq "created" || $sortmode eq "last") { @sortlist = sort{$a<=>$b} (@tmplist); } else { @sortlist = sort{$b<=>$a} (@tmplist); } for($i=0;$i<$threadcount;$i++) { ($dummy, $tmplist[$i]) = split(/\|/, $sortlist[$i], 2); $threadlist[$i] = $tmplist[$i]."\n"; } chomp(@threadlist); } if ($sortmode eq "$default_sort") {$sortmode = "";} if ($sortmode ne "" ) {$sortmode = ";sort=".$sortmode;} if ($datemask eq "$default_mask") {$datemask = "";} if ($datemask ne "") {$datemask = ";date=".$datemask;} # Make sure the starting place makes sense. if( $start > $threadcount ) { $start = int( $threadcount % $maxindex ) * $maxindex; } elsif( $start < 0 ) { $start = 0; } # There are three kinds of lies: lies, damned lies, and statistics. # - Mark Twain # Construct the page links for this board. $indexdisplaynum = 3; # max number of pages to display $tmpa = 1; $tmpx = int( $threadcount / $maxindex ); if ($start >= (($indexdisplaynum-1) * $maxindex)) { $startpage = $start - (($indexdisplaynum-1) * $maxindex); $tmpa = int( $startpage / $maxindex ) + 1; } if ($threadcount >= $start + ($indexdisplaynum * $maxindex)) { $endpage = $start + ($indexdisplaynum * $maxindex); } else { $endpage = $threadcount } if ($startpage > 0) { $pageindex = qq~1 ... ~; } if ($startpage == $maxindex) { $pageindex = qq~1 ~;} for( $counter = $startpage; $counter < $endpage; $counter += $maxindex ) { $pageindex .= $start == $counter ? qq~$tmpa ~ : qq~$tmpa ~; ++$tmpa; } $tmpx = $threadcount - 1 - $maxindex; $outerpn = int($tmpx / $maxindex); $lastpn = int(($threadcount - 1) / $maxindex) + 1; $lastptn = ($lastpn - 1) * $maxindex; if ($endpage < $threadcount - $maxindex ) {$pageindexadd = qq~ ... ~;} if ($endpage != $threadcount) {$pageindexadd .= qq~ $lastpn~;} $pageindex .= $pageindexadd; # 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); # 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]; # Sticky Threads fopen(FILE, "$boardsdir/sticky.stk") || &fatal_error("300 $txt{'106'}: $txt{'23'} sticky.stk"); @stickys = ; $stickycount = $#stickys; fclose(FILE); for ($i=0; $i<=$threadcount; $i++) { ($mnum) = split( /\|/, $threadlist[$i] ); $l = 0; $is = 0; foreach $curnum (@stickys) { if ($mnum == $curnum) { $is = 1; $stickylist{$l} = $threadlist[$i]; #splice(@threadlist,$i,1); last; } $l++; } if ($is == 0) { push(@threadlist2,$threadlist[$i]); } } if (!($threadlist2[0])) { shift(@threadlist2); } #now sort the stickys @stickylist2 = sort {$b <=> $a } keys %stickylist; for ($i=0; $i<=$stickycount; $i++) { chomp $stickylist{$i}; if ($stickylist{$i}) { unshift(@threadlist2,"$stickylist{$i}\n"); } } $counter = 0; $tmpa = ''; if($counter < $start && ($buffer = $threadlist2[$counter])) { $tmpa = $buffer; $counter++; } while($counter < $start && ($buffer = $threadlist2[$counter])) { $counter++; } $#threads = $maxindex - 1; $curln = $counter; $counter = 0; while( $counter < $maxindex && ( $buffer = $threadlist2[$curln+$counter] ) ) { chomp $buffer; $threads[$counter] = $buffer; $counter++; } $#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. $curboardurl = $curposlinks ? qq~$boardname~ : $boardname; $yymain .= qq~
   $mbname
   $cat
   $curboardurl
$showmods
~; if($ShowBDescrip && $bdescrip ne "") { $yymain .= qq~
$bdescrip
~; } $yymain .= qq~
$txt{'139'}: $pageindex ~; if ($username ne 'Guest') { if($showmarkread) { $yymain .= qq~$img{'markboardread'}~; } } $yymain .= qq~ $menusep$img{'newthread'} $img{'createpoll'} 
~; # Begin printing the message index for current board. if ($threadcount == 0) { $sortcolspan = 7; if ($enable_topicrating == 1) {++$sortcolspan;} if (($settings[7] eq 'Administrator' && $adminview != 0) || ($settings[7] eq 'Global Moderator' && $gmodview != 0) || (exists $moderators{$username} && $modview != 0)){++$sortcolspan;} $yymain .= qq~ ~; } $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. $threadclass = 'thread'; if( $mstate == 1 ) { $threadclass = 'locked'; } elsif( $mreplies > 24 ) { $threadclass = 'veryhotthread'; } elsif( $mreplies > 14 ) { $threadclass = 'hotthread'; } elsif( $mstate == 0 ) { $threadclass = 'thread'; } foreach $curnum (@stickys) { if ($mnum == $curnum) { if($threadclass eq 'locked') { $threadclass = 'stickylock'; } else { $threadclass = 'sticky'; } } } $pollthread = 0; fopen (FILE, "$datadir/$mnum.poll"); @data = ; fclose (FILE); chomp $data[0]; ($question, $lockstatus) = split(/\|/, $data[0]); if (-e "$datadir/$mnum.poll") { $micon = "poll_icon"; } if ($lockstatus eq "Locked") { $micon = "poll_icon_closed"; } else { $pollimg = qq~$img{'pollicon'}~; } # 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. ## LAST READ MOD ## $stuff = &getlog($mnum); ($dlp, $lastread) = split( /\|/, $stuff ); if ($lastread ne '') { $lastread = qq~;start=$lastread#$lastread~;} ## /LAST READ MOD ## $threaddate = stringtotime($mdate); if( $max_log_days_old && $dlp != $threaddate && $username ne 'Guest' && &getlog("$currentboard--mark") < $threaddate ) { ## LAST READ MOD ## $new = qq~$txt{'302a'}~; ## /LAST READ MOD ## } else { $new = ''; } # Load the current nickname of the account name of the thread starter. if( $musername ne 'Guest' && -e "$memberdir/$musername.dat" ) { &LoadUser($musername); fopen(FILE, "$datadir/$mnum.txt"); $starter = ; fclose(FILE); ($boards, $names, $emails, $startdate, $repliess, $usernames, $icons, $states) = split( /\|/, $starter ); $startdate = &timeformat($startdate); $mname = $userprofile{$musername}->[1] || $mname || $txt{'470'}; # $mname = qq~$mname
$txt{'30'} $startdate
~; } else { $mname ||= $txt{'470'}; } # ADDED Get date of first post. # $startdate = $mdate; if (-e ("$imagesdir/$musername.gif" )) { $mname = qq~$musername
$txt{'30'} $startdate
~; } else { $mname = qq~$mname
$txt{'30'} $startdate
~; } # 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~
« $txt{'139'} $pages »~; } if(fopen(FILE, "$datadir/$mnum.data")) { $tmpa = ; @other_stuff = ; fclose(FILE); chomp $tmpa; } 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); $yymain .= qq~
~; ++$counter; } $yymain .= qq~
  $txt{'70'} $txt{'109'} $txt{'110'} $txt{'301'} $txt{'111'}

$sorttxt{'4'}

$new $msub $pages $mname $mreplies $views $mydate
$txt{'525'} $lastpostername
~; if ($enable_sortbar == 1) { $yymain .= qq~
~; } $yymain .= qq~
~; if ($enable_sortbar == 1) { $yymain .= qq~ ~; &jumpto; } else { $yymain .= qq~ ~; } $yymain .= qq~
$txt{'139'}: $pageindex $sorttxt{'10'}:   $sorttxt{'20'}:   ~; if ($username ne 'Guest') { if($showmarkread) { $yymain .= qq~$img{'markboardread'}~; } } &jumpto; # Modification 2 $yymain .= qq~ $menusep$img{'newthread'} $img{'createpoll'} 

~; if ($enable_sortbar == 1) { $yymain .= qq~
~; } $yymain .= qq~
$txt{'457'}
$txt{'454'}
$txt{'455'}
$txt{'456'}
$txt{'779'}
$txt{'780'}
$selecthtml
~; $yytitle = $boardname; &template; exit; } sub MarkRead { # Mark all threads in this board as read. &dumplog("$currentboard--mark"); $yySetLocation = qq~$scripturl~; &redirectexit; } 1;