diff --git a/util/db-mysql.sql b/util/db-mysql.sql index 22fe18ee..a3c650bc 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -371,9 +371,10 @@ create table if not exists `customer_settings` ( create table if not exists `online` ( - `username` varchar(255) not null unique, + `username` varchar(255) not null, `ts` int default 0, `last_activity` int default 0, - `ipaddr` varchar(255) default null + `ipaddr` varchar(255) default null, + unique(`username`,`ipaddr`) ) Engine=InnoDB; diff --git a/webui/index.php b/webui/index.php index ca5e633e..0115788c 100644 --- a/webui/index.php +++ b/webui/index.php @@ -75,7 +75,7 @@ if(Registry::get('username')) { } if(ENABLE_SAAS == 1) { - $query = $db->query("UPDATE " . TABLE_ONLINE . " SET last_activity=? WHERE username=?", array(NOW, Registry::get('username'))); + $query = $db->query("UPDATE " . TABLE_ONLINE . " SET last_activity=? WHERE username=? AND ipaddr=?", array(NOW, Registry::get('username'), $_SERVER['REMOTE_ADDR'])); if($db->countAffected() == 0) { $query = $db->query("INSERT INTO " . TABLE_ONLINE . " (username, ts, last_activity, ipaddr) VALUES(?,?,?,?)", array(Registry::get('username'), NOW, NOW, $_SERVER['REMOTE_ADDR'])); diff --git a/webui/model/saas/customer.php b/webui/model/saas/customer.php index d70264c2..cadf2236 100644 --- a/webui/model/saas/customer.php +++ b/webui/model/saas/customer.php @@ -118,7 +118,7 @@ class ModelSaasCustomer extends Model $query = $this->db->query("INSERT INTO " . TABLE_ONLINE . " (username, ts, last_activity, ipaddr) VALUES(?,?,?,?)", array($username, NOW, NOW, $_SERVER['REMOTE_ADDR'])); if($this->db->countAffected() == 0) { - $query = $this->db->query("UPDATE " . TABLE_ONLINE . " SET ts=?, last_activity=?, ipaddr=? WHERE username=?", array(NOW, $_SERVER['REMOTE_ADDR'], $username)); + $query = $this->db->query("UPDATE " . TABLE_ONLINE . " SET ts=?, last_activity=? WHERE username=? AND ipaddr=?", array(NOW, $username, $_SERVER['REMOTE_ADDR'])); } return 1; @@ -128,7 +128,7 @@ class ModelSaasCustomer extends Model public function offline($username = '') { if($username == '') { return 0; } - $query = $this->db->query("DELETE FROM " . TABLE_ONLINE . " WHERE username=?", array($username)); + $query = $this->db->query("DELETE FROM " . TABLE_ONLINE . " WHERE username=? AND ipaddr=?", array($username, $_SERVER['REMOTE_ADDR'])); return 1; } diff --git a/webui/view/javascript/piler-in.js b/webui/view/javascript/piler-in.js index d084a68a..d1096179 100644 --- a/webui/view/javascript/piler-in.js +++ b/webui/view/javascript/piler-in.js @@ -921,9 +921,14 @@ var Piler = clear_ldap_test: function() { $('#LDAPTEST').html(''); - } + }, + reload_page: function() + { + location.reload(true); + } + } diff --git a/webui/view/theme/default/templates/common/layout.tpl b/webui/view/theme/default/templates/common/layout.tpl index d2f85154..c173f7c1 100644 --- a/webui/view/theme/default/templates/common/layout.tpl +++ b/webui/view/theme/default/templates/common/layout.tpl @@ -32,7 +32,14 @@ -
request->get['route']) && $this->request->get['route'] == 'health/health') { ?> onload="Piler.load_health(); setInterval('Piler.load_health()', Piler.health_refresh * 1000);"> +request->get['route'])) { + + if($this->request->get['route'] == 'health/health') { ?> onload="Piler.load_health(); setInterval('Piler.load_health()', Piler.health_refresh * 1000);"request->get['route'] == 'stat/online') { ?> onload="setInterval('Piler.reload_page()', Piler.health_refresh * 1000);">