############################################################################### # Recent.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 3.0 Beta # # Packaged: October 05, 2010 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $recentplver = 'YaBB 3.0 Beta $Revision: 328 $'; if ($action eq 'detailedversion') { return 1; } # Sub Recent_Topics_Posts shows # - all the most recently posted topics (recenttopics) # - OR the X last POSTS (recent) # Meaning each thread will show up ONCE in the list (recenttopics) # OR all new post will be shown even if from the same thread (recent) sub Recent_Topics_Posts { &spam_protection; my ($recent_topics, $display, @data, $numfound, %catid, %catname, $curboard, $boardperms, $i, $c, @mess, @messages, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $mns, $mtime, $board, $notify, $registrationdate, $icanbypass, @bdlist); $recent_topics = $action eq 'recenttopics' ? 1 : 0; $display = $FORM{'display'} || $INFO{'display'} || 10; if ($display < 0) { $display = 5; } elsif ($display > $maxrecentdisplay) { $display = $maxrecentdisplay; } $numfound = 0; &get_forum_master; foreach my $catid (@categoryorder) { my ($catname, $catperms) = split(/\|/, $catinfo{$catid}); unless (&CatAccess($catperms)) { next; } (@bdlist) = split(/\,/, $cat{$catid}); &recursive_check(@bdlist) } sub recursive_check { foreach $curboard (@_) { ($boardname{$curboard}, $boardperms, undef) = split(/\|/, $board{$curboard}); if (!$iamadmin && &AccessCheck($curboard, '', $boardperms) ne "granted") { next; } $catid{$curboard} = $catid; $catname{$curboard} = $catname; my @buffer = &read_DBorFILE(0,'',$boardsdir,$curboard,'txt'); for ($i = 0; ($i < $display && $buffer[$i]); $i++) { ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split(/\|/, $buffer[$i]); chomp $tstate; if ($tstate !~ /h/ || $iamadmin || $iamgmod) { $data[$numfound] = "$tdate|$curboard|$tnum|$treplies|$tusername|$tname|$tstate"; $numfound++; } } if($subboard{$curboard}) { &recursive_check(split(/\|/,$subboard{$curboard})); } } } @data = sort {$b <=> $a} @data; $numfound = 0; $notify = $recent_topics ? scalar @data : (@data > $display ? $display : scalar @data); for ($i = 0; $i < $notify; $i++) { ($mtime, $curboard, $tnum, $treplies, $tusername, $tname, $tstate) = split(/\|/, $data[$i]); next if !(@mess = &read_DBorFILE(0,'',$datadir,$tnum,'txt')); for ($c = ($recent_topics ? $#mess : (@mess > $display ? @mess - $display : 0)); $c < @mess; $c++) { chomp($mess[$c]); if ($mess[$c]) { ($msub, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $message, $mns) = split(/\|/, $mess[$c]); $messages[$numfound] = "$mdate|$curboard|$tnum|$c|$tusername|$tname|$msub|$mname|$memail|$mdate|$musername|$micon|$mreplyno|$mip|$message|$mns|$tstate|$mtime"; $numfound++; } } if ($recent_topics && $numfound == $display) { last; } } @messages = sort {$b <=> $a} @messages; if ($numfound > 0) { if ($numfound > $display) { $numfound = $display; } &LoadCensorList; $icanbypass = &checkUserLockBypass; } else { $yymain .= qq~
$maintxt{'170'}
~; } for ($i = 0; $i < $numfound; $i++) { (undef, $board, $tnum, $c, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $message, $mns, $tstate, $trstart) = split(/\|/, $messages[$i]); if ($tusername ne 'Guest') { &LoadUser($tusername); } if (${$uid.$tusername}{'regtime'}) { $registrationdate = ${$uid.$tusername}{'regtime'}; } else { $registrationdate = $date; } if (${$uid.$tusername}{'regdate'} && $trstart > $registrationdate) { $tname = qq~${$uid.$tusername}{'realname'}~; } elsif ($tusername !~ m~Guest~ && $trstart < $registrationdate) { $tname = qq~$tname - $maintxt{'470a'}~; } else { $tname = "$tname ($maintxt{'28'})"; } if ($musername ne 'Guest') { &LoadUser($musername); } if (${$uid.$musername}{'regtime'}) { $registrationdate = ${$uid.$musername}{'regtime'}; } else { $registrationdate = $date; } if (${$uid.$musername}{'regdate'} && $mdate > $registrationdate) { $mname = qq~${$uid.$musername}{'realname'}~; } elsif ($musername !~ m~Guest~ && $mdate < $registrationdate) { $mname = qq~$mname - $maintxt{'470a'}~; } else { $mname = "$mname ($maintxt{'28'})"; } &wrap; ($message, undef) = &Split_Splice_Move($message,$tnum); if ($enable_ubbc) { $ns = $mns; if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; &ToChars($message); $message = &Censor($message); ($msub, undef) = &Split_Splice_Move($msub,0); &ToChars($msub); $msub = &Censor($msub); if ($iamguest) { $notify = ''; } else { if (${$uid.$username}{'thread_notifications'} =~ /\b$tnum\b/) { $notify = qq~$menusep$img{'del_notify'}~; } else { $notify = qq~$menusep$img{'add_notify'}~; } } $mdate = &timeformat($mdate); # generate a sub board tree my $boardtree = ''; my $parentboard = $board; while($parentboard) { my ($pboardname, undef, undef) = split(/\|/, $board{"$parentboard"}); &ToChars($pboardname); if(${$uid.$parentboard}{'canpost'}) { $pboardname = qq~$pboardname~; } else { $pboardname = qq~$pboardname~; } $boardtree = qq~ / $pboardname$boardtree~; $parentboard = ${$uid.$parentboard}{'parent'}; } $yymain .= qq~
~ . ($i + 1) . qq~  $catname{$board}$boardtree / $msub
 $maintxt{'30'}: $mdate 
$maintxt{'109'} $tname | $maintxt{'197'} $mname  ~; if ($tstate != 1 && (!$iamguest || $enable_guestposting)) { $yymain .= qq~$img{'reply'}$menusep$img{'recentquote'}$notify~; } if ($staff && ($icanbypass || $tstate !~ /l/i) && (!$iammod || &is_moderator($username,$board))) { &LoadLanguage('Display'); $yymain .= $recent_topics ? qq~$menusep$img{'delete'}~ : qq~$menusep$img{'delete'}~; } $yymain .= qq~  
$message

~; } if ($img_greybox) { $yyinlinestyle .= qq~\n~; $yyjavascript .= qq~ var GB_ROOT_DIR = "$yyhtml_root/greybox/"; // -->