WP-UserOnline - Version 2.01

Version Description

Download this release

Release Info

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

Version 2.01

readme-install.txt ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Installation Instructions
2
+ --------------------------------------------------
3
+ // Open wp-admin folder
4
+
5
+ Put:
6
+ ------------------------------------------------------------------
7
+ useronline-install.php
8
+ ------------------------------------------------------------------
9
+
10
+
11
+ // Open wp-content/plugins folder
12
+
13
+ Put:
14
+ ------------------------------------------------------------------
15
+ useronline.php
16
+ ------------------------------------------------------------------
17
+
18
+
19
+ // Open root Wordpress folder
20
+
21
+ Put:
22
+ ------------------------------------------------------------------
23
+ wp-useronline.php
24
+ ------------------------------------------------------------------
25
+
26
+
27
+ // Activate useronline plugin
28
+
29
+
30
+ // Run wp-admin/useronline-install.php
31
+
32
+
33
+ // Open wp-content/themes/<YOUR THEME NAME>/sidebar.php
34
+
35
+ Add:
36
+ ------------------------------------------------------------------
37
+ <?php if (function_exists('useronline')): ?>
38
+ <li>
39
+ <h2>UserOnline</h2>
40
+ <ul>
41
+ <li><a href="<?php echo get_settings('home'); ?>/wp-useronline.php"><?php get_useronline(); ?></a></li>
42
+ </ul>
43
+ </li>
44
+ <?php endif; ?>
45
+ ------------------------------------------------------------------
46
+
47
+
48
+ // To Display Most Number Of Users Online
49
+
50
+ Use:
51
+ ------------------------------------------------------------------
52
+ <?php if (function_exists('useronline')): ?>
53
+ <p>Most Users Ever Online Is <?php get_most_useronline(); ?> On <?php get_most_useronline_date(); ?></p>
54
+ <?php endif; ?>
55
+ ------------------------------------------------------------------
56
+
57
+ Note:
58
+ ------------------------------------------------------------------
59
+ By default, it will be displayed in wp-useronline.php
60
+ ------------------------------------------------------------------
61
+
62
+
63
+ // To Display Users Browsing A Page
64
+
65
+ Use:
66
+ ------------------------------------------------------------------
67
+ <?php if (function_exists('useronline')): ?>
68
+ <?php get_users_browsing_page(); ?>
69
+ <?php endif; ?>
70
+ ------------------------------------------------------------------
71
+
72
+ Note:
73
+ ------------------------------------------------------------------
74
+ Normally, you can place it in page.php or single.php
75
+ ------------------------------------------------------------------
readme-upgrade.txt ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> Upgrade Instructions For Version 2.00 To Version 2.01
2
+ ------------------------------------------------------------------
3
+ // Open wp-admin folder
4
+
5
+ Put:
6
+ ------------------------------------------------------------------
7
+ useronline-upgrade.php
8
+ ------------------------------------------------------------------
9
+
10
+
11
+ // Open wp-content/plugins folder
12
+
13
+ Overwrite:
14
+ ------------------------------------------------------------------
15
+ useronline.php
16
+ ------------------------------------------------------------------
17
+
18
+
19
+ // Open root Wordpress folder
20
+
21
+ Overwrite:
22
+ ------------------------------------------------------------------
23
+ wp-useronline.php
24
+ ------------------------------------------------------------------
25
+
26
+
27
+ // Run wp-admin/useronline-upgrade.php
28
+
29
+ Note:
30
+ ------------------------------------------------------------------
31
+ Please remember to remove useronline-upgrade.php after installation.
32
+ ------------------------------------------------------------------
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ -> Upgrade Instructions For Version 1.0x To Version 2.00
44
+ ------------------------------------------------------------------
45
+ // Open wp-content/plugins folder
46
+
47
+ Put:
48
+ ------------------------------------------------------------------
49
+ useronline.php
50
+ ------------------------------------------------------------------
51
+
52
+
53
+ // Open root Wordpress folder
54
+
55
+ Put:
56
+ ------------------------------------------------------------------
57
+ wp-useronline.php
58
+ ------------------------------------------------------------------
59
+
60
+
61
+ // Remove Previous Traces Of UserOnline Code In Your Theme
62
+
63
+
64
+ // Open wp-content/themes/<YOUR THEME NAME>/sidebar.php
65
+
66
+ Add:
67
+ ------------------------------------------------------------------
68
+ <?php if (function_exists('useronline')): ?>
69
+ <li>
70
+ <h2>UserOnline</h2>
71
+ <ul>
72
+ <li><a href="<?php echo get_settings('home'); ?>/wp-useronline.php"><?php get_useronline(); ?></a></li>
73
+ </ul>
74
+ </li>
75
+ <?php endif; ?>
76
+ ------------------------------------------------------------------
readme.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -> UserOnline Plugin For WordPress 2.0
2
+ --------------------------------------------------
3
+ Author -> Lester 'GaMerZ' Chan
4
+ Email -> gamerz84@hotmail.com
5
+ Website -> http://www.lesterchan.net/
6
+ Demo -> http://www.lesterchan.net/wp-useronline.php
7
+ Documentation -> http://dev.wp-plugins.org/wiki/wp-useronline
8
+ Development -> http://dev.wp-plugins.org/browser/wp-useronline/
9
+ Updated -> 1st February 2006
10
+ --------------------------------------------------
11
+
12
+
13
+ // Version 2.01 (01-02-2006)
14
+ - NEW: Added Users Browsing Page
15
+ - NEW: Added Most Users Ever Online
16
+ - FIXED: Added UNIQUE Key Instead Of Primary Key To Test Whether It Will Solve Duplicate Entry Errors
17
+ - FIXED: Quotes Issue In Page Title
18
+
19
+ // Version 2.00 (01-01-2006)
20
+ - NEW: Compatible With WordPress 2.0
21
+ - NEW: Better Installer
22
+ - NEW: GPL License Added
23
+ - NEW: Page Title Added To wp-useronline.php
24
+ - NEW: Added Extra Bots, Credit To Greg Perry (http://www.gregrperry.com/)
25
+ - FIXED: Cleaner Codes
useronline-install.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.01 |
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
+ | - Install WP-UserOnline 2.01 |
14
+ | - wp-admin/useronline-install.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Require Config
21
+ require('../wp-config.php');
22
+
23
+ ### Variables, Variables, Variables
24
+ $current_timestamp = current_time('timestamp');
25
+ $create_table = array();
26
+ $insert_options = array();
27
+ $error = '';
28
+
29
+ ### Create Tables (1 Tables)
30
+ $create_table[] = "CREATE TABLE $wpdb->useronline (".
31
+ " timestamp int(15) NOT NULL default '0',".
32
+ " username varchar(50) NOT NULL default '',".
33
+ " ip varchar(40) NOT NULL default '',".
34
+ " location varchar(255) NOT NULL default '',".
35
+ " url varchar(255) NOT NULL default '',".
36
+ " UNIQUE KEY (timestamp))";
37
+
38
+ ### Insert Options (2 Rows)
39
+ $insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'useronline_most_users', 'Y', 1, '1', 20, 8, 'Most Users Ever Online Count', 1, 'yes');";
40
+ $insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'useronline_most_timestamp', 'Y', 1, '$current_timestamp', 20, 8, 'Most Users Ever Online Date', 1, 'yes');";
41
+
42
+ ### Check Whether There Is Any Pre Errors
43
+ $wpdb->show_errors = false;
44
+ $check_install = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'useronline_most_users'");
45
+ if($check_install) {
46
+ $error = __('You Had Already Installed WP-UserOnline.');
47
+ }
48
+ if(empty($wpdb->useronline)) {
49
+ $error = __('Please Define The Useronline Table In wp-settings.php.');
50
+ }
51
+ ?>
52
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
53
+ <html xmlns="http://www.w3.org/1999/xhtml">
54
+ <head>
55
+ <title>WordPress &rsaquo; <?php _e('Installing'); ?> &rsaquo; <?php _e('WP-UserOnline 2.01'); ?></title>
56
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
57
+ <style type="text/css" media="screen">
58
+ @import url( wp-admin.css );
59
+ </style>
60
+ </head>
61
+ <body>
62
+ <div class="wrap">
63
+ <h2><?php _e('Install WP-UserOnline 2.01'); ?></h2>
64
+ <p><?php _e('This install script will install WP-UserOnline 2.01 for your Wordpress'); ?>.</p>
65
+ <p>
66
+ <?php _e('This install script will be doing the following:'); ?><br />
67
+ <b>&raquo;</b> <b>1</b> <?php _e('table will be created namely <b>useronline</b>.'); ?><br />
68
+ <b>&raquo;</b> <b>2</b> <?php _e('options will be inserted into the <b>options</b> table.'); ?><br />
69
+ <b>&raquo;</b> <b>2</b> <?php _e('tables will be optimized namely <b>useronline</b> and <b>options</b>.'); ?><br />
70
+ </p>
71
+ <?php
72
+ if(empty($error)) {
73
+ if(!empty($_POST['install'])) {
74
+ // Create Tables
75
+ $create_table_count = 0;
76
+ echo "<p><b>".__('Creating Tables:')."</b>";
77
+ foreach($create_table as $createtable) {
78
+ $wpdb->query($createtable);
79
+ }
80
+ $check_useronline = $wpdb->query("SHOW COLUMNS FROM $wpdb->useronline");
81
+ if($check_useronline) {
82
+ echo "<br /><b>&raquo;</b> Table (<b>$wpdb->useronline</b>) created.";
83
+ $create_table_count++;
84
+ } else {
85
+ echo "<br /><b>&raquo;</b> <font color=\"red\">Table (<b>$wpdb->useronline</b>) table NOT created.</font>";
86
+ }
87
+ echo "<br /><b>&raquo;</b> <b>$create_table_count / 1</b> Table Created.</p>";
88
+ // Insert Options
89
+ $insert_options_count = 0;
90
+ echo "<p><b>".__('Inserting Options:')."</b>";
91
+ foreach($insert_options as $insertoptions) {
92
+ $temp_options = $wpdb->query($insertoptions);
93
+ $temp_option = explode(" ", $insertoptions);
94
+ $temp_option = $temp_option[6];
95
+ $temp_option = substr($temp_option, 1, -2);
96
+ if($temp_options) {
97
+ echo "<br /><b>&raquo;</b> Option (<b>$temp_option</b>) inserted.";
98
+ $insert_options_count ++;
99
+ } else {
100
+ echo "<br /><b>&raquo;</b> <font color=\"red\">Option (<b>$temp_option</b>) NOT inserted.</font>";
101
+ }
102
+ }
103
+ echo "<br /><b>&raquo;</b> <b>$insert_options_count / 2</b> Options Inserted.</p>";
104
+ // Optimize Tables
105
+ $optimize_table_count = 0;
106
+ echo "<p><b>".__('Optimizing Tables:')."</b>";
107
+ $optimize_tables = $wpdb->query("OPTIMIZE TABLE $wpdb->useronline, $wpdb->options");
108
+ if($optimize_tables) {
109
+ echo "<br /><b>&raquo;</b> Tables (<b><b>$wpdb->useronline</b>, <b>$wpdb->options</b></b>) optimized.";
110
+ $optimize_table_count = 2;
111
+ } else {
112
+ echo "<br /><b>&raquo;</b> <font color=\"red\">Tables (<b>$wpdb->useronline</b>, <b>$wpdb->options</b>) NOT optimized.</font>";
113
+ }
114
+ echo "<br /><b>&raquo;</b> <b>$optimize_table_count / 2</b> Tables Optimized.</p>";
115
+ // Check Whether Install Is Successful
116
+ if($create_table_count == 1 && $insert_options_count == 2) {
117
+ echo '<p align="center"><b>'.__('WP-UserOnline 2.01 Installed Successfully.').'</b><br />'.__('Please remember to delete this file before proceeding on.').'</p>';
118
+ }
119
+ } else {
120
+ ?>
121
+ <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
122
+ <div align="center"><input type="submit" name="install" value="<?php _e('Click Here To Install WP-UserOnline 2.01'); ?>" class="button"></div>
123
+ </form>
124
+ <?php
125
+ }
126
+ } else {
127
+ echo "<p align=\"center\"><font color=\"red\"><b>$error</b></font></p>\n";
128
+ }
129
+ ?>
130
+ </div>
131
+ </body>
132
+ </html>
useronline-upgrade.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.01 |
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
+ | - Upgrade WP-UserOnline From 2.00 To 2.01 |
14
+ | - wp-admin/useronline-upgrade.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Require Config
21
+ require('../wp-config.php');
22
+
23
+ ### Variables, Variables, Variables
24
+ $current_timestamp = current_time('timestamp');
25
+ $alter_table = array();
26
+ $insert_options = array();
27
+ $error = '';
28
+
29
+ ### Alter Tables (1 Table, 2 Times)
30
+ $alter_table[] = "ALTER TABLE $wpdb->useronline DROP PRIMARY KEY";
31
+ $alter_table[] = "ALTER TABLE $wpdb->useronline ADD UNIQUE (timestamp)";
32
+
33
+ ### Insert Options (2 Rows)
34
+ $insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'useronline_most_users', 'Y', 1, '1', 20, 8, 'Most Users Ever Online Count', 1, 'yes');";
35
+ $insert_options[] ="INSERT INTO $wpdb->options VALUES (0, 0, 'useronline_most_timestamp', 'Y', 1, '$current_timestamp', 20, 8, 'Most Users Ever Online Date', 1, 'yes');";
36
+
37
+ ### Check Whether There Is Any Pre Errors
38
+ $wpdb->show_errors = false;
39
+ $check_upgrade = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'useronline_most_users'");
40
+ if($check_upgrade) {
41
+ $error = __('You Had Already Installed WP-UserOnline.');
42
+ }
43
+ if(empty($wpdb->useronline)) {
44
+ $error = __('Please Define The Useronline Table In wp-settings.php.');
45
+ }
46
+ ?>
47
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
48
+ <html xmlns="http://www.w3.org/1999/xhtml">
49
+ <head>
50
+ <title>WordPress &rsaquo; <?php _e('Upgrading'); ?> &rsaquo; <?php _e('WP-UserOnline 2.01'); ?></title>
51
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
52
+ <style type="text/css" media="screen">
53
+ @import url( wp-admin.css );
54
+ </style>
55
+ </head>
56
+ <body>
57
+ <div class="wrap">
58
+ <h2><?php _e('Upgrading WP-UserOnline 2.01'); ?></h2>
59
+ <p><?php _e('This upgrade script will upgrade WP-UserOnline to version 2.01 for your Wordpress.'); ?></p>
60
+ <p>
61
+ <?php _e('This upgrade script will be doing the following:'); ?><br />
62
+ <b>&raquo;</b> <b>1</b> <?php _e('table will be altered namely <b>useronline</b>.'); ?><br />
63
+ <b>&raquo;</b> <b>2</b> <?php _e('options will be inserted into the <b>options</b> table.'); ?><br />
64
+ <b>&raquo;</b> <b>2</b> <?php _e('tables will be optimized namely <b>useronline</b> and <b>options</b>.'); ?><br />
65
+ </p>
66
+ <?php
67
+ if(empty($error)) {
68
+ if(!empty($_POST['upgrade'])) {
69
+ // Alter Table
70
+ $alter_table_count = 0;
71
+ echo "<p><b>".__('Altering Tables:')."</b>";
72
+ foreach($alter_table as $altertable) {
73
+ $wpdb->query($altertable);
74
+ }
75
+ $keys = $wpdb->get_row("SHOW INDEX FROM $wpdb->useronline");
76
+ if($keys->Key_name == 'timestamp') {
77
+ echo "<br /><b>&raquo;</b> Table (<b>$wpdb->useronline</b>) altered. Primary Key(timestamp) changed to Unique Key(timestamp).";
78
+ $alter_table_count++;
79
+ } else {
80
+ echo "<br /><b>&raquo;</b> <font color=\"red\">Table (<b>$wpdb->useronline</b>) table NOT altered. Primary Key(timestamp) NOT changed to Unique Key(timestamp).</font>";
81
+ }
82
+ echo "<br /><b>&raquo;</b> <b>$alter_table_count / 1</b> Table Altered.</p>";
83
+ // Insert Options
84
+ $insert_options_count = 0;
85
+ echo "<p><b>".__('Inserting Options:')."</b>";
86
+ foreach($insert_options as $insertoptions) {
87
+ $temp_options = $wpdb->query($insertoptions);
88
+ $temp_option = explode(" ", $insertoptions);
89
+ $temp_option = $temp_option[6];
90
+ $temp_option = substr($temp_option, 1, -2);
91
+ if($temp_options) {
92
+ echo "<br /><b>&raquo;</b> Option (<b>$temp_option</b>) inserted.";
93
+ $insert_options_count ++;
94
+ } else {
95
+ echo "<br /><b>&raquo;</b> <font color=\"red\">Option (<b>$temp_option</b>) NOT inserted.</font>";
96
+ }
97
+ }
98
+ echo "<br /><b>&raquo;</b> <b>$insert_options_count / 2</b> Options Inserted.</p>";
99
+ // Optimize Tables
100
+ $optimize_table_count = 0;
101
+ echo "<p><b>".__('Optimizing Tables:')."</b>";
102
+ $optimize_tables = $wpdb->query("OPTIMIZE TABLE $wpdb->useronline, $wpdb->options");
103
+ if($optimize_tables) {
104
+ echo "<br /><b>&raquo;</b> Tables (<b>$wpdb->useronline</b>, <b>$wpdb->options</b>) optimized.";
105
+ $optimize_table_count = 2;
106
+ } else {
107
+ echo "<br /><b>&raquo;</b> <font color=\"red\">Tables (<b>$wpdb->useronline</b>, <b>$wpdb->options</b>) NOT optimized.</font>";
108
+ }
109
+ echo "<br /><b>&raquo;</b> <b>$optimize_table_count / 2</b> Tables Optimized.</p>";
110
+ // Check Whether Install Is Successful
111
+ if($alter_table_count == 1 && $insert_options_count == 2) {
112
+ echo '<p align="center"><b>'.__('WP-UserOnline Upgraded Successfully To Version 2.01.').'</b><br />'.__('Please remember to delete this file before proceeding on.').'</p>';
113
+ }
114
+ } else {
115
+ ?>
116
+ <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
117
+ <div align="center"><input type="submit" name="upgrade" value="<?php _e('Click Here To Upgrade WP-UserOnline 2.01'); ?>" class="button"></div>
118
+ </form>
119
+ <?php
120
+ }
121
+ } else {
122
+ echo "<p align=\"center\"><font color=\"red\"><b>$error</b></font></p>\n";
123
+ }
124
+ ?>
125
+ </div>
126
+ </body>
127
+ </html>
useronline.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.01
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
+ ### Search Bots Name
35
+ $bots = array('Google Bot' => 'googlebot', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'ubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot');
36
+
37
+
38
+ ### Function: Get IP
39
+ function get_IP() {
40
+ if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
41
+ $ip_address = $_SERVER["REMOTE_ADDR"];
42
+ } else {
43
+ $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
44
+ }
45
+ if(strpos($ip_address, ',') !== false) {
46
+ $ip_address = explode(',', $ip_address);
47
+ $ip_address = $ip_address[0];
48
+ }
49
+ return $ip_address;
50
+ }
51
+
52
+
53
+ ### Function: Process UserOnline
54
+ add_action('wp_head', 'useronline');
55
+ function useronline() {
56
+ global $wpdb, $useronline, $bots;
57
+
58
+ // Useronline Settings
59
+ $timeoutseconds = 300;
60
+ $timestamp = current_time('timestamp');
61
+ $timeout = ($timestamp-$timeoutseconds);
62
+ $ip = get_IP();
63
+ $url = addslashes(urlencode($_SERVER['REQUEST_URI']));
64
+
65
+ // Check For Members
66
+ if(!empty($_COOKIE['comment_author_'.COOKIEHASH])) {
67
+ $memberonline = addslashes(trim($_COOKIE['comment_author_'.COOKIEHASH]));
68
+ $where = "WHERE username='$memberonline'";
69
+ // Check For Admins
70
+ } elseif(!empty($_COOKIE['wordpressuser_'.COOKIEHASH])) {
71
+ $memberonline = addslashes(trim($_COOKIE['wordpressuser_'.COOKIEHASH]));
72
+ $where = "WHERE username='$memberonline'";
73
+ // Check For Guests
74
+ } else {
75
+ $memberonline = 'Guest';
76
+ $where = "WHERE ip='$ip'";
77
+ }
78
+ // Check For Bot
79
+ foreach ($bots as $name => $lookfor) {
80
+ if (stristr($_SERVER['HTTP_USER_AGENT'], $lookfor) !== false) {
81
+ $memberonline = addslashes($name);
82
+ $where = "WHERE ip='$ip'";
83
+ }
84
+ }
85
+ // Check For Page Title
86
+ $make_page = wp_title('&raquo;', false);
87
+ if(empty($make_page)) {
88
+ $make_page = get_bloginfo('name');
89
+ } elseif(is_single()) {
90
+ $make_page = get_bloginfo('name').' &raquo; Blog Archive '.$make_page;
91
+ } else {
92
+ $make_page = get_bloginfo('name').$make_page;
93
+ }
94
+ $make_page = addslashes($make_page);
95
+
96
+ // Update User First
97
+ $update_user = $wpdb->query("UPDATE $wpdb->useronline SET timestamp = '$timestamp', ip = '$ip', location = '$make_page', url = '$url' $where");
98
+
99
+ // If No Such User Insert It
100
+ if(!$update_user) {
101
+ $insert_user = $wpdb->query("INSERT INTO $wpdb->useronline VALUES ('$timestamp', '$memberonline', '$ip', '$make_page', '$url') ON DUPLICATE KEY UPDATE timestamp = '".($timestamp+1)."'");
102
+ }
103
+
104
+ // Delete Users
105
+ $delete_users = $wpdb->query("DELETE FROM $wpdb->useronline WHERE timestamp < $timeout");
106
+
107
+ // Count Users Online
108
+ $useronline = intval($wpdb->get_var("SELECT COUNT(*) FROM $wpdb->useronline"));
109
+
110
+ // Get Most User Online
111
+ $most_useronline = intval(get_settings('useronline_most_users'));
112
+
113
+ // Check Whether Current Users Online Is More Than Most Users Online
114
+ if($useronline > $most_useronline) {
115
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '$useronline' WHERE option_name = 'useronline_most_users'");
116
+ $wpdb->query("UPDATE $wpdb->options SET option_value = '".current_time('timestamp')."' WHERE option_name = 'useronline_most_timestamp'");
117
+ wp_cache_flush();
118
+ }
119
+ }
120
+
121
+
122
+ ### Function: Display UserOnline
123
+ function get_useronline($user = 'User', $users = 'Users', $display = true) {
124
+ global $useronline;
125
+ // Display User Online
126
+ if($display) {
127
+ if($useronline > 1) {
128
+ echo "<b>$useronline</b> $users ".__('Online');
129
+ } else {
130
+ echo "<b>$useronline</b> $user ".__('Online');
131
+ }
132
+ } else {
133
+ return $useronline;
134
+ }
135
+ }
136
+
137
+
138
+ ### Function: Display Max UserOnline
139
+ function get_most_useronline($display = true) {
140
+ $most_useronline_users = intval(get_settings('useronline_most_users'));
141
+ if($display) {
142
+ echo $most_useronline_users;
143
+ } else {
144
+ return $most_useronline_users;
145
+ }
146
+ }
147
+
148
+
149
+ ### Function: Display Max UserOnline Date
150
+ function get_most_useronline_date($date_format = 'jS F Y, H:i', $display =true) {
151
+ $most_useronline_timestamp = get_settings('useronline_most_timestamp');
152
+ $most_useronline_date = gmdate($date_format, $most_useronline_timestamp);
153
+ if($display) {
154
+ echo $most_useronline_date;
155
+ } else {
156
+ return$most_useronline_date;
157
+ }
158
+ }
159
+
160
+
161
+ ### Function: Display Users Browsing The Page
162
+ function get_users_browsing_page() {
163
+ global $wpdb, $bots;
164
+
165
+ // Get Users Browsing Page
166
+ $page_url = addslashes(urlencode($_SERVER['REQUEST_URI']));
167
+ $users_browse = $wpdb->get_results("SELECT username FROM $wpdb->useronline WHERE url = '$page_url'");
168
+
169
+ // Variables
170
+ $members = array();
171
+ $total_users = 0;
172
+ $total_members = 0;
173
+ $total_guests = 0;
174
+ $total_bots = 0;
175
+ $nicetext_members = '';
176
+ $nicetext_guests = '';
177
+ $nicetext_bots = '';
178
+
179
+ // If There Is Users Browsing, Then We Execute
180
+ if($users_browse) {
181
+ // Reassign Bots Name
182
+ $bots_name = array();
183
+ foreach($bots as $botname => $botlookfor) {
184
+ $bots_name[] = $botname;
185
+ }
186
+ // Get Users Information
187
+ foreach($users_browse as $user_browse) {
188
+ if($user_browse->username == 'Guest') {
189
+ $total_guests++;
190
+ } elseif(in_array($user_browse->username, $bots_name)) {
191
+ $total_bots++;
192
+ } else {
193
+ $members[] = stripslashes($user_browse->username);
194
+ $total_members++;
195
+ }
196
+ }
197
+ $total_users = ($total_guests+$total_bots+$total_members);
198
+
199
+ // Nice Text For Members
200
+ if($total_members > 1) {
201
+ $nicetext_members = $total_members.' '.__('Members');
202
+ } else {
203
+ $nicetext_members = $total_members.' '.__('Member');
204
+ }
205
+ // Nice Text For Guests
206
+ if($total_guests > 1) {
207
+ $nicetext_guests = $total_guests.' '.__('Guests');
208
+ } else {
209
+ $nicetext_guests = $total_guests.' '.__('Guest');
210
+ }
211
+ // Nice Text For Bots
212
+ if($total_bots > 1) {
213
+ $nicetext_bots = $total_bots.' '.__('Bots');
214
+ } else {
215
+ $nicetext_bots = $total_bots.' '.__('Bot');
216
+ }
217
+
218
+ // Print User Count
219
+ echo __('Users Browsing This Page: ').'<b>'.$total_users.'</b> ('.$nicetext_members.', '.$nicetext_guests.' '.__('and').' '.$nicetext_bots.')<br />';
220
+
221
+ // Print Member Name
222
+ if($members) {
223
+ $temp_member = '';
224
+ foreach($members as $member) {
225
+ $temp_member .= '<a href="'.get_settings('home').'/wp-stats.php?author='.urlencode($member).'">'.$member.'</a>, ';
226
+ }
227
+ echo __('Members').': '.substr($temp_member, 0, -2);
228
+ }
229
+ } else {
230
+ // This Should Not Happen
231
+ _e('No User Is Browsing This Page');
232
+ }
233
+ }
234
+ ?>
wp-useronline.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ +----------------------------------------------------------------+
4
+ | |
5
+ | WordPress 2.0 Plugin: WP-UserOnline 2.01 |
6
+ | Copyright (c) 2005 Lester "GaMerZ" Chan |
7
+ | |
8
+ | File Written By: |
9
+ | - Lester "GaMerZ" Chan |
10
+ | - http://www.lesterchan.net |
11
+ | |
12
+ | File Information: |
13
+ | - Useronline Page |
14
+ | - wp-useronline.php |
15
+ | |
16
+ +----------------------------------------------------------------+
17
+ */
18
+
19
+
20
+ ### Require WordPress Header
21
+ require(dirname(__FILE__).'/wp-blog-header.php');
22
+
23
+ ### Function: UserOnline Page Title
24
+ add_filter('wp_title', 'useronline_pagetitle');
25
+ function useronline_pagetitle($useronline_pagetitle) {
26
+ return $useronline_pagetitle.' &raquo; UserOnline';
27
+ }
28
+
29
+ ### Reassign Bots Name
30
+ $bots_name = array();
31
+ foreach($bots as $botname => $botlookfor) {
32
+ $bots_name[] = $botname;
33
+ }
34
+
35
+ ### Get The Users Online
36
+ $usersonline = $wpdb->get_results("SELECT * FROM $wpdb->useronline");
37
+
38
+ ### Variables Variables Variables
39
+ $members = array();
40
+ $guests = array();
41
+ $bots = array();
42
+ $total_users = 0;
43
+ $total_members = 0;
44
+ $total_guests = 0;
45
+ $total_bots = 0;
46
+ $nicetext_users = '';
47
+ $nicetext_members = '';
48
+ $nicetext_guests = '';
49
+ $nicetext_bots = '';
50
+
51
+ ### Process Those User Who Is Online
52
+ if($usersonline) {
53
+ foreach($usersonline as $useronline) {
54
+ if($useronline->username == 'Guest') {
55
+ $guests[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
56
+ $total_guests++;
57
+ } elseif(in_array($useronline->username, $bots_name)) {
58
+ $bots[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
59
+ $total_bots++;
60
+ } else {
61
+ $members[] = array('username' => stripslashes($useronline->username), 'timestamp' => $useronline->timestamp, 'ip' => $useronline->ip, 'location' => stripslashes($useronline->location), 'url' => stripslashes(urldecode($useronline->url)));
62
+ $total_members++;
63
+ }
64
+ }
65
+ $total_users = ($total_guests+$total_bots+$total_members);
66
+ }
67
+
68
+ ### Nice Text For Users
69
+ if($total_users > 1) {
70
+ $nicetext_users = $total_users.' '.__('Users');
71
+ } else {
72
+ $nicetext_users = $total_users.' '.__('User');
73
+ }
74
+
75
+ ### Nice Text For Members
76
+ if($total_members > 1) {
77
+ $nicetext_members = $total_members.' '.__('Members');
78
+ } else {
79
+ $nicetext_members = $total_members.' '.__('Member');
80
+ }
81
+
82
+
83
+ ### Nice Text For Guests
84
+ if($total_guests > 1) {
85
+ $nicetext_guests = $total_guests.' '.__('Guests');
86
+ } else {
87
+ $nicetext_guests = $total_guests.' '.__('Guest');
88
+ }
89
+
90
+ ### Nice Text For Bots
91
+ if($total_bots > 1) {
92
+ $nicetext_bots = $total_bots.' '.__('Bots');
93
+ } else {
94
+ $nicetext_bots = $total_bots.' '.__('Bot');
95
+ }
96
+
97
+ ### Function: Check IP
98
+ function check_ip($ip) {
99
+ if(isset($_COOKIE['wordpressuser_'.COOKIEHASH])) {
100
+ return "(<a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$ip\" target=\"_blank\" title=\"".gethostbyaddr($ip)."\">$ip</a>)";
101
+ }
102
+ }
103
+ ?>
104
+ <?php get_header(); ?>
105
+ <div id="content" class="narrowcolumn">
106
+ <p>There are a total of <b><?php echo $nicetext_users; ?></b> online now.</p>
107
+ <p>Out of which, there are <b><?php echo $nicetext_members; ?></b>, <b><?php echo $nicetext_guests; ?></b> and <b><?php echo $nicetext_bots; ?></b>.</p>
108
+ <p>Most users ever online was <b><?php get_most_useronline(); ?></b> on <b><?php get_most_useronline_date(); ?></b></p>
109
+ <table width="100%" border="0" cellspacing="1" cellpadding="5">
110
+ <?php
111
+ // Print Out Members
112
+ if($total_members > 0) {
113
+ echo '<tr><td><h2 class="pagetitle">'.$nicetext_members.' '.__('Online Now').'</h2></td></tr>'."\n";
114
+ }
115
+ $no=1;
116
+ if($members) {
117
+ foreach($members as $member) {
118
+ echo '<tr>'."\n";
119
+ echo '<td><b>#'.$no.' - <a href="'.get_settings('home').'/wp-stats.php?author='.$member['username'].'">'.$member['username'].'</a></b> '.check_ip($member['ip']).' on '.gmdate('d.m.Y @ H:i', $member['timestamp']).'<br />'.$member['location'].' [<a href="'.$member['url'].'">url</a>]</td>'."\n";
120
+ echo '</tr>'."\n";
121
+ $no++;
122
+ }
123
+ }
124
+ // Print Out Guest
125
+ if($total_guests > 0) {
126
+ echo '<tr><td><h2 class="pagetitle">'.$nicetext_guests.' '.__('Online Now').'</h2></td></tr>'."\n";
127
+ }
128
+ $no=1;
129
+ if($guests) {
130
+ foreach($guests as $guest) {
131
+ echo '<tr>'."\n";
132
+ echo '<td><b>#'.$no.' - '.$guest['username'].'</b> '.check_ip($guest['ip']).' on '.gmdate('d.m.Y @ H:i', $guest['timestamp']).'<br />'.$guest['location'].' [<a href="'.$guest['url'].'">url</a>]</td>'."\n";
133
+ echo '</tr>'."\n";
134
+ $no++;
135
+ }
136
+ }
137
+ // Print Out Bots
138
+ if($total_bots > 0) {
139
+ echo '<tr><td><h2 class="pagetitle">'.$nicetext_bots.' '.__('Online Now').'</h2></td></tr>'."\n";
140
+ }
141
+ $no=1;
142
+ if($bots) {
143
+ foreach($bots as $bot) {
144
+ echo '<tr>'."\n";
145
+ echo '<td><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>]</td>'."\n";
146
+ echo '</tr>'."\n";
147
+ $no++;
148
+ }
149
+ }
150
+ if($total_users == 0) {
151
+ echo '<tr><td><h2 class="pagetitle">'.__('No One Is Online Now').'</h2></td></tr>'."\n";
152
+ }
153
+ ?>
154
+ </table>
155
+ </div>
156
+ <?php get_sidebar(); ?>
157
+ <?php get_footer(); ?>