WP-UserOnline - Version 2.02

Version Description

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-UserOnline
Version 2.02
Comparing to
See all releases

Version 2.02

Files changed (5) hide show
  1. readme-install.txt +64 -0
  2. readme-upgrade.txt +25 -0
  3. readme.txt +30 -0
  4. useronline.php +399 -0
  5. wp-useronline.php +143 -0
readme-install.txt ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Installation Instructions
2
+ --------------------------------------------------
3
+ // Open wp-content/plugins folder
4
+
5
+ Put:
6
+ ------------------------------------------------------------------
7
+ useronline.php
8
+ ------------------------------------------------------------------
9
+
10
+
11
+ // Open root Wordpress folder
12
+
13
+ Put:
14
+ ------------------------------------------------------------------
15
+ wp-useronline.php
16
+ ------------------------------------------------------------------
17
+
18
+
19
+ // Activate useronline plugin
20
+
21
+
22
+ // Open wp-content/themes/<YOUR THEME NAME>/sidebar.php
23
+
24
+ Add:
25
+ ------------------------------------------------------------------
26
+ <?php if (function_exists('useronline')): ?>
27
+ <li>
28
+ <h2>UserOnline</h2>
29
+ <ul>
30
+ <li><a href="<?php echo get_settings('home'); ?>/wp-useronline.php"><?php get_useronline(); ?></a></li>
31
+ </ul>
32
+ </li>
33
+ <?php endif; ?>
34
+ ------------------------------------------------------------------
35
+
36
+
37
+ // To Display Most Number Of Users Online
38
+
39
+ Use:
40
+ ------------------------------------------------------------------
41
+ <?php if (function_exists('useronline')): ?>
42
+ <p>Most Users Ever Online Is <?php get_most_useronline(); ?> On <?php get_most_useronline_date(); ?></p>
43
+ <?php endif; ?>
44
+ ------------------------------------------------------------------
45
+
46
+ Note:
47
+ ------------------------------------------------------------------
48
+ By default, it will be displayed in wp-useronline.php
49
+ ------------------------------------------------------------------
50
+
51
+
52
+ // To Display Users Browsing A Page
53
+
54
+ Use:
55
+ ------------------------------------------------------------------
56
+ <?php if (function_exists('useronline')): ?>
57
+ <?php get_users_browsing_page(); ?>
58
+ <?php endif; ?>
59
+ ------------------------------------------------------------------
60
+
61
+ Note:
62
+ ------------------------------------------------------------------
63
+ Normally, you can place it in page.php or single.php
64
+ ------------------------------------------------------------------
readme-upgrade.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Upgrade Instructions For Version 1.0x To Version 2.02
2
+ ------------------------------------------------------------------
3
+ // Deactivate WP-UserOnline
4
+
5
+
6
+ // Open wp-content/plugins folder
7
+
8
+ Overwrite:
9
+ ------------------------------------------------------------------
10
+ useronline.php
11
+ ------------------------------------------------------------------
12
+
13
+
14
+ // Open root Wordpress folder
15
+
16
+ Overwrite:
17
+ ------------------------------------------------------------------
18
+ wp-useronline.php
19
+ ------------------------------------------------------------------
20
+
21
+
22
+ // Activate WP-UserOnline
23
+
24
+
25
+ // Refer to readme-install.txt for further instructions
readme.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> UserOnline Plugin For WordPress 2.0
2
+ --------------------------------------------------
3
+ Author -> Lester 'GaMerZ' Chan
4
+ Email -> gamerz84@hotmail.com
5
+ Website -> http://www.lesterchan.net/
6
+ Demo -> http://www.lesterchan.net/wp-useronline.php
7
+ Documentation -> http://dev.wp-plugins.org/wiki/wp-useronline
8
+ Development -> http://dev.wp-plugins.org/browser/wp-useronline/
9
+ Updated -> 1st March 2006
10
+ --------------------------------------------------
11
+
12
+ // Version 2.02 (01-03-2006)
13
+ - NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin.
14
+ - FIXED: IP 'Unknown' Error, Credit To Brian Layman (http://www.knitchat.com/)
15
+ - FIXED: ON DUPLICATE KEY Error, Credit To Brian Layman (http://www.knitchat.com/)
16
+ - FIXED: DUPLICATE KEY Error By Using DELETE First, Credit To Jody Cairns (http://steelwhitetable.org/blog/)
17
+
18
+ // Version 2.01 (01-02-2006)
19
+ - NEW: Added Users Browsing Page
20
+ - NEW: Added Most Users Ever Online
21
+ - FIXED: Added UNIQUE Key Instead Of Primary Key To Test Whether It Will Solve Duplicate Entry Errors
22
+ - FIXED: Quotes Issue In Page Title
23
+
24
+ // Version 2.00 (01-01-2006)
25
+ - NEW: Compatible With WordPress 2.0
26
+ - NEW: Better Installer
27
+ - NEW: GPL License Added
28
+ - NEW: Page Title Added To wp-useronline.php
29
+ - NEW: Added Extra Bots, Credit To Greg Perry (http://www.gregrperry.com/)
30
+ - FIXED: Cleaner Codes
useronline.php ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP-UserOnline
4
+ Plugin URI: http://www.lesterchan.net/portfolio/programming.php
5
+ Description: Adds A Useronline Feature To WordPress
6
+ Version: 2.02
7
+ Author: GaMerZ
8
+ Author URI: http://www.lesterchan.net
9
+ */
10
+
11
+
12
+ /* Copyright 2005 Lester Chan (email : gamerz84@hotmail.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ */
28
+
29
+
30
+ ### UserOnline Table Name
31
+ $wpdb->useronline = $table_prefix . 'useronline';
32
+
33
+
34
+ ### Function: WP-UserOnline Menu
35
+ add_action('admin_menu', 'useronline_menu');
36
+ function useronline_menu() {
37
+ if (function_exists('add_submenu_page')) {
38
+ add_submenu_page('index.php', __('WP-UserOnline'), __('WP-UserOnline'), 1, 'useronline.php', 'display_useronline');
39
+ }
40
+ }
41
+
42
+
43
+ ### Search Bots Name
44
+ $bots = array('Google Bot' => 'googlebot', 'Google Bot' => 'google', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'ubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com bot' => 'become.com', 'Technorati Blog Bot' => 'technorati');
45
+
46
+
47
+ ### Function: Get IP
48
+ function get_IP() {
49
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
50
+ $ip_address = $_SERVER["REMOTE_ADDR"];
51
+ } else {
52
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
53
+ }
54
+ if(strpos($ip_address, ',') !== false) {
55
+ $ip_address = explode(',', $ip_address);
56
+ $ip_address = $ip_address[0];
57
+ }
58
+ return $ip_address;
59
+ }
60
+
61
+
62
+ ### Function: Process UserOnline
63
+ add_action('admin_head', 'useronline');
64
+ add_action('wp_head', 'useronline');
65
+ function useronline() {
66
+ global $wpdb, $useronline, $bots, $user_identity;
67
+ // Useronline Settings
68
+ $timeoutseconds = 300;
69
+ $timestamp = current_time('timestamp');
70
+ $timeout = ($timestamp-$timeoutseconds);
71
+ $ip = get_IP();
72
+ $url = addslashes(urlencode($_SERVER['REQUEST_URI']));
73
+ $useragent = $_SERVER['HTTP_USER_AGENT'];
74
+
75
+ // Check For Members
76
+ if(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
77
+ $memberonline = addslashes(trim($_COOKIE['comment_author_'.COOKIEHASH]));
78
+ $where = "WHERE username='$memberonline'";
79
+ // Check For Admins
80
+ } elseif(!empty($user_identity)) {
81
+ $memberonline = addslashes($user_identity);
82
+ $where = "WHERE username='$memberonline'";
83
+ // Check For Guests
84
+ } else {
85
+ $memberonline = 'Guest';
86
+ $where = "WHERE ip='$ip'";
87
+ }
88
+ // Check For Bot
89
+ foreach ($bots as $name => $lookfor) {
90
+ if (stristr($useragent, $lookfor) !== false) {
91
+ $memberonline = addslashes($name);
92
+ $where = "WHERE ip='$ip'";
93
+ break;
94
+ }
95
+ }
96
+ $useragent = addslashes($useragent);
97
+
98
+ // Check For Page Title
99
+ $make_page = wp_title('&raquo;', false);
100
+ if(empty($make_page)) {
101
+ $make_page = get_bloginfo('name');
102
+ } elseif(is_single()) {
103
+ $make_page = get_bloginfo('name').' &raquo; Blog Archive '.$make_page;
104
+ } else {
105
+ $make_page = get_bloginfo('name').$make_page;
106
+ }
107
+ $make_page = addslashes($make_page);
108
+
109
+ // Delete Users
110
+ $delete_users = $wpdb->query("DELETE FROM $wpdb->useronline $where OR (timestamp < $timeout)");
111
+
112
+ // Insert Users
113
+ $insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$memberonline', '$useragent', '$ip', '$make_page', '$url')");
114
+
115
+ // Count Users Online
116
+ $useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));
117
+
118
+ // Get Most User Online
119
+ $most_useronline = intval(get_settings('useronline_most_users'));
120
+
121
+ // Check Whether Current Users Online Is More Than Most Users Online
122
+ if($useronline > $most_useronline) {
123
+ update_option('useronline_most_users', $useronline);
124
+ update_option('useronline_most_timestamp', current_time('timestamp'));
125
+ }
126
+ }
127
+
128
+
129
+ ### Function: Display UserOnline
130
+ if(!function_exists('get_useronline')) {
131
+ function get_useronline($user = 'User', $users = 'Users', $display = true) {
132
+ global $useronline;
133
+ // Display User Online
134
+ if($display) {
135
+ if($useronline > 1) {
136
+ echo "<b>$useronline</b> $users ".__('Online');
137
+ } else {
138
+ echo "<b>$useronline</b> $user ".__('Online');
139
+ }
140
+ } else {
141
+ return $useronline;
142
+ }
143
+ }
144
+ }
145
+
146
+ ### Function: Display Max UserOnline
147
+ if(!function_exists('get_most_useronline')) {
148
+ function get_most_useronline($display = true) {
149
+ $most_useronline_users = intval(get_settings('useronline_most_users'));
150
+ if($display) {
151
+ echo $most_useronline_users;
152
+ } else {
153
+ return $most_useronline_users;
154
+ }
155
+ }
156
+ }
157
+
158
+
159
+ ### Function: Display Max UserOnline Date
160
+ if(!function_exists('get_most_useronline_date')) {
161
+ function get_most_useronline_date($date_format = 'jS F Y, H:i', $display =true) {
162
+ $most_useronline_timestamp = get_settings('useronline_most_timestamp');
163
+ $most_useronline_date = gmdate($date_format, $most_useronline_timestamp);
164
+ if($display) {
165
+ echo $most_useronline_date;
166
+ } else {
167
+ return$most_useronline_date;
168
+ }
169
+ }
170
+ }
171
+
172
+
173
+ ### Function: Display Users Browsing The Page
174
+ function get_users_browsing_page() {
175
+ global $wpdb, $bots;
176
+
177
+ // Get Users Browsing Page
178
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
179
+ $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline WHERE url = '$page_url'");
180
+
181
+ // Variables
182
+ $members = array();
183
+ $total_users = 0;
184
+ $total_members = 0;
185
+ $total_guests = 0;
186
+ $total_bots = 0;
187
+ $nicetext_members = '';
188
+ $nicetext_guests = '';
189
+ $nicetext_bots = '';
190
+
191
+ // If There Is Users Browsing, Then We Execute
192
+ if($users_browse) {
193
+ // Reassign Bots Name
194
+ $bots_name = array();
195
+ foreach($bots as $botname => $botlookfor) {
196
+ $bots_name[] = $botname;
197
+ }
198
+ // Get Users Information
199
+ foreach($users_browse as $user_browse) {
200
+ if($user_browse->username == 'Guest') {
201
+ $total_guests++;
202
+ } elseif(in_array($user_browse->username, $bots_name)) {
203
+ $total_bots++;
204
+ } else {
205
+ $members[] = stripslashes($user_browse->username);
206
+ $total_members++;
207
+ }
208
+ }
209
+ $total_users = ($total_guests+$total_bots+$total_members);
210
+
211
+ // Nice Text For Members
212
+ if($total_members > 1) {
213
+ $nicetext_members = $total_members.' '.__('Members');
214
+ } else {
215
+ $nicetext_members = $total_members.' '.__('Member');
216
+ }
217
+ // Nice Text For Guests
218
+ if($total_guests > 1) {
219
+ $nicetext_guests = $total_guests.' '.__('Guests');
220
+ } else {
221
+ $nicetext_guests = $total_guests.' '.__('Guest');
222
+ }
223
+ // Nice Text For Bots
224
+ if($total_bots > 1) {
225
+ $nicetext_bots = $total_bots.' '.__('Bots');
226
+ } else {
227
+ $nicetext_bots = $total_bots.' '.__('Bot');
228
+ }
229
+
230
+ // Print User Count
231
+ echo __('Users Browsing This Page: ').'<b>'.$total_users.'</b> ('.$nicetext_members.', '.$nicetext_guests.' '.__('and').' '.$nicetext_bots.')<br />';
232
+
233
+ // Print Member Name
234
+ if($members) {
235
+ $temp_member = '';
236
+ foreach($members as $member) {
237
+ $temp_member .= '<a href="'.get_settings('home').'/wp-stats.php?author='.urlencode($member).'">'.$member.'</a>, ';
238
+ }
239
+ echo __('Members').': '.substr($temp_member, 0, -2);
240
+ }
241
+ } else {
242
+ // This Should Not Happen
243
+ _e('No User Is Browsing This Page');
244
+ }
245
+ }
246
+
247
+
248
+ ### Function: Check IP
249
+ function check_ip($ip) {
250
+ if(!empty($_COOKIE[USER_COOKIE]) && ($ip != 'unknown')) {
251
+ return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)";
252
+ }
253
+ }
254
+
255
+
256
+ ### Function: Display UserOnline For Admin
257
+ function display_useronline() {
258
+ global $wpdb, $bots;
259
+ // Reassign Bots Name
260
+ $bots_name = array();
261
+ foreach($bots as $botname => $botlookfor) {
262
+ $bots_name[] = $botname;
263
+ }
264
+
265
+ // Get The Users Online
266
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
267
+
268
+ // Variables Variables Variables
269
+ $members = array();
270
+ $guests = array();
271
+ $bots = array();
272
+ $total_users = 0;
273
+ $total_members = 0;
274
+ $total_guests = 0;
275
+ $total_bots = 0;
276
+ $nicetext_users = '';
277
+ $nicetext_members = '';
278
+ $nicetext_guests = '';
279
+ $nicetext_bots = '';
280
+
281
+ // Process Those User Who Is Online
282
+ if($usersonline) {
283
+ foreach($usersonline as $useronline) {
284
+ if($useronline->username == 'Guest') {
285
+ $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
286
+ $total_guests++;
287
+ } elseif(in_array($useronline->username, $bots_name)) {
288
+ $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
289
+ $total_bots++;
290
+ } else {
291
+ $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
292
+ $total_members++;
293
+ }
294
+ }
295
+ $total_users = ($total_guests+$total_bots+$total_members);
296
+ }
297
+
298
+ // Nice Text For Users
299
+ if($total_users > 1) {
300
+ $nicetext_users = $total_users.' '.__('Users');
301
+ } else {
302
+ $nicetext_users = $total_users.' '.__('User');
303
+ }
304
+
305
+ // Nice Text For Members
306
+ if($total_members > 1) {
307
+ $nicetext_members = $total_members.' '.__('Members');
308
+ } else {
309
+ $nicetext_members = $total_members.' '.__('Member');
310
+ }
311
+
312
+
313
+ // Nice Text For Guests
314
+ if($total_guests > 1) {
315
+ $nicetext_guests = $total_guests.' '.__('Guests');
316
+ } else {
317
+ $nicetext_guests = $total_guests.' '.__('Guest');
318
+ }
319
+
320
+ // Nice Text For Bots
321
+ if($total_bots > 1) {
322
+ $nicetext_bots = $total_bots.' '.__('Bots');
323
+ } else {
324
+ $nicetext_bots = $total_bots.' '.__('Bot');
325
+ }
326
+ ?>
327
+ <div class="wrap">
328
+ <h2>UserOnline Stats</h2>
329
+ <p>There are a total of <b><?php echo $nicetext_users; ?></b> online now.</p>
330
+ <p>Out of which, there are <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p>
331
+ <p>Most users ever online was <b><?php get_most_useronline(); ?></b> on <b><?php get_most_useronline_date(); ?></b></p>
332
+ </div>
333
+ <?php
334
+ // Print Out Members
335
+ if($total_members > 0) {
336
+ echo '<div class="wrap"><h2>'.$nicetext_members.' '.__('Online Now').'</h2>'."\n";
337
+ }
338
+ $no=1;
339
+ if($members) {
340
+ foreach($members as $member) {
341
+ echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n";
342
+ $no++;
343
+ }
344
+ echo '</div>';
345
+ }
346
+ // Print Out Guest
347
+ if($total_guests > 0) {
348
+ echo '<div class="wrap"><h2>'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
349
+ }
350
+ $no=1;
351
+ if($guests) {
352
+ foreach($guests as $guest) {
353
+ echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n";
354
+ $no++;
355
+ }
356
+ echo '</div>';
357
+ }
358
+ // Print Out Bots
359
+ if($total_bots > 0) {
360
+ echo '<div class="wrap"><h2>'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
361
+ }
362
+ $no=1;
363
+ if($bots) {
364
+ foreach($bots as $bot) {
365
+ echo '<p><b>#'.$no.' - '.$bot['username'].'</b> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i', $bot['timestamp']).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</p>'."\n";
366
+ $no++;
367
+ }
368
+ echo '</div>';
369
+ }
370
+ if($total_users == 0) {
371
+ echo '<div class="wrap"><h2>'.__('No One Is Online Now').'</h2></div>'."\n";
372
+ }
373
+ ?>
374
+ <?php
375
+ }
376
+
377
+
378
+ ### Function: Create UserOnline Table
379
+ add_action('activate_useronline.php', 'create_useronline_table');
380
+ function create_useronline_table() {
381
+ global $wpdb;
382
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
383
+ // Drop UserOnline Table
384
+ $wpdb->query("DROP TABLE IF EXISTS $wpdb->useronline");
385
+ // Create UserOnline Table
386
+ $create_table = "CREATE TABLE $wpdb->useronline (".
387
+ " timestamp int(15) NOT NULL default '0',".
388
+ " username varchar(50) NOT NULL default '',".
389
+ " useragent char(100) NOT NULL,".
390
+ " ip varchar(40) NOT NULL default '',".
391
+ " location varchar(255) NOT NULL default '',".
392
+ " url varchar(255) NOT NULL default '',".
393
+ " UNIQUE KEY useronline_id (timestamp,username,ip,useragent))";
394
+ maybe_create_table($wpdb->useronline, $create_table);
395
+ // Add In Options
396
+ add_option('useronline_most_users', 1, 'Most Users Ever Online Count');
397
+ add_option('useronline_most_timestamp', current_time('timestamp'), 'Most Users Ever Online Date');
398
+ }
399
+ ?>
wp-useronline.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.02 |
6
+ | Copyright (c) 2005 Lester "GaMerZ" Chan |
7
+ | |
8
+ | File Written By: |
9
+ | - Lester "GaMerZ" Chan |
10
+ | - http://www.lesterchan.net |
11
+ | |
12
+ | File Information: |
13
+ | - Useronline Page |
14
+ | - wp-useronline.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Require WordPress Header
21
+ require(dirname(__FILE__).'/wp-blog-header.php');
22
+
23
+ ### Function: UserOnline Page Title
24
+ add_filter('wp_title', 'useronline_pagetitle');
25
+ function useronline_pagetitle($useronline_pagetitle) {
26
+ return $useronline_pagetitle.' &raquo; UserOnline';
27
+ }
28
+
29
+ ### Reassign Bots Name
30
+ $bots_name = array();
31
+ foreach($bots as $botname => $botlookfor) {
32
+ $bots_name[] = $botname;
33
+ }
34
+
35
+ ### Get The Users Online
36
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
37
+
38
+ ### Variables Variables Variables
39
+ $members = array();
40
+ $guests = array();
41
+ $bots = array();
42
+ $total_users = 0;
43
+ $total_members = 0;
44
+ $total_guests = 0;
45
+ $total_bots = 0;
46
+ $nicetext_users = '';
47
+ $nicetext_members = '';
48
+ $nicetext_guests = '';
49
+ $nicetext_bots = '';
50
+
51
+ ### Process Those User Who Is Online
52
+ if($usersonline) {
53
+ foreach($usersonline as $useronline) {
54
+ if($useronline->username == 'Guest') {
55
+ $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
56
+ $total_guests++;
57
+ } elseif(in_array($useronline->username, $bots_name)) {
58
+ $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
59
+ $total_bots++;
60
+ } else {
61
+ $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
62
+ $total_members++;
63
+ }
64
+ }
65
+ $total_users = ($total_guests+$total_bots+$total_members);
66
+ }
67
+
68
+ ### Nice Text For Users
69
+ if($total_users > 1) {
70
+ $nicetext_users = $total_users.' '.__('Users');
71
+ } else {
72
+ $nicetext_users = $total_users.' '.__('User');
73
+ }
74
+
75
+ ### Nice Text For Members
76
+ if($total_members > 1) {
77
+ $nicetext_members = $total_members.' '.__('Members');
78
+ } else {
79
+ $nicetext_members = $total_members.' '.__('Member');
80
+ }
81
+
82
+
83
+ ### Nice Text For Guests
84
+ if($total_guests > 1) {
85
+ $nicetext_guests = $total_guests.' '.__('Guests');
86
+ } else {
87
+ $nicetext_guests = $total_guests.' '.__('Guest');
88
+ }
89
+
90
+ ### Nice Text For Bots
91
+ if($total_bots > 1) {
92
+ $nicetext_bots = $total_bots.' '.__('Bots');
93
+ } else {
94
+ $nicetext_bots = $total_bots.' '.__('Bot');
95
+ }
96
+ ?>
97
+ <?php get_header(); ?>
98
+ <div id="content" class="narrowcolumn">
99
+ <p>There are a total of <b><?php echo $nicetext_users; ?></b> online now.</p>
100
+ <p>Out of which, there are <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p>
101
+ <p>Most users ever online was <b><?php get_most_useronline(); ?></b> on <b><?php get_most_useronline_date(); ?></b></p>
102
+ <?php
103
+ // Print Out Members
104
+ if($total_members > 0) {
105
+ echo '<h2 class="pagetitle">'.$nicetext_members.' '.__('Online Now').'</h2>'."\n";
106
+ }
107
+ $no=1;
108
+ if($members) {
109
+ foreach($members as $member) {
110
+ echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n";
111
+ $no++;
112
+ }
113
+ }
114
+ // Print Out Guest
115
+ if($total_guests > 0) {
116
+ echo '<h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
117
+ }
118
+ $no=1;
119
+ if($guests) {
120
+ foreach($guests as $guest) {
121
+ echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n";
122
+ $no++;
123
+ }
124
+ }
125
+ // Print Out Bots
126
+ if($total_bots > 0) {
127
+ echo '<h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
128
+ }
129
+ $no=1;
130
+ if($bots) {
131
+ foreach($bots as $bot) {
132
+ echo '<p><b>#'.$no.' - '.$bot['username'].'</b> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i', $bot['timestamp']).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</p>'."\n";
133
+ $no++;
134
+ }
135
+ }
136
+ if($total_users == 0) {
137
+ echo '<h2 class="pagetitle">'.__('No One Is Online Now').'</h2>'."\n";
138
+ }
139
+ ?>
140
+ </table>
141
+ </div>
142
+ <?php get_sidebar(); ?>
143
+ <?php get_footer(); ?>