diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0c4bf2746b..71b6135a72 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2012-07-13 Miguel de Dios + + * godmode/snmpconsole/snmp_alert.php, + godmode/servers/manage_recontask_form.php, + include/functions_filemanager.php, include/functions_networkmap.php, + include/constants.php, include/graphs/functions_gd.php, + include/graphs/functions_pchart.php, + operation/events/events_list.php, operation/agentes/graphs.php, + operation/agentes/networkmap.php, operation/agentes/stat_win.php, + operation/agentes/estado_ultimopaquete.php, + operation/agentes/networkmap.topology.php, + operation/agentes/networkmap.groups.php, + operation/gis_maps/render_view.php: cleaned source code style and + change magic numbers for time constants. + 2012-07-13 Sergio Martin * pandoradb_data.sql: Fixed missed column name change diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index 3a4d5400f2..3f2b977692 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -164,7 +164,7 @@ $fields['recon_script'] = __("Custom script"); $table->data[2][0] = "".__('Mode').""; $table->data[2][1] = html_print_select ($fields, "mode", $mode, '', '', 0, true); - + // Network $table->data[3][0] = "".__('Network'); $table->data[3][1] = html_print_input_text ('network', $network, '', 25, 0, true); @@ -172,15 +172,15 @@ $table->data[3][1] = html_print_input_text ('network', $network, '', 25, 0, true // Interval $values = array (); $values[0] = __('Manual'); -$values[3600] = __('%d hour', 1); -$values[7200] = __('%d hours', 2); -$values[21600] = __('%d hours', 6); -$values[43200] = __('%d hours', 12); -$values[86400] = __('%d day', 1); -$values[432000] = __('%d days', 5); -$values[604800] = __('%d week', 1); -$values[1209600] = __('%d weeks', 2); -$values[2592000] = __('%d month', 1); +$values[SECONDS_1HOUR] = __('%d hour', 1); +$values[SECONDS_2HOUR] = __('%d hours', 2); +$values[SECONDS_6HOURS] = __('%d hours', 6); +$values[SECONDS_12HOURS] = __('%d hours', 12); +$values[SECONDS_1DAY] = __('%d day', 1); +$values[SECONDS_5DAY] = __('%d days', 5); +$values[SECONDS_1WEEK] = __('%d week', 1); +$values[SECONDS_2WEEK] = __('%d weeks', 2); +$values[SECONDS_1MONTH] = __('%d month', 1); $table->data[4][0] = "".__('Interval'); $table->data[4][1] = html_print_select ($values, "interval", $interval, '', '', '', true); @@ -285,25 +285,25 @@ echo ""; /* */ - + \ No newline at end of file diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index d024b8b23e..6d129d2119 100644 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -27,11 +27,16 @@ if (! check_acl ($config['id_user'], 0, "LW")) { // ============= if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") { - ui_print_page_header (__('SNMP Console')." » ".__('Create alert'), "images/computer_error.png", false, "snmp_alert", true); -} else if (isset ($_GET["update_alert"]) && $_GET["update_alert"] != "-1") { - ui_print_page_header (__('SNMP Console')." » ".__('Update alert'), "images/computer_error.png", false, "snmp_alert", true); -} else if (isset ($_GET["submit"])) { - ui_print_page_header (__('SNMP Console')." » ".__('Update alert'), "images/computer_error.png", false, "snmp_alert", true); + ui_print_page_header (__('SNMP Console')." » ".__('Create alert'), + "images/computer_error.png", false, "snmp_alert", true); +} +else if (isset ($_GET["update_alert"]) && $_GET["update_alert"] != "-1") { + ui_print_page_header (__('SNMP Console')." » ".__('Update alert'), + "images/computer_error.png", false, "snmp_alert", true); +} +else if (isset ($_GET["submit"])) { + ui_print_page_header (__('SNMP Console')." » ".__('Update alert'), + "images/computer_error.png", false, "snmp_alert", true); $id_as = (int) get_parameter_get ("submit", -1); $source_ip = (string) get_parameter_post ("source_ip"); $alert_type = (int) get_parameter_post ("alert_type"); //Event, e-mail @@ -81,7 +86,7 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") { '_snmp_f6_' => $custom_oid_data_6, 'trap_type' => $trap_type, 'single_value' => $single_value); - + $result = db_process_sql_insert('talert_snmp', $values); if (!$result) { @@ -93,28 +98,30 @@ if (isset ($_GET["update_alert"]) && $_GET["update_alert"] == "-1") { echo '

'.__('Successfully created').'

'; } - } else { + } + else { $sql = sprintf ("UPDATE talert_snmp SET - priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s', - oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', - _snmp_f5_ = '%s', _snmp_f6_ = '%s', trap_type = %d, single_value = '%s' - WHERE id_as = %d", - $priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value, - $oid, $time_threshold, $max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2, $custom_oid_data_3, - $custom_oid_data_4, $custom_oid_data_5, $custom_oid_data_6, $trap_type, $single_value, $id_as); + priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', description = '%s', agent = '%s', custom_oid = '%s', + oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', + _snmp_f5_ = '%s', _snmp_f6_ = '%s', trap_type = %d, single_value = '%s' + WHERE id_as = %d", + $priority, $alert_type, $al_field1, $al_field2, $al_field3, $description, $source_ip, $custom_value, + $oid, $time_threshold, $max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2, $custom_oid_data_3, + $custom_oid_data_4, $custom_oid_data_5, $custom_oid_data_6, $trap_type, $single_value, $id_as); $result = db_process_sql ($sql); - + if (!$result) { db_pandora_audit("SNMP management", "Fail try to update snmp alert #$id_as"); echo '

'.__('There was a problem updating the alert').'

'; - } else { + } + else { db_pandora_audit("SNMP management", "Update snmp alert #$id_as"); echo '

'.__('Successfully updated').'

'; } } - -} else { +} +else { ui_print_page_header (__('SNMP Console')." » ".__('Alert overview'), "images/computer_error.png", false, "snmp_alert", true); } @@ -144,7 +151,8 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { $custom_oid_data_6 = $alert["_snmp_f6_"]; $trap_type = $alert["trap_type"]; $single_value = $alert["single_value"]; -} elseif (isset ($_GET["update_alert"])) { +} +elseif (isset ($_GET["update_alert"])) { // Variable init $id_as = -1; $source_ip = ""; @@ -191,114 +199,114 @@ if (isset ($_GET["delete_alert"])) { // Delete alert if (isset ($_GET["update_alert"])) { //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated echo '
'; - + /* SNMP alert filters */ - + echo ''; - + // Description echo ''; - - - + + + //echo ''; - + // OID echo ''; - + // Custom echo ''; - + // SNMP Agent echo ''; - + // Trap type echo ''; - + // Single value echo ''; - + // Custom OID/Data #1 echo ''; + echo ui_print_help_icon ("field_match_snmp", true); + + echo ''; // Custom OID/Data #2 echo ''; // Custom OID/Data #3 echo ''; // Custom OID/Data #4 echo ''; // Custom OID/Data #5 echo ''; - + //echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + // Custom OID/Data #6 echo ''; //Button //echo '
'.__('Description').''; html_print_input_text ("description", $description, '', 60); echo '
' . __('Alert filters') . ui_print_help_icon("snmp_alert_filters", true) . '
'.__('OID').''; html_print_input_text ("oid", $oid, '', 50, 255); echo '
'.__('Custom Value/OID'); - echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_textarea ("custom_value", $custom_value, 2, $custom_value, 'style="width:400px;"'); - + echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + html_print_textarea ("custom_value", $custom_value, 2, $custom_value, 'style="width:400px;"'); + echo '
'.__('SNMP Agent').' (IP)'; html_print_input_text ("source_ip", $source_ip, '', 20); echo '
'.__('Trap type').''; $trap_types = array(-1 => __('None'), 0 => __('Cold start (0)'), 1 => __('Warm start (1)'), 2 => __('Link down (2)'), 3 => __('Link up (3)'), 4 => __('Authentication failure (4)'), 5 => __('Other')); echo html_print_select ($trap_types, 'trap_type', $trap_type, '', '', '', false, false, false); echo '
'.__('Single value').''; html_print_input_text ("single_value", $single_value, '', 20); echo '
'.__('Custom OID/Data #1'); - echo ui_print_help_icon ("field_match_snmp", true); - - echo ''; - html_print_input_text ("custom_oid_data_1", $custom_oid_data_1, '', 60); - echo '
'; + html_print_input_text ("custom_oid_data_1", $custom_oid_data_1, '', 60); + echo '
'.__('Custom OID/Data #2'); - //echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_input_text ("custom_oid_data_2", $custom_oid_data_2, '', 60); + //echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + html_print_input_text ("custom_oid_data_2", $custom_oid_data_2, '', 60); echo '
'.__('Custom OID/Data #3'); - //echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_input_text ("custom_oid_data_3", $custom_oid_data_3, '', 60); + //echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + html_print_input_text ("custom_oid_data_3", $custom_oid_data_3, '', 60); echo '
'.__('Custom OID/Data #4'); - //echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_input_text ("custom_oid_data_4", $custom_oid_data_4, '', 60); + //echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + html_print_input_text ("custom_oid_data_4", $custom_oid_data_4, '', 60); echo '
'.__('Custom OID/Data #5'); - //echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_input_text ("custom_oid_data_5", $custom_oid_data_5, '', 60); - echo '
'; + html_print_input_text ("custom_oid_data_5", $custom_oid_data_5, '', 60); + echo '
'.__('Custom OID/Data #6'); - //echo ui_print_help_icon ("snmp_alert_custom", true); - - echo ''; - html_print_input_text ("custom_oid_data_6", $custom_oid_data_6, '', 60); + //echo ui_print_help_icon ("snmp_alert_custom", true); + + echo ''; + html_print_input_text ("custom_oid_data_6", $custom_oid_data_6, '', 60); echo '
'; - + // End table //echo "
"; // Alert configuration - + //echo ''; -// echo ''; + //echo ''; // Alert fields echo ''; @@ -317,29 +325,29 @@ if (isset ($_GET["update_alert"])) { echo ''; - + // Time Threshold echo ''; - + // Priority echo ''; + echo ''; + + echo '
' . __('Alert configuration') . ui_print_help_icon("snmp_alert_configuration", true) . '
' . __('Alert configuration') . ui_print_help_icon("snmp_alert_configuration", true) . '
'.__('Field #1 (Alias, name)'); - echo ui_print_help_icon ("snmp_alert_field1", true); - echo ''; + echo ui_print_help_icon ("snmp_alert_field1", true); + echo ''; html_print_input_text ("al_field1", $al_field1, '', 60); echo '
'.__('Max. number of alerts').''; html_print_input_text ("max_alerts", $max_alerts, '', 3); echo '
'.__('Time threshold').''; $fields = array (); $fields[$time_threshold] = human_time_description_raw ($time_threshold); - $fields[300] = human_time_description_raw (300); - $fields[600] = human_time_description_raw (600); - $fields[900] = human_time_description_raw (900); - $fields[1800] = human_time_description_raw (1800); - $fields[3600] = human_time_description_raw (3600); - $fields[7200] = human_time_description_raw (7200); - $fields[18000] = human_time_description_raw (18000); - $fields[43200] = human_time_description_raw (43200); - $fields[86400] = human_time_description_raw (86400); - $fields[604800] = human_time_description_raw (604800); + $fields[SECONDS_5MINUTES] = human_time_description_raw (SECONDS_5MINUTES); + $fields[SECONDS_10MINUTES] = human_time_description_raw (SECONDS_10MINUTES); + $fields[SECONDS_15MINUTES] = human_time_description_raw (SECONDS_15MINUTES); + $fields[SECONDS_30MINUTES] = human_time_description_raw (SECONDS_30MINUTES); + $fields[SECONDS_1HOUR] = human_time_description_raw (SECONDS_1HOUR); + $fields[SECONDS_2HOUR] = human_time_description_raw (SECONDS_2HOUR); + $fields[SECONDS_5HOUR] = human_time_description_raw (SECONDS_5HOUR); + $fields[SECONDS_12HOURS] = human_time_description_raw (SECONDS_12HOURS); + $fields[SECONDS_1DAY] = human_time_description_raw (SECONDS_1DAY); + $fields[SECONDS_1WEEK] = human_time_description_raw (SECONDS_1WEEK); $fields[-1] = __('Other value'); html_print_select ($fields, "time_threshold", $time_threshold, '', '', '0', false, false, false, '" style="margin-right:60px'); echo '
'.__('Priority').''; echo html_print_select (get_priorities (), "priority", $priority, '', '', '0', false, false, false); @@ -353,7 +361,7 @@ if (isset ($_GET["update_alert"])) { if ($result === false) { $result = array (); } - + foreach ($result as $row) { $fields[$row["id"]] = $row["name"]; } @@ -369,21 +377,22 @@ if (isset ($_GET["update_alert"])) { "alert_type", $alert_type, '', '', 0, false, false, false); break; } - echo '
'; - echo ''; - echo ""; echo '
'; if ($id_as > 0) { html_print_submit_button (__('Update'), "submit", false, 'class="sub upd"', false); - } else { + } + else { html_print_submit_button (__('Create'), "submit", false, 'class="sub wand"', false); } echo '
'; echo ""; -} else { - +} +else { require_once ('include/functions_alerts.php'); //Overview @@ -401,13 +410,13 @@ if (isset ($_GET["update_alert"])) { $table->width = "98%"; $table->class= "databox"; $table->align = array (); - + $table->head[0] = __('Alert action'); $table->head[1] = __('SNMP Agent'); $table->size[1] = "90px"; $table->align[1] = 'center'; - + $table->head[2] = __('OID'); $table->align[2] = 'center'; @@ -421,41 +430,42 @@ if (isset ($_GET["update_alert"])) { $table->head[6] = __('Last fired'); $table->align[6] = 'center'; - + $table->head[7] = __('Action'); $table->size[7] = "50px"; $table->align[7] = 'center'; - + foreach ($result as $row) { $data = array (); $data[0] = '' . alerts_get_alert_action_name ($row["id_alert"]) . ''; - + $data[1] = __('SNMP Agent'); - $data[1] = $row["agent"]; + $data[1] = $row["agent"]; $data[2] = __('OID'); $data[2] = $row["oid"]; $data[3] = __('Custom Value/OID'); $data[3] = $row["custom_oid"]; - + $data[4] = $row["description"]; $data[5] = $row["times_fired"]; - + if (($row["last_fired"] != "1970-01-01 00:00:00") and ($row["last_fired"] != "01-01-1970 00:00:00")) { $data[6] = ui_print_timestamp($row["last_fired"], true); - } else { + } + else { $data[6] = __('Never'); } $data[7] = '' . - html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . - '  ' . - html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; + html_print_image("images/config.png", true, array("border" => '0', "alt" => __('Update'))) . '' . + '  ' . + html_print_image("images/cross.png", true, array("border" => '0', "alt" => __('Delete'))) . ''; $idx = count ($table->data); //The current index of the table is 1 less than the count of table data so we count before adding to table->data array_push ($table->data, $data); $table->rowclass[$idx] = get_priority_class ($row["priority"]); } - + if (!empty ($table->data)) { html_print_table ($table); } @@ -466,7 +476,7 @@ if (isset ($_GET["update_alert"])) { echo ''; html_print_submit_button (__('Create'), "add_alert", false, 'class="sub next"'); echo "
"; - + echo '
'; echo '

'.__('Legend').'

'; foreach (get_priorities () as $num => $name) { diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 1a387f24b2..5e59436777 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -53,6 +53,7 @@ define ('ERR_CONNECTION', -80000); /* Seconds in a time unit constants */ define('SECONDS_1MINUTE', 60); +define('SECONDS_2MINUTES', 120); define('SECONDS_5MINUTES', 300); define('SECONDS_10MINUTES', 600); define('SECONDS_15MINUTES', 900); diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 0faa66e0fe..e74ac37f2c 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -436,21 +436,21 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $ $("#main_buttons").css("display", "none"); $("#create_folder").css("display", ""); } - + function show_upload_file() { $("#table1-1").css('display', ''); $("#main_buttons").css("display", "none"); $("#upload_file").css("display", ""); } - + function show_create_text_file() { $("#table1-1").css('display', ''); $("#main_buttons").css("display", "none"); $("#create_text_file").css("display", ""); } - + function show_main_buttons_folder() { //$("#main_buttons").css("display", ""); $("#table1-1").css('display', 'none'); @@ -609,13 +609,13 @@ function filemanager_file_explorer($real_directory, $relative_directory, $url, $ $data[4] .= html_print_input_hidden ('filename', $fileinfo['realpath'], true); $data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'] . $config['dbpass']), true); $data[4] .= html_print_input_hidden ('delete_file', 1, true); - + $relative_dir = str_replace($config['homedir'], '', dirname($fileinfo['realpath'])); if ($relative_dir[0] == '/') { $relative_dir = substr($relative_dir, 1); } $hash2 = md5($relative_dir . $config['dbpass']); - + $data[4] .= html_print_input_hidden ('directory', $relative_dir, true); $data[4] .= html_print_input_hidden ('hash2', $hash2, true); $data[4] .= ''; @@ -672,7 +672,8 @@ function filemanager_box_upload_file_complex($real_directory, $relative_director echo '

'; echo __('Please check that current directory has write rights for HTTP server'); echo '

'; - } else { + } + else { $table->data[1][0] = __('Upload') . ui_print_help_tip (__("The zip upload in this dir, easy to upload multiple files."), true); $table->data[1][1] = html_print_input_file ('file', true, false); $table->data[1][2] = html_print_radio_button('zip_or_file', 'zip', __('Multiple files zipped'), false, true); @@ -709,7 +710,8 @@ function filemanager_box_upload_file_explorer($real_directory, $relative_directo echo '

'; echo __('Please check that current directory has write rights for HTTP server'); echo '

'; - } else { + } + else { $table->data[1][0] = __('Upload file'); $table->data[1][1] = html_print_input_file ('file', true, false); $table->data[1][2] = html_print_submit_button (__('Go'), 'go', false, @@ -744,7 +746,8 @@ function filemanager_box_upload_zip_explorer($real_directory, $relative_director echo '

'; echo __('Please check that current directory has write rights for HTTP server'); echo '

'; - } else { + } + else { $table->data[1][0] = __('Upload zip file: ') . ui_print_help_tip (__("The zip upload in this dir, easy to upload multiple files."), true); $table->data[1][1] = html_print_input_file ('file', true, false); $table->data[1][2] = html_print_submit_button (__('Go'), 'go', false, @@ -779,7 +782,8 @@ function filemanager_box_create_text_explorer($real_directory, $relative_directo echo '

'; echo __('Please check that current directory has write rights for HTTP server'); echo '

'; - } else { + } + else { $table->data[1][0] = __('Create text file: '); $table->data[1][1] = html_print_input_text('name_file', '', '', 30, 50, true); $table->data[1][2] = html_print_submit_button (__('Create'), 'create', false, @@ -854,7 +858,7 @@ function filemanager_is_writable_dir ($dirpath, $force = false) { if (filemanager_is_writable_dir (realpath ($dirpath.'/..'))) return true; else if (! $force) - return is_writable ($dirpath); + return is_writable ($dirpath); return (is_writable ($dirpath) || @chmod ($dirpath, 0755)); } @@ -891,11 +895,14 @@ function filemanager_get_file_info ($filepath) { $info['mime'] = MIME_DIR; $info['is_dir'] = true; $info['size'] = 0; - } else if (strpos ($info['mime_extend'], 'image') !== false) { + } + else if (strpos ($info['mime_extend'], 'image') !== false) { $info['mime'] = MIME_IMAGE; - } else if (in_array ($info['mime_extend'], $zip_mimes)) { + } + else if (in_array ($info['mime_extend'], $zip_mimes)) { $info['mime'] = MIME_ZIP; - } else if (strpos ($info['mime_extend'], 'text') !== false) { + } + else if (strpos ($info['mime_extend'], 'text') !== false) { $info['mime'] = MIME_TEXT; } @@ -921,7 +928,8 @@ function filemanager_list_dir ($dirpath) { $info = filemanager_get_file_info ($dirpath.'/'.$file); if ($info['is_dir']) { $dirs[$file] = $info; - } else { + } + else { $files[$file] = $info; } } diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 0e6f60512f..aeccbc842b 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -478,7 +478,7 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu // Returns a module node definition function networkmap_create_module_node ($module, $simple = 0, $font_size = 10) { $status = modules_get_agentmodule_status($module['id_agente_modulo']); - + // Set node status switch($status) { case 0: @@ -497,7 +497,7 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10) { $status_color = '#BBBBBB'; // Unknown monitor break; } - + if ($simple == 0){ $node = $module['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.30, height=0.30, label=< @@ -524,7 +524,7 @@ function networkmap_create_pandora_node ($name, $font_size = 10, $simple = 0, $s $node = '0 [ color="#364D1F", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.8, height=0.6, label=<'.$label.'>, shape="ellipse", tooltip="ajax.php?page=include/ajax/networkmap.ajax&action=get_networkmap_summary&stats='.$stats_json.'", URL="index.php?sec=estado&sec2=operation/agentes/group_view" ];'; - + return $node; } diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 83874a2e5f..bd3c32aa0b 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -253,11 +253,11 @@ function gd_progress_bubble ($width, $height, $progress, $title, $font, $out_of_ // *************************************************************************** function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode = 1, $fontsize=10, $value_text = '', $colorRGB = '') { - if($out_of_lim_str === false) { + if ($out_of_lim_str === false) { $out_of_lim_str = "Out of limits"; } - if($out_of_lim_image === false) { + if ($out_of_lim_image === false) { $out_of_lim_image = "images_graphs/outlimits.png"; } @@ -273,7 +273,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim function drawRating($rating, $width, $height, $font, $out_of_lim_str, $mode, $fontsize, $value_text, $color) { global $config; global $REMOTE_ADDR; - + // Round corners defined in global setup if ($config["round_corner"] != 0) { $radius = ($height > 18) ? 8 : 0; @@ -281,7 +281,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim else { $radius = 0; } - + if ($width == 0) { $width = 150; } @@ -352,7 +352,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim $x2 = $ratingbar30; } ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$blue); - } + } if ($rating > 50) if ($rating > 100) @@ -397,8 +397,6 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim imagePNG($image); imagedestroy($image); - - } function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) @@ -406,7 +404,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim // Draw rectangle without corners ImageFilledRectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color); ImageFilledRectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color); - + // Draw circled corners ImageFilledEllipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color); ImageFilledEllipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color); @@ -427,7 +425,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim $imgPng = imageCreateFromPng($out_of_lim_image); imageAlphaBlending($imgPng, true); imageSaveAlpha($imgPng, true); - imagePng($imgPng); + imagePng($imgPng); } else drawRating($progress, $width, $height, $font, $out_of_lim_str, $mode, 6, $value_text, $color); diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index 13f4ca21e2..548db8e80c 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -847,7 +847,7 @@ function pch_threshold_graph ($graph_type, $index, $data, $width, $height, $font $settings = array("Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE); $myPicture->drawSplineChart($settings); $myPicture->setShadow(FALSE); - + if($show_legend) { /* Write the chart legend */ $myPicture->drawLegend(643,210,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index c43ff6bbc3..fe73c81e3d 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -461,15 +461,19 @@ foreach ($modules as $module) { echo ""; } - + echo "
' . ui_print_moduletype_icon ($module['id_tipo_modulo'], true, true, false). '
"; $graph_label = io_safe_output($module["nombre"]); - echo "" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . " "; + echo "" . html_print_image('images/grafica_m.png' , true, array("border" => '0', "alt" => '')) . " "; - $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=604800&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=6000','week_".$win_handle."')"; + $link ="winopeng(" . + "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1WEEK . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=6000','week_".$win_handle."')"; echo '' . html_print_image("images/grafica_w.png", true, array("border" => '0', "alt" => '')) . ' '; - $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=600','day_".$win_handle."')"; + $link ="winopeng(" . + "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1DAY . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=600','day_".$win_handle."')"; echo '' . html_print_image("images/grafica_d.png", true, array("border" => '0', "alt" => '')) . ' '; - - $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=3600&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=60','hour_".$win_handle."')"; + + $link ="winopeng(" . + "'operation/agentes/stat_win.php?type=$graph_type&period=" . SECONDS_1HOUR . "&id=".$module["id_agente_modulo"]."&label=".base64_encode($graph_label)."&refresh=60','hour_".$win_handle."')"; echo '' . html_print_image("images/grafica_h.png", true, array("border" => '0', "alt" => "")) . ''; } @@ -484,7 +488,7 @@ foreach ($modules as $module) { else { echo ""; if ($module["utimestamp"] != 0){ $seconds = get_system_time () - $module["utimestamp"]; diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index e523ad6d5a..611ed7418f 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -27,10 +27,9 @@ if (! check_acl ($config['id_user'], $id_grupo, "AR")) { require_once ($config["homedir"] . '/include/functions_graph.php'); -$period = get_parameter ( "period", 3600); $draw_alerts = get_parameter("draw_alerts", 0); $avg_only = get_parameter ("avg_only", 1); -$period = get_parameter ("period", 3600); +$period = get_parameter ("period", SECONDS_1HOUR); $width = get_parameter ("width", 555); $height = get_parameter ("height", 245); $label = get_parameter ("label", ""); diff --git a/pandora_console/operation/agentes/networkmap.groups.php b/pandora_console/operation/agentes/networkmap.groups.php index a907659389..3d6ad06533 100644 --- a/pandora_console/operation/agentes/networkmap.groups.php +++ b/pandora_console/operation/agentes/networkmap.groups.php @@ -61,11 +61,13 @@ $filename_dot .= "_".$id_networkmap.".dot"; if ($regen != 1 && file_exists ($filename_img) && filemtime ($filename_img) > get_system_time () - 300) { $result = true; -} else { +} +else { $fh = @fopen ($filename_dot, 'w'); if ($fh === false) { $result = false; - } else { + } + else { fwrite ($fh, $graph); $cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; $result = system ($cmd); @@ -81,18 +83,20 @@ if ($result !== false) { echo "
Apparently something went wrong reading the output.
"; echo "
Is ".$config["attachment_store"]." readable by the webserver process?"; echo "

Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?"; + return; } html_print_image ($filename_img, false, array ("alt" => __('Network map'), "usemap" => "#networkmap")); require ($filename_map); -} else { +} +else { ui_print_error_message (__('Map could not be generated')); echo $result; echo "
Apparently something went wrong executing the command or writing the output.
"; echo "
Is ".$filter." (usually part of GraphViz) and echo installed and able to be executed by the webserver process?"; echo "

Is your webserver restricted from executing command line tools through the system() call (PHP Safe Mode or SELinux)"; echo "

Is ".$config["attachment_store"]." writeable by the webserver process? To change this do the following (POSIX-based systems): chown <apache user> ".$config["attachment_store"]; + return; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 6f78716b47..ac8b606f15 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -68,7 +68,7 @@ if ($add_networkmap) { $name = $activeTab; $check = db_get_value('name', 'tnetwork_map', 'name', $name); $sql = db_get_value_filter('COUNT(name)', 'tnetwork_map', array('name' => "%$name")); - + if ($check) { $id_networkmap = networkmap_create_networkmap("($sql) ".$name, $activeTab, $layout, $nooverlap, $simple, $regen, $font_size, $group, $module_group, $depth, $modwithalerts, $hidepolicymodules, $zoom, $ranksep, $center); $message = ui_print_result_message ($id_networkmap, @@ -106,11 +106,11 @@ if($save_networkmap || $update_networkmap) { if($save_networkmap) { if (!$check || $subcheck == $name) { $result = networkmap_update_networkmap($id_networkmap, array('name' => $name, 'type' => $activeTab, 'layout' => $layout, - 'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size, - 'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts, - 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'center' => $center, - 'show_snmp_modules' => (int)$show_snmp_modules)); - + 'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size, + 'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts, + 'hide_policy_modules' => $hidepolicymodules, 'zoom' => $zoom, 'distance_nodes' => $ranksep, 'center' => $center, + 'show_snmp_modules' => (int)$show_snmp_modules)); + $message = ui_print_result_message ($result, __('Network map saved successfully'), __('Could not save network map'), '', true); @@ -169,26 +169,26 @@ if($recenter_networkmap) { if ($pure == 1) { $buttons['screen'] = array('active' => false, 'text' => '' . - html_print_image("images/normalscreen.png", true, array ('title' => __('Normal screen'))) .''); - -} else { + html_print_image("images/normalscreen.png", true, array ('title' => __('Normal screen'))) .''); +} +else { $buttons['screen'] = array('active' => false, 'text' => '' . - html_print_image("images/fullscreen.png", true, array ('title' => __('Full screen'))) .''); + html_print_image("images/fullscreen.png", true, array ('title' => __('Full screen'))) .''); } -if($config['enterprise_installed']) { +if ($config['enterprise_installed']) { $buttons['policies'] = array('active' => $activeTab == 'policies', 'text' => '' . - html_print_image("images/policies.png", true, array ("title" => __('Policies view'))) .''); + html_print_image("images/policies.png", true, array ("title" => __('Policies view'))) .''); } $buttons['groups'] = array('active' => $activeTab == 'groups', 'text' => '' . - html_print_image("images/group.png", true, array ("title" => __('Groups view'))) .''); + html_print_image("images/group.png", true, array ("title" => __('Groups view'))) .''); $buttons['topology'] = array('active' => $activeTab == 'topology', 'text' => '' . - html_print_image("images/recon.png", true, array ("title" => __('Topology view'))) .''); + html_print_image("images/recon.png", true, array ("title" => __('Topology view'))) .''); $buttons['separator'] = array('separator' => ''); @@ -204,22 +204,22 @@ $buttons['combolist'] = $combolist; $buttons['addmap'] = array('active' => $activeTab == false, 'text' => '' . - html_print_image("images/add.png", true, array ("title" => __('Add map'))) .''); + html_print_image("images/add.png", true, array ("title" => __('Add map'))) .''); if (!$nomaps && $id_networkmap != 0) { $buttons['deletemap'] = array('active' => $activeTab == false, 'text' => '' . - html_print_image("images/cross.png", true, array ("title" => __('Delete map'))) .''); + html_print_image("images/cross.png", true, array ("title" => __('Delete map'))) .''); $buttons['savemap'] = array('active' => $activeTab == false, 'text' => '' . - html_print_image("images/file.png", true, array ("title" => __('Save map'))) .''); + &tab='.$activeTab.'&save_networkmap=1&name='.$name.'&group='.$group.' + &layout='.$layout.'&nooverlap='.$nooverlap.'&simple='.$simple.'&regen='.$regen.' + &zoom='.$zoom.'&ranksep='.$ranksep.'&fontsize='.$font_size.'&depth='.$depth.' + &modwithalerts='.$modwithalerts.'&hidepolicymodules='.$hidepolicymodules.' + &module_group='.$module_group.'&pure='.$pure.'&hidden_options='.(int)$hidden_options.' + &show_snmp_modules='.(int)$show_snmp_modules.'">' . + html_print_image("images/file.png", true, array ("title" => __('Save map'))) .''); } $title = ''; diff --git a/pandora_console/operation/agentes/networkmap.topology.php b/pandora_console/operation/agentes/networkmap.topology.php index b5e5010833..7d4680337e 100644 --- a/pandora_console/operation/agentes/networkmap.topology.php +++ b/pandora_console/operation/agentes/networkmap.topology.php @@ -66,7 +66,8 @@ else { $fh = @fopen ($filename_dot, 'w'); if ($fh === false) { $result = false; - } else { + } + else { fwrite ($fh, $graph); $cmd = "$filter -Tcmapx -o".$filename_map." -Tpng -o".$filename_img." ".$filename_dot; $result = system ($cmd); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index df5fe08f0e..5421dd1cfb 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -167,7 +167,7 @@ if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) { exit; } -$period = get_parameter ( "period", 3600); +$period = get_parameter ( "period", SECONDS_1HOUR); $draw_alerts = get_parameter("draw_alerts", 0); $avg_only = get_parameter ("avg_only", 1); $show_other = (bool)get_parameter('show_other', false); diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 3dc0f0108d..d9692ca7ee 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -220,7 +220,7 @@ if ($id_user_ack != "0") if ($event_view_hr > 0) { - $unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds + $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); $sql_post .= " AND (utimestamp > ".$unixtime . " OR estado = 2)"; } diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 4609bc2eb0..ccb94f2c16 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -97,19 +97,19 @@ else { if (check_acl ($config["id_user"], $map['group_id'], "IW")) $buttons [] = ''.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; - + $buttonsString = '' . html_print_image("images/bricks.png", true, array("class" => "top", "border" => '0')) . '  Agent - test_gis1