Who’s online?
-
Um…
Something is very wrong… =(Warning: Invalid argument supplied for foreach() in /home/tekwh0re/public_html/wp/wp-useronline.php on line 48
Here is the code:
< ?php
/* wp-useronline.php
*
* Last Updated On 8th June 2004
*
* An addon to WordPress 1.2 and above which allow you to tell the user location on your blog
* Demo of this file @ https://www.lesterchan.net/blogs/wp-online.php
* Created By Lester "GamerZ" Chan - http:/www.lesterchan.net
* Copyright ???? 2004 Lester "GamerZ" Chan. All Rights Reserved.
*
* You may modify this file to suit your owns needs, but please keep the copyright in tag. Thanks
* Any problems, email me @ [email protected] or post it in the WordPress forums @ https://www.ads-software.com/support/
*/
// Require WordPress Header
require('wp-blog-header.php');
// Search Bots
$bots = array('Google Bot' => 'googlebot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'ask jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'inktomi', 'Turnitin.com' => 'turnitinbot');
// Reassign Bots Name
$bots_name = array();
foreach($bots as $botname => $botlookfor) {
$bots_name[] = $botname;
}
// Get User Online
$usersonline = $wpdb->get_results("SELECT * FROM $tableuseronline");
// Type Of Users Array
$bots = array();
$guests = array();
$members = array();
// Users Count
$total = array();
$total['bots'] = 0;
$total['guests'] = 0;
$total['members'] = 0;
// Alternate Colour Cells
$alt_color[0] = '#DCDCDC'; // Header Cell
$alt_color[1] = '#FAFAFA'; // Alt Cell 1
$alt_color[2] = '#F0F0F0'; // Alt Cell 2
$alt_color[3] = '#C8C8C8'; // Border Colour
// Assign It To Array
foreach($usersonline as $useronline) {
if($useronline->username == 'Guest') {
$guests[] = array('username' => $useronline->username, 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $useronline->url);
$total['guests']++;
} elseif(in_array($useronline->username, $bots_name)) {
$bots[] = array('username' => $useronline->username, 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $useronline->url);
$total['bots']++;
} else {
$members[] = array('username' => $useronline->username, 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $useronline->url);
$total['members']++;
}
}
// Nicer Text
$nicetext = array();
if($total['bots'] > 1) { $nicetext['bots'] = 'Bots'; } else { $nicetext['bots'] = 'Bot'; }
if($total['guests'] > 1) { $nicetext['guests'] = 'Guests'; } else { $nicetext['guests'] = 'Guest'; }
if($total['members'] > 1) { $nicetext['members'] = 'Members'; } else { $nicetext['members'] = 'Member'; }
// Check IP
function check_ip($ip) {
global $cookiehash;
if(isset($_COOKIE['wordpressuser_'.$cookiehash])) {
return "($ip)";
}
}
?>
There Are A Total Of <b>< ?=$total['members'].' '.$nicetext['members']?></></b>, <b>al['guests'].' '.$nicetext['guests']?></b> And <b>< ?=$total['bots'].' '.$nicetext['bots']?></></b> Online Now.<b>p>
<table bgcolor="<?php echo $alt_color[3]; ?>" cellspacing="0" cellpadding="0" align="center" width="100%">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="5">
<tr>
<td bgcolor="<?php echo $alt_color[0]; ?>"><b>No.</b></td>
<td bgcolor="<?php echo $alt_color[0]; ?>"><b>User's Name</b></td>
</tr>
< ?php
// Print Out Members
if($total['members'] > 0) {
echo '<tr><td bgcolor="'.$alt_color[0].'" colspan="2"><b>'.$total['members'].' '.$nicetext['members'].' Online Now</b></td></tr>';
}
$no=1;
foreach($members as $member) {
if($no%2 == 0)
$bgcolor = $alt_color[2];
else
$bgcolor = $alt_color[1];
echo '<tr>';
echo '<td bgcolor="'.$bgcolor.'"><b>#'.$no.'
'.$member['username'].'</b> '.check_ip($member['ip']).'</td>'."n";
echo '<td bgcolor="'.$bgcolor.'">'.date('d.m.Y @ H:i',($member['timestamp']+(get_settings('time_difference') * 3600))).'
'.$member['location'].' [url]</td>'."n";
echo '</tr>';
$no++;
}
// Print Out Guest
if($total['guests'] > 0) {
echo '<tr><td bgcolor="'.$alt_color[0].'" colspan="2"><b>'.$total['guests'].' '.$nicetext['guests'].' Online Now</b></td></tr>';
}
$no=1;
foreach($guests as $guest) {
if($no%2 == 0)
$bgcolor = $alt_color[2];
else
$bgcolor = $alt_color[1];
echo '<tr>';
echo '<td bgcolor="'.$bgcolor.'"><b>#'.$no.'
'.$guest['username'].'</b> '.check_ip($guest['ip']).'</td>'."n";
echo '<td bgcolor="'.$bgcolor.'">'.date('d.m.Y @ H:i',($guest['timestamp']+(get_settings('time_difference') * 3600))).'
'.$guest['location'].' [url]</td>'."n";
echo '</tr>';
$no++;
}
// Print Out Bots
if($total['bots'] > 0) {
echo '<tr><td bgcolor="'.$alt_color[0].'" colspan="2"><b>'.$total['bots'].' '.$nicetext['bots'].' Online Now</b></td></tr>';
}
$no=1;
foreach($bots as $bot) {
if($no%2 == 0)
$bgcolor = $alt_color[2];
else
$bgcolor = $alt_color[1];
echo '<tr>';
echo '<td bgcolor="'.$bgcolor.'"><b>#'.$no.'
'.$bot['username'].'</b> '.check_ip($bot['ip']).'</td>'."n";
echo '<td bgcolor="'.$bgcolor.'">'.date('d.m.Y @ H:i',($bot['timestamp']+(get_settings('time_difference') * 3600))).'
'.$bot['location'].' [url]</td>'."n";
echo '</tr>';
$no++;
}
?>
</></table>
</td>/table></tr></table></b></>
Did something in SQL get screwed up?
- The topic ‘Who’s online?’ is closed to new replies.