$ /sales/inquiry/sales_orders_view.php
13-Oct-2009 Joe Hunt
-+ Added discrete users online in footer (from Wish List Forum)
++ Added discrete users online in footer (from Wish List Forum) (New rerun)
$ /admin/db/users_db.inc
/sql/alter2.2.sql
/sql/en_US-new.sql
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
- $ip = substr($_SERVER['REMOTE_ADDR'], 0, strrpos($_SERVER['REMOTE_ADDR'],"."));
-
- // Add user to database
- $loopcap = 0;
- while($loopcap<3 && db_query("INSERT INTO ".TB_PREF."useronline VALUES('". $timestamp ."','". $ip ."','". $_SERVER['PHP_SELF'] ."')"))
- { // In geval van error
- $timestamp = $timestamp+$ip{0};
- $loopcap++;
+ /*
+ This will try to find out if user is coming behind proxy server. Why is this important?
+ If you have high traffic web site, it might happen that you receive lot of traffic
+ from the same proxy server (like AOL). In that case, the script would count them all as 1 user.
+ This function tryes to get real IP address.
+ Note that getenv() function doesn't work when PHP is running as ISAPI module
+ */
+ if (getenv('HTTP_CLIENT_IP')) {
+ $ip = getenv('HTTP_CLIENT_IP');
}
-
+ elseif (getenv('HTTP_X_FORWARDED_FOR')) {
+ $ip = getenv('HTTP_X_FORWARDED_FOR');
+ }
+ elseif (getenv('HTTP_X_FORWARDED')) {
+ $ip = getenv('HTTP_X_FORWARDED');
+ }
+ elseif (getenv('HTTP_FORWARDED_FOR')) {
+ $ip = getenv('HTTP_FORWARDED_FOR');
+ }
+ elseif (getenv('HTTP_FORWARDED')) {
+ $ip = getenv('HTTP_FORWARDED');
+ }
+ else {
+ $ip = $_SERVER['REMOTE_ADDR'];
+ }
+
+ // Add user to database
+ db_query("INSERT INTO ".TB_PREF."useronline (timestamp, ip, file) VALUES ('". $timestamp ."','". $ip ."','". $_SERVER['PHP_SELF'] ."')");
//Remove users that were not online within $timeoutseconds.
db_query("DELETE FROM ".TB_PREF."useronline WHERE timestamp<". $timeout);
UNIQUE KEY(`record_id`,`tag_id`)
) TYPE=MyISAM;
-DROP TABLE IF EXISTS `0_usersonline`;
+DROP TABLE IF EXISTS `0_useronline` ;
CREATE TABLE `0_useronline` (
+ `id` int(11) NOT NULL AUTO_INCREMENT ,
`timestamp` int(15) NOT NULL default '0',
`ip` varchar(40) NOT NULL default '',
`file` varchar(100) NOT NULL default '',
- PRIMARY KEY (`timestamp`),
- KEY `ip` (`ip`),
- KEY `file` (`file`)
-) TYPE=MyISAM;
+ PRIMARY KEY `id` (`id`) ,
+ KEY (`timestamp`)
+) TYPE=MYISAM AUTO_INCREMENT=1;
ALTER TABLE `0_suppliers` ADD COLUMN `phone2` varchar(30) NOT NULL default '' AFTER `phone`;
ALTER TABLE `0_cust_branch` ADD COLUMN `phone2` varchar(30) NOT NULL default '' AFTER `phone`;
### Data of table `0_tag_associations` ###
-DROP TABLE IF EXISTS `0_usersonline`;
+DROP TABLE IF EXISTS `0_useronline` ;
CREATE TABLE `0_useronline` (
+ `id` int(11) NOT NULL AUTO_INCREMENT ,
`timestamp` int(15) NOT NULL default '0',
`ip` varchar(40) NOT NULL default '',
`file` varchar(100) NOT NULL default '',
- PRIMARY KEY (`timestamp`),
- KEY `ip` (`ip`),
- KEY `file` (`file`)
-) TYPE=MyISAM;
+ PRIMARY KEY `id` (`id`) ,
+ KEY (`timestamp`)
+) TYPE=MYISAM AUTO_INCREMENT=1;
### Data of table `0_tag_associations` ###
-DROP TABLE IF EXISTS `0_usersonline`;
+DROP TABLE IF EXISTS `0_useronline` ;
CREATE TABLE `0_useronline` (
+ `id` int(11) NOT NULL AUTO_INCREMENT ,
`timestamp` int(15) NOT NULL default '0',
`ip` varchar(40) NOT NULL default '',
`file` varchar(100) NOT NULL default '',
- PRIMARY KEY (`timestamp`),
- KEY `ip` (`ip`),
- KEY `file` (`file`)
-) TYPE=MyISAM;
+ PRIMARY KEY `id` (`id`) ,
+ KEY (`timestamp`)
+) TYPE=MYISAM AUTO_INCREMENT=1;