#!/usr/bin/perl ################################################################### # Whoson.pl # # Version: 1.1 # Original Mod by Sonic, updated by LoonyPandora. Special Thanks to Michael Prager ################################################################### ### Version Info ### $YaBBversion = '1 Gold - SP 1.1'; $whosonplver = '1 Gold - SP 1.1'; ###### ################################################# ## Here comes the part you can/have to edit ## ################################################# $display = 8; # number of headlines displayed $snip_headlines_when_longer_than = 30; # snip off a too long title, set 0 to always display the full title $headerfontsize = 2; #Size of Font for Headings $textfontsize = 1; # Font Size for Normal Text $fontcolor = "#000000"; # font color $fontface = "Arial, Helvetica, sans-serif"; # font face $scripturl = qq~$boardurl/YaBB.pl~; # change the .pl ending to .cgi if you have the cgi version of yabb $adv_imbox = 1; #Set to 1 if you have The Advanced IM Box installed $new_mark_colour = "#FF0000"; #Select the colour of the NEW indicator next to posts that have not been read ################################################# &WhoHeader; if ($INFO{'action'} eq 'Members') { &WhoMembers; } elsif ($INFO{'action'} eq 'Users') { &WhoUsers; } elsif ($INFO{'action'} eq 'Time') { &WhatTime; } elsif ($INFO{'action'} eq 'IM') { &WhoIM; } elsif ($INFO{'action'} eq 'Recent') { &WhoRecent; } elsif ($INFO{'action'} eq 'Stats') { &WhoStats; } elsif ($INFO{'action'} eq 'Chat') { &WhoChat; } elsif ($INFO{'action'} eq 'Birthday') { &WhoBirthday; } elsif ($INFO{'action'} eq 'CalStuff') { &CalStuff; } elsif ($INFO{'action'} eq 'ShowAll') { &ShowAll; } exit; sub ShowAll { # Change the order to what you want or delete the ones you don't want # &WhatTime; &WhoIM; &WhoRecent; &WhoStats; &WhoUsers; &WhoMembers; &CalStuff; &WhoBirthday; } sub WhoHeader { ### This section is taken from YaBB.pl ### if( $ENV{'SERVER_SOFTWARE'} =~ /IIS/ ) { $yyIIS = 1; $0 =~ m~(.*)(\\|/)~; $yypath = $1; $yypath =~ s~\\~/~g; chdir($yypath); push(@INC,$yypath); } use CGI::Carp qw(fatalsToBrowser); require "Settings.pl"; require "$language"; require "$sourcedir/Subs.pl"; require "$sourcedir/Load.pl"; use CGI qw/:standard/; ### Load the user's cookie (or set to guest) ### &LoadCookie; if( fopen(FILE, "$memberdir/$username.dat") ) {; @settings=; fclose(FILE); for( $_ = 0; $_ < @settings; $_++ ) { $settings[$_] =~ s~[\n\r]~~g; } $realname = $settings[1]; } ### Prints HTTP headers - based on header in Sub.pl ### if( $yyForceIIS ) { $headers = "HTTP/1.0 200 OK\n"; } $headers .= "Content-type: text/html;CHARSET=$yycharset\n\n"; print $headers; } sub WhatTime { $yytime = &timeformat($date, 1); print qq~ $yytime ~; } sub WhoMembers { my( $memcount, $latestmember ) = &MembershipGet; &LoadUser($latestmember); $thelatestmember = qq~$userprofile{$latestmember}->[1]~; print qq~ » $txt{'331'} $txt{'201'}:
-- $thelatestmember

$whotxt{'12'}:
-- $txt{'303'}
-- $txt{'304'}
-- $txt{'305'} $txt{'411'} $TopAmmount $txt{'306'}
~; } sub WhoUsers { $guests = 0; $counter = 0; $modcounter = 0; $admincounter = 0; $users = ''; $moderators = ''; $admins = ''; fopen(FILE, "$vardir/log.txt"); @entries = ; fclose(FILE); foreach $curentry (@entries) { chomp $curentry; ($name, $value) = split(/\|/, $curentry); if( $name ) { &LoadUser($name); if( exists $userprofile{$name} ) { if ($userprofile{$name}->[7] eq "Administrator") { $admins .= qq~ $userprofile{$name}->[1], \n~; $admincounter++; } elsif ($userprofile{$name}->[7] eq "Global Moderator") { $moderators .= qq~ $userprofile{$name}->[1], \n~; $modcounter++; } else { $users .= qq~ $userprofile{$name}->[1], \n~; $counter++; } } else { ++$guests; } } } $users =~ s~, \n\Z~~; $moderators =~ s~, \n\Z~~; $admins =~ s~, \n\Z~~; $countonl = $counter + $admincounter + $modcounter + $guests; chomp $users; if($users eq '') { $users = "$whotxt{'01'}"; } chomp $admins; if($admins eq '') { $admins = "$whotxt{'01'}"; } chomp $moderators; if($moderators eq '') { $moderators = "$whotxt{'01'}"; } if($countonl eq '') { $countonl = "$whotxt{'01'}"; } print qq~ » $txt{'158'} $txt{'94'}: $countonl

$txt{'684'}:
   $admins
$whotxt{'14'}:
   $moderators
$txt{'142'}:
   $users
$txt{'141'}: $guests
~; } sub WhoIM { if ($username eq 'Guest') { print qq~$txt{'248'} $txt{'28'}. $txt{'249'} $txt{'34'} $txt{'377'} $txt{'97'}.~;} if($username ne "Guest" && $username ne '' && $action ne "logout") { fopen(IM, "$memberdir/$username.msg"); @immessages = ; fclose(IM); fopen(OM, "$memberdir/$username.outbox"); @outmessages = ; fclose(OM); $moutnum=@outmessages; foreach $curline (@immessages) { ($imusername, $imsub, $imdate, $mmessage, $imessageid, $mip, $imnew) = split(/\|/,$curline); if($imnew == 1) { $imnewcount++; } } if($imnewcount eq "") { $imnewcount=0; } if($imnewcount == 1) { $imnewtext = qq~$imtxt{'16'}.~; } else { $imnewtext = qq~$imtxt{'17'}.~; } if($enable_mailsounds == 1) { if($imnewcount > 0 && $action eq "" && $INFO{'board'} eq "" || $imnewcount > 0 && $action eq "login2") { if(fopen (FILE, "$memberdir/$username.imconfig") ) { open(FILE, "$memberdir/$username.imconfig"); @userimcfg = ; close(FILE); $userimcfg[2] =~ s/\n//g; if($userimcfg[2] ne "blank.wav" && $userimcfg[2] ne "") { $imsound = qq~~; } } } } $mnum = @immessages; $minnum = @immessages; } if ($username ne 'Guest') { if ($adv_imbox eq '1') { print qq~ » $whotxt{'15'} $txt{'247'} $realname,
$txt{'152'} $minnum ~; if($minnum == 1) { print $whotxt{'13'}; } else { print $whotxt{'05'}; } print qq~ $imnewcount $imnewtext
~; } if ($adv_imbox eq '0') { print qq~ » $whotxt{'15'} $txt{'247'} $realname,
$txt{'152'} $messnum ~; if($messnum == 1) { print $txt{'153a'}; } else { print $whotxt{'05'}; } print qq~
~; } } else { ### Quick Login Box by Michael ### print qq~ » $whotxt{'09'}
$txt{'35'}:
$txt{'36'}:
$whotxt{'10'}
~; } ###/Quick Login Box ### } sub WhoStats { fopen(FILE, "$vardir/cat.txt"); @categories = ; fclose(FILE); my( $memcount, $latestmember ) = &MembershipGet; print qq~ » $txt{'200'} ~; $totalm = 0; $totalt = 0; for( $catnum = 0; $catnum < @categories; $catnum++ ) { chomp $categories[$catnum]; $curcat = $categories[$catnum]; fopen(FILE, "$boardsdir/$curcat.cat"); $catname{$curcat} = ; chomp $catname{$curcat}; $cataccess{$curcat} = ; chomp $cataccess{$curcat}; @{$catboards{$curcat}} = ; fclose(FILE); @membergroups = split( /,/, $cataccess{$curcat} ); $openmemgr{$curcat} = 0; 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; ( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($curboard); $lastposttime{$curboard} = $lastposttime eq 'N/A' || ! $lastposttime ? $txt{'470'} : &timeformat($lastposttime); $lastpostrealtime{$curboard} = $lastposttime eq 'N/A' || ! $lastposttime ? '' : $lastposttime; if( $lastposter =~ m~\AGuest-(.*)~ ) { $lastposter = $1; $lastposterguest{$curboard} = 1; } $lastposter{$curboard} = $lastposter eq 'N/A' || ! $lastposter ? $txt{'470'} : $lastposter; $messagecount{$curboard} = $messagecount || 0; $threadcount{$curboard} = $threadcount || 0; $totalm += $messagecount; $totalt += $threadcount; } } print qq~ $txt{'488'}  $memcount
$txt{'489'}  $totalm
$txt{'490'}  $totalt
~; } ########## Insert Newcalendar Stuff ########## sub CalStuff { if(-e("$sourcedir/Newcalendar.pl")) { print qq~ » $whotxt{'16'} ~; require "$sourcedir/Newcalendar.pl"; &WhosCal; print qq~
~; } 1; } ######### End Newcalendar Stuff ############# sub WhoRecent { foreach (split(/; /,$ENV{'HTTP_COOKIE'})) { $_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($cookie,$value) = split(/=/); $yyCookies{$cookie} = $value; } if( $yyCookies{$cookiepassword} ) { $password = $yyCookies{$cookiepassword}; $username = $yyCookies{$cookieusername} || 'Guest'; } else { $password = ''; $username = 'Guest'; } $cgi = qq~$scripturl?board=$currentboard~; @categories = (); open(FILE, "$vardir/cat.txt"); &lock(FILE); @categories = ; &unlock(FILE); close(FILE); $oldestfound = stringtotime("01/10/37 at 00:00:00"); foreach $curcat (@categories) { chomp $curcat; open(FILE, "$boardsdir/$curcat.cat"); &lock(FILE); $catname{$curcat} = ; chomp $catname{$curcat}; $cataccess{$curcat} = ; chomp $cataccess{$curcat}; @{$catboards{$curcat}} = ; &unlock(FILE); close(FILE); $openmemgr{$curcat} = 0; @membergroups = split( /,/, $cataccess{$curcat} ); if( ! $cataccess{$curcat} ) { $openmemgr{$curcat} = 1; } unless( $openmemgr{$curcat} ) { next; } foreach $curboard (@{$catboards{$curcat}}) { chomp $curboard; open(FILE, "$boardsdir/$curboard.txt"); &lock(FILE); @threads = ; &unlock(FILE); close(FILE); open(FILE, "$boardsdir/$curboard.dat"); &lock(FILE); @boardinfo = ; &unlock(FILE); close(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] ); open(FILE, "$datadir/$tnum.txt") || next; &lock(FILE); while( ) { $message = $_; } # get only the last post for this thread. &unlock(FILE); close(FILE); chomp $message; if( $message ) { ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = split(/\|/,$message); $mtime = stringtotime($mdate); if( $numfound >= $display && $mtime <= $oldestfound ) { next; } else { # 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($tnum); $threaddate = stringtotime($tdate); if( $max_log_days_old && $dlp < $threaddate && $username ne 'Guest' && &getlog("$currentboard--mark") < $threaddate ) { $tmpx = &getlog("$curboard--mark"); $new = qq~ NEW~; } else { $new = ''; } $data{$mtime} = [$curboard, $tnum, $treplies, $tusername, $tname, $tsub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $new]; if( $mtime < $oldestfound ) { $oldestfound = $mtime; } ++$numfound; } } } } } @messages = sort {$b <=> $a } keys %data; if( @messages ) { if( @messages > $display ) { $#messages = $display - 1; } $counter = 1; open(FILE,"$vardir/censor.txt"); &lock(FILE); while( chomp( $buffer = ) ) { ($tmpa,$tmpb) = split(/=/,$buffer); push(@censored,[$tmpa,$tmpb]); } &unlock(FILE); close(FILE); } else { print qq~
No Entries available
~; } print <<"EOT"; » $whotxt{'17'} EOT for( $i = 0; $i < @messages; $i++ ) { ($board, $tnum, $c, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $new) = @{ $data{$messages[$i]} }; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } if ($snip_headlines_when_longer_than) { if (length($msub) > $snip_headlines_when_longer_than) { $msub = substr($msub,0,$snip_headlines_when_longer_than); $msub .= "...";} } print <<"EOT"; $counter.   $msub$new
EOT ++$counter; } print <<"EOT"; EOT sub lock { my $lock_file = $_[0]; my $flag = 1; my $count = 0; if($use_flock==1) { flock($lock_file, $LOCK_EX); } elsif ($use_flock==2) { while($flag and $count < 15) { $flag = ($lock_file); $count++; } unlink($lock_file) if ($count == 15); open(LOCK_FILE, ">$lock_file"); } } sub unlock { my $lock_file = $_[0]; if($use_flock==1) { flock($lock_file, $LOCK_UN); } elsif ($use_flock==2) { close(LOCK_FILE); unlink($lock_file) if (-e $lock_file); } } sub stringtotime { unless( $_[0] ) { return 0; } my( $adate, $atime ) = split(m~ at ~, $_[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( timelocal($asec, $amin, $ahour, $aday, $amonth, $ayear) - (3600*$timeoffset) ); } sub getlog { if( $username eq 'Guest' || $max_log_days_old == 0 ) { return; } my $entry = $_[0]; unless( defined %yyuserlog ) { %yyuserlog = (); my( $name, $value, $thistime, $adate, $atime, $amonth, $aday, $ayear, $ahour, $amin, $asec ); my $mintime = time - ( $max_log_days_old * 86400 ); open(MLOG, "$memberdir/$username.log"); &lock(MLOG); while( ) { chomp; ($name, $value, $thistime) = split( /\|/, $_ ); unless( $name ) { next; } if( $value ) { $thistime = stringtotime($value); } if( $thistime > $mintime ) { $yyuserlog{$name} = $thistime; } } &unlock(MLOG); close(MLOG); } return $yyuserlog{$entry}; } } sub WhoChat { $cguests = 0; $cusers = ''; open(OF,"$vardir/online.txt") or dienice ("Can't open file: $!"); @ary = ; foreach $line (@ary) { chomp($line); ($of,$name,$ip,$displayname,$level,$time,$non1,$non2) = split(/°¸/,$line); if( $name ) { if( exists $userprofile{$name} ) { $cusers .= qq~ $displayname, \n~; } else { ++$cguests; } } close(OF); } $cusers =~ s~, \n\Z~~; if($cusers eq '') { $cusers = "$whotxt{'01'}"; } if ($password eq ""){ $yymain .=qq~$chadmtxt{'8'}~;} else { $yymain .=qq~$chadmtxt{'10'} ~; } print qq~ » $chadmtxt{'7'}   $cusers 
$yymain ~; } sub WhoBirthday { ############################################### #Birthday mod plugin for YaBB 1Gold # # By Max : staff@my.netvigator.com # ############################################### &timeformat($date); ($tocheckm, $tocheckd, $trash) = split(/\//, $date); $whobd = ""; $countbd = 0; ## get the userlist to check open(FILE, "$memberdir/memberlist.txt") || die "cannot open list file"; @members = ; close(FILE); foreach $usernames (@members) { chomp $usernames; open(FILE, "$memberdir/$usernames.dat") || die "cannot open user file"; @userbd = ; close(FILE); chomp $userbd[16]; ($matchm, $matchd, $trash) = split(/\//, $userbd[16]); if(($tocheckm == $matchm) && ($tocheckd == $matchd)) { $userbd[6] =~ s/ //g; chomp $userbd[6]; $whobg .=qq~$userbd[1]
~; $countbd++; }#end if }#end foreach chomp $whobg; if($whobg eq '') { $whobg = "$whotxt{'01'}"; } print qq~ » $whotxt{'11'}    $whobg  ~; } exit;