############################################################################### # MessageIndex.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.3 # # Released: December 2001; Updated April 6, 2003 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2003 YaBB (www.yabbforum.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # # Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com # ############################################################################### $messageindexplver = "1 Gold - SP 1.3"; 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]; # 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; ###Next 2 lines Sticky Group mod $stkynum = ''; if($start < $maxdisplay){ $stkynum = scalar @stickylist2; } 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; if((exists $moderators{$username} && $modview == 1) || ($settings[7] eq 'Administrator' && $adminview == 1) || ($settings[7] eq 'Global Moderator' && $gmodview == 1)) { $yymain .= qq~~; } $yymain .= qq~
   $mbname
   $cat
   $curboardurl
$showmods
~; if (($settings[7] eq 'Administrator' && $adminview >= 2) || ($settings[7] eq 'Global Moderator' && $gmodview >= 2) || (exists $moderators{$username} && $modview >= 2)){ $yymain .= qq~
~; } 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'}$menusep$img{'createpoll'} 
~; # Look for reverse order this tboard if ( -e "$boardsdir/$currentboard.reverse" ) { $revboard=1; if( $settings[7] eq 'Administrator' || (exists $moderators{$username}) ) { $yymain .= qq~ ~; } else { $yymain .= qq~~; } } else { $revboard=0; if( $settings[7] eq 'Administrator' || (exists $moderators{$username}) ) { $yymain .= qq~ ~; } else { $yymain .= qq~~; } } $yymain .= qq~ ~; ###Start Sticky Group mod if($stkynum){ $yymain .= qq~ ~; } ###End Sticky Group mod ~; if (($settings[7] eq 'Administrator' && $adminview == 3) || ($settings[7] eq 'Global Moderator' && $gmodview == 3) || (exists $moderators{$username} && $modview == 3)){ $yymain .= qq~ ~; } elsif (($settings[7] eq 'Administrator' && $adminview != 0) || ($settings[7] eq 'Global Moderator' && $gmodview != 0) || (exists $moderators{$username} && $modview != 0)){ $yymain .= qq~ ~; } $yymain .= qq~ # 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. $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 = ''; } if ( $settings[7] eq 'Administrator' || (exists $moderators{$username}) ) { if ( $revboard == 1 ) { if (-e "$datadir/$mnum.reverse") {$new = qq~$new $rordertxt{'2'}~;} else {$new = qq~$new $rordertxt{'1'}~;} } else { if (-e "$datadir/$mnum.reverse") {$new = qq~$new $rordertxt{'1'}~;} else {$new = qq~$new $rordertxt{'2'}~;} } } else { if ( $revboard == 1 ) { if (-e "$datadir/$mnum.reverse") {;} else {$new = qq~$new $rordertxt{'1'}~;} } else { if (-e "$datadir/$mnum.reverse") {$new = qq~$new $rordertxt{'1'}~;} } } # 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; # Look for reverse order this thread. if (-e "$datadir/$mnum.reverse") { $revthread = 1; } else { $revthread = 0; } $has_reverse=0 ; if ( $revboard && !$revthread ) { $has_reverse=1; } else { if ( !$revboard && $revthread ) {$has_reverse=1; } } if ( $has_reverse ) { for( $tmpb = $threadlength-1; $tmpb > -1 ; $tmpb -= $maxmessagedisplay ) { $pages .= qq~$tmpa\n~; ++$tmpa; } } else{ for( $tmpb = 0; $tmpb < $threadlength; $tmpb += $maxmessagedisplay ) { $pages .= qq~$tmpa\n~; ++$tmpa; } } $pages =~ s/\n\Z//; $pages = qq~
« $txt{'139'} $txt_sb{'1001'} $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; ###Start Sticky Group mod if(($stkynum && ($counter >= $stkynum)) && ($stkyshowed < 1)){ $yymain .= qq~
~; $stkyshowed = 1; } ###End Sticky Group mod # Print the thread info. $mydate = &timeformat($mdate); $yymain .= qq~ ~; if (($settings[7] eq 'Administrator' && $adminview == 3) || ($settings[7] eq 'Global Moderator' && $gmodview == 3) || (exists $moderators{$username} && $modview == 3)){ $yymain .= qq~ ~; } elsif (($settings[7] eq 'Administrator' && $adminview == 2) || ($settings[7] eq 'Global Moderator' && $gmodview == 2) || (exists $moderators{$username} && $modview == 2)){ $yymain .= qq~ ~; } elsif (($settings[7] eq 'Administrator' && $adminview == 1) || ($settings[7] eq 'Global Moderator' && $gmodview == 1) || (exists $moderators{$username} && $modview == 1)){ $yymain .= qq~ ~; } $yymain .= qq~ ~; ++$counter; $mcount++; } fopen(FILE, "$vardir/cat.txt"); @categories = ; fclose(FILE); $boardlist=""; foreach $curcat (@categories) { $curcat =~ s/[\n\r]//g; fopen(CAT, "$boardsdir/$curcat.cat"); @catinfo = ; fclose(CAT); $catinfo[1] =~ s/[\n\r]//g; $curcatname="$catinfo[0]"; boardcheck: foreach $curboard (@catinfo) { $curboard =~ s/[\n\r]//g; fopen(BOARD, "$boardsdir/$curboard.dat"); @boardinfo = ; fclose(BOARD); chomp @boardinfo; $curboardname = $boardinfo[0]; if($curboard ne "$catinfo[0]" && $curboard ne "$catinfo[1]" && $currentboard ne $curboard) { $curboard =~ s/[\n\r]//g; $boardlist .= " ~; } elsif (($settings[7] eq 'Administrator' && $adminview == 2) || ($settings[7] eq 'Global Moderator' && $gmodview == 2) || (exists $moderators{$username} && $modview == 2)){ $yymain .= qq~ ~; } $yymain .= qq~
  $rordertxt{'1'} $txt{'70'}$txt{'70'} $rordertxt{'2'} $txt{'70'}$txt{'70'}$txt{'109'} $txt{'110'} $txt{'301'} $txt{'111'}
 $stickygrp{'1'}
$txt{'104'} $txt{'781'} $txt{'132'} $txt{'63'}$txt{'2'}
 $stickygrp{'2'}
$micon $new $mpoll$msub $pages $mname $mreplies $views $mydate
$txt{'525'} $lastpostername
$txt{'104'}  $txt{'781'}  $txt{'132'}  $txt{'63'}
$txt{'133'}:   $txt{'737'}
$txt{'104'}   $txt{'781'}   $txt{'31'}   $txt{'133'}:   $txt{'737'}
$txt{'139'}: $pageindex ~; if ($username ne 'Guest') { if($showmarkread) { $yymain .= qq~$img{'markboardread'}~; } } &jumpto; $yymain .= qq~ $menusep$img{'newthread'}$menusep$img{'createpoll'} 

~; if (($settings[7] eq 'Administrator' && $adminview >= 2) || ($settings[7] eq 'Global Moderator' && $gmodview >= 2) || (exists $moderators{$username} && $modview >= 2)) { if (($settings[7] eq 'Administrator' && $adminview == 3) || ($settings[7] eq 'Global Moderator' && $gmodview == 3) || (exists $moderators{$username} && $modview == 3)) { $offset="6"; } else { $offset="7"; } $yymain .= qq~
~; } $yymain .= qq~
$brdsrch{'1'}:  $brdsrch{'2'} $txt{'579'}. $brdsrch{'3'}: 

$txt{'457'}
$txt{'454'}
$txt{'455'}
$txt{'456'}
$txt{'779'}
$txt{'780'}
$selecthtml
~; ### Quick Reply Box 1.3 ### # MBCO2 Post access check if ($start_users{$currentboard} || $start_groups{$currentboard}) { my $access = &AccessCheck($currentboard, 1) || ""; if ($access eq "denied") {$enable_quickpost = 0;} } if ($username ne "Guest" && $enable_quickpost == 1) { $yymain .= qq~
$qrb_txt{'1'}
~; if ($enable_quicksmilies == 1) { if ($smiliestyle eq 1){$smiliewinlink = "$scripturl?action=smilieput";} else { $smiliewinlink = "$scripturl?action=smilieindex";} $moresmilieslist = ""; $more_smilie_array = ""; $i=0; if ($showadded eq 1){ # show added smilies on smiley bar while($SmilieURL[$i]) { if ($SmilieURL[$i]=~ /\//i) {$tmpurl = $SmilieURL[$i];} else {$tmpurl = qq~$imagesdir/$SmilieURL[$i]~;} $moresmilieslist .= qq~ document.write("+'$SmilieLinebreak[$i] ");\n~; $tmpcode = $SmilieCode[$i]; $tmpcode =~ s/\"/"+'"'+"/g; &FromHTML($tmpcode); $tmpcode =~ s/$/\$/g; $tmpcode =~ s/@/\@/g; $more_smilie_array .= qq~" $tmpcode", ~; $i++; } } if ($showsmdir eq 1){ # show auto smilies on smiley bar opendir(DIR, "$smiliesdir"); @contents = readdir(DIR); closedir(DIR); foreach $line (sort {uc($a) cmp uc($b)} @contents){ ($name, $extension) = split (/\./, $line); if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i ){ if ($line !~ /banner/i) { $moresmilieslist .= qq~ document.write("$name ");\n~; $more_smilie_array .= qq~" [smiley=$line]", ~; $i++ } } } } $more_smilie_array .= qq~""~; $yymain .= qq~ ~; } $yymain .= qq~
$txt{'70'}:
$txt{'297'}: ~; if ($showadded == 3 || ($showadded == 2 && $detachblock == 1) || $showsmdir == 3 || ($showsmdir == 2 && $detachblock == 1)){ $yymain .= qq~ $smiltxt{'1'}~; } $yymain .= qq~
$txt{'72'}:
 
~; } ### Quick Reply Box 1.3 ### $yytitle = $boardname; &template; exit; } sub MarkRead { # Mark all threads in this board as read. &dumplog("$currentboard--mark"); $yySetLocation = qq~$scripturl~; &redirectexit; } sub Rorder{ my $rev = $INFO{'num'}; my $th = $INFO{'thname'}; if ( $rev==0 ) { if (-e "$boardsdir/$currentboard.reverse") {unlink("$boardsdir/$currentboard.reverse");} else { fopen (FILE, ">$boardsdir/$currentboard.reverse"); fclose (FILE); } } else { if (-e "$datadir/$rev.reverse") {unlink("$datadir/$rev.reverse");} else { fopen (FILE, ">$datadir/$rev.reverse"); print FILE "Board: $currentboard - Topic: $th"; fclose (FILE); } } $yySetLocation = qq~$cgi\;~; &redirectexit; } 1;