WP-UserOnline - Version 2.03

Version Description

Download this release

Release Info

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

Version 2.03

Files changed (5) hide show
  1. readme-install.txt +85 -0
  2. readme-upgrade.txt +25 -0
  3. readme.txt +36 -0
  4. useronline.php +486 -0
  5. wp-useronline.php +149 -0
readme-install.txt ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // To Display Users Browsing Site
52
+
53
+ Use:
54
+ ------------------------------------------------------------------
55
+ <?php if (function_exists('useronline')): ?>
56
+ <?php get_users_browsing_site(); ?>
57
+ <?php endif; ?>
58
+ ------------------------------------------------------------------
59
+
60
+ Note:
61
+ ------------------------------------------------------------------
62
+ Normally, you can place it in page.php, single.php or sidebar.php
63
+ ------------------------------------------------------------------
64
+
65
+ // To Display Users Browsing A Page
66
+
67
+ Use:
68
+ ------------------------------------------------------------------
69
+ <?php if (function_exists('useronline')): ?>
70
+ <?php get_users_browsing_page(); ?>
71
+ <?php endif; ?>
72
+ ------------------------------------------------------------------
73
+
74
+ Note:
75
+ ------------------------------------------------------------------
76
+ Normally, you can place it in page.php or single.php
77
+ ------------------------------------------------------------------
78
+
79
+
80
+ // Tutorial On How To Integrate wp-useronline.php With Your Theme
81
+
82
+ Go To:
83
+ ------------------------------------------------------------------
84
+ http://www.lesterchan.net/wordpress/tutorials/integrating/
85
+ ------------------------------------------------------------------
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,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 April 2006
10
+ --------------------------------------------------
11
+
12
+
13
+ // Version 2.03 (01-04-2006)
14
+ - NEW: Added get_users_browsing_site(); To Display Users Browsing The Site
15
+ - FIXED: wp-stats.php Link
16
+ - FIXED: Some Grammer Errors, Credit To xclouds (http://www.xclouds.com/)
17
+
18
+ // Version 2.02 (01-03-2006)
19
+ - NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin.
20
+ - FIXED: IP 'Unknown' Error, Credit To Brian Layman (http://www.knitchat.com/)
21
+ - FIXED: ON DUPLICATE KEY Error, Credit To Brian Layman (http://www.knitchat.com/)
22
+ - FIXED: DUPLICATE KEY Error By Using DELETE First, Credit To Jody Cairns (http://steelwhitetable.org/blog/)
23
+
24
+ // Version 2.01 (01-02-2006)
25
+ - NEW: Added Users Browsing Page
26
+ - NEW: Added Most Users Ever Online
27
+ - FIXED: Added UNIQUE Key Instead Of Primary Key To Test Whether It Will Solve Duplicate Entry Errors
28
+ - FIXED: Quotes Issue In Page Title
29
+
30
+ // Version 2.00 (01-01-2006)
31
+ - NEW: Compatible With WordPress 2.0
32
+ - NEW: Better Installer
33
+ - NEW: GPL License Added
34
+ - NEW: Page Title Added To wp-useronline.php
35
+ - NEW: Added Extra Bots, Credit To Greg Perry (http://www.gregrperry.com/)
36
+ - FIXED: Cleaner Codes
useronline.php ADDED
@@ -0,0 +1,486 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.03
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');
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>'.number_format($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 number_format($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 Site
174
+ function get_users_browsing_site() {
175
+ global $wpdb, $bots;
176
+
177
+ // Get Users Browsing Site
178
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
179
+ $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline");
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 Guests
212
+ if($total_guests == 1) {
213
+ $nicetext_guests = $total_guests.' '.__('Guest');
214
+ } else {
215
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
216
+ }
217
+ // Nice Text For Bots
218
+ if($total_bots == 1) {
219
+ $nicetext_bots = $total_bots.' '.__('Bot');
220
+ } else {
221
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
222
+ }
223
+
224
+ // Print Member Name
225
+ if($members) {
226
+ $temp_member = '';
227
+ foreach($members as $member) {
228
+ $temp_member .= '<a href="'.get_settings('home').'/wp-stats.php?author='.urlencode($member).'">'.$member.'</a>, ';
229
+ }
230
+ if(!function_exists('get_totalposts')) {
231
+ $temp_member = strip_tags($temp_member);
232
+ }
233
+ }
234
+ // Print Guests
235
+ if($total_guests > 0) {
236
+ $temp_member .= $nicetext_guests.', ';
237
+ }
238
+ // Print Bots
239
+ if($total_bots > 0) {
240
+ $temp_member .= $nicetext_bots.', ';
241
+ }
242
+ // Print User Count
243
+ $temp_member = substr($temp_member, 0, -2);
244
+ echo __('Users: ').'<b>'.$temp_member.'</b><br />';
245
+ } else {
246
+ // This Should Not Happen
247
+ _e('No User Is Browsing This Page');
248
+ }
249
+ }
250
+
251
+
252
+ ### Function: Display Users Browsing The Page
253
+ function get_users_browsing_page() {
254
+ global $wpdb, $bots;
255
+
256
+ // Get Users Browsing Page
257
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
258
+ $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline WHERE url = '$page_url'");
259
+
260
+ // Variables
261
+ $members = array();
262
+ $total_users = 0;
263
+ $total_members = 0;
264
+ $total_guests = 0;
265
+ $total_bots = 0;
266
+ $nicetext_members = '';
267
+ $nicetext_guests = '';
268
+ $nicetext_bots = '';
269
+
270
+ // If There Is Users Browsing, Then We Execute
271
+ if($users_browse) {
272
+ // Reassign Bots Name
273
+ $bots_name = array();
274
+ foreach($bots as $botname => $botlookfor) {
275
+ $bots_name[] = $botname;
276
+ }
277
+ // Get Users Information
278
+ foreach($users_browse as $user_browse) {
279
+ if($user_browse->username == 'Guest') {
280
+ $total_guests++;
281
+ } elseif(in_array($user_browse->username, $bots_name)) {
282
+ $total_bots++;
283
+ } else {
284
+ $members[] = stripslashes($user_browse->username);
285
+ $total_members++;
286
+ }
287
+ }
288
+ $total_users = ($total_guests+$total_bots+$total_members);
289
+
290
+ // Nice Text For Members
291
+ if($total_members == 1) {
292
+ $nicetext_members = $total_members.' '.__('Member');
293
+ } else {
294
+ $nicetext_members = number_format($total_members).' '.__('Members');
295
+ }
296
+ // Nice Text For Guests
297
+ if($total_guests == 1) {
298
+ $nicetext_guests = $total_guests.' '.__('Guest');
299
+ } else {
300
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
301
+ }
302
+ // Nice Text For Bots
303
+ if($total_bots == 1) {
304
+ $nicetext_bots = $total_bots.' '.__('Bot');
305
+ } else {
306
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
307
+ }
308
+
309
+ // Print User Count
310
+ echo __('Users Browsing This Page: ').'<b>'.number_format($total_users).'</b> ('.$nicetext_members.', '.$nicetext_guests.' '.__('and').' '.$nicetext_bots.')<br />';
311
+
312
+ // Print Member Name
313
+ if($members) {
314
+ $temp_member = '';
315
+ foreach($members as $member) {
316
+ $temp_member .= '<a href="'.get_settings('home').'/wp-stats.php?author='.urlencode($member).'">'.$member.'</a>, ';
317
+ }
318
+ if(!function_exists('get_totalposts')) {
319
+ $temp_member = strip_tags($temp_member);
320
+ }
321
+ echo __('Members').': '.substr($temp_member, 0, -2);
322
+ }
323
+ } else {
324
+ // This Should Not Happen
325
+ _e('No User Is Browsing This Page');
326
+ }
327
+ }
328
+
329
+
330
+ ### Function: Check IP
331
+ function check_ip($ip) {
332
+ if(!empty($_COOKIE[USER_COOKIE]) && ($ip != 'unknown')) {
333
+ return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)";
334
+ }
335
+ }
336
+
337
+
338
+ ### Function: Display UserOnline For Admin
339
+ function display_useronline() {
340
+ global $wpdb, $bots;
341
+ // Reassign Bots Name
342
+ $bots_name = array();
343
+ foreach($bots as $botname => $botlookfor) {
344
+ $bots_name[] = $botname;
345
+ }
346
+
347
+ // Get The Users Online
348
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
349
+
350
+ // Variables Variables Variables
351
+ $members = array();
352
+ $guests = array();
353
+ $bots = array();
354
+ $total_users = 0;
355
+ $total_members = 0;
356
+ $total_guests = 0;
357
+ $total_bots = 0;
358
+ $nicetext_users = '';
359
+ $nicetext_members = '';
360
+ $nicetext_guests = '';
361
+ $nicetext_bots = '';
362
+
363
+ // Process Those User Who Is Online
364
+ if($usersonline) {
365
+ foreach($usersonline as $useronline) {
366
+ if($useronline->username == 'Guest') {
367
+ $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
368
+ $total_guests++;
369
+ } elseif(in_array($useronline->username, $bots_name)) {
370
+ $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
371
+ $total_bots++;
372
+ } else {
373
+ $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
374
+ $total_members++;
375
+ }
376
+ }
377
+ $total_users = ($total_guests+$total_bots+$total_members);
378
+ }
379
+
380
+ // Nice Text For Users
381
+ if($total_users == 1) {
382
+ $nicetext_users = $total_users.' '.__('User');
383
+ } else {
384
+ $nicetext_users = number_format($total_users).' '.__('Users');
385
+ }
386
+
387
+ // Nice Text For Members
388
+ if($total_members == 1) {
389
+ $nicetext_members = $total_members.' '.__('Member');
390
+ } else {
391
+ $nicetext_members = number_format($total_members).' '.__('Members');
392
+ }
393
+
394
+
395
+ // Nice Text For Guests
396
+ if($total_guests == 1) {
397
+ $nicetext_guests = $total_guests.' '.__('Guest');
398
+ } else {
399
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
400
+ }
401
+
402
+ // Nice Text For Bots
403
+ if($total_bots == 1) {
404
+ $nicetext_bots = $total_bots.' '.__('Bot');
405
+ } else {
406
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
407
+ }
408
+ ?>
409
+ <div class="wrap">
410
+ <h2>UserOnline Stats</h2>
411
+ <p><?php if ($total_users == 1) { _e('There is '); } else { _e('There are a total of '); } ?><b><?php echo $nicetext_users; ?></b> online now: <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p>
412
+ <p>Most users ever online were <b><?php get_most_useronline(); ?></b>, on <b><?php get_most_useronline_date(); ?></b></p>
413
+ </div>
414
+ <?php
415
+ // Print Out Members
416
+ if($total_members > 0) {
417
+ echo '<div class="wrap"><h2>'.$nicetext_members.' '.__('Online Now').'</h2>'."\n";
418
+ }
419
+ $no=1;
420
+ if($members) {
421
+ $wp_stats = false;
422
+ if(function_exists('get_totalposts')) {
423
+ $wp_stats = true;
424
+ }
425
+ foreach($members as $member) {
426
+ if($wp_stats) {
427
+ 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";
428
+ } else {
429
+ echo '<p><b>#'.$no.' - '.$member['username'].'</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";
430
+ }
431
+ $no++;
432
+ }
433
+ }
434
+ // Print Out Guest
435
+ if($total_guests > 0) {
436
+ echo '<div class="wrap"><h2>'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
437
+ }
438
+ $no=1;
439
+ if($guests) {
440
+ foreach($guests as $guest) {
441
+ 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";
442
+ $no++;
443
+ }
444
+ echo '</div>';
445
+ }
446
+ // Print Out Bots
447
+ if($total_bots > 0) {
448
+ echo '<div class="wrap"><h2>'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
449
+ }
450
+ $no=1;
451
+ if($bots) {
452
+ foreach($bots as $bot) {
453
+ 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";
454
+ $no++;
455
+ }
456
+ echo '</div>';
457
+ }
458
+ if($total_users == 0) {
459
+ echo '<div class="wrap"><h2>'.__('No One Is Online Now').'</h2></div>'."\n";
460
+ }
461
+ echo '</div>';
462
+ }
463
+
464
+
465
+ ### Function: Create UserOnline Table
466
+ add_action('activate_useronline.php', 'create_useronline_table');
467
+ function create_useronline_table() {
468
+ global $wpdb;
469
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
470
+ // Drop UserOnline Table
471
+ $wpdb->query("DROP TABLE IF EXISTS $wpdb->useronline");
472
+ // Create UserOnline Table
473
+ $create_table = "CREATE TABLE $wpdb->useronline (".
474
+ " timestamp int(15) NOT NULL default '0',".
475
+ " username varchar(50) NOT NULL default '',".
476
+ " useragent char(100) NOT NULL,".
477
+ " ip varchar(40) NOT NULL default '',".
478
+ " location varchar(255) NOT NULL default '',".
479
+ " url varchar(255) NOT NULL default '',".
480
+ " UNIQUE KEY useronline_id (timestamp,username,ip,useragent))";
481
+ maybe_create_table($wpdb->useronline, $create_table);
482
+ // Add In Options
483
+ add_option('useronline_most_users', 1, 'Most Users Ever Online Count');
484
+ add_option('useronline_most_timestamp', current_time('timestamp'), 'Most Users Ever Online Date');
485
+ }
486
+ ?>
wp-useronline.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.03 |
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.' '.__('User');
71
+ } else {
72
+ $nicetext_users = number_format($total_users).' '.__('Users');
73
+ }
74
+
75
+ ### Nice Text For Members
76
+ if($total_members == 1) {
77
+ $nicetext_members = $total_members.' '.__('Member');
78
+ } else {
79
+ $nicetext_members = number_format($total_members).' '.__('Members');
80
+ }
81
+
82
+
83
+ ### Nice Text For Guests
84
+ if($total_guests == 1) {
85
+ $nicetext_guests = $total_guests.' '.__('Guest');
86
+ } else {
87
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
88
+ }
89
+
90
+ ### Nice Text For Bots
91
+ if($total_bots == 1) {
92
+ $nicetext_bots = $total_bots.' '.__('Bot');
93
+ } else {
94
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
95
+ }
96
+ ?>
97
+ <?php get_header(); ?>
98
+ <div id="content" class="narrowcolumn">
99
+ <p><?php if ($total_users == 1) { _e('There is '); } else { _e('There are a total of '); } ?><b><?php echo $nicetext_users; ?></b> online now: <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p>
100
+ <p>Most users ever online were <b><?php get_most_useronline(); ?></b>, on <b><?php get_most_useronline_date(); ?></b></p>
101
+ <?php
102
+ // Print Out Members
103
+ if($total_members > 0) {
104
+ echo '<h2 class="pagetitle">'.$nicetext_members.' '.__('Online Now').'</h2>'."\n";
105
+ }
106
+ $no=1;
107
+ if($members) {
108
+ $wp_stats = false;
109
+ if(function_exists('get_totalposts')) {
110
+ $wp_stats = true;
111
+ }
112
+ foreach($members as $member) {
113
+ if($wp_stats) {
114
+ 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";
115
+ } else {
116
+ echo '<p><b>#'.$no.' - '.$member['username'].'</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";
117
+ }
118
+ $no++;
119
+ }
120
+ }
121
+ // Print Out Guest
122
+ if($total_guests > 0) {
123
+ echo '<h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
124
+ }
125
+ $no=1;
126
+ if($guests) {
127
+ foreach($guests as $guest) {
128
+ 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";
129
+ $no++;
130
+ }
131
+ }
132
+ // Print Out Bots
133
+ if($total_bots > 0) {
134
+ echo '<h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
135
+ }
136
+ $no=1;
137
+ if($bots) {
138
+ foreach($bots as $bot) {
139
+ 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";
140
+ $no++;
141
+ }
142
+ }
143
+ if($total_users == 0) {
144
+ echo '<h2 class="pagetitle">'.__('No One Is Online Now').'</h2>'."\n";
145
+ }
146
+ ?>
147
+ </div>
148
+ <?php get_sidebar(); ?>
149
+ <?php get_footer(); ?>