Version Description
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-UserOnline |
Version | 1.00 |
Comparing to | |
See all releases |
Version 1.00
- readme.txt +65 -0
- useronline-install.php +29 -0
- useronline.php +74 -0
- wp-useronline.php +108 -0
readme.txt
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-> Useronline Plugin For WordPress
|
2 |
+
--------------------------------------------------
|
3 |
+
Author -> Lester 'GaMerZ' Chan
|
4 |
+
Email -> lesterch@singnet.com.sg
|
5 |
+
Website -> http://www.lesterchan.net/
|
6 |
+
Demo -> http://www.lesterchan.net/wp-useronline.php
|
7 |
+
Updated -> 29th April 2005
|
8 |
+
--------------------------------------------------
|
9 |
+
|
10 |
+
|
11 |
+
-> Installation Instructions
|
12 |
+
--------------------------------------------------
|
13 |
+
// Open wp-settings.php
|
14 |
+
|
15 |
+
Find:
|
16 |
+
------------------------------------------------------------------
|
17 |
+
$wpdb->postmeta = $table_prefix . 'postmeta';
|
18 |
+
------------------------------------------------------------------
|
19 |
+
Add Below It:
|
20 |
+
------------------------------------------------------------------
|
21 |
+
$wpdb->useronline = $table_prefix . 'useronline';
|
22 |
+
------------------------------------------------------------------
|
23 |
+
|
24 |
+
|
25 |
+
// Open wp-admin folder
|
26 |
+
|
27 |
+
Put:
|
28 |
+
------------------------------------------------------------------
|
29 |
+
useronline-install.php
|
30 |
+
------------------------------------------------------------------
|
31 |
+
|
32 |
+
|
33 |
+
// Open root Wordpress folder
|
34 |
+
|
35 |
+
Put:
|
36 |
+
------------------------------------------------------------------
|
37 |
+
wp-useronline.php
|
38 |
+
------------------------------------------------------------------
|
39 |
+
|
40 |
+
|
41 |
+
// Open wp-content/plugins folder
|
42 |
+
|
43 |
+
Put:
|
44 |
+
------------------------------------------------------------------
|
45 |
+
useronline.php
|
46 |
+
------------------------------------------------------------------
|
47 |
+
|
48 |
+
|
49 |
+
// Activate useronline plugin
|
50 |
+
|
51 |
+
|
52 |
+
// Run wp-admin/useronline-install.php
|
53 |
+
|
54 |
+
Note:
|
55 |
+
------------------------------------------------------------------
|
56 |
+
If You See A Blank Page Means It Is Successfully
|
57 |
+
------------------------------------------------------------------
|
58 |
+
|
59 |
+
|
60 |
+
// Open wp-content/themes/<YOUR THEME NAME>/header.php
|
61 |
+
|
62 |
+
Add:
|
63 |
+
------------------------------------------------------------------
|
64 |
+
<p align="center"><a href="wp-useronline.php"><?php get_useronline(); ?></a></p>
|
65 |
+
------------------------------------------------------------------
|
useronline-install.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Useronline Plugin For WordPress
|
4 |
+
* - useronline-install.php
|
5 |
+
*
|
6 |
+
* Copyright � 2004-2005 Lester "GaMerZ" Chan
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Require WordPress Config
|
11 |
+
require_once('../wp-config.php');
|
12 |
+
|
13 |
+
// Create Useronline Table
|
14 |
+
$sql[] = "CREATE TABLE $wpdb->useronline (".
|
15 |
+
" `timestamp` int(15) NOT NULL default '0',".
|
16 |
+
" `username` varchar(50) NOT NULL default '',".
|
17 |
+
" `ip` varchar(40) NOT NULL default '',".
|
18 |
+
" `location` varchar(255) NOT NULL default '',".
|
19 |
+
" `url` varchar(255) NOT NULL default '',".
|
20 |
+
" PRIMARY KEY (`timestamp`),".
|
21 |
+
" KEY `username` (`username`),".
|
22 |
+
" KEY `ip` (`ip`),".
|
23 |
+
" KEY `file` (`location`))";
|
24 |
+
|
25 |
+
// Run The Queries
|
26 |
+
foreach($sql as $query) {
|
27 |
+
$wpdb->query($query);
|
28 |
+
}
|
29 |
+
?>
|
useronline.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Useronline
|
4 |
+
Plugin URI: http://www.lesterchan.net/portfolio/programming.php
|
5 |
+
Description: Adds A Useronline Feature To WordPress
|
6 |
+
Version: 1.5
|
7 |
+
Author: GaMerZ
|
8 |
+
Author URI: http://www.lesterchan.net
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
### Get IP
|
13 |
+
function get_IP() {
|
14 |
+
if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
|
15 |
+
$ip_address = $_SERVER["REMOTE_ADDR"];
|
16 |
+
} else {
|
17 |
+
$ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
|
18 |
+
}
|
19 |
+
if(strpos($ip_address, ',') !== false) {
|
20 |
+
$ip_address = explode(',', $ip_address);
|
21 |
+
$ip_address = $ip_address[0];
|
22 |
+
}
|
23 |
+
return $ip_address;
|
24 |
+
}
|
25 |
+
|
26 |
+
### Useronline Function
|
27 |
+
function get_useronline($user = 'User', $users = 'Users', $usertimeout = 300) {
|
28 |
+
global $wpdb;
|
29 |
+
// Search Bots
|
30 |
+
$bots = array('Google Bot' => 'googlebot', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'askjeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot');
|
31 |
+
|
32 |
+
// Useronline Settings
|
33 |
+
$timeoutseconds = $usertimeout;
|
34 |
+
$timestamp = time();
|
35 |
+
$timeout = $timestamp-$timeoutseconds;
|
36 |
+
|
37 |
+
// Check Members
|
38 |
+
if(isset($_COOKIE['comment_author_'.COOKIEHASH])) {
|
39 |
+
$memberonline = trim($_COOKIE['comment_author_'.COOKIEHASH]);
|
40 |
+
$where = "WHERE username='$memberonline'";
|
41 |
+
// Check Guests
|
42 |
+
} else {
|
43 |
+
$memberonline = 'Guest';
|
44 |
+
$where = "WHERE ip='".get_IP()."'";
|
45 |
+
}
|
46 |
+
// Check For Bot
|
47 |
+
foreach ($bots as $name => $lookfor) {
|
48 |
+
if (stristr($_SERVER['HTTP_USER_AGENT'], $lookfor) !== false) {
|
49 |
+
$memberonline = addslashes($name);
|
50 |
+
$where = "WHERE ip='".get_IP()."'";
|
51 |
+
}
|
52 |
+
}
|
53 |
+
// Update User First
|
54 |
+
$make_page = wp_title('»', false);
|
55 |
+
if(empty($make_page)) {
|
56 |
+
$make_page = get_bloginfo('name');
|
57 |
+
} else {
|
58 |
+
$make_page = get_bloginfo('name').' » Blog Archive'.$make_page;
|
59 |
+
}
|
60 |
+
$update_user = $wpdb->query("UPDATE $wpdb->useronline SET timestamp = '$timestamp', ip = '".get_IP()."', location = '".addslashes($make_page)."', url = '".$_SERVER['REQUEST_URI']."' $where");
|
61 |
+
// If No User Insert It
|
62 |
+
if(!$update_user) {
|
63 |
+
$insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$memberonline', '".get_IP()."', '".addslashes($make_page)."', '".$_SERVER['REQUEST_URI']."')");
|
64 |
+
}
|
65 |
+
|
66 |
+
$delete_users = $wpdb->query("DELETE FROM $wpdb->useronline WHERE timestamp < $timeout");
|
67 |
+
$useronline = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline");
|
68 |
+
if($useronline > 1) {
|
69 |
+
echo "<b>$useronline</b> $users Online";
|
70 |
+
} else {
|
71 |
+
echo "<b>$useronline</b> $user Online";
|
72 |
+
}
|
73 |
+
}
|
74 |
+
?>
|
wp-useronline.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Useronline Plugin For WordPress
|
4 |
+
* - wp-useronline.php
|
5 |
+
*
|
6 |
+
* Copyright � 2004-2005 Lester "GaMerZ" Chan
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Require WordPress Header
|
11 |
+
require('wp-blog-header.php');
|
12 |
+
|
13 |
+
// Search Bots
|
14 |
+
$bots = array('Google Bot' => 'googlebot', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'askjeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot');
|
15 |
+
|
16 |
+
// Reassign Bots Name
|
17 |
+
$bots_name = array();
|
18 |
+
foreach($bots as $botname => $botlookfor) {
|
19 |
+
$bots_name[] = $botname;
|
20 |
+
}
|
21 |
+
|
22 |
+
// Get User Online
|
23 |
+
$usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
|
24 |
+
|
25 |
+
// Type Of Users Array
|
26 |
+
$bots = array();
|
27 |
+
$guests = array();
|
28 |
+
$members = array();
|
29 |
+
|
30 |
+
// Users Count
|
31 |
+
$total = array();
|
32 |
+
$total['bots'] = 0;
|
33 |
+
$total['guests'] = 0;
|
34 |
+
$total['members'] = 0;
|
35 |
+
|
36 |
+
// Assign It To Array
|
37 |
+
foreach($usersonline as $useronline) {
|
38 |
+
if($useronline->username == 'Guest') {
|
39 |
+
$guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $useronline->url);
|
40 |
+
$total['guests']++;
|
41 |
+
} elseif(in_array($useronline->username, $bots_name)) {
|
42 |
+
$bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $useronline->url);
|
43 |
+
$total['bots']++;
|
44 |
+
} else {
|
45 |
+
$members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $useronline->url);
|
46 |
+
$total['members']++;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
// Nicer Text
|
51 |
+
$nicetext = array();
|
52 |
+
if($total['bots'] > 1) { $nicetext['bots'] = 'Bots'; } else { $nicetext['bots'] = 'Bot'; }
|
53 |
+
if($total['guests'] > 1) { $nicetext['guests'] = 'Guests'; } else { $nicetext['guests'] = 'Guest'; }
|
54 |
+
if($total['members'] > 1) { $nicetext['members'] = 'Members'; } else { $nicetext['members'] = 'Member'; }
|
55 |
+
|
56 |
+
// Check IP
|
57 |
+
function check_ip($ip) {
|
58 |
+
if(isset($_COOKIE['wordpressuser_'.COOKIEHASH])) {
|
59 |
+
return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)";
|
60 |
+
}
|
61 |
+
}
|
62 |
+
?>
|
63 |
+
<?php get_header(); ?>
|
64 |
+
<div id="content" class="narrowcolumn">
|
65 |
+
<p>There Are A Total Of <b><?=$total['members'].' '.$nicetext['members']?></b>, <b><?=$total['guests'].' '.$nicetext['guests']?></b> And <b><?=$total['bots'].' '.$nicetext['bots']?></b> Online Now.<b></b> </p>
|
66 |
+
<table width="100%" border="0" cellspacing="1" cellpadding="5">
|
67 |
+
<?php
|
68 |
+
if($total['members'] > 0) {
|
69 |
+
echo '<tr><td><h2 class="pagetitle">'.$total['members'].' '.$nicetext['members'].' Online Now</h2></td></tr>';
|
70 |
+
}
|
71 |
+
?>
|
72 |
+
<?php
|
73 |
+
$no=1;
|
74 |
+
foreach($members as $member) {
|
75 |
+
echo '<tr>';
|
76 |
+
echo '<td><b>#'.$no.' - <a href="wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i',($member['timestamp']+(get_settings('gmt_offset') * 3600))).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</td>'."\n";
|
77 |
+
echo '</tr>';
|
78 |
+
$no++;
|
79 |
+
}
|
80 |
+
// Print Out Guest
|
81 |
+
if($total['guests'] > 0) {
|
82 |
+
echo '<tr><td><h2 class="pagetitle">'.$total['guests'].' '.$nicetext['guests'].' Online Now</h2></td></tr>';
|
83 |
+
}
|
84 |
+
$no=1;
|
85 |
+
foreach($guests as $guest) {
|
86 |
+
echo '<tr>';
|
87 |
+
echo '<td><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i',($guest['timestamp']+(get_settings('gmt_offset') * 3600))).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</td>'."\n";
|
88 |
+
echo '</tr>';
|
89 |
+
$no++;
|
90 |
+
}
|
91 |
+
// Print Out Bots
|
92 |
+
if($total['bots'] > 0) {
|
93 |
+
echo '<tr><td><h2 class="pagetitle">'.$total['bots'].' '.$nicetext['bots'].' Online Now</h2></td></tr>';
|
94 |
+
}
|
95 |
+
$no=1;
|
96 |
+
foreach($bots as $bot) {
|
97 |
+
echo '<tr>';
|
98 |
+
echo '<td><b>#'.$no.' - '.$bot['username'].'</b> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i',($bot['timestamp']+(get_settings('gmt_offset') * 3600))).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</td>'."\n";
|
99 |
+
echo '</tr>';
|
100 |
+
$no++;
|
101 |
+
}
|
102 |
+
?>
|
103 |
+
</table>
|
104 |
+
</div>
|
105 |
+
<?php
|
106 |
+
get_sidebar();
|
107 |
+
get_footer();
|
108 |
+
?>
|