pandorafms/pandora_console/general/logon_ok.php

303 lines
9.2 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once ("include/config.php");
// This solves problems in enterprise load
global $config;
check_login ();
2008-06-26 Esteban Sanchez <estebans@artica.es> * ajax.php: Sed id_user in config array. * godmode/menu.php, general/header.php, operation/menu.php: Replaced lang_label with lang_string(). * general/logon_ok.php: Reduced one indentation level. * godmode/agentes/agent_manager.php: Replaced lang_label with lang_string(). Use pandora functions. * include/functions_html.php, godmode/agentes/configurar_agente.php: Tab and blankspaces style correction. * godmode/reporting/map_builder.php: Complete rewritten to provide an intuitive way of build the maps. It's cool, useful and very simple. * godmode/reporting/reporting_builder.php: Deleted an output debug. * godmode/setup/setup.php: Rewritten to use pandora functions. Added a colorpicker for color settings. * include/config.php: Reset pandora password. We must solve things with this file... * include/functions.php: Check if input is an array on safe_input(). Use filename as id in array returned by list_files(). * include/functions_db.php: Renamed return_coordinate_* functions. Style correction. * include/javascript/jquery.js: Updated to 1.2.6. * include/javascript/jquery.ui.datepicker.js: Code minimized. * include/javascript/pandora.js: Style correction. * include/javascript/wz_jsgraphics.js: Added a class to the elements of a line, so it can be modified using javascript. * /include/styles/pandora.css: Added style to some tables dropdowns. Added new styles relative to visual map editor. * operation/reporting/reporting_viewer.php: Style correction. Added jQuery UI. * operation/visual_console/index.php: Use Pandora functions. * operation/visual_console/render_view.php: Drawing the map is now on functions_visual_map.php. Added a countdown if a refresh time is set. Use pandora functions. Style correction. * reporting/fgraph.php: Style correction. Use graphic_error() if there's no data on grafico_modulo_sparse(). * images/trash.png: Added to repository. Image used on trash area on visual map editor. * images/console/background/africa.jpg, images/console/background/asia.jpg, images/console/background/europe.jpg, images/console/background/north_america.jpg, images/console/background/oceania.jpg, images/console/background/shouth_america.jpg, images/console/background/world.jpg: Added to repository. Useful and cool map backgrounds. * include/functions_visual_map.php: Added to repository. Implements visual map functions like drawing the map. * include/javascript/jquery.colorpicker.js: Added to repository. Implements a color picker widget. * /include/javascript/jquery.countdown.js: Added to repository. Implements a countdown widget. * include/javascript/jquery.ui.core.js: Added to repository. jQuery UI core. * include/javascript/jquery.ui.draggable.js: Added to repository. jQuery draggable plugin. * include/javascript/jquery.ui.droppable.js: Added to repository. jQuery droppable plugin. * include/javascript/pandora_visual_console.js: Added to repository. Function useful to visual map interface. * include/languages/countdown_*.js: Added to repository. Countdown localization. * include/languages/date_es_la.js, include/languages/date_gl.js, include/languages/time_es_la.js, include/languages/time_gl.js: Added to repository. Missing localizations. * include/styles/color-picker.css: Added to repository. Colorpicker style sheet. * include/styles/countdown.css: Added to repository. Countdown style sheet. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@899 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-26 15:26:48 +02:00
/* Call all extensions login function */
//extensions_call_login_function ();
require_once ("include/functions_reporting.php");
require_once ("include/functions_tactical.php");
require_once ($config["homedir"] . '/include/functions_graph.php');
if (tags_has_user_acl_tags()) {
ui_print_tags_warning();
}
$user_strict = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
$data = array();
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
$data['monitor_unknown'] = (int) $all_data['_monitors_unknown_'];
$data['monitor_ok'] = (int) $all_data['_monitors_ok_'];
$data['monitor_warning'] = (int) $all_data['_monitors_warning_'];
$data['monitor_critical'] = (int) $all_data['_monitors_critical_'];
$data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_alerts'] = (int) $all_data['_monitors_alerts_'];
$data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['total_agents'] = (int) $all_data['_total_agents_'];
$data["monitor_checks"] = (int) $all_data['_monitor_checks_'];
if (!empty($all_data)) {
if ($data["monitor_not_normal"] > 0 && $data["monitor_checks"] > 0) {
$data['monitor_health'] = format_numeric (100 - ($data["monitor_not_normal"] / ($data["monitor_checks"] / 100)), 1);
}
else {
$data["monitor_health"] = 100;
}
if ($data["monitor_not_init"] > 0 && $data["monitor_checks"] > 0) {
$data["module_sanity"] = format_numeric (100 - ($data["monitor_not_init"] / ($data["monitor_checks"] / 100)), 1);
}
else {
$data["module_sanity"] = 100;
}
if (isset($data["alerts"])) {
if ($data["monitor_alerts_fired"] > 0 && $data["alerts"] > 0) {
$data["alert_level"] = format_numeric (100 - ($data["monitor_alerts_fired"] / ($data["alerts"] / 100)), 1);
}
else {
$data["alert_level"] = 100;
}
}
else {
$data["alert_level"] = 100;
$data["alerts"] = 0;
}
$data["monitor_bad"] = $data["monitor_critical"] + $data["monitor_warning"];
if ($data["monitor_bad"] > 0 && $data["monitor_checks"] > 0) {
$data["global_health"] = format_numeric (100 - ($data["monitor_bad"] / ($data["monitor_checks"] / 100)), 1);
}
else {
$data["global_health"] = 100;
}
$data["server_sanity"] = format_numeric (100 - $data["module_sanity"], 1);
}
2014-10-21 11:11:09 +02:00
?>
2015-03-31 09:28:06 +02:00
<table border="0" width="100%">
2014-10-21 11:11:09 +02:00
<tr>
2015-04-15 09:45:13 +02:00
<td width="25%" style="padding-right: 20px;" valign="top">
2014-10-21 11:11:09 +02:00
<?php
///////////////
// Overview Table
///////////////
$table = new stdClass();
2014-10-21 11:11:09 +02:00
$table->class = "databox";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->head = array ();
$table->data = array ();
2015-04-15 09:45:13 +02:00
$table->headstyle[0] = 'text-align:center;';
2014-10-21 11:11:09 +02:00
$table->width = "100%";
$table->head[0] = '<span>' . __('%s Overview', get_product_name()) . '</span>';
2015-06-08 13:13:09 +02:00
$table->head_colspan[0] = 4;
2014-10-21 11:11:09 +02:00
// Indicators
$tdata = array();
2015-03-31 09:28:06 +02:00
$stats = reporting_get_stats_indicators($data, 120, 10,false);
$status = '<table class="status_tactical">';
foreach ( $stats as $stat ) {
$status .= '<tr><td><b>' . $stat['title'] . '</b>' . '</td><td>' . $stat['graph'] . "</td></tr>" ;
}
$status .= '</table>';
$table->data[0][0] = $status;
2014-10-21 11:11:09 +02:00
$table->rowclass[] = '';
$table->data[] = $tdata;
// Alerts
$tdata = array();
$tdata[0] = reporting_get_stats_alerts($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Modules by status
$tdata = array();
2015-03-31 09:28:06 +02:00
$tdata[0] = reporting_get_stats_modules_status($data,180, 100);
2014-10-21 11:11:09 +02:00
$table->rowclass[] = '';
$table->data[] = $tdata;
// Total agents and modules
$tdata = array();
$tdata[0] = reporting_get_stats_agents_monitors($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Users
if (users_is_admin()) {
$tdata = array();
$tdata[0] = reporting_get_stats_users($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
}
2014-10-21 11:11:09 +02:00
html_print_table($table);
unset($table);
?>
</td>
2015-04-15 09:45:13 +02:00
<td width="75%" valign="top">
2014-10-21 11:11:09 +02:00
<?php
$options = array();
$options['id_user'] = $config['id_user'];
$options['modal'] = false;
$options['limit'] = 3;
$news = get_news($options);
if (!empty($news)) {
//////////////////NEWS BOARD/////////////////////////////
echo '<div id="news_board">';
2015-06-12 15:50:46 +02:00
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">';
echo '<tr><th style="text-align:center;"><span >' . __('News board') . '</span></th></tr>';
2014-10-21 11:11:09 +02:00
if ($config["prominent_time"] == "timestamp") {
$comparation_suffix = "";
}
else {
$comparation_suffix = __('ago');
}
foreach ($news as $article) {
$text = io_safe_output($article["text"]);
2015-06-12 15:50:46 +02:00
echo '<tr><th class="green_title">'.$article["subject"].'</th></tr>';
2014-10-21 11:11:09 +02:00
echo '<tr><td>' . __('by') . ' <b>' .
$article["author"] . '</b> <i>' . ui_print_timestamp ($article["timestamp"], true).'</i> ' . $comparation_suffix . '</td></tr>';
echo '<tr><td class="datos">';
echo nl2br($text);
echo '</td></tr>';
}
echo '</table>';
echo '</div>'; // News board
echo '<br><br>';
//////////////////END OF NEWS BOARD/////////////////////////////
}
//////////////////LAST ACTIVITY/////////////////////////////
// Show last activity from this user
echo '<div id="activity">';
$table = new stdClass();
$table->class = "databox data";
2014-10-21 11:11:09 +02:00
$table->width = '100%'; //Don't specify px
$table->data = array ();
$table->size = array ();
$table->size[0] = '5%';
$table->size[1] = '15%';
$table->size[2] = '15%';
$table->size[3] = '10%';
$table->size[4] = '25%';
2014-10-21 11:11:09 +02:00
$table->head = array ();
$table->head[0] = __('User');
$table->head[1] = __('Action');
$table->head[2] = __('Date');
$table->head[3] = __('Source IP');
$table->head[4] = __('Comments');
$table->title = '<span>' . __('This is your last activity performed on the %s console', get_product_name()) . '</span>';
2014-10-21 11:11:09 +02:00
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ("SELECT id_usuario,accion, ip_origen,descripcion,utimestamp
2014-10-21 11:11:09 +02:00
FROM tsesion
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - " . SECONDS_1WEEK . ")
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10", $config["id_user"]);
break;
case "postgresql":
$sql = sprintf ("SELECT \"id_usuario\", accion, \"ip_origen\", descripcion, utimestamp
2014-10-21 11:11:09 +02:00
FROM tsesion
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . ")
AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10", $config["id_user"]);
break;
case "oracle":
$sql = sprintf ("SELECT id_usuario, accion, ip_origen, descripcion, utimestamp
2014-10-21 11:11:09 +02:00
FROM tsesion
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - " . SECONDS_1WEEK . ")
AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC", $config["id_user"]);
break;
}
$sessions = db_get_all_rows_sql ($sql);
if ($sessions === false)
2015-06-08 13:13:09 +02:00
$sessions = array ();
2014-10-21 11:11:09 +02:00
foreach ($sessions as $session) {
$data = array ();
switch ($config["dbtype"]) {
case "mysql":
case "oracle":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
case "postgresql":
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
break;
}
$data[0] = '<strong>' . $session_id_usuario . '</strong>';
$data[1] = ui_print_session_action_icon ($session['accion'], true) . ' ' . $session['accion'];
$data[2] = ui_print_help_tip(date($config["date_format"], $session['utimestamp']), true)
. human_time_comparation($session['utimestamp'], 'tiny');
$data[3] = $session_ip_origen;
$description = str_replace(array(',', ', '), ', ', $session['descripcion']);
if(strlen($description)>100){
$data[4] = '<div >' . io_safe_output(substr($description, 0, 150).'...') . '</div>';
}
else{
$data[4] = '<div >' . io_safe_output($description) . '</div>';
}
2016-06-20 10:34:20 +02:00
2014-10-21 11:11:09 +02:00
array_push ($table->data, $data);
}
echo "<div style='width:100%; overflow-x:auto;'>";
html_print_table ($table);
unset($table);
echo "</div>";
echo "</div>"; // activity
//////////////////END OF LAST ACTIVIYY/////////////////////////////
?>
</td>
</tr>
</table>