############################################################################### # 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 ); 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; } # 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]; # Begin FTT Corporation language mod &openlngboardfile; $lngcurlngboard = $currentboard."_".$languagecode; if ($lngboard{$lngcurlngboard} eq "on") { $bdescrip = &getlngboard2($currentboard); } # End FTT Corporation language mod # 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 = ; $threadcount = $#threadlist; @threadlist2 = ''; fclose(FILE); # 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); # Begin addon for boardlinksSP1 $blink = ''; $i=0; $ii=0; while($LinkBoard[$i]) { if ($LinkBoard[$i] eq $currentboard){ if ($ii == 0){ if ( $LinkURL[$i] =~ m/\°/ ) { $blink .= qq~$LinkName[$i]~; } else { $blink .= qq~$LinkName[$i]~; } $ii=1; } else { if ( $LinkURL[$i] =~ m/\°/ ) { $blink .= qq~$blinkstxt{'13'}$LinkName[$i]~; } else { $blink .= qq~$blinkstxt{'13'}$LinkName[$i]~; } } } $i++; } if ($blink ne ''){ $blink = qq~
$blinkstxt{'12'}$boardname
$blink


~; } if ($boardlinks != 1) { $blink =~ s~\°~\@~ig; $yymain .= "$blink"; } # End addon for boardlinksSP1 # 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'}~; } # --- Added for Notify Plus 2.2 --- # # Notification on Board-level is enabled ? if($enable_notification_board == 1) { $yymain .= qq~$menusep$img{'notify'}~; } # --- /Added for Notify Plus 2.2 --- # } $yymain .= qq~ $menusep$img{'newthread'}$menusep$img{'createpoll'} 
~; # Begin printing the message index for current board. $counter = $start; foreach( @threads ) { ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split( /\|/, $_ ); # --- Added for Notify Plus 2.2 --- # # Reset Mark-image $markimg = ""; # Is mark thread enabled and it's a Member ? if ($enable_mark_thread == 1 && $username ne 'Guest') { # Has the member a notification on this thread ?! if (fopen(FILE, "$datadir/$mnum.mail")) { # Read all records fopen(FILE, "$datadir/$mnum.mail"); @mails = ; fclose(FILE); foreach $record (@mails) { chomp($record); ($email, $format) = split(/\|/, $record); chomp($email); # Yep, Notification found if ($email eq $settings[2]) { $markimg = qq~~; last; } # End Foreach } # End if Has the member a notification } # End if Is mark thread enabled } # --- /Added for Notify Plus 2.2 --- # # 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'; } } } # 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. $micon = qq~~; $mpoll = ""; if (-e "$datadir/$mnum.poll") { $mpoll = qq~$polltxt{'15'}: ~; fopen (FILE, "$datadir/$mnum.poll"); $poll_question = ; fclose (FILE); chomp $poll_question; ($dummy, $poll_locked, $dummy) = split(/\|/, $poll_question, 3); $micon = qq~$img{'pollicon'}~; if ($poll_locked) { $micon = $img{'polliconclosed'}; } else { fopen(FILE, "$datadir/$mnum.polled"); $polled = ; fclose(FILE); $dlp = &getlog($mnum); ($dummy, $dummy, $dummy, $vote_date, $dummy) = split(/\|/, $polled); $vote_date = stringtotime($vote_date); if( $max_log_days_old && $dlp < $vote_date && $username ne 'Guest' && &getlog("$currentboard--mark") < $vote_date ) {$micon = qq~$img{'polliconnew'}~;} } } 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~
« $txt{'139'} $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; if ($userprofile{$musername}->[7] eq 'Administrator' && $micon eq "lamp"){$backbg = "announcebg"; } elsif ($userprofile{$musername}->[7] eq 'Administrator' && $micon eq "exclamation"){$backbg = "adminbg"; } else {$backbg = "windowbg2"; } # Print the thread info. $mydate = &timeformat($mdate); $yymain .= qq~
~; ++$counter; } $yymain .= qq~
  $txt{'70'} $txt{'109'} $txt{'110'} $txt{'301'} $txt{'111'}
$micon $new $mpoll $markimg $msub $pages $mname $mreplies $views $mydate
$txt{'525'} $lastpostername
$txt{'139'}: $pageindex ~; if ($username ne 'Guest') { if($showmarkread) { $yymain .= qq~$img{'markboardread'}~; } # --- Added for Notify Plus 2.2 --- # # Notification on Board-level is enabled ? if($enable_notification_board == 1) { $yymain .= qq~$menusep$img{'notify'}~; } # --- /Added for Notify Plus 2.2 --- # } &jumpto; $yymain .= qq~ $menusep$img{'newthread'}$menusep$img{'createpoll'} 

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