WP-UserOnline - Version 2.04

Version Description

Download this release

Release Info

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

Version 2.04

readme.html ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.04 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.04&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.04%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" title="http://www.lesterchan.net/wordpress">http://www.lesterchan.net/wordpress</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 July 2006</p>
214
+ <div class="SubSubTitle">Changelog</div>
215
+ <ul>
216
+ <li>
217
+ <b>Version 2.04 (01-07-2006)</b>
218
+ <ul>
219
+ <li>NEW: AJAX Is Now Used For Updating Users Online Every 1 Minute Without Refreshing The Page</li>
220
+ <li>NEW: You Can Now Place Users Online Count And Users Browsing Site Data On The Sidebar As A Widget</li>
221
+ <li>NEW: UserOnline Options Panel And The Code That WP-UserOnline Generated Is XHTML 1.0 Transitional</li>
222
+ <li>NEW: Added Useronline Options In WP Administration Panel Under 'Options -> Useronline'</li>
223
+ <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>
224
+ </ul>
225
+ </li>
226
+ <li>
227
+ <b>Version 2.03 (01-04-2006)</b>
228
+ <ul>
229
+ <li>NEW: Added get_users_browsing_site(); To Display Users Browsing The Site</li>
230
+ <li>FIXED: wp-stats.php Link</li>
231
+ <li>FIXED: Some Grammer Errors, Credit To xclouds (http://www.xclouds.com/)</li>
232
+ </ul>
233
+ </li>
234
+ <li>
235
+ <b>Version 2.02 (01-03-2006)</b>
236
+ <ul>
237
+ <li>NEW: No More Install/Upgrade File, It Will Install/Upgrade When You Activate The Plugin.</li>
238
+ <li>FIXED: IP 'Unknown' Error, Credit To Brian Layman (http://www.knitchat.com/)</li>
239
+ <li>FIXED: ON DUPLICATE KEY Error, Credit To Brian Layman (http://www.knitchat.com/)</li>
240
+ <li>FIXED: DUPLICATE KEY Error By Using DELETE First, Credit To Jody Cairns (http://steelwhitetable.org/blog/)</li>
241
+ </ul>
242
+ </li>
243
+ <li>
244
+ <b>Version 2.01 (01-02-2006)</b>
245
+ <ul>
246
+ <li>NEW: Added Users Browsing Page</li>
247
+ <li>NEW: Added Most Users Ever Online</li>
248
+ <li>FIXED: Added UNIQUE Key Instead Of Primary Key To Test Whether It Will Solve Duplicate Entry Errors</li>
249
+ <li>FIXED: Quotes Issue In Page Title</li>
250
+ </ul>
251
+ </li>
252
+ <li>
253
+ <b>Version 2.00 (01-01-2006)</b>
254
+ <ul>
255
+ <li>NEW: Compatible With Only WordPress 2.0</li>
256
+ <li>NEW: Better Installer</li>
257
+ <li>NEW: GPL License Added</li>
258
+ <li>NEW: Page Title Added To wp-useronline.php</li>
259
+ <li>NEW: Added Extra Bots, Credit To Greg Perry (http://www.gregrperry.com/)</li>
260
+ <li>FIXED: Cleaner Codes</li>
261
+ </ul>
262
+ </li>
263
+ </ul>
264
+ </div>
265
+
266
+ <!-- Installation Instructions -->
267
+ <div id="Install" style="display: none;">
268
+ <div class="SubTitle">&raquo; Installation Instructions</div>
269
+ <ol>
270
+ <li>
271
+ Open <b>wp-content/plugins</b> Folder
272
+ </li>
273
+ <li>
274
+ Put:
275
+ <blockquote>Folder: useronline</blockquote>
276
+ </li>
277
+ <li>
278
+ <b>Activate</b> WP-UserOnline Plugin
279
+ </li>
280
+ <li>
281
+ Refer To <b>Usage</b> For Further Instructions
282
+ </li>
283
+ </ol>
284
+ </div>
285
+
286
+ <!-- Upgrade Instructions -->
287
+ <div id="Upgrade" style="display: none;">
288
+ <div class="SubTitle">&raquo; Upgrade Instructions</div>
289
+ <div class="SubSubTitle">From v1.0x To v2.04</div>
290
+ <ol>
291
+ <li>
292
+ <b>Deactivate</b> WP-UserOnline Plugin
293
+ </li>
294
+ <li>
295
+ Open <b>Root WordPress</b> Folder
296
+ </li>
297
+ <li>
298
+ Delete:
299
+ <blockquote>File: wp-useronline.php</blockquote>
300
+ </li>
301
+ <li>
302
+ Open <b>wp-content/plugins</b> Folder
303
+ </li>
304
+ <li>
305
+ Delete:
306
+ <blockquote>File: useronline.php</blockquote>
307
+ </li>
308
+ <li>
309
+ Put:
310
+ <blockquote>Folder: useronline</blockquote>
311
+ </li>
312
+ <li>
313
+ <b>Activate</b> WP-UserOnline Plugin
314
+ </li>
315
+ <li>
316
+ Refer To <b>Usage</b> For Further Instructions
317
+ </li>
318
+ </ol>
319
+ </div>
320
+
321
+ <!-- Usage Instructions -->
322
+ <div id="Usage" style="display: none;">
323
+ <div class="SubTitle">&raquo; Usage Instructions</div>
324
+ <div class="SubSubTitle">General Usage</div>
325
+ <ol>
326
+ <li>
327
+ Open <b>wp-content/themes/&lt;YOUR THEME NAME&gt;/sidebar.php</b>
328
+ </li>
329
+ <li>
330
+ Add Anywhere:
331
+ <blockquote>
332
+ &lt;?php if (function_exists('useronline')): ?&gt;<br />
333
+ &nbsp;&nbsp;&nbsp;&lt;li&gt;<br />
334
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;UserOnline&lt;/h2&gt;<br />
335
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
336
+ &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 />
337
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
338
+ &nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
339
+ &lt;?php endif; ?&gt;
340
+ </blockquote>
341
+ </li>
342
+ <li>
343
+ Tutorial On How To Integrate wp-useronline.php With Your Theme:
344
+ <blockquote><a href="http://www.lesterchan.net/wordpress/tutorials/integrating/" target="_blank">http://www.lesterchan.net/wordpress/tutorials/integrating/</a></blockquote>
345
+ </li>
346
+ </ol>
347
+ <div class="SubSubTitle">UserOnline Stats (Outside WP Loop)</div>
348
+ <ul>
349
+ <li>
350
+ To Display <b>Most Number Of Users Online</b>
351
+ </li>
352
+ <li>
353
+ Use:
354
+ <blockquote>
355
+ &lt;?php if (function_exists('get_most_useronline')): ?&gt;<br />
356
+ &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 />
357
+ &lt;?php endif; ?&gt;
358
+ </blockquote>
359
+ </li>
360
+ <li>
361
+ To Display <b>Users Browsing Site</b>
362
+ </li>
363
+ <li>
364
+ Use:
365
+ <blockquote>
366
+ &lt;?php if (function_exists('get_users_browsing_site')): ?&gt;<br />
367
+ &nbsp;&nbsp;&nbsp;&lt;div id="useronline-browsing-site"&gt;&lt;?php get_users_browsing_site(); ?&gt;&lt;/div&gt;<br />
368
+ &lt;?php endif; ?&gt;
369
+ </blockquote>
370
+ </li>
371
+ <li>
372
+ To Display <b>Users Browsing A Page</b>
373
+ </li>
374
+ <li>
375
+ Use:
376
+ <blockquote>
377
+ &lt;?php if (function_exists('get_users_browsing_page')): ?&gt;<br />
378
+ &nbsp;&nbsp;&nbsp;&lt;div id="useronline-browsing-page"&gt;&lt;?php get_users_browsing_page(); ?&gt;&lt;/div&gt;<br />
379
+ &lt;?php endif; ?&gt;
380
+ </blockquote>
381
+ </li>
382
+ </ul>
383
+ </div>
384
+ </div>
385
+ </div>
386
+ <p id="Copyright">WP-UserOnline 2.04<br />Copyright &copy; 2006 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
387
+ </body>
388
+ </html>
useronline/useronline-js.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ +----------------------------------------------------------------+
3
+ | |
4
+ | WordPress 2.0 Plugin: WP-UserOnline 2.04 |
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(site_url + '/index.php');
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(site_url + '/index.php');
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(site_url + '/index.php');
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,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.04 |
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
+ $update_useronline_queries = array();
37
+ $update_useronline_text = array();
38
+ $update_useronline_queries[] = update_option('useronline_timeout', $useronline_timeout);
39
+ $update_useronline_queries[] = update_option('useronline_bots', $useronline_bots);
40
+ $update_useronline_text[] = __('Useronline Timeout');
41
+ $update_useronline_text[] = __('Useronline Bots');
42
+ $i=0;
43
+ $text = '';
44
+ foreach($update_useronline_queries as $update_useronline_query) {
45
+ if($update_useronline_query) {
46
+ $text .= '<font color="green">'.$update_useronline_text[$i].' '.__('Updated').'</font><br />';
47
+ }
48
+ $i++;
49
+ }
50
+ if(empty($text)) {
51
+ $text = '<font color="red">'.__('No Useronline Option Updated').'</font>';
52
+ }
53
+ }
54
+
55
+ ### Get Useronline Bots
56
+ $useronline_options_bots = get_settings('useronline_bots');
57
+ $useronline_options_bots_name = '';
58
+ $useronline_options_bots_agent = '';
59
+ foreach($useronline_options_bots as $botname => $botagent) {
60
+ $useronline_options_bots_name .= $botname."\n";
61
+ $useronline_options_bots_agent .= $botagent."\n";
62
+ }
63
+ $useronline_options_bots_name = trim($useronline_options_bots_name);
64
+ $useronline_options_bots_agent = trim($useronline_options_bots_agent);
65
+ ?>
66
+ <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
67
+ <div class="wrap">
68
+ <h2><?php _e('Useronline Options'); ?></h2>
69
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
70
+ <fieldset class="options">
71
+ <legend><?php _e('Useronline Options'); ?></legend>
72
+ <table width="100%" border="0" cellspacing="3" cellpadding="3">
73
+ <tr valign="top">
74
+ <th align="left" width="30%"><?php _e('Time Out'); ?></th>
75
+ <td align="left">
76
+ <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).
77
+ </td>
78
+ </tr>
79
+ <tr valign="top">
80
+ <th align="left" width="30%"><?php _e('Bots Name/User Agent'); ?></th>
81
+ <td align="left">
82
+ Here are a list of bots and their partial browser agents.<br />On the left column will be the <b>Bot's Name</b> and on the right column will be their <b>Partial Browser Agent</b>.<br />Start each entry on a new line.
83
+ <br /><br />
84
+ <textarea cols="20" rows="30" name="useronline_bots_name"><?php echo $useronline_options_bots_name; ?></textarea>
85
+ <textarea cols="20" rows="30" name="useronline_bots_agent"><?php echo $useronline_options_bots_agent; ?></textarea>
86
+ </td>
87
+ </tr>
88
+ </table>
89
+ </fieldset>
90
+ <div align="center">
91
+ <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)" />
92
+ </div>
93
+ </form>
94
+ </div>
useronline/useronline-widget.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.04
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 = __('UserOnline');
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');
62
+ }
63
+ if ($_POST['useronline-submit']) {
64
+ $options['display_usersbrowsingsite'] = intval($_POST['useronline-usersbrowsingsite']);
65
+ update_option('widget_useronline', $options);
66
+ }
67
+ echo '<p style="text-align: center;"><label for="useronline-usersbrowsingsite">Display Users Browsing Site Under Users Online Count?</label></p>'."\n";
68
+ echo '<p style="text-align: center;"><input type="radio" id="useronline-usersbrowsingsite" name="useronline-usersbrowsingsite" value="1"';
69
+ checked(1, intval($options['display_usersbrowsingsite']));
70
+ echo ' />&nbsp;Yes&nbsp;&nbsp;&nbsp;<input type="radio" id="useronline-usersbrowsingsite" name="useronline-usersbrowsingsite" value="0"';
71
+ checked(0, intval($options['display_usersbrowsingsite']));
72
+ echo ' />&nbsp;No</p>'."\n";
73
+ echo '<input type="hidden" id="useronline-submit" name="useronline-submit" value="1" />'."\n";
74
+ }
75
+
76
+ // Register Widgets
77
+ register_sidebar_widget('UserOnline', 'widget_useronline');
78
+ register_widget_control('UserOnline', 'widget_useronline_options', 350, 100);
79
+ }
80
+
81
+
82
+ ### Function: Load The WP-UserOnline Widget
83
+ add_action('plugins_loaded', 'widget_useronline_init');
84
+ ?>
useronline/useronline.php ADDED
@@ -0,0 +1,554 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.04
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
+ echo '<script type="text/javascript">'."\n";
50
+ echo '/* Start Of Javascript Generated By WP-UserOnline 2.04 */'."\n";
51
+ echo '/* <![CDATA[ */'."\n";
52
+ echo "\t".'if(site_url != \''.get_settings('siteurl').'\') {'."\n";
53
+ echo "\t\t".'var site_url = \''.get_settings('siteurl').'\';'."\n";
54
+ echo "\t".'}'."\n";
55
+ echo "\t".'var useronline_timeout = '.(get_settings('useronline_timeout')*1000).';'."\n";
56
+ echo '/* ]]> */'."\n";
57
+ echo '/* End Of Javascript Generated By WP-UserOnline 2.04 */'."\n";
58
+ echo '</script>'."\n";
59
+ echo '<script src="'.get_settings('siteurl').'/wp-includes/js/tw-sack.js" type="text/javascript"></script>'."\n";
60
+ echo '<script src="'.get_settings('siteurl').'/wp-content/plugins/useronline/useronline-js.js" type="text/javascript"></script>'."\n";
61
+ }
62
+
63
+
64
+ ### Function: Process AJAX Request
65
+ add_action('init', 'useronline_ajax');
66
+ function useronline_ajax() {
67
+ global $wpdb, $useronline;
68
+ $mode = trim($_GET['useronline_mode']);
69
+ if(!empty($mode)) {
70
+ switch($mode) {
71
+ case 'useronline_count':
72
+ $useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));
73
+ get_useronline();
74
+ break;
75
+ case 'useronline_browsingsite':
76
+ get_users_browsing_site();
77
+ break;
78
+ case 'useronline_browsingpage':
79
+ get_users_browsing_page();
80
+ break;
81
+ }
82
+ exit();
83
+ }
84
+ }
85
+
86
+
87
+ ### Function: Process UserOnline
88
+ add_action('admin_head', 'useronline');
89
+ add_action('wp_head', 'useronline');
90
+ function useronline() {
91
+ global $wpdb, $useronline, $user_identity;
92
+ // Useronline Settings
93
+ $timeoutseconds = get_settings('useronline_timeout');
94
+ $timestamp = current_time('timestamp');
95
+ $timeout = ($timestamp-$timeoutseconds);
96
+ $ip = get_ipaddress();
97
+ $url = addslashes(urlencode($_SERVER['REQUEST_URI']));
98
+ $useragent = $_SERVER['HTTP_USER_AGENT'];
99
+
100
+ // Check For Members
101
+ if(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
102
+ $memberonline = addslashes(trim($_COOKIE['comment_author_'.COOKIEHASH]));
103
+ $where = "WHERE username='$memberonline'";
104
+ // Check For Admins
105
+ } elseif(!empty($user_identity)) {
106
+ $memberonline = addslashes($user_identity);
107
+ $where = "WHERE username='$memberonline'";
108
+ // Check For Guests
109
+ } else {
110
+ $memberonline = 'Guest';
111
+ $where = "WHERE ip='$ip'";
112
+ }
113
+ // Check For Bot
114
+ $bots = get_settings('useronline_bots');
115
+ foreach ($bots as $name => $lookfor) {
116
+ if (stristr($useragent, $lookfor) !== false) {
117
+ $memberonline = addslashes($name);
118
+ $where = "WHERE ip='$ip'";
119
+ break;
120
+ }
121
+ }
122
+ $useragent = addslashes($useragent);
123
+
124
+ // Check For Page Title
125
+ $make_page = wp_title('&raquo;', false);
126
+ if(empty($make_page)) {
127
+ $make_page = get_bloginfo('name');
128
+ } elseif(is_single()) {
129
+ $make_page = get_bloginfo('name').' &raquo; Blog Archive '.$make_page;
130
+ } else {
131
+ $make_page = get_bloginfo('name').$make_page;
132
+ }
133
+ $make_page = addslashes($make_page);
134
+
135
+ // Delete Users
136
+ $delete_users = $wpdb->query("DELETE FROM $wpdb->useronline $where OR (timestamp < $timeout)");
137
+
138
+ // Insert Users
139
+ $insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$memberonline', '$useragent', '$ip', '$make_page', '$url')");
140
+
141
+ // Count Users Online
142
+ $useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));
143
+
144
+ // Get Most User Online
145
+ $most_useronline = intval(get_settings('useronline_most_users'));
146
+
147
+ // Check Whether Current Users Online Is More Than Most Users Online
148
+ if($useronline > $most_useronline) {
149
+ update_option('useronline_most_users', $useronline);
150
+ update_option('useronline_most_timestamp', current_time('timestamp'));
151
+ }
152
+ }
153
+
154
+
155
+ ### Function: Display UserOnline
156
+ if(!function_exists('get_useronline')) {
157
+ function get_useronline($user = 'User', $users = 'Users', $display = true) {
158
+ global $useronline;
159
+ // Display User Online
160
+ if($display) {
161
+ if($useronline > 1) {
162
+ echo '<a href="'.get_settings('siteurl').'/wp-content/plugins/useronline/wp-useronline.php"><b>'.number_format($useronline).'</b> '.$users.' '.__('Online').'</a>'."\n";
163
+ } else {
164
+ echo '<a href="'.get_settings('siteurl').'/wp-content/plugins/useronline/wp-useronline.php"><b>'.$useronline.'</b> '.$user.' '.__('Online').'</a>'."\n";
165
+ }
166
+ } else {
167
+ return $useronline;
168
+ }
169
+ }
170
+ }
171
+
172
+ ### Function: Display Max UserOnline
173
+ if(!function_exists('get_most_useronline')) {
174
+ function get_most_useronline($display = true) {
175
+ $most_useronline_users = intval(get_settings('useronline_most_users'));
176
+ if($display) {
177
+ echo number_format($most_useronline_users);
178
+ } else {
179
+ return $most_useronline_users;
180
+ }
181
+ }
182
+ }
183
+
184
+
185
+ ### Function: Display Max UserOnline Date
186
+ if(!function_exists('get_most_useronline_date')) {
187
+ function get_most_useronline_date($date_format = 'jS F Y, H:i', $display =true) {
188
+ $most_useronline_timestamp = get_settings('useronline_most_timestamp');
189
+ $most_useronline_date = gmdate($date_format, $most_useronline_timestamp);
190
+ if($display) {
191
+ echo $most_useronline_date;
192
+ } else {
193
+ return$most_useronline_date;
194
+ }
195
+ }
196
+ }
197
+
198
+
199
+ ### Function: Display Users Browsing The Site
200
+ function get_users_browsing_site() {
201
+ global $wpdb;
202
+
203
+ // Get Users Browsing Site
204
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
205
+ $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline");
206
+
207
+ // Variables
208
+ $members = array();
209
+ $total_users = 0;
210
+ $total_members = 0;
211
+ $total_guests = 0;
212
+ $total_bots = 0;
213
+ $nicetext_members = '';
214
+ $nicetext_guests = '';
215
+ $nicetext_bots = '';
216
+
217
+ // If There Is Users Browsing, Then We Execute
218
+ if($users_browse) {
219
+ // Reassign Bots Name
220
+ $bots = get_settings('useronline_bots');
221
+ $bots_name = array();
222
+ foreach($bots as $botname => $botlookfor) {
223
+ $bots_name[] = $botname;
224
+ }
225
+ // Get Users Information
226
+ foreach($users_browse as $user_browse) {
227
+ if($user_browse->username == 'Guest') {
228
+ $total_guests++;
229
+ } elseif(in_array($user_browse->username, $bots_name)) {
230
+ $total_bots++;
231
+ } else {
232
+ $members[] = stripslashes($user_browse->username);
233
+ $total_members++;
234
+ }
235
+ }
236
+ $total_users = ($total_guests+$total_bots+$total_members);
237
+
238
+ // Nice Text For Guests
239
+ if($total_guests == 1) {
240
+ $nicetext_guests = $total_guests.' '.__('Guest');
241
+ } else {
242
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
243
+ }
244
+ // Nice Text For Bots
245
+ if($total_bots == 1) {
246
+ $nicetext_bots = $total_bots.' '.__('Bot');
247
+ } else {
248
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
249
+ }
250
+
251
+ // Print Member Name
252
+ if($members) {
253
+ $temp_member = '';
254
+ foreach($members as $member) {
255
+ $temp_member .= '<a href="'.get_settings('home').'/wp-stats.php?author='.urlencode($member).'">'.$member.'</a>, ';
256
+ }
257
+ if(!function_exists('get_totalposts')) {
258
+ $temp_member = strip_tags($temp_member);
259
+ }
260
+ }
261
+ // Print Guests
262
+ if($total_guests > 0) {
263
+ $temp_member .= $nicetext_guests.', ';
264
+ }
265
+ // Print Bots
266
+ if($total_bots > 0) {
267
+ $temp_member .= $nicetext_bots.', ';
268
+ }
269
+ // Print User Count
270
+ $temp_member = substr($temp_member, 0, -2);
271
+ echo __('Users: ').'<b>'.$temp_member.'</b><br />';
272
+ } else {
273
+ // This Should Not Happen
274
+ _e('No User Is Browsing This Site');
275
+ }
276
+ }
277
+
278
+
279
+ ### Function: Display Users Browsing The Page
280
+ function get_users_browsing_page() {
281
+ global $wpdb;
282
+
283
+ // Get Users Browsing Page
284
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
285
+ $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline WHERE url = '$page_url'");
286
+
287
+ // Variables
288
+ $members = array();
289
+ $total_users = 0;
290
+ $total_members = 0;
291
+ $total_guests = 0;
292
+ $total_bots = 0;
293
+ $nicetext_members = '';
294
+ $nicetext_guests = '';
295
+ $nicetext_bots = '';
296
+
297
+ // If There Is Users Browsing, Then We Execute
298
+ if($users_browse) {
299
+ // Reassign Bots Name
300
+ $bots = get_settings('useronline_bots');
301
+ $bots_name = array();
302
+ foreach($bots as $botname => $botlookfor) {
303
+ $bots_name[] = $botname;
304
+ }
305
+ // Get Users Information
306
+ foreach($users_browse as $user_browse) {
307
+ if($user_browse->username == 'Guest') {
308
+ $total_guests++;
309
+ } elseif(in_array($user_browse->username, $bots_name)) {
310
+ $total_bots++;
311
+ } else {
312
+ $members[] = stripslashes($user_browse->username);
313
+ $total_members++;
314
+ }
315
+ }
316
+ $total_users = ($total_guests+$total_bots+$total_members);
317
+
318
+ // Nice Text For Members
319
+ if($total_members == 1) {
320
+ $nicetext_members = $total_members.' '.__('Member');
321
+ } else {
322
+ $nicetext_members = number_format($total_members).' '.__('Members');
323
+ }
324
+ // Nice Text For Guests
325
+ if($total_guests == 1) {
326
+ $nicetext_guests = $total_guests.' '.__('Guest');
327
+ } else {
328
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
329
+ }
330
+ // Nice Text For Bots
331
+ if($total_bots == 1) {
332
+ $nicetext_bots = $total_bots.' '.__('Bot');
333
+ } else {
334
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
335
+ }
336
+
337
+ // Print User Count
338
+ echo __('Users Browsing This Page: ').'<b>'.number_format($total_users).'</b> ('.$nicetext_members.', '.$nicetext_guests.' '.__('and').' '.$nicetext_bots.')<br />';
339
+
340
+ // Print Member Name
341
+ if($members) {
342
+ $temp_member = '';
343
+ foreach($members as $member) {
344
+ $temp_member .= '<a href="'.get_settings('home').'/wp-stats.php?author='.urlencode($member).'">'.$member.'</a>, ';
345
+ }
346
+ if(!function_exists('get_totalposts')) {
347
+ $temp_member = strip_tags($temp_member);
348
+ }
349
+ echo __('Members').': '.substr($temp_member, 0, -2);
350
+ }
351
+ } else {
352
+ // This Should Not Happen
353
+ _e('No User Is Browsing This Page');
354
+ }
355
+ }
356
+
357
+
358
+ ### Function: Get IP Address
359
+ if(!function_exists('get_ipaddress')) {
360
+ function get_ipaddress() {
361
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
362
+ $ip_address = $_SERVER["REMOTE_ADDR"];
363
+ } else {
364
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
365
+ }
366
+ if(strpos($ip_address, ',') !== false) {
367
+ $ip_address = explode(',', $ip_address);
368
+ $ip_address = $ip_address[0];
369
+ }
370
+ return $ip_address;
371
+ }
372
+ }
373
+
374
+
375
+ ### Function: Check IP
376
+ function check_ip($ip) {
377
+ if(is_user_logged_in() && ($ip != 'unknown')) {
378
+ return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)";
379
+ }
380
+ }
381
+
382
+
383
+ ### Function: Output User's Country Flag/Name
384
+ function ip2nation_country($ip, $display_countryname = 0) {
385
+ if(function_exists('wp_ozh_ip2nation')) {
386
+ $country_code = wp_ozh_getCountryCode(0, $ip);
387
+ $country_name = wp_ozh_getCountryName(0, $ip);
388
+ if($country_name != 'Private') {
389
+ $temp = '<img src="http://frenchfragfactory.net/images/flag_'.$country_code.'.gif" alt="'.$country_name.'" />';
390
+ if($display_countryname) {
391
+ $temp .= $country_name;
392
+ }
393
+ return $temp.' ';
394
+ } else {
395
+ return;
396
+ }
397
+ }
398
+ return;
399
+ }
400
+
401
+
402
+ ### Function: Display UserOnline For Admin
403
+ function display_useronline() {
404
+ global $wpdb;
405
+ // Reassign Bots Name
406
+ $bots = get_settings('useronline_bots');
407
+ $bots_name = array();
408
+ foreach($bots as $botname => $botlookfor) {
409
+ $bots_name[] = $botname;
410
+ }
411
+
412
+ // Get The Users Online
413
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
414
+
415
+ // Variables Variables Variables
416
+ $members = array();
417
+ $guests = array();
418
+ $bots = array();
419
+ $total_users = 0;
420
+ $total_members = 0;
421
+ $total_guests = 0;
422
+ $total_bots = 0;
423
+ $nicetext_users = '';
424
+ $nicetext_members = '';
425
+ $nicetext_guests = '';
426
+ $nicetext_bots = '';
427
+
428
+ // Process Those User Who Is Online
429
+ if($usersonline) {
430
+ foreach($usersonline as $useronline) {
431
+ if($useronline->username == 'Guest') {
432
+ $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
433
+ $total_guests++;
434
+ } elseif(in_array($useronline->username, $bots_name)) {
435
+ $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
436
+ $total_bots++;
437
+ } else {
438
+ $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
439
+ $total_members++;
440
+ }
441
+ }
442
+ $total_users = ($total_guests+$total_bots+$total_members);
443
+ }
444
+
445
+ // Nice Text For Users
446
+ if($total_users == 1) {
447
+ $nicetext_users = $total_users.' '.__('User');
448
+ } else {
449
+ $nicetext_users = number_format($total_users).' '.__('Users');
450
+ }
451
+
452
+ // Nice Text For Members
453
+ if($total_members == 1) {
454
+ $nicetext_members = $total_members.' '.__('Member');
455
+ } else {
456
+ $nicetext_members = number_format($total_members).' '.__('Members');
457
+ }
458
+
459
+
460
+ // Nice Text For Guests
461
+ if($total_guests == 1) {
462
+ $nicetext_guests = $total_guests.' '.__('Guest');
463
+ } else {
464
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
465
+ }
466
+
467
+ // Nice Text For Bots
468
+ if($total_bots == 1) {
469
+ $nicetext_bots = $total_bots.' '.__('Bot');
470
+ } else {
471
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
472
+ }
473
+ ?>
474
+ <div class="wrap">
475
+ <h2>UserOnline Stats</h2>
476
+ <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>
477
+ <p>Most users ever online were <b><?php get_most_useronline(); ?></b>, on <b><?php get_most_useronline_date(); ?></b></p>
478
+ </div>
479
+ <?php
480
+ // Print Out Members
481
+ if($total_members > 0) {
482
+ echo '<div class="wrap"><h2>'.$nicetext_members.' '.__('Online Now').'</h2>'."\n";
483
+ }
484
+ $no=1;
485
+ if($members) {
486
+ $wp_stats = false;
487
+ if(function_exists('get_totalposts')) {
488
+ $wp_stats = true;
489
+ }
490
+ foreach($members as $member) {
491
+ if($wp_stats) {
492
+ echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.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";
493
+ } else {
494
+ 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";
495
+ }
496
+ $no++;
497
+ }
498
+ }
499
+ // Print Out Guest
500
+ if($total_guests > 0) {
501
+ echo '<div class="wrap"><h2>'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
502
+ }
503
+ $no=1;
504
+ if($guests) {
505
+ foreach($guests as $guest) {
506
+ echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.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";
507
+ $no++;
508
+ }
509
+ echo '</div>';
510
+ }
511
+ // Print Out Bots
512
+ if($total_bots > 0) {
513
+ echo '<div class="wrap"><h2>'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
514
+ }
515
+ $no=1;
516
+ if($bots) {
517
+ foreach($bots as $bot) {
518
+ 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";
519
+ $no++;
520
+ }
521
+ echo '</div>';
522
+ }
523
+ if($total_users == 0) {
524
+ echo '<div class="wrap"><h2>'.__('No One Is Online Now').'</h2></div>'."\n";
525
+ }
526
+ echo '</div>';
527
+ }
528
+
529
+
530
+ ### Function: Create UserOnline Table
531
+ add_action('activate_useronline/useronline.php', 'create_useronline_table');
532
+ function create_useronline_table() {
533
+ global $wpdb;
534
+ $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');
535
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
536
+ // Drop UserOnline Table
537
+ $wpdb->query("DROP TABLE IF EXISTS $wpdb->useronline");
538
+ // Create UserOnline Table
539
+ $create_table = "CREATE TABLE $wpdb->useronline (".
540
+ " timestamp int(15) NOT NULL default '0',".
541
+ " username varchar(50) NOT NULL default '',".
542
+ " useragent varchar(255) NOT NULL default '',".
543
+ " ip varchar(40) NOT NULL default '',".
544
+ " location varchar(255) NOT NULL default '',".
545
+ " url varchar(255) NOT NULL default '',".
546
+ " UNIQUE KEY useronline_id (timestamp,username,ip,useragent))";
547
+ maybe_create_table($wpdb->useronline, $create_table);
548
+ // Add In Options
549
+ add_option('useronline_most_users', 1, 'Most Users Ever Online Count');
550
+ add_option('useronline_most_timestamp', current_time('timestamp'), 'Most Users Ever Online Date');
551
+ add_option('useronline_timeout', 300, 'Timeout In Seconds');
552
+ add_option('useronline_bots', $bots, 'Bots Name/Useragent');
553
+ }
554
+ ?>
useronline/wp-useronline.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.04 |
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('../../../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 = get_settings('useronline_bots');
31
+ $bots_name = array();
32
+ foreach($bots as $botname => $botlookfor) {
33
+ $bots_name[] = $botname;
34
+ }
35
+
36
+ ### Get The Users Online
37
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
38
+
39
+ ### Variables Variables Variables
40
+ $members = array();
41
+ $guests = array();
42
+ $bots = array();
43
+ $total_users = 0;
44
+ $total_members = 0;
45
+ $total_guests = 0;
46
+ $total_bots = 0;
47
+ $nicetext_users = '';
48
+ $nicetext_members = '';
49
+ $nicetext_guests = '';
50
+ $nicetext_bots = '';
51
+
52
+ ### Process Those User Who Is Online
53
+ if($usersonline) {
54
+ foreach($usersonline as $useronline) {
55
+ if($useronline->username == 'Guest') {
56
+ $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
57
+ $total_guests++;
58
+ } elseif(in_array($useronline->username, $bots_name)) {
59
+ $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
60
+ $total_bots++;
61
+ } else {
62
+ $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
63
+ $total_members++;
64
+ }
65
+ }
66
+ $total_users = ($total_guests+$total_bots+$total_members);
67
+ }
68
+
69
+ ### Nice Text For Users
70
+ if($total_users == 1) {
71
+ $nicetext_users = $total_users.' '.__('User');
72
+ } else {
73
+ $nicetext_users = number_format($total_users).' '.__('Users');
74
+ }
75
+
76
+ ### Nice Text For Members
77
+ if($total_members == 1) {
78
+ $nicetext_members = $total_members.' '.__('Member');
79
+ } else {
80
+ $nicetext_members = number_format($total_members).' '.__('Members');
81
+ }
82
+
83
+
84
+ ### Nice Text For Guests
85
+ if($total_guests == 1) {
86
+ $nicetext_guests = $total_guests.' '.__('Guest');
87
+ } else {
88
+ $nicetext_guests = number_format($total_guests).' '.__('Guests');
89
+ }
90
+
91
+ ### Nice Text For Bots
92
+ if($total_bots == 1) {
93
+ $nicetext_bots = $total_bots.' '.__('Bot');
94
+ } else {
95
+ $nicetext_bots = number_format($total_bots).' '.__('Bots');
96
+ }
97
+ ?>
98
+ <?php get_header(); ?>
99
+ <div id="content" class="narrowcolumn">
100
+ <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>
101
+ <p>Most users ever online were <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
+ $wp_stats = false;
110
+ if(function_exists('get_totalposts')) {
111
+ $wp_stats = true;
112
+ }
113
+ foreach($members as $member) {
114
+ if($wp_stats) {
115
+ echo '<p><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.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";
116
+ } else {
117
+ 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";
118
+ }
119
+ $no++;
120
+ }
121
+ }
122
+ // Print Out Guest
123
+ if($total_guests > 0) {
124
+ echo '<h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2>'."\n";
125
+ }
126
+ $no=1;
127
+ if($guests) {
128
+ foreach($guests as $guest) {
129
+ echo '<p><b>#'.$no.' - '.$guest['username'].'</b> '.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";
130
+ $no++;
131
+ }
132
+ }
133
+ // Print Out Bots
134
+ if($total_bots > 0) {
135
+ echo '<h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2>'."\n";
136
+ }
137
+ $no=1;
138
+ if($bots) {
139
+ foreach($bots as $bot) {
140
+ 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";
141
+ $no++;
142
+ }
143
+ }
144
+ if($total_users == 0) {
145
+ echo '<h2 class="pagetitle">'.__('No One Is Online Now').'</h2>'."\n";
146
+ }
147
+ ?>
148
+ </div>
149
+ <?php get_sidebar(); ?>
150
+ <?php get_footer(); ?>