функция последние 10 сообщений я вроде наладил, но всё равно работает с 10 попытки (раньше и так не работало)...
Проблема в том что скрипту похоже не хватает ресурсов (ограничения срабатывают)...
Вот скрипт
###############################################################################
# Recent.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 © 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 #
###############################################################################
$recentplver = "1 Gold - SP 1.3";
sub stringtotime1 {
unless( $_[0] ) { return 0; }
my( $adate, $atime ) = split(m~ $txt{'107'} ~, $_[0]);
my( $amonth, $aday, $ayear ) = split(m~/~, $adate);
my( $ahour, $amin, $asec ) = split (m~:~, $atime);
$asec = int($asec) || 0;
$amin = int($amin) || 0;
$ahour = int($ahour) || 0;
$ayear = int($ayear) || 0;
$amonth = int($amonth) || 0;
$aday = int($aday) || 0;
$ayear += 100;
if( $amonth < 1 ) { $amonth = 0; }
elsif( $amonth > 12 ) { $amonth = 11; }
else { --$amonth; }
if( $aday < 1 ) { $aday = 1; }
elsif( $aday > 31 ) { $aday = 31; }
return( $asec+(($amin+(($ahour+(($aday+(($amonth+(($ayear-2000)*12))*31))*24))*60))*60)); return( timelocal($asec, $amin, $ahour, $aday, $amonth, $ayear) - (3600*$timeoffset) );
}
***
sub RecentPosts {
my $display = 10;
my( @memset, @categories, %data, %cat, $numfound, $oldestfound, $curcat, %catname, %cataccess, %catboards, $openmemgr, @membergroups, %openmemgr, $curboard, @threads, @boardinfo, $i, $c, @messages, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mns, $mtime, $counter, $board, $notify );
@categories = ();
fopen(FILE, "$vardir/cat.txt");
@categories = <FILE>;
fclose(FILE);
$oldestfound = stringtotime("01/10/37 $txt{'107'} 00:00:00");
foreach $curcat (@categories) {
chomp $curcat;
fopen(FILE, "$boardsdir/$curcat.cat");
$catname{$curcat} = <FILE>;
chomp $catname{$curcat};
$cataccess{$curcat} = <FILE>;
chomp $cataccess{$curcat};
@{$catboards{$curcat}} = <FILE>;
fclose(FILE);
$openmemgr{$curcat} = 0;
@membergroups = split( /,/, $cataccess{$curcat} );
foreach $tmpa (@membergroups) {
if( $tmpa eq $settings[7]) { $openmemgr{$curcat} = 1; last; }
}
if( ! $cataccess{$curcat} || $settings[7] eq 'Administrator' || $settings[7] eq 'Global Moderator' ) {
$openmemgr{$curcat} = 1;
}
unless( $openmemgr{$curcat} ) { next; }
foreach $curboard (@{$catboards{$curcat}}) {
chomp $curboard;
fopen(FILE, "$boardsdir/$curboard.txt");
@threads = <FILE>;
fclose(FILE);
fopen(FILE, "$boardsdir/$curboard.dat");
@boardinfo = <FILE>;
fclose(FILE);
foreach (@boardinfo) {
chomp;
}
@{$boardinfo{$curboard}} = @boardinfo;
$cat{$curboard} = $curcat;
for ($i = 0; $i < @threads; $i++) {
chomp $threads[$i];
($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split( /|/, $threads[$i] );
fopen(FILE, "$datadir/$tnum.txt") || next;
while( <FILE> ) { $message = $_; }
# get only the last post for this thread.
fclose(FILE);
chomp $message;
if( $message ) {
($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = split(/|/,$message);
if ($mdate) {
$mtime = stringtotime1($mdate);
if( $numfound >= $display && $mtime <= $oldestfound ) {
next;
}
else {
$data{$mtime} = [$curboard, $tnum, $treplies, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $tstate];
if( $mtime < $oldestfound ) { $oldestfound = $mtime; }
++$numfound;
}
}
}
}
}
}
@messages = sort {$b <=> $a } keys %data;
if( @messages ) {
if( @messages > $display ) { $#messages = $display - 1; }
$counter = 1;
# Load Censor List
&LoadCensorList;
}
else {
$yymain .= qq~<hr class="hr"><b>$txt{'170'}</b><hr>~;
}
for( $i = 0; $i < @messages; $i++ ) {
($board, $tnum, $c, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $tstate) = @{ $data{$messages[$i]} };
$displayname = $mname;
if( $tusername ne 'Guest' ) {
&LoadUser($tusername);
$tname = exists $userprofile{$tusername} ? $userprofile{$tusername}->[1] : $tname;
$tname ||= $txt{'470'};
$tname = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$tusername}" alt="$txt{'27'}: $musername">$tname</a>~;
}
if( $musername ne 'Guest' ) {
&LoadUser($musername);
$mname = exists $userprofile{$musername} ? $userprofile{$musername}->[1] : $mname;
$mname ||= $txt{'470'};
$mname = qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$musername}" alt="$txt{'27'}: $musername">$mname</a>~;
}
foreach (@censored) {
($tmpa,$tmpb) = @{$_};
$message =~ s~Q$tmpaE~$tmpb~gi;
$msub =~ s~Q$tmpaE~$tmpb~gi;
}
&wrap;
if($enable_ubbc) { $ns = $mns; if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; }
&wrap2;
if($enable_notification) { $notify = qq~$menusep<a href="$scripturl?board=$board;action=notify;thread=$tnum;start=$startnum">$img{'notify'}</a>~; }
$mdate = &timeformat($mdate);
$yymain .= qq~
<table border="0" width="100%" cellspacing="1" bgcolor="$color{'bordercolor'}" class="bordercolor">
<tr>
<td align="left" bgcolor="$color{'titlebg'}" class="titlebg"><font class="text1" color="$color{'titletext'}" size="2"> $counter </font></td>
<td width="75%" bgcolor="$color{'titlebg'}" class="titlebg"><font class="text1" color="$color{'titletext'}" size="2"> $catname{$cat{$board}} / $boardinfo{$board}->[0] / <a href="$scripturl?board=$board;action=display;num=$tnum;start=$c#$c"><u><font class="text1" color="$color{'titletext'}" size="2">$msub</font></a></font></u></td>
<td align="right" bgcolor="$color{'titlebg'}" class="titlebg" nowrap> <font class="text1" color="$color{'titletext'}" size="2">$mdate </font></td>
</tr><tr>
<td colspan="3" bgcolor="$color{'catbg'}" class="catbg"><font class="catbg" size="2">$txt{'109'} $tname | $txt{'22'} $txt{'525'} $mname</font></td>
</tr><tr height="80">
<td colspan="3" bgcolor="$color{'windowbg2'}" class="windowbg2" valign=top><font size="2">$message</font></td>
</tr><tr>
<td colspan="3" bgcolor="$color{'catbg'}" class="catbg"><font size="2">
~;
if ($tstate != 1)
{
$yymain .= qq~<a href="$scripturl?board=$board;action=post;num=$tnum;start=$c;title=Post+reply">$img{'reply'}</a>$menusep<a href="$scripturl?board=$board;action=post;num=$tnum;quote=$c;title=Post+reply">$img{'replyquote'}</a>$notify~;
}
$yymain .= qq~
</font></td>
</tr>
</table><br>
~;
++$counter;
}
$yymain .= qq~
<font size="1"><a href="$cgi">$txt{'236'}</a> $txt{'237'}<br></font>
~;
$yytitle = $txt{'214'};
&template;
exit;
}
1;
Так вот если закоментировать красную строчку, то скрипт работать не будет совсем... Если у кого есть соображения, поделитесь...