mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:41:59 +01:00
added online users feature
This commit is contained in:
parent
920f4208ba
commit
93e9c7ce33
@ -370,3 +370,10 @@ create table if not exists `customer_settings` (
|
||||
) Engine=InnoDB;
|
||||
|
||||
|
||||
create table if not exists `online` (
|
||||
`username` varchar(255) not null unique,
|
||||
`ts` int default 0,
|
||||
`last_activity` int default 0,
|
||||
`ipaddr` varchar(255) default null
|
||||
) Engine=InnoDB;
|
||||
|
||||
|
@ -25,4 +25,10 @@ create table if not exists `customer_settings` (
|
||||
`colour` varchar(255) default null
|
||||
) Engine=InnoDB;
|
||||
|
||||
create table if not exists `online` (
|
||||
`username` varchar(255) not null unique,
|
||||
`ts` int default 0,
|
||||
`last_activity` int default 0,
|
||||
`ipaddr` varchar(255) default null
|
||||
) Engine=InnoDB;
|
||||
|
||||
|
@ -272,6 +272,7 @@ define('TABLE_RETENTION_RULE', 'retention_rule');
|
||||
define('TABLE_OPTION', 'option');
|
||||
define('TABLE_LDAP', 'ldap');
|
||||
define('TABLE_CUSTOMER_SETTINGS', 'customer_settings');
|
||||
define('TABLE_ONLINE', 'online');
|
||||
define('TABLE_GOOGLE', 'google');
|
||||
define('TABLE_GOOGLE_IMAP', 'google_imap');
|
||||
define('VIEW_MESSAGES', 'v_messages');
|
||||
|
@ -18,6 +18,9 @@ class ControllerHealthWorker extends Controller {
|
||||
|
||||
$this->load->model('health/health');
|
||||
$this->load->model('stat/counter');
|
||||
if(ENABLE_SAAS == 1) {
|
||||
$this->load->model('saas/customer');
|
||||
}
|
||||
|
||||
$request = Registry::get('request');
|
||||
|
||||
@ -37,6 +40,9 @@ class ControllerHealthWorker extends Controller {
|
||||
$this->data['health'][] = $this->model_health_health->checksmtp($smtp, $lang->data['text_error']);
|
||||
}
|
||||
|
||||
if(ENABLE_SAAS == 1) {
|
||||
$this->data['num_of_online_users'] = $this->model_saas_customer->count_online();
|
||||
}
|
||||
|
||||
$this->data['processed_emails'] = $this->model_health_health->count_processed_emails();
|
||||
|
||||
|
@ -29,6 +29,7 @@ class ControllerLoginLogin extends Controller {
|
||||
|
||||
if(ENABLE_SAAS == 1) {
|
||||
$this->load->model('saas/ldap');
|
||||
$this->load->model('saas/customer');
|
||||
}
|
||||
|
||||
$this->document->title = $this->data['text_login'];
|
||||
@ -39,6 +40,10 @@ class ControllerLoginLogin extends Controller {
|
||||
|
||||
$this->model_user_prefs->get_user_preferences($_SESSION['username']);
|
||||
|
||||
if(ENABLE_SAAS == 1) {
|
||||
$this->model_saas_customer->online($_SESSION['username']);
|
||||
}
|
||||
|
||||
LOGGER('logged in');
|
||||
|
||||
if(isAdminUser() == 1) {
|
||||
|
@ -18,6 +18,11 @@ class ControllerLoginLogout extends Controller {
|
||||
|
||||
$this->document->title = $this->data['text_logout'];
|
||||
|
||||
if(ENABLE_SAAS == 1) {
|
||||
$this->load->model('saas/customer');
|
||||
$this->model_saas_customer->offline(Registry::get('username'));
|
||||
}
|
||||
|
||||
logout();
|
||||
|
||||
$this->render();
|
||||
|
33
webui/controller/stat/online.php
Normal file
33
webui/controller/stat/online.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerStatOnline extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "stat/online.tpl";
|
||||
$this->layout = "common/layout";
|
||||
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
|
||||
$this->load->model('saas/customer');
|
||||
|
||||
$this->document->title = $this->data['text_statistics'];
|
||||
|
||||
if(Registry::get('admin_user') == 0) {
|
||||
die("go away");
|
||||
}
|
||||
|
||||
$this->data['users'] = $this->model_saas_customer->get_online_users();
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -73,6 +73,15 @@ if(Registry::get('username')) {
|
||||
else {
|
||||
$action = new Router('search/search');
|
||||
}
|
||||
|
||||
if(ENABLE_SAAS == 1) {
|
||||
$query = $db->query("UPDATE " . TABLE_ONLINE . " SET last_activity=? WHERE username=?", array(NOW, Registry::get('username')));
|
||||
|
||||
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']));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if(ENABLE_GOOGLE_LOGIN == 1 && isset($request->get['route']) && $request->get['route'] == 'login/google') {
|
||||
|
@ -164,8 +164,10 @@ $_['text_invalid_policy_setting'] = "Ungültige Methodeneinstellung";
|
||||
$_['text_invalid_uid'] = "Benutzerkennung ungültig";
|
||||
$_['text_invalid_username'] = "Ungültiger Benutzername";
|
||||
$_['text_ipaddr'] = "IP-Adresse";
|
||||
|
||||
$_['text_language'] = "Sprache";
|
||||
$_['text_last'] = "Letzte";
|
||||
$_['text_last_activity'] = "Letzte Aktivitat";
|
||||
$_['text_last_update'] = "Letzte Aktualisierung";
|
||||
$_['text_latest_emails'] = "Letzte Nachrichten";
|
||||
$_['text_ldap'] = "LDAP";
|
||||
@ -177,6 +179,7 @@ $_['text_ldap_host'] = "LDAP-Host";
|
||||
$_['text_ldap_type'] = "LDAP-Typ";
|
||||
$_['text_load'] = "Laden";
|
||||
$_['text_loading'] = "lade";
|
||||
$_['text_logged_in'] = "Logged in";
|
||||
$_['text_logged_out'] = "Sie haben sich abgemeldet";
|
||||
$_['text_login'] = "Anmeldung";
|
||||
$_['text_login2'] = "Anmeldung";
|
||||
|
@ -164,8 +164,10 @@ $_['text_invalid_policy_setting'] = "Invalid policy setting";
|
||||
$_['text_invalid_uid'] = "Invalid uid";
|
||||
$_['text_invalid_username'] = "Invalid username";
|
||||
$_['text_ipaddr'] = "IP address";
|
||||
|
||||
$_['text_language'] = "Language";
|
||||
$_['text_last'] = "Last";
|
||||
$_['text_last_activity'] = "Last activity";
|
||||
$_['text_last_update'] = "Last update";
|
||||
$_['text_latest_emails'] = "Latest emails";
|
||||
$_['text_ldap'] = "LDAP";
|
||||
@ -177,6 +179,7 @@ $_['text_ldap_host'] = "LDAP host";
|
||||
$_['text_ldap_type'] = "LDAP type";
|
||||
$_['text_load'] = "Load";
|
||||
$_['text_loading'] = "loading";
|
||||
$_['text_logged_in'] = "Logged in";
|
||||
$_['text_logged_out'] = "You are logged out";
|
||||
$_['text_login'] = "Login";
|
||||
$_['text_login2'] = "login";
|
||||
|
@ -167,6 +167,7 @@ $_['text_ipaddr'] = "IP c
|
||||
|
||||
$_['text_language'] = "Nyelv";
|
||||
$_['text_last'] = "Utolsó";
|
||||
$_['text_last_activity'] = "Utolsó aktivitás";
|
||||
$_['text_latest_emails'] = "Legfrissebb emailek";
|
||||
$_['text_last_update'] = "Utolsó frissítés";
|
||||
$_['text_ldap'] = "LDAP";
|
||||
@ -178,6 +179,7 @@ $_['text_ldap_host'] = "LDAP kiszolg
|
||||
$_['text_ldap_type'] = "LDAP típus";
|
||||
$_['text_load'] = "Betöltés";
|
||||
$_['text_loading'] = "töltődik";
|
||||
$_['text_logged_in'] = "Bejelentkezés";
|
||||
$_['text_logged_out'] = "Ön kijelentkezett";
|
||||
$_['text_login'] = "Bejelentkezés";
|
||||
$_['text_login2'] = "bejelentkezés";
|
||||
|
@ -167,6 +167,7 @@ $_['text_ipaddr'] = "IP cím";
|
||||
|
||||
$_['text_language'] = "Nyelv";
|
||||
$_['text_last'] = "Utolsó";
|
||||
$_['text_last_activity'] = "Utolsó aktivitás";
|
||||
$_['text_latest_emails'] = "Legfrissebb emailek";
|
||||
$_['text_last_update'] = "Utolsó frissítés";
|
||||
$_['text_ldap'] = "LDAP";
|
||||
@ -178,6 +179,7 @@ $_['text_ldap_host'] = "LDAP kiszolgáló";
|
||||
$_['text_ldap_type'] = "LDAP típus";
|
||||
$_['text_load'] = "Betöltés";
|
||||
$_['text_loading'] = "töltődik";
|
||||
$_['text_logged_in'] = "Bejelentkezés";
|
||||
$_['text_logged_out'] = "Ön kijelentkezett";
|
||||
$_['text_login'] = "Bejelentkezés";
|
||||
$_['text_login2'] = "bejelentkezés";
|
||||
|
@ -163,6 +163,7 @@ $_['text_ipaddr'] = "Endereço IP";
|
||||
|
||||
$_['text_language'] = "Idioma";
|
||||
$_['text_last'] = "Último";
|
||||
$_['text_last_activity'] = "Last activity";
|
||||
$_['text_last_update'] = "Última atualização";
|
||||
$_['text_latest_emails'] = "Emails mais recentes";
|
||||
$_['text_ldap_auditor_member_dn'] = "Auditor member DN";
|
||||
@ -173,6 +174,7 @@ $_['text_ldap_host'] = "LDAP host";
|
||||
$_['text_ldap_type'] = "LDAP type";
|
||||
$_['text_load'] = "Carregar";
|
||||
$_['text_loading'] = "carregando";
|
||||
$_['text_logged_in'] = "Logged in";
|
||||
$_['text_logged_out'] = "Você não está logado";
|
||||
$_['text_login'] = "Login";
|
||||
$_['text_login2'] = "login";
|
||||
|
@ -111,6 +111,43 @@ class ModelSaasCustomer extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function online($username = '') {
|
||||
if($username == '') { return 0; }
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public function offline($username = '') {
|
||||
if($username == '') { return 0; }
|
||||
|
||||
$query = $this->db->query("DELETE FROM " . TABLE_ONLINE . " WHERE username=?", array($username));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public function count_online() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS num FROM " . TABLE_ONLINE);
|
||||
|
||||
return $query->row['num'];
|
||||
}
|
||||
|
||||
|
||||
public function get_online_users() {
|
||||
$query = $this->db->query("SELECT * FROM " . TABLE_ONLINE . " ORDER BY username ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -27,6 +27,13 @@
|
||||
<td><div class="progress <?php if($swapinfo < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $swapinfo; ?>%"></div> <?php print $swapinfo; ?>% / <?php print $totalswap; ?> MB</div></td>
|
||||
</tr>
|
||||
|
||||
<?php if(ENABLE_SAAS == 1) { ?>
|
||||
<tr>
|
||||
<th class="span4"><?php print $text_online_users; ?>:</th>
|
||||
<td class="span8"><a href="index.php?route=stat/online"><?php print $num_of_online_users; ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
|
||||
<h2><i class="icon-hdd icon-2x pull-left"></i> Storage</h2>
|
||||
|
30
webui/view/theme/default/templates/stat/online.tpl
Normal file
30
webui/view/theme/default/templates/stat/online.tpl
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
<h4><?php print $text_online_users; ?></h4>
|
||||
|
||||
<div class="listarea">
|
||||
|
||||
<?php if(isset($users)){ ?>
|
||||
|
||||
<table id="ss1" class="table table-striped table-condensed">
|
||||
<tr>
|
||||
<th class="domaincell"><?php print $text_username; ?></th>
|
||||
<th class="domaincell"><?php print $text_ipaddr; ?></th>
|
||||
<th class="domaincell"><?php print $text_logged_in; ?></th>
|
||||
<th class="domaincell"><?php print $text_last_activity; ?></th>
|
||||
</tr>
|
||||
|
||||
<?php foreach($users as $user) { ?>
|
||||
<tr>
|
||||
<td class="domaincell"><?php print $user['username']; ?></td>
|
||||
<td class="domaincell"><?php print $user['ipaddr']; ?></td>
|
||||
<td class="domaincell"><?php print date("Y.m.d. G:i:s", $user['ts']); ?></td>
|
||||
<td class="domaincell"><?php print date("Y.m.d. G:i:s", $user['last_activity']); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user