#!/usr/bin/perl ################################################################### # Whoson.pl # # Version: 1.2.2 # 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'; ###### &WhoHeader; if ($INFO{'info'} eq 'Members') { &WhoMembers; } elsif ($INFO{'info'} eq 'Users') { &WhoUsers; } elsif ($INFO{'info'} eq 'Time') { &WhatTime; } elsif ($INFO{'info'} eq 'IM') { &WhoIM; } elsif ($INFO{'info'} eq 'Recent') { &WhoRecent; } elsif ($INFO{'info'} eq 'Stats') { &WhoStats; } elsif ($INFO{'info'} eq 'Chat') { &WhoChat; } elsif ($INFO{'info'} eq 'Birthday') { &WhoBirthday; } elsif ($INFO{'info'} eq 'CalStuff') { &CalStuff; } elsif ($INFO{'info'} eq 'Menu') { &Menu; } elsif ($INFO{'info'} eq 'ShowAll') { &ShowAll; } exit; sub ShowAll { &Menu if ($menu eq '1'); &WhatTime if ($what_time eq '1'); &WhoIM if ($who_im eq '1'); &WhoRecent if ($who_recent eq '1'); &WhoStats if ($who_stats eq '1'); &WhoUsers if ($who_users eq '1'); &WhoMembers if ($who_members eq '1'); &CalStuff if ($cal_stuff eq '1'); &WhoBirthday if ($who_birthday eq '1'); &WhoChat if ($who_chat eq '1'); exit; } 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"; require "$vardir/WhosonSettings.txt"; 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; &WriteLog; } sub WhatTime { $yytime = &timeformat($date, 1); print qq~ $yytime ~; } sub Menu { $yyposition = $yytitle; $yytitle = "$mbname - $yytitle"; if ($defaultml == 0) { $mldefault = "mlall"; } elsif ($defaultml == 1) { $mldefault = "mlpost"; } elsif ($defaultml == 2) { $mldefault = "mlalfa"; } elsif ($defaultml == 3) { $mldefault = "mlgrp"; } print qq~ ~; if ($home eq '1') { print qq~ $img{'home'}~; } if ($help eq '1') { print qq~ $who_menusep$img{'help'}~; } if ($search eq '1') { print qq~ $who_menusep$img{'search'}~; } if ($memberlist eq '1') { print qq~ $who_menusep$img{'memberlist'}~; } if ($calendar eq '1') { if ($newcalopen == 1 || $settings[7] eq 'Administrator' || $settings[7] eq $newcalgroup ) { print qq~ $who_menusep$img{'newcalendar'}~; } } if ($games eq '1') { print qq~ $who_menusep$img{'games'}~; } if ($admin eq '1') { if($settings[7] eq 'Administrator') { print qq~ $who_menusep$img{'admin'}~; } if($settings[7] eq 'Global Moderator' && $allow_mod == 1) { print qq~ $who_menusep$img{'moderate'}~; } } if ($guest_stuff eq '1') { if($username eq 'Guest') { print qq~ $who_menusep$img{'login'} $who_menusep$img{'register'}~; } if($username ne 'Guest') { &LoadUser($username); print qq~ $who_menusep$img{'profile'}~; if($enable_notification) { print qq~ $who_menusep$img{'notification'}~; } print qq~ $who_menusep$img{'logout'}~; } } print qq~ ~; } 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 ne 'Guest') { require "$sourcedir/Load.pl"; &LoadIMs; 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
~; } else { 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 { @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~$whotxt{'48'}~; } print qq~ » $whotxt{'17'} ~; 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) { if (length($msub) > $snip_headlines) { $msub = substr($msub,0,$snip_headlines); $msub .= "...";} } print qq~ $counter.   $msub$new
~; ++$counter; } print qq~ ~; 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 = check_flock($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 { if(-e("$sourcedir/Chat.pl")) { $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;