2009-12-07 14:25:30 +01:00
|
|
|
<?php
|
|
|
|
|
2011-03-22 23:11:57 +01:00
|
|
|
// Pandora FMS - http://pandorafms.com
|
2009-12-07 14:25:30 +01:00
|
|
|
// ==================================================
|
2020-11-27 13:52:35 +01:00
|
|
|
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
2011-03-22 23:11:57 +01:00
|
|
|
// Please see http://pandorafms.org for full contribution list
|
2009-12-07 14:25:30 +01:00
|
|
|
// This program is free software; you can redistribute it and/or
|
2011-03-23 Raul Mateos <raulofpandora@gmail.com>
* extensions/ssh_console.php, extensions/vnc_view.php,
extensions/update_manager.php, extensions/users_connected.php,
extensions/extension_uploader.php, extensions/insert_data.php,
extensions/module_groups.php, extensions/plugin_registration.php,
extensions/agent_modules.php, extensions/resource_registration.php,
extensions/resource_exportation.php, extensions/dbmanager.php,
extensions/pandora_logs.php, general/*.php, ajax.php,
operation/search_*.php, operation/menu.php, operation/extensions.php,
godmode/menu.php, godmode/extensions.php, godmode/admin_access_logs.php:
CReverted unwanted license changes.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4126 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-23 17:13:28 +01:00
|
|
|
// modify it under the terms of the GNU General Public License
|
2011-03-22 23:11:57 +01:00
|
|
|
// as published by the Free Software Foundation; version 2
|
2009-12-07 14:25:30 +01:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-03-22 23:11:57 +01:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-12-07 14:25:30 +01:00
|
|
|
// GNU General Public License for more details.
|
2019-01-30 16:18:44 +01:00
|
|
|
function users_extension_main()
|
|
|
|
{
|
|
|
|
users_extension_main_god(false);
|
2010-11-04 19:23:40 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
function users_extension_main_god($god=true)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
if (isset($config['id_user'])) {
|
|
|
|
if (!check_acl($config['id_user'], 0, 'UM')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($god) {
|
|
|
|
$image = 'images/gm_users.png';
|
|
|
|
} else {
|
2021-03-11 15:40:23 +01:00
|
|
|
$image = 'images/user.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Header
|
|
|
|
ui_print_page_header(__('Users connected'), $image, false, '', $god);
|
|
|
|
|
2021-01-26 13:35:46 +01:00
|
|
|
// Get groups user has permission
|
|
|
|
$group_um = users_get_groups_UM($config['id_user']);
|
|
|
|
// Is admin or has group permissions all.
|
|
|
|
$groups = implode(',', array_keys($group_um, 1));
|
|
|
|
|
|
|
|
// Get user conected last 5 minutes.Show only those on which the user has permission.
|
2019-01-30 16:18:44 +01:00
|
|
|
switch ($config['dbtype']) {
|
|
|
|
case 'mysql':
|
2021-01-26 13:35:46 +01:00
|
|
|
$sql = sprintf(
|
|
|
|
'SELECT tusuario.id_user, tusuario.last_connect
|
|
|
|
FROM tusuario
|
|
|
|
INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user
|
|
|
|
AND tusuario_perfil.id_grupo IN (%s)
|
|
|
|
WHERE last_connect > (UNIX_TIMESTAMP(NOW()) - '.SECONDS_5MINUTES.')
|
|
|
|
GROUP BY tusuario.id_user
|
|
|
|
ORDER BY last_connect DESC',
|
|
|
|
$groups
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'postgresql':
|
2021-01-26 13:35:46 +01:00
|
|
|
$sql = sprintf(
|
|
|
|
"SELECT tusuario.id_user, tusuario.last_connect
|
|
|
|
FROM tusuario
|
|
|
|
INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user
|
|
|
|
AND tusuario_perfil.id_grupo IN (%s)
|
|
|
|
WHERE last_connect > (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_5MINUTES.')
|
|
|
|
GROUP BY tusuario.id_user
|
|
|
|
ORDER BY last_connect DESC',
|
|
|
|
$groups
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'oracle':
|
2021-01-26 13:35:46 +01:00
|
|
|
$sql = sprintf(
|
|
|
|
"SELECT tusuario.id_user, tusuario.last_connect
|
|
|
|
FROM tusuario
|
|
|
|
INNER JOIN tusuario_perfil ON tusuario_perfil.id_usuario = tusuario.id_user
|
|
|
|
AND tusuario_perfil.id_grupo IN (%s)
|
|
|
|
WHERE last_connect > (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_5MINUTES.')
|
|
|
|
GROUP BY tusuario.id_user
|
|
|
|
ORDER BY last_connect DESC',
|
|
|
|
$groups
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows = db_get_all_rows_sql($sql);
|
|
|
|
|
|
|
|
if (empty($rows)) {
|
|
|
|
$rows = [];
|
|
|
|
echo "<div class='nf'>".__('No other users connected').'</div>';
|
|
|
|
} else {
|
2019-03-27 17:03:55 +01:00
|
|
|
$table->cellpadding = 0;
|
|
|
|
$table->cellspacing = 0;
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->width = '100%';
|
2019-03-27 17:03:55 +01:00
|
|
|
$table->class = 'info_table';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->size = [];
|
|
|
|
$table->data = [];
|
|
|
|
$table->head = [];
|
|
|
|
|
|
|
|
$table->head[0] = __('User');
|
|
|
|
$table->head[1] = __('IP');
|
2020-12-15 17:40:15 +01:00
|
|
|
$table->head[2] = __('Last login');
|
|
|
|
$table->head[3] = __('Last contact');
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
$rowPair = true;
|
|
|
|
$iterator = 0;
|
|
|
|
|
|
|
|
// Get data
|
|
|
|
foreach ($rows as $row) {
|
2020-12-15 17:40:15 +01:00
|
|
|
// Get data of user's last login.
|
2019-01-30 16:18:44 +01:00
|
|
|
switch ($config['dbtype']) {
|
|
|
|
case 'mysql':
|
|
|
|
case 'postgresql':
|
2020-12-15 17:40:15 +01:00
|
|
|
$last_login_data = db_get_row_sql(
|
2019-01-30 16:18:44 +01:00
|
|
|
sprintf(
|
2020-12-15 17:40:15 +01:00
|
|
|
"SELECT ip_origen, utimestamp
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
FROM tsesion
|
|
|
|
WHERE id_usuario = '%s'
|
2019-01-30 16:18:44 +01:00
|
|
|
AND descripcion = '".io_safe_input('Logged in')."'
|
|
|
|
ORDER BY fecha DESC",
|
|
|
|
$row['id_user']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'oracle':
|
2020-12-15 17:40:15 +01:00
|
|
|
$last_login_data = db_get_row_sql(
|
2019-01-30 16:18:44 +01:00
|
|
|
sprintf(
|
2020-12-15 17:40:15 +01:00
|
|
|
"SELECT ip_origen, utimestamp
|
2012-07-16 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_modules.php, extensions/users_connected.php,
extensions/agents_alerts.php,
operation/visual_console/render_view.php,
operation/visual_console/public_console.php,
operation/agentes/networkmap.groups.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/networkmap.topology.php, general/header.php,
godmode/db/db_refine.php, godmode/agentes/configurar_agente.php,
godmode/alerts/configure_alert_compound.php,
godmode/setup/setup_visuals.php, godmode/snmpconsole/snmp_alert.php,
godmode/modules/manage_network_components_form_wmi.php,
include/functions_config.php, include/functions_api.php,
include/functions_agents.php, include/functions_forecast.php:
cleaned source code style and change magic numbers for time
constants.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6773 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-16 11:24:04 +02:00
|
|
|
FROM tsesion
|
|
|
|
WHERE id_usuario = '%s'
|
2019-01-30 16:18:44 +01:00
|
|
|
AND to_char(descripcion) = '".io_safe_input('Logged in')."'
|
|
|
|
ORDER BY fecha DESC",
|
|
|
|
$row['id_user']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($rowPair) {
|
|
|
|
$table->rowclass[$iterator] = 'rowPair';
|
|
|
|
} else {
|
|
|
|
$table->rowclass[$iterator] = 'rowOdd';
|
|
|
|
}
|
|
|
|
|
|
|
|
$rowPair = !$rowPair;
|
|
|
|
$iterator++;
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
$data[0] = '<a href="index.php?sec=gusuarios&sec2=godmode/users/configure_user&id='.$row['id_user'].'">'.$row['id_user'].'</a>';
|
2020-12-15 17:40:15 +01:00
|
|
|
$data[1] = $last_login_data['ip_origin'];
|
|
|
|
$data[2] = date($config['date_format'], $last_login_data['utimestamp']);
|
|
|
|
$data[3] = date($config['date_format'], $row['last_connect']);
|
2019-01-30 16:18:44 +01:00
|
|
|
array_push($table->data, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
html_print_table($table);
|
|
|
|
}
|
2009-12-27 22:31:54 +01:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
extensions_add_operation_menu_option(__('Users connected'), 'workspace', 'users/icon.png', 'v1r1', '', 'UM');
|
2009-12-07 14:25:30 +01:00
|
|
|
|
2011-05-11 14:15:14 +02:00
|
|
|
extensions_add_godmode_function('users_extension_main_god');
|
|
|
|
extensions_add_main_function('users_extension_main');
|