WP-UserOnline - Version 2.05

Version Description

Download this release

Release Info

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

Version 2.05

readme.html ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>WP-UserOnline 2.05 Readme</title>
6
+ <style type="text/css" media="screen">
7
+ /* Default Style */
8
+ BODY {
9
+ font-family: Verdana, Arial;
10
+ font-size: 12px;
11
+ color: #000000;
12
+ background: #FFFFFF;
13
+ }
14
+ P {
15
+ padding-left: 10px;
16
+ }
17
+ BLOCKQUOTE {
18
+ margin: 10px 20px 0px 20px;
19
+ padding: 10px;
20
+ border: 1px solid #8d8d8d;
21
+ background-color: #f5f5f5;
22
+ }
23
+ LI {
24
+ margin-top: 20px;
25
+ }
26
+ UL LI UL LI {
27
+ margin-top: 10px;
28
+ }
29
+ A, A:active, A:link, A:visited {
30
+ color: #2d3a4c;
31
+ text-decoration: none;
32
+ }
33
+ A:hover {
34
+ color: #5577a5;
35
+ text-decoration: underline;
36
+ }
37
+ /* Place Holder Style */
38
+ #Container {
39
+ width: 780px;
40
+ margin-left: auto;
41
+ margin-right: auto;
42
+ }
43
+ #Content {
44
+ background-color: #fafafa;
45
+ border: 1px solid #a2b6cb;
46
+ padding: 10px;
47
+ margin-top: -13px;
48
+ }
49
+ /* Title Style */
50
+ #Title {
51
+ font-family: Verdana, Arial;
52
+ font-size: 22px;
53
+ font-weight: bold;
54
+ color: #389aff;
55
+ border-bottom: 1px solid #389aff;
56
+ margin-bottom: 10px;
57
+ }
58
+ .SubTitle {
59
+ font-family: Verdana, Arial;
60
+ font-size: 18px;
61
+ font-weight: bold;
62
+ color: #5b87b4;
63
+ }
64
+ .SubSubTitle {
65
+ font-family: Verdana, Arial;
66
+ font-size: 14px;
67
+ font-weight: bold;
68
+ color: #73a4d6;
69
+ }
70
+ /* Tabs */
71
+ UL#Tabs {
72
+ font-family: Verdana, Arial;
73
+ font-size: 12px;
74
+ font-weight: bold;
75
+ list-style-type: none;
76
+ padding-bottom: 28px;
77
+ border-bottom: 1px solid #a2b6cb;
78
+ margin-bottom: 12px;
79
+ z-index: 1;
80
+ }
81
+ #Tabs LI.Tab {
82
+ float: right;
83
+ height: 25px;
84
+ background-color: #deedfb;
85
+ margin: 2px 0px 0px 5px;
86
+ border: 1px solid #a2b6cb;
87
+ }
88
+ #Tabs LI.Tab A {
89
+ float: left;
90
+ display: block;
91
+ color: #666666;
92
+ text-decoration: none;
93
+ padding: 5px;
94
+ }
95
+ #Tabs LI.Tab A:hover {
96
+ background-color: #bfe0fe;
97
+ border-bottom: 1px solid #bfe0fe;
98
+ }
99
+ /* Selected Tab */
100
+ #Tabs LI.SelectedTab {
101
+ float: right;
102
+ height: 25px;
103
+ background-color: #fafafa;
104
+ margin: 2px 0px 0px 5px;
105
+ border-top: 1px solid #a2b6cb;
106
+ border-right: 1px solid #a2b6cb;
107
+ border-bottom: 1px solid #fafafa;
108
+ border-left: 1px solid #a2b6cb;
109
+ }
110
+ #Tabs LI.SelectedTab A {
111
+ float: left;
112
+ display: block;
113
+ color: #666666;
114
+ text-decoration: none;
115
+ padding: 5px;
116
+ cursor: default;
117
+ }
118
+ /* Copyright */
119
+ #Copyright {
120
+ text-align: center;
121
+ }
122
+ </style>
123
+ <script type="text/javascript">
124
+ // Index Page
125
+ function index() {
126
+ // Tab
127
+ document.getElementById('IndexTab').className = 'SelectedTab';
128
+ document.getElementById('InstallTab').className = 'Tab';
129
+ document.getElementById('UpgradeTab').className = 'Tab';
130
+ document.getElementById('UsageTab').className = 'Tab';
131
+ // Page
132
+ document.getElementById('Index').style.display= 'block';
133
+ document.getElementById('IndexTab').className = 'SelectedTab';
134
+ document.getElementById('Install').style.display = 'none';
135
+ document.getElementById('Upgrade').style.display = 'none';
136
+ document.getElementById('Usage').style.display = 'none';
137
+ }
138
+ // Installation Page
139
+ function install() {
140
+ // Tab
141
+ document.getElementById('IndexTab').className = 'Tab';
142
+ document.getElementById('InstallTab').className = 'SelectedTab';
143
+ document.getElementById('UpgradeTab').className = 'Tab';
144
+ document.getElementById('UsageTab').className = 'Tab';
145
+ // Page
146
+ document.getElementById('Index').style.display= 'none';
147
+ document.getElementById('Install').style.display = 'block';
148
+ document.getElementById('Upgrade').style.display = 'none';
149
+ document.getElementById('Usage').style.display = 'none';
150
+ }
151
+ // Upgrade Page
152
+ function upgrade() {
153
+ // Tab
154
+ document.getElementById('IndexTab').className = 'Tab';
155
+ document.getElementById('InstallTab').className = 'Tab';
156
+ document.getElementById('UpgradeTab').className = 'SelectedTab';
157
+ document.getElementById('UpgradeTab').href = 'Tab';
158
+ document.getElementById('UsageTab').className = 'Tab';
159
+ // Page
160
+ document.getElementById('Index').style.display= 'none';
161
+ document.getElementById('Install').style.display = 'none';
162
+ document.getElementById('Upgrade').style.display = 'block';
163
+ document.getElementById('Usage').style.display = 'none';
164
+ }
165
+ // Usage Page
166
+ function usage() {
167
+ // Tab
168
+ document.getElementById('IndexTab').className = 'Tab';
169
+ document.getElementById('InstallTab').className = 'Tab';
170
+ document.getElementById('UpgradeTab').className = 'Tab';
171
+ document.getElementById('UsageTab').className = 'SelectedTab';
172
+ // Page
173
+ document.getElementById('Index').style.display= 'none';
174
+ document.getElementById('Install').style.display = 'none';
175
+ document.getElementById('Upgrade').style.display = 'none';
176
+ document.getElementById('Usage').style.display = 'block';
177
+ }
178
+ </script>
179
+ </head>
180
+ <body>
181
+ <div id="Container">
182
+ <!-- Title -->
183
+ <div id="Title">WP-UserOnline 2.05&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
184
+
185
+ <!-- Tabs -->
186
+ <ul id="Tabs">
187
+ <li id="UsageTab" class="Tab"><a href="#Usage" onclick="usage(); return false;" title="Usage Instructions">Usage</a></li>
188
+ <li id="UpgradeTab" class="Tab"><a href="#Upgrade" onclick="upgrade(); return false;" title="Upgrade Instructions">Upgrade</a></li>
189
+ <li id="InstallTab" class="Tab"><a href="#Installation" onclick="install(); return false;" title="Installation Instructions">Installation</a></li>
190
+ <li id="IndexTab" class="SelectedTab"><a href="#Index" onclick="index(); return false;" title="Index Instructions">Index</a></li>
191
+ </ul>
192
+
193
+ <!-- Content -->
194
+ <div id="Content">
195
+ <!-- Index -->
196
+ <div id="Index">
197
+ <div class="SubTitle">&raquo; Index</div>
198
+ <div class="SubSubTitle">Plugin Information</div>
199
+ <p><b>Author</b><br /><b>&raquo;</b> Lester 'GaMerZ' Chan</p>
200
+ <p>
201
+ <b>EMail:</b><br /><b>&raquo;</b>
202
+ <script type="text/javascript">
203
+ /* <![CDATA[*/
204
+ document.write(' <a href="mailto:gamerz84@hotmail.com?Subject=WP-UserOnline%202.05%20Support" title="EMail To gamerz84@hotmail.com">gamerz84@hotmail.com</a>');
205
+ /* ]]> */
206
+ </script>
207
+ </p>
208
+ <p><b>Website:</b><br /><b>&raquo;</b> <a href="http://www.lesterchan.net/" title="http://www.lesterchan.net/">http://www.lesterchan.net/</a></p>
209
+ <p><b>Demo:</b><br /><b>&raquo;</b> <a href="http://www.lesterchan.net/wordpress/useronline/" title="http://www.lesterchan.net/wordpress/useronline/">http://www.lesterchan.net/wordpress/useronline/</a></p>
210
+ <p><b>Documentation:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/wiki/wp-useronline" title="http://dev.wp-plugins.org/wiki/wp-useronline">http://dev.wp-plugins.org/wiki/wp-useronline</a></p>
211
+ <p><b>Development:</b><br /><b>&raquo;</b> <a href="http://dev.wp-plugins.org/browser/wp-useronline/" title="http://dev.wp-plugins.org/browser/wp-useronline/">http://dev.wp-plugins.org/browser/wp-useronline/</a></p>
212
+ <p><b>Support Forums:</b><br /><b>&raquo;</b> <a href="http://forums.lesterchan.net/viewforum.php?f=10" title="http://forums.lesterchan.net/viewforum.php?f=10">http://forums.lesterchan.net/viewforum.php?f=10</a></p>
213
+ <p><b>Updated:</b><br /><b>&raquo;</b> 1st October 2006</p>
214
+ <p><b>Note:</b><br /><b>&raquo;</b> I have changed some of WP-UserOnline's structure, So if there is any bug, please contact me immediately.</p>
215
+ <div class="SubSubTitle">Changelog</div>
216
+ <ul>
217
+ <li>
218
+ <b>Version 2.05 (01-10-2006)</b>
219
+ <ul>
220
+ <li>NEW: UserOnline Is Now Embedded Into A Page, And Hence No More Integrating Of UserOnline Page (Removed wp-useronline.php)</li>
221
+ <li>NEW: Changed In WP-UserOnline Structure: Members Mean Registered Users and Guests Mean Comment Authors</li>
222
+ <li>NEW: get_users_browsing_site(false) And get_users_browsing_page(false) Will Now Return An Array Containing Total Users, Total Members, Total Guests and Total Bots Online</li>
223
+ <li>NEW: Added Widget Title Option To WP-UserOnline Widget</li>
224
+ <li>FIXED: Invalid IP Error</li>
225
+ <li>FIXED: If Site URL Doesn't Match WP Option's Site URL, WP-UserOnline Will Not Work</li>
226
+ </ul>
227
+ </li>
228
+ <li>
229
+ <b>Version 2.04 (01-07-2006)</b>
230
+ <ul>
231
+ <li>NEW: AJAX Is Now Used For Updating Users Online Every 1 Minute Without Refreshing The Page</li>
232
+ <li>NEW: You Can Now Place Users Online Count And Users Browsing Site Data On The Sidebar As A Widget</li>
233
+ <li>NEW: UserOnline Options Panel And The Code That WP-UserOnline Generated Is XHTML 1.0 Transitional</li>
234
+ <li>NEW: Added Useronline Options In WP Administration Panel Under 'Options -> Useronline'</li>
235
+ <li>NEW: If You Have <a href="http://frenchfragfactory.net/ozh/archives/2004/08/27/ip-to-nation-plugin/">ip2nation Plugin</a> Installed, The User's/Guest's Country Flag Will Be Displayed</li>
236
+ </ul>
237
+ </li>
238
+ <li>
239
+ <b>Version 2.03 (01-04-2006)</b>
240
+ <ul>
241
+ <li>NEW: Added get_users_browsing_site(); To Display Users Browsing The Site</li>
242
+ <li>FIXED: wp-stats.php Link</li>
243
+ <li>FIXED: Some Grammer Errors, Credit To xclouds (http://www.xclouds.com/)</li>
244
+ </ul>
245
+ </li>
246
+ <li>
247
+ <b>Version 2.02 (01-03-2006)</b>
248
+ <ul>
249
+ <li>NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin.</li>
250
+ <li>FIXED: IP 'Unknown' Error, Credit To Brian Layman (http://www.knitchat.com/)</li>
251
+ <li>FIXED: ON DUPLICATE KEY Error, Credit To Brian Layman (http://www.knitchat.com/)</li>
252
+ <li>FIXED: DUPLICATE KEY Error By Using DELETE First, Credit To Jody Cairns (http://steelwhitetable.org/blog/)</li>
253
+ </ul>
254
+ </li>
255
+ <li>
256
+ <b>Version 2.01 (01-02-2006)</b>
257
+ <ul>
258
+ <li>NEW: Added Users Browsing Page</li>
259
+ <li>NEW: Added Most Users Ever Online</li>
260
+ <li>FIXED: Added UNIQUE Key Instead Of Primary Key To Test Whether It Will Solve Duplicate Entry Errors</li>
261
+ <li>FIXED: Quotes Issue In Page Title</li>
262
+ </ul>
263
+ </li>
264
+ <li>
265
+ <b>Version 2.00 (01-01-2006)</b>
266
+ <ul>
267
+ <li>NEW: Compatible With Only WordPress 2.0</li>
268
+ <li>NEW: Better Installer</li>
269
+ <li>NEW: GPL License Added</li>
270
+ <li>NEW: Page Title Added To wp-useronline.php</li>
271
+ <li>NEW: Added Extra Bots, Credit To Greg Perry (http://www.gregrperry.com/)</li>
272
+ <li>FIXED: Cleaner Codes</li>
273
+ </ul>
274
+ </li>
275
+ </ul>
276
+ </div>
277
+
278
+ <!-- Installation Instructions -->
279
+ <div id="Install" style="display: none;">
280
+ <div class="SubTitle">&raquo; Installation Instructions</div>
281
+ <ol>
282
+ <li>
283
+ Open <b>wp-content/plugins</b> Folder
284
+ </li>
285
+ <li>
286
+ Put:
287
+ <blockquote>Folder: useronline</blockquote>
288
+ </li>
289
+ <li>
290
+ <b>Activate</b> WP-UserOnline Plugin
291
+ </li>
292
+ <li>
293
+ Refer To <b>Usage</b> For Further Instructions
294
+ </li>
295
+ </ol>
296
+ </div>
297
+
298
+ <!-- Upgrade Instructions -->
299
+ <div id="Upgrade" style="display: none;">
300
+ <div class="SubTitle">&raquo; Upgrade Instructions</div>
301
+ <div class="SubSubTitle">From v1.0x To v2.05</div>
302
+ <ol>
303
+ <li>
304
+ <b>Deactivate</b> WP-UserOnline Plugin
305
+ </li>
306
+ <li>
307
+ Open <b>Root WordPress</b> Folder
308
+ </li>
309
+ <li>
310
+ Delete file if exists:
311
+ <blockquote>File: wp-useronline.php</blockquote>
312
+ </li>
313
+ <li>
314
+ Open <b>wp-content/plugins</b> Folder
315
+ </li>
316
+ <li>
317
+ Put:
318
+ <blockquote>Folder: useronline</blockquote>
319
+ </li>
320
+ <li>
321
+ Delete file if exists:
322
+ <blockquote>File: useronline.php</blockquote>
323
+ </li>
324
+ <li>
325
+ Open <b>wp-content/plugins/useronline</b> Folder
326
+ </li>
327
+ <li>
328
+ Delete file if exists:
329
+ <blockquote>File: wp-useronline.php</blockquote>
330
+ </li>
331
+ <li>
332
+ <b>Activate</b> WP-UserOnline Plugin
333
+ </li>
334
+ <li>
335
+ Refer To <b>Usage</b> For Further Instructions
336
+ </li>
337
+ </ol>
338
+ </div>
339
+
340
+ <!-- Usage Instructions -->
341
+ <div id="Usage" style="display: none;">
342
+ <div class="SubTitle">&raquo; Usage Instructions</div>
343
+ <div class="SubSubTitle">General Usage (Without Widget)</div>
344
+ <ol>
345
+ <li>
346
+ Open <b>wp-content/themes/&lt;YOUR THEME NAME&gt;/sidebar.php</b>
347
+ </li>
348
+ <li>
349
+ Add Anywhere:
350
+ <blockquote>
351
+ &lt;?php if (function_exists('useronline')): ?&gt;<br />
352
+ &nbsp;&nbsp;&nbsp;&lt;li&gt;<br />
353
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;UserOnline&lt;/h2&gt;<br />
354
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
355
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;div id="useronline-count"&gt;&lt;?php get_useronline(); ?&gt;&lt;/div&gt;&lt;/li&gt;<br />
356
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
357
+ &nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
358
+ &lt;?php endif; ?&gt;
359
+ </blockquote>
360
+ </li>
361
+ </ol>
362
+ <div class="SubSubTitle">General Usage (With Widget)</div>
363
+ <ol>
364
+ <li>
365
+ <b>Activate</b> WP-UserOnline Widget Plugin
366
+ </li>
367
+ <li>
368
+ Go to 'WP-Admin -> Presentation -> Sidebar Widgets'
369
+ </li>
370
+ <li>
371
+ <b>Drag</b> the UserOnline Widget to your sidebar
372
+ </li>
373
+ <li>
374
+ You can <b>configure</b> the UserOnline Widget by clicking on the configure icon
375
+ </li>
376
+ <li>
377
+ Click 'Save changes'
378
+ </li>
379
+ <li>
380
+ Scroll down for instructions on how to create a <b>UserOnline Page</b>.
381
+ </li>
382
+ </ol>
383
+ <div class="SubSubTitle">UserOnline Page</div>
384
+ <ol>
385
+ <li>
386
+ Go to 'WP-Admin -> Write -> Write Page'
387
+ </li>
388
+ <li>
389
+ Type any title you like in the post's title area
390
+ </li>
391
+ <li>
392
+ Type '<b>[page_useronline]</b>' in the post's content area (without the quotes)
393
+ </li>
394
+ <li>
395
+ Type '<b>useronline</b>' in the post's slug area (without the quotes)
396
+ </li>
397
+ <li>
398
+ Click 'Publish'
399
+ </li>
400
+ <li>If you <b>ARE NOT</b> using nice permalinks, you need to go to 'WP-Admin -> Options -> Useronline' and under '<b>UserOnline URL</b>', you need to fill in the URL to the UserOnline Page you created above.</li>
401
+ </ol>
402
+ <div class="SubSubTitle">UserOnline Stats (Outside WP Loop)</div>
403
+ <ul>
404
+ <li>
405
+ To Display <b>Most Number Of Users Online</b>
406
+ </li>
407
+ <li>
408
+ Use:
409
+ <blockquote>
410
+ &lt;?php if (function_exists('get_most_useronline')): ?&gt;<br />
411
+ &nbsp;&nbsp;&nbsp;&lt;p&gt;Most Users Ever Online Is &lt;?php get_most_useronline(); ?&gt; On &lt;?php get_most_useronline_date(); ?&gt;&lt;/p&gt;<br />
412
+ &lt;?php endif; ?&gt;
413
+ </blockquote>
414
+ </li>
415
+ <li>
416
+ To Display <b>Users Browsing Site</b>
417
+ </li>
418
+ <li>
419
+ Use:
420
+ <blockquote>
421
+ &lt;?php if (function_exists('get_users_browsing_site')): ?&gt;<br />
422
+ &nbsp;&nbsp;&nbsp;&lt;div id="useronline-browsing-site"&gt;&lt;?php get_users_browsing_site(); ?&gt;&lt;/div&gt;<br />
423
+ &lt;?php endif; ?&gt;
424
+ </blockquote>
425
+ </li>
426
+ <li>
427
+ To Display <b>Users Browsing A Page</b>
428
+ </li>
429
+ <li>
430
+ Use:
431
+ <blockquote>
432
+ &lt;?php if (function_exists('get_users_browsing_page')): ?&gt;<br />
433
+ &nbsp;&nbsp;&nbsp;&lt;div id="useronline-browsing-page"&gt;&lt;?php get_users_browsing_page(); ?&gt;&lt;/div&gt;<br />
434
+ &lt;?php endif; ?&gt;
435
+ </blockquote>
436
+ </li>
437
+ </ul>
438
+ </div>
439
+ </div>
440
+ </div>
441
+ <p id="Copyright">WP-UserOnline 2.05<br />Copyright &copy; 2006 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
442
+ </body>
443
+ </html>
useronline/useronline-js.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-UserOnline 2.05 |
5
+ | Copyright (c) 2006 Lester "GaMerZ" Chan |
6
+ | |
7
+ | File Written By: |
8
+ | - Lester "GaMerZ" Chan |
9
+ | - http://www.lesterchan.net |
10
+ | |
11
+ | File Information: |
12
+ | - Useronline Javascript File |
13
+ | - wp-content/plugins/useronline/useronline-js.js |
14
+ | |
15
+ +----------------------------------------------------------------+
16
+ */
17
+
18
+
19
+
20
+ // UserOnline JavaScript Init
21
+ function useronline_init() {
22
+ // Check Users Count
23
+ if(document.getElementById('useronline-count') != null ) {
24
+ setInterval("get_useronline_count()", useronline_timeout);
25
+ }
26
+ // Check Users Browsing Site
27
+ if(document.getElementById('useronline-browsing-site') != null ) {
28
+ setInterval("get_useronline_browsingsite()", useronline_timeout);
29
+ }
30
+ // Check Users Browsing Page
31
+ if(document.getElementById('useronline-browsing-page') != null) {
32
+ setInterval("get_useronline_browsingpage()", useronline_timeout);
33
+ }
34
+ }
35
+
36
+
37
+ // Get UserOnline Count
38
+ function get_useronline_count() {
39
+ useronline_count = new sack(ajax_url);
40
+ useronline_count.setVar("useronline_mode", 'useronline_count');
41
+ useronline_count.method = 'GET';
42
+ useronline_count.element = 'useronline-count';
43
+ useronline_count.runAJAX();
44
+ useronline_count = null;
45
+ }
46
+
47
+
48
+ // Get Users Browsing Site
49
+ function get_useronline_browsingsite() {
50
+ useronline_browsingsite = new sack(ajax_url);
51
+ useronline_browsingsite.setVar("useronline_mode", 'useronline_browsingsite');
52
+ useronline_browsingsite.method = 'GET';
53
+ useronline_browsingsite.element = 'useronline-browsing-site';
54
+ useronline_browsingsite.runAJAX();
55
+ useronline_browsingsite = null;
56
+ }
57
+
58
+
59
+ // Get Users Browsing Page
60
+ function get_useronline_browsingpage() {
61
+ useronline_browsingpage = new sack(ajax_url);
62
+ useronline_browsingpage.setVar("useronline_mode", 'useronline_browsingpage');
63
+ useronline_browsingpage.method = 'GET';
64
+ useronline_browsingpage.element = 'useronline-browsing-page';
65
+ useronline_browsingpage.runAJAX();
66
+ useronline_browsingpage = null;
67
+ }
68
+
69
+
70
+ // Init UserOnline
71
+ window.onload = useronline_init;
useronline/useronline-options.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.05 |
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 Options Page |
14
+ | - wp-content/plugins/useronline/useronline-options.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Variables Variables Variables
21
+ $base_name = plugin_basename('useronline/useronline-options.php');
22
+ $base_page = 'admin.php?page='.$base_name;
23
+
24
+ ### If Form Is Submitted
25
+ if($_POST['Submit']) {
26
+ $useronline_bots = array();
27
+ $useronline_timeout = intval($_POST['useronline_timeout']);
28
+ $useronline_bots_name = explode("\n", trim($_POST['useronline_bots_name']));
29
+ $useronline_bots_agent = explode("\n", trim($_POST['useronline_bots_agent']));
30
+ $useronline_bots_keys = array_values((array) $useronline_bots_name);
31
+ $useronline_bots_vals = array_values((array) $useronline_bots_agent);
32
+ $n = max(count($useronline_bots_keys), count($useronline_bots_vals));
33
+ for($i = 0; $i < $n; $i++) {
34
+ $useronline_bots[trim($useronline_bots_keys[$i])] = trim($useronline_bots_vals[$i]);
35
+ }
36
+ $useronline_url = addslashes(trim($_POST['useronline_url']));
37
+ $update_useronline_queries = array();
38
+ $update_useronline_text = array();
39
+ $update_useronline_queries[] = update_option('useronline_timeout', $useronline_timeout);
40
+ $update_useronline_queries[] = update_option('useronline_bots', $useronline_bots);
41
+ $update_useronline_queries[] = update_option('useronline_url', $useronline_url);
42
+ $update_useronline_text[] = __('Useronline Timeout');
43
+ $update_useronline_text[] = __('Useronline Bots');
44
+ $update_useronline_text[] = __('Useronline URL');
45
+ $i=0;
46
+ $text = '';
47
+ foreach($update_useronline_queries as $update_useronline_query) {
48
+ if($update_useronline_query) {
49
+ $text .= '<font color="green">'.$update_useronline_text[$i].' '.__('Updated').'</font><br />';
50
+ }
51
+ $i++;
52
+ }
53
+ if(empty($text)) {
54
+ $text = '<font color="red">'.__('No Useronline Option Updated').'</font>';
55
+ }
56
+ }
57
+
58
+ ### Get Useronline Bots
59
+ $useronline_options_bots = get_settings('useronline_bots');
60
+ $useronline_options_bots_name = '';
61
+ $useronline_options_bots_agent = '';
62
+ foreach($useronline_options_bots as $botname => $botagent) {
63
+ $useronline_options_bots_name .= $botname."\n";
64
+ $useronline_options_bots_agent .= $botagent."\n";
65
+ }
66
+ $useronline_options_bots_name = trim($useronline_options_bots_name);
67
+ $useronline_options_bots_agent = trim($useronline_options_bots_agent);
68
+ ?>
69
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
70
+ <div class="wrap">
71
+ <h2><?php _e('Useronline Options'); ?></h2>
72
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
73
+ <fieldset class="options">
74
+ <legend><?php _e('Useronline Options'); ?></legend>
75
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
76
+ <tr valign="top">
77
+ <th align="left" width="30%"><?php _e('Time Out'); ?></th>
78
+ <td align="left">
79
+ <input type="text" name="useronline_timeout" value="<?php echo get_settings('useronline_timeout'); ?>" size="4" /><br />How long till it will remove the user from the database (In seconds).
80
+ </td>
81
+ </tr>
82
+ <tr valign="top">
83
+ <th align="left" width="30%"><?php _e('UserOnline URL'); ?></th>
84
+ <td align="left">
85
+ <input type="text" name="useronline_url" value="<?php echo get_settings('useronline_url'); ?>" size="50" /><br />URL To UserOnline Page<br />Example: http://www.yoursite.com/blogs/useronline/<br />Example: http://www.yoursite.com/blogs/?page_id=2
86
+ </td>
87
+ </tr>
88
+ <tr valign="top">
89
+ <th align="left" width="30%"><?php _e('Bots Name/User Agent'); ?></th>
90
+ <td align="left">
91
+ Here are a list of bots and their partial browser agents.<br />On the left column will be the <strong>Bot's Name</strong> and on the right column will be their <strong>Partial Browser Agent</strong>.<br />Start each entry on a new line.
92
+ <br /><br />
93
+ <textarea cols="20" rows="30" name="useronline_bots_name"><?php echo $useronline_options_bots_name; ?></textarea>
94
+ <textarea cols="20" rows="30" name="useronline_bots_agent"><?php echo $useronline_options_bots_agent; ?></textarea>
95
+ </td>
96
+ </tr>
97
+ </table>
98
+ </fieldset>
99
+ <div align="center">
100
+ <input type="submit" name="Submit" class="button" value="<?php _e('Update Options'); ?>" />&nbsp;&nbsp;<input type="button" name="cancel" value="Cancel" class="button" onclick="javascript:history.go(-1)" />
101
+ </div>
102
+ </form>
103
+ </div>
useronline/useronline-widget.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP-UserOnline Widget
4
+ Plugin URI: http://www.lesterchan.net/portfolio/programming.php
5
+ Description: Adds a UserOnline Widget To Display Users Online From WP-UserOnline Plugin
6
+ Version: 2.05
7
+ Author: GaMerZ
8
+ Author URI: http://www.lesterchan.net
9
+ */
10
+
11
+
12
+ /* Copyright 2006 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
+ ### Function: Init WP-UserOnline Widget
31
+ function widget_useronline_init() {
32
+ if (!function_exists('register_sidebar_widget')) {
33
+ return;
34
+ }
35
+
36
+ ### Function: WP-UserOnline Widget
37
+ function widget_useronline($args) {
38
+ extract($args);
39
+ $options = get_option('widget_useronline');
40
+ $title = htmlspecialchars($options['title']);
41
+ echo $before_widget.$before_title.$title.$after_title;
42
+ if (function_exists('useronline')) {
43
+ echo '<ul>'."\n";
44
+ echo '<li><div id="useronline-count">';
45
+ get_useronline();
46
+ echo '</div></li>'."\n";
47
+ if(intval($options['display_usersbrowsingsite']) == 1) {
48
+ echo '<li><div id="useronline-browsing-site">';
49
+ get_users_browsing_site();
50
+ echo '</div></li>'."\n";
51
+ }
52
+ echo '</ul>'."\n";
53
+ }
54
+ echo $after_widget;
55
+ }
56
+
57
+ ### Function: WP-UserOnline Widget Options
58
+ function widget_useronline_options() {
59
+ $options = get_option('widget_useronline');
60
+ if (!is_array($options)) {
61
+ $options = array('display_usersbrowsingsite' => '0', 'title' => 'UserOnline');
62
+ }
63
+ if ($_POST['useronline-submit']) {
64
+ $options['display_usersbrowsingsite'] = intval($_POST['useronline-usersbrowsingsite']);
65
+ $options['title'] = strip_tags(stripslashes($_POST['useronline-title']));
66
+ update_option('widget_useronline', $options);
67
+ }
68
+ echo '<p style="text-align: left;"><label for="useronline-title">Widget Title:</label>&nbsp;&nbsp;&nbsp;<input type="text" id="useronline-title" name="useronline-title" value="'.htmlspecialchars($options['title']).'" />';
69
+ echo '<p style="text-align: center;"><label for="useronline-usersbrowsingsite">Display Users Browsing Site Under Users Online Count?</label></p>'."\n";
70
+ echo '<p style="text-align: center;"><input type="radio" id="useronline-usersbrowsingsite" name="useronline-usersbrowsingsite" value="1"';
71
+ checked(1, intval($options['display_usersbrowsingsite']));
72
+ echo ' />&nbsp;Yes&nbsp;&nbsp;&nbsp;<input type="radio" id="useronline-usersbrowsingsite" name="useronline-usersbrowsingsite" value="0"';
73
+ checked(0, intval($options['display_usersbrowsingsite']));
74
+ echo ' />&nbsp;No</p>'."\n";
75
+ echo '<input type="hidden" id="useronline-submit" name="useronline-submit" value="1" />'."\n";
76
+ }
77
+
78
+ // Register Widgets
79
+ register_sidebar_widget('UserOnline', 'widget_useronline');
80
+ register_widget_control('UserOnline', 'widget_useronline_options', 350, 120);
81
+ }
82
+
83
+
84
+ ### Function: Load The WP-UserOnline Widget
85
+ add_action('plugins_loaded', 'widget_useronline_init');
86
+ ?>
useronline/useronline.php ADDED
@@ -0,0 +1,662 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.05
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/useronline.php', 'display_useronline');
39
+ }
40
+ if (function_exists('add_options_page')) {
41
+ add_options_page(__('Useronline'), __('Useronline'), 'manage_options', 'useronline/useronline-options.php');
42
+ }
43
+ }
44
+
45
+
46
+ ### Function: Displays UserOnline Header
47
+ add_action('wp_head', 'useronline_header');
48
+ function useronline_header() {
49
+ if(strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') === false) {
50
+ $ajax_url = $_SERVER['SCRIPT_NAME'];
51
+ } else {
52
+ $ajax_url = $_SERVER['PHP_SELF'];
53
+ }
54
+ echo '<script type="text/javascript">'."\n";
55
+ echo '/* Start Of Javascript Generated By WP-UserOnline 2.05 */'."\n";
56
+ echo '/* <![CDATA[ */'."\n";
57
+ echo "\t".'if(site_url != \''.get_settings('siteurl').'\' || ajax_url != \''.$ajax_url.'\') {'."\n";
58
+ echo "\t\t".'var site_url = \''.get_settings('siteurl').'\';'."\n";
59
+ echo "\t\t".'var ajax_url = \''.$ajax_url.'\';'."\n";
60
+ echo "\t".'}'."\n";
61
+ echo "\t".'var useronline_timeout = '.(get_settings('useronline_timeout')*1000).';'."\n";
62
+ echo '/* ]]> */'."\n";
63
+ echo '/* End Of Javascript Generated By WP-UserOnline 2.05 */'."\n";
64
+ echo '</script>'."\n";
65
+ echo '<script src="'.get_settings('siteurl').'/wp-includes/js/tw-sack.js" type="text/javascript"></script>'."\n";
66
+ echo '<script src="'.get_settings('siteurl').'/wp-content/plugins/useronline/useronline-js.js" type="text/javascript"></script>'."\n";
67
+ }
68
+
69
+ ### Function: Process AJAX Request
70
+ add_action('init', 'useronline_ajax');
71
+ function useronline_ajax() {
72
+ global $wpdb, $useronline;
73
+ $mode = trim($_GET['useronline_mode']);
74
+ if(!empty($mode)) {
75
+ switch($mode) {
76
+ case 'useronline_count':
77
+ $useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));
78
+ get_useronline();
79
+ break;
80
+ case 'useronline_browsingsite':
81
+ get_users_browsing_site();
82
+ break;
83
+ case 'useronline_browsingpage':
84
+ get_users_browsing_page();
85
+ break;
86
+ }
87
+ exit();
88
+ }
89
+ }
90
+
91
+
92
+ ### Function: Process UserOnline
93
+ add_action('admin_head', 'useronline');
94
+ add_action('wp_head', 'useronline');
95
+ function useronline() {
96
+ global $wpdb, $useronline;
97
+ // Useronline Settings
98
+ $timeoutseconds = get_settings('useronline_timeout');
99
+ $timestamp = current_time('timestamp');
100
+ $timeout = ($timestamp-$timeoutseconds);
101
+ $ip = get_ipaddress();
102
+ $url = addslashes(urlencode($_SERVER['REQUEST_URI']));
103
+ $useragent = $_SERVER['HTTP_USER_AGENT'];
104
+ $current_user = wp_get_current_user();
105
+
106
+ // Check For Bot
107
+ $bots = get_settings('useronline_bots');
108
+ foreach ($bots as $name => $lookfor) {
109
+ if (stristr($useragent, $lookfor) !== false) {
110
+ $user_id = 0;
111
+ $display_name = addslashes($name);
112
+ $user_name = addslashes($lookfor);
113
+ $type = 'bot';
114
+ $where = "WHERE ip = '$ip'";
115
+ $bot_found = true;
116
+ break;
117
+ }
118
+ }
119
+
120
+ // If No Bot Is Found, Then We Check Members And Guests
121
+ if(!$bot_found) {
122
+ // Check For Member
123
+ if($current_user->ID > 0) {
124
+ $user_id = $current_user->ID;
125
+ $display_name = addslashes($current_user->display_name);
126
+ $user_name = addslashes($current_user->user_login);
127
+ $type = 'member';
128
+ $where = "WHERE userid = '$user_id'";
129
+ // Check For Comment Author (Guest)
130
+ } elseif(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
131
+ $user_id = 0;
132
+ $display_name = addslashes(trim($_COOKIE['comment_author_'.COOKIEHASH]));
133
+ $user_name = "guest_$display_name";
134
+ $type = 'guest';
135
+ $where = "WHERE ip = '$ip'";
136
+ // Check For Guest
137
+ } else {
138
+ $user_id = 0;
139
+ $display_name = 'Guest';
140
+ $user_name = "guest";
141
+ $type = 'guest';
142
+ $where = "WHERE ip = '$ip'";
143
+ }
144
+ }
145
+
146
+ // Get User Agent
147
+ $useragent = addslashes($useragent);
148
+
149
+ // Check For Page Title
150
+ $make_page = wp_title('&raquo;', false);
151
+ if(empty($make_page)) {
152
+ $make_page = get_bloginfo('name');
153
+ } elseif(is_single()) {
154
+ $make_page = get_bloginfo('name').' &raquo; Blog Archive '.$make_page;
155
+ } else {
156
+ $make_page = get_bloginfo('name').$make_page;
157
+ }
158
+ $make_page = addslashes($make_page);
159
+
160
+ // Delete Users
161
+ $delete_users = $wpdb->query("DELETE FROM $wpdb->useronline $where OR (timestamp < $timeout)");
162
+
163
+ // Insert Users
164
+ $insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$user_id', '$user_name', '$display_name', '$useragent', '$ip', '$make_page', '$url', '$type')");
165
+
166
+ // Count Users Online
167
+ $useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));
168
+
169
+ // Get Most User Online
170
+ $most_useronline = intval(get_settings('useronline_most_users'));
171
+
172
+ // Check Whether Current Users Online Is More Than Most Users Online
173
+ if($useronline > $most_useronline) {
174
+ update_option('useronline_most_users', $useronline);
175
+ update_option('useronline_most_timestamp', current_time('timestamp'));
176
+ }
177
+ }
178
+
179
+
180
+ ### Function: Display UserOnline
181
+ if(!function_exists('get_useronline')) {
182
+ function get_useronline($user = 'User', $users = 'Users', $display = true) {
183
+ global $useronline;
184
+ $useronline_url = get_settings('useronline_url');
185
+ // Display User Online
186
+ if($display) {
187
+ if($useronline > 1) {
188
+ echo '<a href="'.$useronline_url.'"><strong>'.number_format($useronline).'</strong> '.$users.' '.__('Online').'</a>'."\n";
189
+ } else {
190
+ echo '<a href="'.$useronline_url.'"><strong>'.$useronline.'</strong> '.$user.' '.__('Online').'</a>'."\n";
191
+ }
192
+ } else {
193
+ return number_format($useronline);
194
+ }
195
+ }
196
+ }
197
+
198
+
199
+ ### Function: Display Max UserOnline
200
+ if(!function_exists('get_most_useronline')) {
201
+ function get_most_useronline($display = true) {
202
+ $most_useronline_users = intval(get_settings('useronline_most_users'));
203
+ if($display) {
204
+ echo number_format($most_useronline_users);
205
+ } else {
206
+ return $most_useronline_users;
207
+ }
208
+ }
209
+ }
210
+
211
+
212
+ ### Function: Display Max UserOnline Date
213
+ if(!function_exists('get_most_useronline_date')) {
214
+ function get_most_useronline_date($display = true, $date_format = 'jS F Y, H:i') {
215
+ $most_useronline_timestamp = get_settings('useronline_most_timestamp');
216
+ $most_useronline_date = gmdate($date_format, $most_useronline_timestamp);
217
+ if($display) {
218
+ echo $most_useronline_date;
219
+ } else {
220
+ return$most_useronline_date;
221
+ }
222
+ }
223
+ }
224
+
225
+
226
+ ### Function: Display Users Browsing The Site
227
+ function get_users_browsing_site($display = true) {
228
+ global $wpdb;
229
+
230
+ // Get Users Browsing Site
231
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
232
+ $users_browse = $wpdb->get_results("SELECT displayname, type FROM $wpdb->useronline ORDER BY type");
233
+
234
+ // Variables
235
+ $members = array();
236
+ $guests = array();
237
+ $bots = array();
238
+ $total_users = 0;
239
+ $total_members = 0;
240
+ $total_guests = 0;
241
+ $total_bots = 0;
242
+ $nicetext_members = '';
243
+ $nicetext_guests = '';
244
+ $nicetext_bots = '';
245
+
246
+ // If There Is Users Browsing, Then We Execute
247
+ if($users_browse) {
248
+ // Get Users Information
249
+ foreach($users_browse as $user_browse) {
250
+ switch($user_browse->type) {
251
+ case 'member':
252
+ $members[] = stripslashes($user_browse->displayname);
253
+ $total_members++;
254
+ break;
255
+ case 'guest':
256
+ $guests[] = stripslashes($user_browse->displayname);
257
+ $total_guests++;
258
+ break;
259
+ case 'bot':
260
+ $bots[] = stripslashes($user_browse->displayname);
261
+ $total_bots++;
262
+ break;
263
+ }
264
+ }
265
+ $total_users = ($total_guests+$total_bots+$total_members);
266
+
267
+ // If We Do Not Display It, Return Respective Users Count
268
+ if(!$display) {
269
+ return array ($total_users, $total_members, $total_guests, $total_bots);
270
+ }
271
+
272
+ // Nice Text For Guests
273
+ if($total_guests == 1) {
274
+ $nicetext_guests = $total_guests.' '.__('Guest');
275
+ } else {
276
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
277
+ }
278
+ // Nice Text For Bots
279
+ if($total_bots == 1) {
280
+ $nicetext_bots = $total_bots.' '.__('Bot');
281
+ } else {
282
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
283
+ }
284
+
285
+ // Print Member Name
286
+ if($members) {
287
+ $temp_member = '';
288
+ foreach($members as $member) {
289
+ $temp_member .= '<a href="'.useronline_stats_page_link(urlencode($member)).'">'.$member.'</a>, ';
290
+ }
291
+ if(!function_exists('get_totalposts')) {
292
+ $temp_member = strip_tags($temp_member);
293
+ }
294
+ }
295
+ // Print Guests
296
+ if($total_guests > 0) {
297
+ $temp_member .= $nicetext_guests.', ';
298
+ }
299
+ // Print Bots
300
+ if($total_bots > 0) {
301
+ $temp_member .= $nicetext_bots.', ';
302
+ }
303
+ // Print User Count
304
+ $temp_member = substr($temp_member, 0, -2);
305
+ echo __('Users: ').'<strong>'.$temp_member.'</strong><br />';
306
+ } else {
307
+ // This Should Not Happen
308
+ _e('No User Is Browsing This Site');
309
+ }
310
+ }
311
+
312
+
313
+ ### Function: Display Users Browsing The Page
314
+ function get_users_browsing_page($display = true) {
315
+ global $wpdb;
316
+
317
+ // Get Users Browsing Page
318
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
319
+ $users_browse = $wpdb->get_results("SELECT displayname, type FROM $wpdb->useronline WHERE url = '$page_url' ORDER BY type");
320
+
321
+ // Variables
322
+ $members = array();
323
+ $guests = array();
324
+ $bots = array();
325
+ $total_users = 0;
326
+ $total_members = 0;
327
+ $total_guests = 0;
328
+ $total_bots = 0;
329
+ $nicetext_members = '';
330
+ $nicetext_guests = '';
331
+ $nicetext_bots = '';
332
+
333
+ // If There Is Users Browsing, Then We Execute
334
+ if($users_browse) {
335
+ // Reassign Bots Name
336
+ $bots = get_settings('useronline_bots');
337
+ $bots_name = array();
338
+ foreach($bots as $botname => $botlookfor) {
339
+ $bots_name[] = $botname;
340
+ }
341
+ // Get Users Information
342
+ foreach($users_browse as $user_browse) {
343
+ switch($user_browse->type) {
344
+ case 'member':
345
+ $members[] = stripslashes($user_browse->displayname);
346
+ $total_members++;
347
+ break;
348
+ case 'guest':
349
+ $guests[] = stripslashes($user_browse->displayname);
350
+ $total_guests++;
351
+ break;
352
+ case 'bot':
353
+ $bots[] = stripslashes($user_browse->displayname);
354
+ $total_bots++;
355
+ break;
356
+ }
357
+ }
358
+ $total_users = ($total_guests+$total_bots+$total_members);
359
+
360
+ // If We Do Not Display It, Return Respective Users Count
361
+ if(!$display) {
362
+ return array ($total_users, $total_members, $total_guests, $total_bots);
363
+ }
364
+
365
+ // Nice Text For Members
366
+ if($total_members == 1) {
367
+ $nicetext_members = $total_members.' '.__('Member');
368
+ } else {
369
+ $nicetext_members = number_format($total_members).' '.__('Members');
370
+ }
371
+ // Nice Text For Guests
372
+ if($total_guests == 1) {
373
+ $nicetext_guests = $total_guests.' '.__('Guest');
374
+ } else {
375
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
376
+ }
377
+ // Nice Text For Bots
378
+ if($total_bots == 1) {
379
+ $nicetext_bots = $total_bots.' '.__('Bot');
380
+ } else {
381
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
382
+ }
383
+
384
+ // Print User Count
385
+ echo __('Users Browsing This Page: ').'<strong>'.number_format($total_users).'</strong> ('.$nicetext_members.', '.$nicetext_guests.' '.__('and').' '.$nicetext_bots.')<br />';
386
+
387
+ // Print Member Name
388
+ if($members) {
389
+ $temp_member = '';
390
+ foreach($members as $member) {
391
+ $temp_member .= '<a href="'.useronline_stats_page_link(urlencode($member)).'">'.$member.'</a>, ';
392
+ }
393
+ if(!function_exists('get_totalposts')) {
394
+ $temp_member = strip_tags($temp_member);
395
+ }
396
+ echo __('Members').': '.substr($temp_member, 0, -2);
397
+ }
398
+ } else {
399
+ // This Should Not Happen
400
+ _e('No User Is Browsing This Page');
401
+ }
402
+ }
403
+
404
+
405
+ ### Function: Get IP Address
406
+ if(!function_exists('get_ipaddress')) {
407
+ function get_ipaddress() {
408
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
409
+ $ip_address = $_SERVER["REMOTE_ADDR"];
410
+ } else {
411
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
412
+ }
413
+ if(strpos($ip_address, ',') !== false) {
414
+ $ip_address = explode(',', $ip_address);
415
+ $ip_address = $ip_address[0];
416
+ }
417
+ return $ip_address;
418
+ }
419
+ }
420
+
421
+
422
+ ### Function: Check IP
423
+ function check_ip($ip) {
424
+ $current_user = wp_get_current_user();
425
+ $user_level = intval($current_user->wp_user_level);
426
+ $ip2long = ip2long($ip);
427
+ if($user_level == 10 && ($ip != 'unknown') && $ip == long2ip($ip2long) && $ip2long !== false) {
428
+ return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)";
429
+ }
430
+ }
431
+
432
+
433
+ ### Function Check If User Is Online
434
+ function is_online($user_login) {
435
+ global $wpdb;
436
+ $is_online = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline WHERE username = '$user_login' LIMIT 1");
437
+ return intval($is_online);
438
+ }
439
+
440
+
441
+ ### Function: Output User's Country Flag/Name
442
+ function ip2nation_country($ip, $display_countryname = 0) {
443
+ if(function_exists('wp_ozh_ip2nation')) {
444
+ $country_code = wp_ozh_getCountryCode(0, $ip);
445
+ $country_name = wp_ozh_getCountryName(0, $ip);
446
+ $country_mirror = '';
447
+ $mirrors = array("http://frenchfragfactory.net/images", "http://www.lesterchan.net/wordpress/images/flags");
448
+ if($country_name != 'Private') {
449
+ foreach($mirrors as $mirror) {
450
+ if(file($mirror.'/flag_sg.gif')) {
451
+ $country_mirror = $mirror;
452
+ break;
453
+ }
454
+ }
455
+ $temp = '<img src="'.$mirror.'/flag_'.$country_code.'.gif" alt="'.$country_name.'" />';
456
+ if($display_countryname) {
457
+ $temp .= $country_name;
458
+ }
459
+ return $temp.' ';
460
+ } else {
461
+ return;
462
+ }
463
+ }
464
+ return;
465
+ }
466
+
467
+
468
+ ### Function: Display UserOnline For Admin
469
+ function display_useronline() {
470
+ $useronline_page = useronline_page();
471
+ echo "<div class=\"wrap\">\n$useronline_page</div>\n";
472
+ }
473
+
474
+
475
+ ### Function: Place Polls Archive In Content
476
+ add_filter('the_content', 'place_useronlinepage', '7');
477
+ function place_useronlinepage($content){
478
+ $content = preg_replace( "/\[page_useronline\]/ise", "useronline_page()", $content);
479
+ return $content;
480
+ }
481
+
482
+
483
+ ### Function: UserOnline Page
484
+ function useronline_page() {
485
+ global $wpdb;
486
+ // Get The Users Online
487
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline ORDER BY type");
488
+
489
+ // Variables Variables Variables
490
+ $useronline_output = '';
491
+ $members = array();
492
+ $guests = array();
493
+ $bots = array();
494
+ $total_users = 0;
495
+ $total_members = 0;
496
+ $total_guests = 0;
497
+ $total_bots = 0;
498
+ $nicetext_users = '';
499
+ $nicetext_members = '';
500
+ $nicetext_guests = '';
501
+ $nicetext_bots = '';
502
+ $url_front = 'http://'.$_SERVER['SERVER_NAME'];
503
+
504
+ // Process Those User Who Is Online
505
+ if($usersonline) {
506
+ foreach($usersonline as $useronline) {
507
+ switch($useronline->type) {
508
+ case 'member':
509
+ $members[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $url_front.stripslashes(urldecode($useronline->url)));
510
+ $total_members++;
511
+ break;
512
+ case 'guest':
513
+ $guests[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $url_front.stripslashes(urldecode($useronline->url)));
514
+ $total_guests++;
515
+ break;
516
+ case 'bot':
517
+ $bots[] = array('timestamp' => $useronline->timestamp, 'user_id' => $useronline->userid, 'user_name' => stripslashes($useronline->username), 'display_name' => stripslashes($useronline->displayname), 'user_agent' => stripslashes($useronline->useragent), 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => $url_front.stripslashes(urldecode($useronline->url)));
518
+ $total_bots++;
519
+ break;
520
+ }
521
+ }
522
+ $total_users = ($total_guests+$total_bots+$total_members);
523
+ }
524
+
525
+ // Nice Text For Users
526
+ if($total_users == 1) {
527
+ $nicetext_users = $total_users.' '.__('User');
528
+ } else {
529
+ $nicetext_users = number_format($total_users).' '.__('Users');
530
+ }
531
+
532
+ // Nice Text For Members
533
+ if($total_members == 1) {
534
+ $nicetext_members = $total_members.' '.__('Member');
535
+ } else {
536
+ $nicetext_members = number_format($total_members).' '.__('Members');
537
+ }
538
+
539
+
540
+ // Nice Text For Guests
541
+ if($total_guests == 1) {
542
+ $nicetext_guests = $total_guests.' '.__('Guest');
543
+ } else {
544
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
545
+ }
546
+
547
+ // Nice Text For Bots
548
+ if($total_bots == 1) {
549
+ $nicetext_bots = $total_bots.' '.__('Bot');
550
+ } else {
551
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
552
+ }
553
+
554
+ // Check Whether WP-Stats Is Activated
555
+ $wp_stats = false;
556
+ if(function_exists('get_totalposts')) {
557
+ $wp_stats = true;
558
+ }
559
+ $useronline_output .= '<p>';
560
+ if ($total_users == 1) {
561
+ $useronline_output .= __('There is ');
562
+ } else {
563
+ $useronline_output .= __('There are a total of ');
564
+ }
565
+ $useronline_output .= "<strong>$nicetext_users</strong> online now: <strong>$nicetext_members</strong>, <strong>$nicetext_guests</strong> and <strong>$nicetext_bots</strong>.</p>\n";
566
+ $useronline_output .= "<p>Most users ever online were <strong>".get_most_useronline(false)."</strong>, on <strong>".get_most_useronline_date(false)."</strong></p>\n";
567
+ // Print Out Members
568
+ if($total_members > 0) {
569
+ $useronline_output .= '<h2>'.$nicetext_members.' '.__('Online Now').'</h2>'."\n";
570
+ }
571
+ $no=1;
572
+ if($members) {
573
+ foreach($members as $member) {
574
+ if($wp_stats) {
575
+ $useronline_output .= '<p><strong>#'.$no.' - <a href="'.useronline_stats_page_link($member['display_name']).'">'.$member['display_name'].'</a></strong> '.ip2nation_country($member['ip']).check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n";
576
+ } else {
577
+ $useronline_output .= '<p><strong>#'.$no.' - '.$member['user_name'].'</strong> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</p>'."\n";
578
+ }
579
+ $no++;
580
+ }
581
+ }
582
+
583
+ // Print Out Guest
584
+ if($total_guests > 0) {
585
+ $useronline_output .= '<h2>'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
586
+ }
587
+ $no=1;
588
+ if($guests) {
589
+ foreach($guests as $guest) {
590
+ if($wp_stats) {
591
+ $useronline_output .= '<p><strong>#'.$no.' - <a href="'.useronline_stats_page_link($guest['display_name']).'">'.$guest['display_name'].'</a></strong> '.ip2nation_country($guest['ip']).check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n";
592
+ } else {
593
+ $useronline_output .= '<p><strong>#'.$no.' - '.$guest['user_name'].'</strong> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</p>'."\n";
594
+ }
595
+ $no++;
596
+ }
597
+ }
598
+
599
+ // Print Out Bots
600
+ if($total_bots > 0) {
601
+ $useronline_output .= '<h2>'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
602
+ }
603
+ $no=1;
604
+ if($bots) {
605
+ foreach($bots as $bot) {
606
+ $useronline_output .= '<p><strong>#'.$no.' - '.$bot['display_name'].'</strong> '.check_ip($bot['ip']).' on '.gmdate('d.m.Y @ H:i', $bot['timestamp']).'<br />'.$bot['location'].' [<a href="'.$bot['url'].'">url</a>]</p>'."\n";
607
+ $no++;
608
+ }
609
+ }
610
+
611
+ // Print Out No One Is Online Now
612
+ if($total_users == 0) {
613
+ $useronline_output .= '<h2>'.__('No One Is Online Now').'</h2>'."\n";
614
+ }
615
+
616
+ // Output UserOnline Page
617
+ return $useronline_output;
618
+ }
619
+
620
+
621
+ ### Function: Stats Page Link
622
+ function useronline_stats_page_link($author) {
623
+ $stats_url = get_settings('stats_url');
624
+ if(strpos($stats_url, '?') !== false) {
625
+ $stats_url = "$stats_url&amp;stats_author=$author";
626
+ } else {
627
+ $stats_url = "$stats_url?stats_author=$author";
628
+ }
629
+ return $stats_url;
630
+ }
631
+
632
+
633
+ ### Function: Create UserOnline Table
634
+ add_action('activate_useronline/useronline.php', 'create_useronline_table');
635
+ function create_useronline_table() {
636
+ global $wpdb;
637
+ $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' => 'pubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com' => 'become.com');
638
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
639
+ // Drop UserOnline Table
640
+ $wpdb->query("DROP TABLE IF EXISTS $wpdb->useronline");
641
+ // Create UserOnline Table
642
+ $create_table = "CREATE TABLE $wpdb->useronline (".
643
+ " timestamp int(15) NOT NULL default '0',".
644
+ " userid int(10) NOT NULL default '0',".
645
+ " username varchar(150) NOT NULL default '',".
646
+ " displayname varchar(255) NOT NULL default '',".
647
+ " useragent varchar(255) NOT NULL default '',".
648
+ " ip varchar(40) NOT NULL default '',".
649
+ " location varchar(255) NOT NULL default '',".
650
+ " url varchar(255) NOT NULL default '',".
651
+ " type enum('member','guest','bot') NOT NULL default 'guest',".
652
+ " UNIQUE KEY useronline_id (timestamp,username,ip,useragent)) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
653
+ maybe_create_table($wpdb->useronline, $create_table);
654
+ // Add In Options
655
+ add_option('useronline_most_users', 1, 'Most Users Ever Online Count');
656
+ add_option('useronline_most_timestamp', current_time('timestamp'), 'Most Users Ever Online Date');
657
+ add_option('useronline_timeout', 300, 'Timeout In Seconds');
658
+ add_option('useronline_bots', $bots, 'Bots Name/Useragent');
659
+ // Database Upgrade For WP-UserOnline 2.05
660
+ add_option('useronline_url', get_settings('siteurl').'/useronline/', 'UserOnline Page URL');
661
+ }
662
+ ?>