mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 18:40:13 +01:00
online users fix
This commit is contained in:
parent
3664b775bb
commit
3d8d08f2bd
@ -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;
|
||||
|
||||
|
@ -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']));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -921,9 +921,14 @@ var Piler =
|
||||
clear_ldap_test: function()
|
||||
{
|
||||
$('#LDAPTEST').html('');
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
reload_page: function()
|
||||
{
|
||||
location.reload(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,14 @@
|
||||
<link rel="shortcut icon" href="/view/theme/default/assets/ico/favicon.png">
|
||||
</head>
|
||||
|
||||
<body<?php if(isset($this->request->get['route']) && $this->request->get['route'] == 'health/health') { ?> onload="Piler.load_health(); setInterval('Piler.load_health()', Piler.health_refresh * 1000);"<?php } ?>>
|
||||
<body<?php
|
||||
|
||||
if(isset($this->request->get['route'])) {
|
||||
|
||||
if($this->request->get['route'] == 'health/health') { ?> onload="Piler.load_health(); setInterval('Piler.load_health()', Piler.health_refresh * 1000);"<?php }
|
||||
if($this->request->get['route'] == 'stat/online') { ?> onload="setInterval('Piler.reload_page()', Piler.health_refresh * 1000);"<?php }
|
||||
|
||||
} ?>>
|
||||
|
||||
<div id="piler1" class="container">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user