From 1e15f1c92bd12d4d88f3226c6f5cba6e5e61b80b Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Thu, 24 Dec 2009 10:00:30 +0000 Subject: [PATCH] agent added to online table for easier detection of bots --- e107_admin/includes/infopanel.php | 6 ++++-- e107_admin/sql/core_sql.php | 7 ++++--- e107_handlers/online_class.php | 23 ++++++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/e107_admin/includes/infopanel.php b/e107_admin/includes/infopanel.php index 6a001dbe8..4c8476d69 100644 --- a/e107_admin/includes/infopanel.php +++ b/e107_admin/includes/infopanel.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/includes/infopanel.php,v $ - | $Revision: 1.17 $ - | $Date: 2009-11-18 01:04:42 $ + | $Revision: 1.18 $ + | $Date: 2009-12-24 10:00:30 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -133,6 +133,7 @@ $text .= " Username IP Page + Agent "; @@ -146,6 +147,7 @@ $text .= " ".renderOnlineName($val['online_user_id'])." ".e107::ipDecode($val['online_ip'])." ".$tp->text_truncate($val['online_location'],50)." + ".$tp->text_truncate($val['online_agent'],20,'...')." "; } diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php index 3da536612..d8a3f0be4 100644 --- a/e107_admin/sql/core_sql.php +++ b/e107_admin/sql/core_sql.php @@ -9,8 +9,8 @@ * Core SQL * * $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ - * $Revision: 1.45 $ - * $Date: 2009-12-15 11:51:02 $ + * $Revision: 1.46 $ + * $Date: 2009-12-24 10:00:30 $ * $Author: e107coders $ */ @@ -354,7 +354,8 @@ CREATE TABLE online ( online_ip varchar(45) NOT NULL default '', online_location text NOT NULL, online_pagecount tinyint(3) unsigned NOT NULL default '0', - online_active int(10) unsigned NOT NULL default '0' + online_active int(10) unsigned NOT NULL default '0', + online_agent varchar(255) NOT NULL default '' ) TYPE=MyISAM; # -------------------------------------------------------- diff --git a/e107_handlers/online_class.php b/e107_handlers/online_class.php index 83bde274f..31bba2849 100755 --- a/e107_handlers/online_class.php +++ b/e107_handlers/online_class.php @@ -9,8 +9,8 @@ * e107 Main * * $Source: /cvs_backup/e107_0.8/e107_handlers/online_class.php,v $ - * $Revision: 1.7 $ - * $Date: 2009-11-18 01:04:43 $ + * $Revision: 1.8 $ + * $Date: 2009-12-24 10:00:30 $ * $Author: e107coders $ */ @@ -41,7 +41,20 @@ class e_online $page = (strpos(e_SELF, "content") !== FALSE) ? e_SELF.".".e_QUERY : $page; $page = $tp -> toDB($page, true); $ip = $e107->getip(); - $udata = (USER === true ? USERID.".".USERNAME : "0"); + $udata = (USER === true) ? USERID.".".USERNAME : "0"; + $agent = $_SERVER['HTTP_USER_AGENT']; + + $insert_query = array( + 'online_timestamp' => time(), + 'online_flag' => 0, + 'online_user_id' => $udata, + 'online_ip' => $ip, + 'online_location' => $page, + 'online_pagecount' => 1, + 'online_active' => 0, + 'online_agent' => $agent + ); + if (USER) { // Find record that matches IP or visitor, or matches user info @@ -80,7 +93,7 @@ class e_online } else { - $sql->db_Insert("online", " '".time()."', '0', '{$udata}', '{$ip}', '{$page}', 1, 0"); + $sql->db_Insert("online",$insert_query); } } else @@ -106,7 +119,7 @@ class e_online } else { - $sql->db_Insert("online", " '".time()."', '0', '0', '{$ip}', '{$page}', 1, 0"); + $sql->db_Insert("online",$insert_query); } }