############################################################################### # 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 (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 # ############################################################################### $recentplver = "1 Gold - SP 1.3"; sub LastPost { # easiest way to add check if cat.txt was loaded in Recent.pl or BoardIndex.pl before # but not the best. Next releases should have for each file a function in load.pl to read the data # and check on each call if the data was already loaded if( ! $yyCatsLoaded) { fopen(FILE, "$vardir/cat.txt"); @categories = ; fclose(FILE); } # Load Censor List &LoadCensorList; %data= (); foreach $curcat (@categories) { $curcat =~ s/[\n\r]//g; fopen(CAT, "$boardsdir/$curcat.cat"); $curcatname = ; $curcataccess = ; @catboards = ; fclose(CAT); chomp $curcatname; chomp $curcataccess; %membergroups = (); foreach(split(/\,/,$curcataccess)) { $membergroups{$_} = $_; } if($curcataccess) { if($settings[7] ne 'Administrator' && $settings[7] ne 'Global Moderator' && !exists $membergroups{$settings[7]}) { next; } } foreach $curboard (@catboards ) { chomp $curboard; #### unless ($settings[7] eq "Administrator") { my $cookiename = "$cookiepassword$curboard"; my $crypass = crypt($boardpw{$curboard},$pwseed); my $access = &AccessCheck($curboard, ''); if (($boardpw{$curboard} && $yyCookies{$cookiename} ne $crypass) || ($access ne "granted")) { next; } } #### fopen(BOARDDATA, "$boardsdir/$curboard.txt"); $message = ; fclose(BOARDDATA); ($mnum, $msub, $dummy, $dummy, $datetime, $mreplies) = split(/\|/, $message); $mydatetime = &timeformat($datetime); foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } if($recentsender eq "admin") { $post = qq~"$msub" « $mydatetime »\n~; } else { $post = qq~$txt{'235'}: $msub **$txt{'792'}** $txt{'793'}~; } $totaltime = stringtotime($datetime); $data{$totaltime}= $post; } } @num = sort {$b <=> $a } keys %data; $yymain .= "$data{$num[0]}"; } sub RecentPosts { my( $lastmoddate, $lastmoduser ); 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 = ; fclose(FILE); $oldestfound = stringtotime("01/10/37 $txt{'107'} 00:00:00"); foreach $curcat (@categories) { chomp $curcat; fopen(FILE, "$boardsdir/$curcat.cat"); $catname{$curcat} = ; chomp $catname{$curcat}; $cataccess{$curcat} = ; chomp $cataccess{$curcat}; @{$catboards{$curcat}} = ; 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 = ; fclose(FILE); #### unless ($settings[7] eq "Administrator") { my $cookiename = "$cookiepassword$curboard"; my $crypass = crypt($boardpw{$curboard},$pwseed); my $access = &AccessCheck($curboard, ''); if (($boardpw{$curboard} && $yyCookies{$cookiename} ne $crypass) || ($access ne "granted")) { next; } } #### fopen(FILE, "$boardsdir/$curboard.dat"); @boardinfo = ; 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( ) { $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, $lastmoddate, $lastmoduser) = split(/\|/,$message); $mtime = stringtotime($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, $lastmoddate, $lastmoduser]; 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~
$txt{'170'}
~; } for( $i = 0; $i < @messages; $i++ ) { ($board, $tnum, $c, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $tstate, $lastmoddate, $lastmoduser) = @{ $data{$messages[$i]} }; $displayname = $mname; if( $tusername ne 'Guest' ) { &LoadUser($tusername); $tname = exists $userprofile{$tusername} ? $userprofile{$tusername}->[1] : $tname; $tname ||= $txt{'470'}; $tname = qq~$tname~; } if( $musername ne 'Guest' ) { &LoadUser($musername); $mname = exists $userprofile{$musername} ? $userprofile{$musername}->[1] : $mname; $mname ||= $txt{'470'}; $mname = qq~$mname~; } foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } ### Begin Enable HTML Mod $html_username = $musername; if ($message =~ /\#enable_html/isg) { $lastmoduser =~ s~\n~~g; if ($lastmoduser ne $html_username && $lastmoduser ne '') { $html_username = $lastmoduser; } $message_backup = $message; # since $message is no local variable, it often gets overwritten accidently somehwere (couldn't find out where) $enable_html = HTML_allow($html_username); $message = $message_backup; if ($enable_html == 1) { $message =~ s/\#enable_html//isg; $message =~ s/
/\n/ig; &FromHTML($message); } } else { $enable_html = 0; } if ($enable_html != 1) { &wrap; if($enable_ubbc) { $ns = $mns; if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; } ### End Enable HTML Mod if($enable_notification) { $notify = qq~$menusep$img{'notify'}~; } $mdate = &timeformat($mdate); $yymain .= qq~
 $counter   $catname{$cat{$board}} / $boardinfo{$board}->[0] / $msub  $mdate 
$txt{'109'} $tname | $txt{'22'} $txt{'525'} $mname
$message
  ~; if ($tstate != 1) { $yymain .= qq~$img{'reply'}$menusep$img{'replyquote'}$notify~; } $yymain .= qq~

~; ++$counter; } $yymain .= qq~ $txt{'236'} $txt{'237'}
~; $yytitle = $txt{'214'}; &template; exit; } sub WAP { fopen(WAP, "$vardir/wap_posts.txt") || &fatal_error("Could not open file to read posts for WAP browsing."); @wap = ; fclose(WAP); my $i = 1; my $wappost = ''; my $wapsubjlist = ''; foreach $entry(@wap) { ($wapsubj, $wapname, $wapdate, $wapmsg) = split(/\|/, $entry); $wapmsg =~ s~
~
~isg; $wapmsg =~ s~[\$]~\$\$~g; $wapmsg =~ s/\[smilie=(.*?)\]//isg; $wapmsg =~ s/\[smiley=(.*?)\]//isg; $wapsubjlist .= qq~

$wapsubj
$wapdate Door: $wapname

~; $wappost .= qq~

$wapsubj
$wapmsg

~; $i++; } # Send Content-type and Set-Cookie headers print "Content-type: text/vnd.wap.wml \n\n"; # Send WML header info print "\n\n"; print "\n"; # Send deck print qq~

svs

$wapsubjlist
$wappost
~; exit; } 1;