From 915065cbcb95795008f494594a9c8d2a0e124687 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 26 Jul 2012 11:05:05 +0000 Subject: [PATCH] 2012-07-26 Miguel de Dios * operation/users/user_edit.php, operation/events/events_validate.php, operation/search_graphs.php, godmode/events/event_filter.php, godmode/events/custom_events.php, godmode/massive/massive_standby_alerts.php, godmode/massive/massive_copy_modules.php, godmode/tag/tag.php, godmode/netflow/nf_report.php, godmode/agentes/configure_field.php, godmode/agentes/agent_manager.php, godmode/agentes/agent_template.php, godmode/agentes/fields_manager.php, godmode/servers/recon_script.php, godmode/servers/plugin.php, include/functions_modules.php: improved the source structure. * operation/search_modules.php: fixed the search when the modules haven't inicialiced. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 17 ++++ .../godmode/agentes/agent_manager.php | 99 +++++++++---------- .../godmode/agentes/agent_template.php | 40 +++++--- .../godmode/agentes/configure_field.php | 8 +- .../godmode/agentes/fields_manager.php | 16 +-- .../godmode/events/custom_events.php | 24 ++--- .../godmode/events/event_filter.php | 13 +-- .../godmode/massive/massive_copy_modules.php | 14 ++- .../massive/massive_standby_alerts.php | 3 +- pandora_console/godmode/netflow/nf_report.php | 24 +++-- pandora_console/godmode/servers/plugin.php | 56 ++++++----- .../godmode/servers/recon_script.php | 80 ++++++++------- pandora_console/godmode/tag/tag.php | 15 ++- pandora_console/include/functions_modules.php | 20 ++-- .../operation/events/events_validate.php | 3 +- pandora_console/operation/search_graphs.php | 9 +- pandora_console/operation/search_modules.php | 24 +++-- pandora_console/operation/users/user_edit.php | 6 +- 18 files changed, 261 insertions(+), 210 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 79e91eb289..aabc015d53 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2012-07-26 Miguel de Dios + + * operation/users/user_edit.php, + operation/events/events_validate.php, operation/search_graphs.php, + godmode/events/event_filter.php, godmode/events/custom_events.php, + godmode/massive/massive_standby_alerts.php, + godmode/massive/massive_copy_modules.php, godmode/tag/tag.php, + godmode/netflow/nf_report.php, godmode/agentes/configure_field.php, + godmode/agentes/agent_manager.php, + godmode/agentes/agent_template.php, + godmode/agentes/fields_manager.php, + godmode/servers/recon_script.php, godmode/servers/plugin.php, + include/functions_modules.php: improved the source structure. + + * operation/search_modules.php: fixed the search when the modules + haven't inicialiced. + 2012-07-26 Sergio Martin * include/functions_html.php: Change the sort function diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 73037c8ee5..2cb5527b5e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -14,9 +14,9 @@ // GNU General Public License for more details. if (is_ajax ()) { - + global $config; - + $search_parents = (bool) get_parameter ('search_parents'); $search_parents_2 = (bool) get_parameter ('search_parents_2'); @@ -48,52 +48,52 @@ if (is_ajax ()) { } return; - } - - if ($search_parents_2) { - require_once ('include/functions_agents.php'); - - $id_agent = (int) get_parameter ('id_agent'); - $string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */ - - $filter = array (); - - switch ($config['dbtype']){ - case "mysql": - case "postgresql": - $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; - break; - case "oracle": - $filter[] = '(upper(nombre) LIKE upper("%'.$string.'%") OR upper(direccion) LIKE upper("%'.$string.'%") OR upper(comentarios) LIKE upper("%'.$string.'%"))'; - break; - } - $filter[] = 'id_agente != '.$id_agent; - - $agents = agents_get_agents ($filter, array ('id_agente', 'nombre', 'direccion')); - if ($agents === false) - $agents = array(); - - $data = array(); - foreach ($agents as $agent) { - $data[] = array('id' => $agent['id_agente'], - 'name' => io_safe_output($agent['nombre']), - 'ip' => io_safe_output($agent['direccion'])); - } - - echo json_encode($data); - - return; - } - + } + + if ($search_parents_2) { + require_once ('include/functions_agents.php'); + + $id_agent = (int) get_parameter ('id_agent'); + $string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */ + + $filter = array (); + + switch ($config['dbtype']){ + case "mysql": + case "postgresql": + $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; + break; + case "oracle": + $filter[] = '(upper(nombre) LIKE upper("%'.$string.'%") OR upper(direccion) LIKE upper("%'.$string.'%") OR upper(comentarios) LIKE upper("%'.$string.'%"))'; + break; + } + $filter[] = 'id_agente != '.$id_agent; + + $agents = agents_get_agents ($filter, array ('id_agente', 'nombre', 'direccion')); + if ($agents === false) + $agents = array(); + + $data = array(); + foreach ($agents as $agent) { + $data[] = array('id' => $agent['id_agente'], + 'name' => io_safe_output($agent['nombre']), + 'ip' => io_safe_output($agent['direccion'])); + } + + echo json_encode($data); + + return; + } + $get_modules_json_for_multiple_snmp = (bool) get_parameter("get_modules_json_for_multiple_snmp", 0); if ($get_modules_json_for_multiple_snmp) { require_once ('include/graphs/functions_utils.php'); - + $idSNMP = get_parameter('id_snmp'); $id_snmp_serialize = get_parameter('id_snmp_serialize'); $snmp = unserialize_in_temp($id_snmp_serialize, false); - + $oid_snmp = array(); $out = false; foreach($idSNMP as $id) { @@ -103,24 +103,24 @@ if (is_ajax ()) { if (! preg_match ( "/if/", $key)) { continue; } - + $oid_snmp[$value['oid']] = $key; } - + if($out === false){ $out = $oid_snmp; } else{ $out = array_intersect($out,$oid_snmp); } - + $oid_snmp = array(); } - + echo json_encode($out); } - - return; + + return; } // Load global vars enterprise_include ('godmode/agentes/agent_manager.php'); @@ -185,8 +185,7 @@ $table->data[0][0] = __('Agent name') . $table->data[0][1] = html_print_input_text ('agente', $nombre_agente, '', 50, 100,true); if ($id_agente) { - - $table->data[0][1] .= " ".__("ID")."  $id_agente  "; + $table->data[0][1] .= " ".__("ID")."  $id_agente  "; $table->data[0][1] .= '  '; $table->data[0][1] .= html_print_image ("images/lupa.png", true, array ("border" => 0, "title" => __('Agent detail'))); $table->data[0][1] .= ''; @@ -213,7 +212,7 @@ if ($id_agente) { $table->data[1][1] .= '    '; $ip_all = agents_get_addresses ($id_agente); - + $table->data[1][1] .= html_print_select ($ip_all, "address_list", $direccion_agente, '', '', 0, true); $table->data[1][1] .= " ". html_print_checkbox ("delete_ip", 1, false, true).__('Delete selected'); } diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index d5b516a9db..a3200ded6b 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -40,7 +40,8 @@ if (isset ($_POST["template_id"])) { $os_version = $row["os_version"]; $agent_version = $row["agent_version"]; $disabled= $row["disabled"]; - } else { + } + else { return; } @@ -55,7 +56,7 @@ if (isset ($_POST["template_id"])) { if ($nc === false) { $nc = array (); } - foreach ($nc as $row2) { + foreach ($nc as $row2) { // Insert each module from tnetwork_component into agent $values = array( 'id_agente' => $id_agente, @@ -142,16 +143,22 @@ echo ''; // ========================== // MODULE VISUALIZATION TABLE // ========================== - - switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - $sql = sprintf ("SELECT * FROM tagente_modulo WHERE id_agente = %d AND delete_pending = false ORDER BY id_module_group, nombre", $id_agente); - break; - case "oracle": - $sql = sprintf ("SELECT * FROM tagente_modulo WHERE id_agente = %d AND (delete_pending <> 1 AND delete_pending IS NOT NULL) ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)", $id_agente); - break; - } +switch ($config["dbtype"]) { + case "mysql": + case "postgresql": + $sql = sprintf ("SELECT * + FROM tagente_modulo + WHERE id_agente = %d AND delete_pending = false + ORDER BY id_module_group, nombre", $id_agente); + break; + case "oracle": + $sql = sprintf ("SELECT * + FROM tagente_modulo + WHERE id_agente = %d + AND (delete_pending <> 1 AND delete_pending IS NOT NULL) + ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)", $id_agente); + break; +} $result = db_get_all_rows_sql ($sql); if ($result === false) { $result = array (); @@ -179,7 +186,8 @@ foreach ($result as $row) { $data[0] = '' . $row["nombre"]; if ($row["id_tipo_modulo"] > 0) { $data[1] = html_print_image("images/" . modules_show_icon_type ($row["id_tipo_modulo"]), true, array("border" => "0")); - } else { + } + else { $data[1] = ''; } $data[2] = mb_substr ($row["descripcion"], 0, 60); @@ -194,8 +202,8 @@ foreach ($result as $row) { if (!empty ($table->data)) { html_print_table ($table); unset ($table); -} else { +} +else { echo '
No modules
'; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 154c1c6e0f..6ba5fcb99e 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -34,7 +34,8 @@ if ($id_field) { $name = $field['name']; $display_on_front = $field['display_on_front']; ui_print_page_header (__("Update agent custom field"), "images/note.png", false, "", true, ""); -} else { +} +else { ui_print_page_header (__("Create agent custom field"), "images/note.png", false, "", true, ""); } @@ -54,11 +55,12 @@ if ($id_field) { html_print_input_hidden ('update_field', 1); html_print_input_hidden ('id_field', $id_field); html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); -} else { +} +else { html_print_input_hidden ('create_field', 1); html_print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); } echo ''; echo ''; -?> +?> \ No newline at end of file diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index fd7c984188..de0b10e537 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -42,9 +42,11 @@ if ($create_field) { /*Check if name field is empty*/ if ($name == ""){ echo "

".__('The name must not be empty')."

"; - } else if ($name == db_get_value ('name', 'tagent_custom_fields', 'name', $name)) { + } + else if ($name == db_get_value ('name', 'tagent_custom_fields', 'name', $name)) { echo "

".__('The name must be unique')."

"; - } else { + } + else { $result = db_process_sql_insert('tagent_custom_fields', array('name' => $name, 'display_on_front' => $display_on_front)); echo "

".__('Field successfully created')."

"; } @@ -71,7 +73,7 @@ if ($update_field) { } /* Delete field */ -if ($delete_field) { +if ($delete_field) { $result = db_process_sql_delete('tagent_custom_fields', array('id_field' => $id_field)); if (!$result) @@ -82,7 +84,7 @@ if ($delete_field) { $fields = db_get_all_fields_in_table('tagent_custom_fields'); - $table->width = '98%'; +$table->width = '98%'; if ($fields) { $table->head = array (); $table->head[0] = __('Field'); @@ -102,14 +104,14 @@ if($fields === false) $fields = array(); foreach ($fields as $field) { $data[0] = ''.$field['name'].''; - + if($field['display_on_front']) { $data[1] = html_print_image('images/tick.png', true); } else { $data[1] = html_print_image('images/delete.png', true); } - + $data[2] = '' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0')) . ''; $data[2] .= '  ' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "title" => __('Delete'), "border" => '0')) . ''; @@ -125,4 +127,4 @@ html_print_submit_button (__('Create field'), 'crt', false, 'class="sub next"'); echo ''; echo ''; -?> +?> \ No newline at end of file diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index a8acdd3d54..c289b9b991 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -35,16 +35,18 @@ $fields_selected = explode (',', $config['event_fields']); if ($default != 0) { $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); $fields_selected = explode (',', $event_fields); -} else if ($update != '') { +} +else if ($update != '') { $fields_selected = (array)get_parameter('fields_selected'); if ($fields_selected[0] == '') { $event_fields = io_safe_input('evento,id_agente,estado,timestamp'); $fields_selected = explode (',', $event_fields); - } else { + } + else { $event_fields = implode (',', $fields_selected); } - + $values = array( 'token' => 'event_fields', 'value' => $event_fields @@ -156,7 +158,7 @@ $table->data[1][0] = '' . __('Fields available').''; $table->data[1][1] = html_print_select ($fields_available, 'fields_available[]', true, '', '', '', true, true, false, '', false, 'width: 200px'); $table->data[1][2] = html_print_image('images/darrowright.png', true, array('id' => 'right', 'title' => __('Add fields to select'))); //html_print_input_image ('add', 'images/darrowright.png', 1, '', true, array ('title' => __('Add tags to module'))); $table->data[1][2] .= '



' . html_print_image('images/darrowleft.png', true, array('id' => 'left', 'title' => __('Delete fields to select'))); //html_print_input_image ('add', 'images/darrowleft.png', 1, '', true, array ('title' => __('Delete tags to module'))); - + $table->data[1][3] = '' . __('Fields selected') . ''; $table->data[1][4] = html_print_select($result_selected, 'fields_selected[]', true, '', '', '', true, true, false, '', false, 'width: 200px'); @@ -164,7 +166,7 @@ echo '
'; - html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); + html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); echo '
'; echo ''; ?> @@ -181,9 +183,9 @@ $(document).ready (function () { $("select[name='fields_selected[]']").append($("").html(field_name).attr("value", id_field)); $("#fields_available").find("option[value='" + id_field + "']").remove(); } - }); + }); }); - + $("#left").click (function () { jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) { field_name = $(value).html(); @@ -192,15 +194,13 @@ $(document).ready (function () { $("select[name='fields_available[]']").append($("").val(field_name).html('' + id_field + '')); $("#fields_selected").find("option[value='" + id_field + "']").remove(); } - }); + }); }); $("#submit-upd_button").click(function () { - $('#fields_selected option').map(function(){ + $('#fields_selected option').map(function() { $(this).attr('selected','selected'); }); }); }); - - - + \ No newline at end of file diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 6cb913a56a..4bd6e1c516 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -58,17 +58,18 @@ if ($delete){ else { $result = db_process_sql_delete ('tevent_filter', array ('id_filter' => $id)); } - + if ($result !== false) { $result = true; - } else { + } + else { $result = false; } ui_print_result_message ($result, __('Successfully deleted'), __('Not deleted. Error deleting data')); - + } if ($multiple_delete) { @@ -79,7 +80,7 @@ if ($multiple_delete) { foreach ($ids as $id) { $result = db_process_sql_delete ('tevent_filter', array ('id_filter' => $id)); - + if ($result === false) { db_process_sql_rollback(); break; @@ -92,7 +93,7 @@ if ($multiple_delete) { if ($result !== false) $result = true; else $result = false; - + ui_print_result_message ($result, __('Successfully deleted'), __('Not deleted. Error deleting data')); @@ -185,4 +186,4 @@ function check_all_checkboxes() { $(".check_delete").attr('checked', false); } } - + \ No newline at end of file diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index 0c17102546..375ed45e6f 100644 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -265,7 +265,8 @@ $(document).ready (function () { module_alerts = Array (); if (! data) { no_alerts = true; - } else { + } + else { jQuery.each (data, function (i, val) { module_name = $("").append (val["module_name"]); option = $("") @@ -287,12 +288,14 @@ $(document).ready (function () { $("span.without_modules, span.without_alerts").show (); $("span.with_modules, span.with_alerts, #target_table-operations").hide (); - } else { + } + else { if (no_modules) { $("span.without_modules").show (); $("span.with_modules").hide (); $("#checkbox-copy_modules").uncheck (); - } else { + } + else { $("span.without_modules").hide (); $("span.with_modules").show (); $("#checkbox-copy_modules").check (); @@ -302,7 +305,8 @@ $(document).ready (function () { $("span.without_alerts").show (); $("span.with_alerts").hide (); $("#checkbox-copy_alerts").uncheck (); - } else { + } + else { $("span.without_alerts").hide (); $("span.with_alerts").show (); $("#checkbox-copy_alerts").check (); @@ -357,4 +361,4 @@ $(document).ready (function () { }); }); /* ]]> */ - + \ No newline at end of file diff --git a/pandora_console/godmode/massive/massive_standby_alerts.php b/pandora_console/godmode/massive/massive_standby_alerts.php index 74b16382b6..b1f3c75325 100644 --- a/pandora_console/godmode/massive/massive_standby_alerts.php +++ b/pandora_console/godmode/massive/massive_standby_alerts.php @@ -207,7 +207,8 @@ $(document).ready (function () { if (this.value != 0) { $("#id_not_standby_alerts").enable (); $("#id_standby_alerts").enable (); - } else { + } + else { $("#id_group, #id_not_standby_alerts").disable (); $("#id_group, #id_standby_alerts").disable (); } diff --git a/pandora_console/godmode/netflow/nf_report.php b/pandora_console/godmode/netflow/nf_report.php index 1de2c56251..af38a9b18c 100644 --- a/pandora_console/godmode/netflow/nf_report.php +++ b/pandora_console/godmode/netflow/nf_report.php @@ -41,10 +41,10 @@ $id = (int) get_parameter ('id'); if ($delete) { $result = db_process_sql_delete ('tnetflow_report', array ('id_report' => $id)); - + if ($result !== false) $result = true; else $result = false; - + ui_print_result_message ($result, __('Successfully deleted'), __('Not deleted. Error deleting data')); @@ -59,7 +59,7 @@ if ($multiple_delete) { foreach ($ids as $id) { $result = db_process_sql_delete ('tnetflow_report', array ('id_report' => $id)); - + if ($result === false) { db_process_sql_rollback(); break; @@ -72,7 +72,7 @@ if ($multiple_delete) { if ($result !== false) $result = true; else $result = false; - + ui_print_result_message ($result, __('Successfully deleted'), __('Not deleted. Error deleting data')); @@ -92,7 +92,7 @@ $sql = "SELECT * FROM tnetflow_report WHERE id_group IN (".implode(',',$groups_i $reports = db_get_all_rows_sql($sql); if ($reports === false) $reports = array(); - + $table->width = '98%'; $table->head = array (); $table->head[0] = __('Report name'); @@ -100,7 +100,7 @@ $table->head[1] = __('Description'); $table->head[2] = __('Group'); $table->head[3] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - + $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->align = array (); @@ -118,8 +118,7 @@ $total_reports = $total_reports[0]['total']; //ui_pagination ($total_reports, $url); - foreach ($reports as $report) { - +foreach ($reports as $report) { $data = array (); $data[0] = ''.$report['id_name'].''; @@ -138,7 +137,7 @@ $total_reports = $total_reports[0]['total']; array_push ($table->data, $data); } -if(isset($data)) { +if (isset($data)) { echo "
"; html_print_input_hidden('multiple_delete', 1); html_print_table ($table); @@ -146,7 +145,8 @@ if(isset($data)) { html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); echo ""; echo "
"; -}else { +} +else { echo "
".__('There are no defined reports')."
"; } @@ -159,7 +159,6 @@ echo '
- function check_all_checkboxes() { if ($("input[name=all_delete]").attr('checked')) { $(".check_delete").attr('checked', true); @@ -168,5 +167,4 @@ function check_all_checkboxes() { $(".check_delete").attr('checked', false); } } - - + \ No newline at end of file diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index ab5929b64e..e4bc939c44 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -41,7 +41,7 @@ if (! check_acl ($config['id_user'], 0, "LM")) { $view = get_parameter ("view", ""); $create = get_parameter ("create", ""); -if ($view != ""){ +if ($view != "") { $form_id = $view; $plugin = db_get_row ("tplugin", "id", $form_id); $form_name = $plugin["name"]; @@ -54,7 +54,7 @@ if ($view != ""){ $form_pass_opt = $plugin ["pass_opt"]; $form_plugin_type = $plugin ["plugin_type"]; } -if ($create != ""){ +if ($create != "") { $form_name = ""; $form_description = ""; $form_max_timeout = ""; @@ -69,7 +69,7 @@ if ($create != ""){ // SHOW THE FORM // ================================================================= -if (($create != "") OR ($view != "")){ +if (($create != "") OR ($view != "")) { if ($create != "") ui_print_page_header (__('Plugin creation') . ui_print_help_icon("plugin_definition", true), "", false, "", true); @@ -77,70 +77,72 @@ if (($create != "") OR ($view != "")){ ui_print_page_header (__('Plugin update') . ui_print_help_icon("plugin_definition", true), "", false, "", true); $plugin_id = get_parameter ("view",""); } - - + + if ($create == "") echo ""; else echo ""; - + echo ''; - echo ''; echo ''; - echo ''; echo ''; - - echo ''; echo ''; echo ''; - - echo ''; echo ''; - - echo ''; echo ''; - - - echo ''; echo ''; - - echo ''; echo ''; - + echo ''; echo ''; - + echo '
'.__('Name'); + echo '
'.__('Name') . ''; echo '
'.__('Plugin command'); + echo '
'.__('Plugin command') . ''; echo '
'.__('Plugin type'); + + echo '
'.__('Plugin type') . ''; $fields[0]= __("Standard"); $fields[1]= __("Nagios"); html_print_select ($fields, "form_plugin_type", $form_plugin_type); - echo '
'.__('Max. timeout'); + echo '
'.__('Max. timeout') . ''; echo '
'.__('IP address option'); + + echo '
'.__('IP address option') . ''; echo '
'.__('Port option'); + + echo '
'.__('Port option') . ''; echo '
'.__('User option'); + + + echo '
'.__('User option') . ''; echo '
'.__('Password option'); + + echo '
'.__('Password option') . ''; echo '
'.__('Description').'
'; echo ''; echo '
'; if ($create != ""){ - echo ""; - } else { - echo ""; + echo ""; + } + else { + echo ""; } echo '
'; } - else { ui_print_page_header (__('Plugins registered in Pandora FMS'), "", false, "", true); - + // Update plugin if (isset($_GET["update_plugin"])){ // if modified any parameter $plugin_id = get_parameter ("update_plugin", 0); diff --git a/pandora_console/godmode/servers/recon_script.php b/pandora_console/godmode/servers/recon_script.php index 0234ac867c..7bcd81abc1 100644 --- a/pandora_console/godmode/servers/recon_script.php +++ b/pandora_console/godmode/servers/recon_script.php @@ -18,7 +18,8 @@ if (is_ajax ()) { $get_reconscript_description = get_parameter('get_reconscript_description'); $id_reconscript = get_parameter('id_reconscript'); - $description = db_get_value_filter('description', 'trecon_script', array('id_recon_script' => $id_reconscript)); + $description = db_get_value_filter('description', 'trecon_script', + array('id_recon_script' => $id_reconscript)); echo htmlentities (io_safe_output($description), ENT_QUOTES, "UTF-8", true); return; @@ -38,21 +39,21 @@ if (! check_acl ($config['id_user'], 0, "LM")) { if (!check_refererer()) { require ("general/noaccess.php"); - + return; } $view = get_parameter ("view", ""); $create = get_parameter ("create", ""); -if ($view != ""){ +if ($view != "") { $form_id = $view; $reconscript = db_get_row ("trecon_script", "id_recon_script", $form_id); $form_name = $reconscript["name"]; $form_description = $reconscript["description"]; $form_script = $reconscript ["script"]; } -if ($create != ""){ +if ($create != "") { $form_name = ""; $form_description = ""; $form_script = ""; @@ -64,33 +65,35 @@ if ($create != ""){ if (($create != "") OR ($view != "")){ if ($create != "") - ui_print_page_header (__('Recon script creation') . ui_print_help_icon("reconscript_definition", true), "", false, "", true); + ui_print_page_header (__('Recon script creation') . + ui_print_help_icon("reconscript_definition", true), "", false, "", true); else { - ui_print_page_header (__('Recon script update') . ui_print_help_icon("reconscript_definition", true), "", false, "", true); + ui_print_page_header (__('Recon script update') . + ui_print_help_icon("reconscript_definition", true), "", false, "", true); $id_recon_script = get_parameter ("view",""); } - - + + if ($create == "") echo "
"; else echo ""; - + echo ''; - echo ''; echo ''; - echo ''; echo ''; - - echo ''; + + echo ''; echo ''; - + echo '
'.__('Name'); + echo '
' . __('Name') . ''; echo '
'.__('Script fullpath'); + echo '
' . __('Script fullpath') . ''; echo '
'.__('Description').'
' . __('Description') . '
'; echo ''; echo '
'; @@ -111,7 +114,7 @@ else { $id_recon_script = get_parameter ("update_reconscript", 0); $reconscript_name = get_parameter ("form_name", ""); $reconscript_description = get_parameter ("form_description", ""); - $reconscript_script = get_parameter ("form_script", ""); + $reconscript_script = get_parameter ("form_script", ""); $sql_update ="UPDATE trecon_script SET name = '$reconscript_name', @@ -122,14 +125,15 @@ else { if ($reconscript_name != '' && $reconscript_script != '') $result = db_process_sql ($sql_update); if (! $result) { - echo "

".__('Problem updating')."

"; - } else { - echo "

".__('Updated successfully')."

"; + echo "

" . __('Problem updating') . "

"; + } + else { + echo "

" . __('Updated successfully') . "

"; } } - + // Create reconscript - if (isset($_GET["create_reconscript"])) { + if (isset($_GET["create_reconscript"])) { $reconscript_name = get_parameter ("form_name", ""); $reconscript_description = get_parameter ("form_description", ""); $reconscript_script = get_parameter ("form_script", ""); @@ -141,48 +145,48 @@ else { $result = false; if ($values['name'] != '' && $values['script'] != '') $result = db_process_sql_insert('trecon_script', $values); - if (! $result){ - echo "

".__('Problem creating')."

"; + if (! $result) { + echo "

" . __('Problem creating') . "

"; } else { - echo "

".__('Created successfully')."

"; + echo "

" . __('Created successfully') . "

"; } } - - if (isset($_GET["kill_reconscript"])){ // if delete alert + + if (isset($_GET["kill_reconscript"])) { // if delete alert $reconscript_id = get_parameter ("kill_reconscript", 0); $result = db_process_sql_delete('trecon_script', array('id_recon_script' => $reconscript_id)); - if (! $result){ - echo "

".__('Problem deleting reconscript')."

"; + if (! $result) { + echo "

" . __('Problem deleting reconscript') . "

"; } else { - echo "

".__('reconscript deleted successfully')."

"; + echo "

" . __('reconscript deleted successfully') . "

"; } if ($reconscript_id != 0){ $result = db_process_sql_delete('trecon_task', array('id_recon_script' => $reconscript_id)); } } - + // If not edition or insert, then list available reconscripts $rows = db_get_all_rows_in_table('trecon_script'); if ($rows !== false) { echo ''; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; $color = 0; foreach ($rows as $row) { - if ($color == 1){ + if ($color == 1) { $tdcolor = "datos"; $color = 0; - } + } else { $tdcolor = "datos2"; $color = 1; @@ -203,7 +207,8 @@ else { echo "
".__('Name')."".__('Command')."".__('Description')."".__('Delete')."" . __('Name') . "" . __('Command') . "" . __('Description') . "" . __('Delete') . "
"; } else { - echo '
'. __('There are no recon scripts in the system') . '
'; + echo '
'. + __('There are no recon scripts in the system') . '
'; echo "
"; } echo ""; @@ -212,5 +217,4 @@ else { echo ""; echo "
"; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/godmode/tag/tag.php b/pandora_console/godmode/tag/tag.php index 84452544d0..d83597f941 100644 --- a/pandora_console/godmode/tag/tag.php +++ b/pandora_console/godmode/tag/tag.php @@ -72,11 +72,12 @@ ui_print_page_header (__('Tags configuration'), "images/setup.png", false, "", t // Delete action: This will delete a tag if ($delete != 0) { $return_delete = tags_delete_tag ($delete); - + if ($return_delete === false) { db_pandora_audit("Tag management", "Fail try to delete tag #$delete"); echo '

'.__('Error deleting tag').'

'; - } else { + } + else { db_pandora_audit("Tag management", "Delete tag #$delete"); echo '

'.__('Successfully deleted tag').'

'; } @@ -94,7 +95,7 @@ $result = false; if ($search != 0) { $result = tags_search_tag($tag_name, $filter); } -else{ +else { $result = tags_search_tag(false, $filter); } @@ -103,6 +104,7 @@ echo ""; echo ""; echo ""; echo ""; echo ""; +echo ""; echo "
"; echo '' . __("Name") . "/" . __("Description") . ''; +echo ""; echo ''; html_print_input_hidden ("search_tag", "1"); @@ -110,11 +112,14 @@ echo ""; echo "   "; html_print_submit_button (__('Filter'), 'filter_button', false, 'class="sub search"'); echo ""; +echo ""; echo '
'; html_print_input_hidden ("create_tag", "1", true); html_print_submit_button (__('Create tag'), 'create_button', false, 'class="sub next"'); echo "
"; +echo "
"; // Prepare pagination @@ -124,7 +129,7 @@ ui_pagination ($total_tags, $url); $rowPair = true; $iterator = 0; -if (!empty($result)){ +if (!empty($result)) { $table->width = '98%'; $table->data = array (); @@ -187,4 +192,4 @@ ui_require_jquery_file ('cluetip'); return false; }); /* ]]> */ - + \ No newline at end of file diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index d5487e19f5..c3c734ff77 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1128,14 +1128,14 @@ function modules_get_previous_data ($id_agent_module, $utimestamp = 0, $string = function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) { if (empty ($utimestamp)) $utimestamp = time (); - + if ($string == 1) { $table = 'tagente_datos_string'; } else { $table = 'tagente_datos'; } - + $interval = modules_get_interval ($id_agent_module); $sql = sprintf ('SELECT * FROM tagente_datos @@ -1144,7 +1144,7 @@ function modules_get_next_data ($id_agent_module, $utimestamp = 0, $string = 0) AND utimestamp >= %d ORDER BY utimestamp ASC', $id_agent_module, $utimestamp + $interval, $utimestamp); - + return db_get_row_sql ($sql, true); } @@ -1161,32 +1161,32 @@ function modules_get_agentmodule_data ($id_agent_module, $period, $date = 0) { if ($date < 1) { $date = get_system_time (); } - + $datelimit = $date - $period; - + $sql = sprintf ("SELECT datos AS data, utimestamp FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d AND utimestamp <= %d ORDER BY utimestamp ASC", $id_agent_module, $datelimit, $date); - + $values = db_get_all_rows_sql ($sql, true, false); - + if ($values === false) { return array (); } - + $module_name = modules_get_agentmodule_name ($id_agent_module); $agent_id = modules_get_agentmodule_agent ($id_agent_module); $agent_name = modules_get_agentmodule_agent_name ($id_agent_module); - + foreach ($values as $key => $data) { $values[$key]["module_name"] = $module_name; $values[$key]["agent_id"] = $agent_id; $values[$key]["agent_name"] = $agent_name; } - + return $values; } diff --git a/pandora_console/operation/events/events_validate.php b/pandora_console/operation/events/events_validate.php index 05221cab86..303a7bbea5 100644 --- a/pandora_console/operation/events/events_validate.php +++ b/pandora_console/operation/events/events_validate.php @@ -101,7 +101,8 @@ $string .= '
'; $string .= '
'; if ($event["estado"] == 0 ) { $string .= html_print_select(array('1' => __('Validate'), '2' => __('Set in process'), '3' => __('Add comment')), 'select_validate', '', '', '', 0, true, false, false, 'select_validate').'

'; -} else if ($event["estado"] == 2 ) { +} +else if ($event["estado"] == 2 ) { $string .= html_print_select(array('1' => __('Validate'), '3' => __('Add comment')), 'select_validate', '', '', '', 0, true, false, false, 'select_validate').'

'; } diff --git a/pandora_console/operation/search_graphs.php b/pandora_console/operation/search_graphs.php index 6aed815332..0be56fd79f 100755 --- a/pandora_console/operation/search_graphs.php +++ b/pandora_console/operation/search_graphs.php @@ -25,15 +25,16 @@ $graphs = false; if ($searchGraphs) { //Check ACL $usergraphs = custom_graphs_get_user($config['id_user'], true); - + $usergraphs_id = array_keys($usergraphs); if(!$usergraphs_id){ $graphs_condition = " AND 1<>1"; - }else { + } + else { $graphs_condition = " AND id_graph IN (".implode(',',$usergraphs_id).")"; } - + $sql = "SELECT id_graph, name, description FROM tgraph WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$graphs_condition ." @@ -50,7 +51,7 @@ if ($searchGraphs) { } if ($graphs === false) { - echo "
" . __("Zero results found") . "
\n"; + echo "
" . __("Zero results found") . "
\n"; } else { $table->cellpadding = 4; diff --git a/pandora_console/operation/search_modules.php b/pandora_console/operation/search_modules.php index fe112a6c6c..28356d2ac5 100644 --- a/pandora_console/operation/search_modules.php +++ b/pandora_console/operation/search_modules.php @@ -147,7 +147,7 @@ if ($searchModules) { } if (!$modules) { - echo "
" . __("Zero results found") . "
\n"; + echo "
" . __("Zero results found") . "
\n"; } else { $totalModules = db_get_all_rows_sql("SELECT COUNT(t1.id_agente_modulo) AS count_modules " . $chunk_sql); @@ -202,7 +202,11 @@ else { $intervalCell = modules_get_interval ($module['id_agente_modulo']); - if($module['utimestamp'] == 0 && (($module['module_type'] < 21 || $module['module_type'] > 23) && $module['module_type'] != 100)){ + if ($module['utimestamp'] == 0 && + ( + ($module['id_tipo_modulo'] < 21 || $module['id_tipo_modulo'] > 23) && + $module['id_tipo_modulo'] != 100) + ) { $statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true); } elseif ($module["estado"] == 0) { @@ -230,17 +234,17 @@ else { } $graphCell = ""; - if ($module['history_data'] == 1){ - + if ($module['history_data'] == 1) { + $graph_type = return_graphtype ($module["id_tipo_modulo"]); - + $name_module_type = modules_get_moduletype_name ($module["id_tipo_modulo"]); $handle = "stat" . $name_module_type . "_" . $module["id_agente_modulo"]; $url = 'include/procesos.php?agente=' . $module["id_agente_modulo"]; $win_handle = dechex(crc32($module["id_agente_modulo"] . $module["module_name"])); - + $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module["id_agente_modulo"]."&label=".base64_encode($module["module_name"])."&refresh=600','day_".$win_handle."')"; - + $graphCell = '' . html_print_image("images/chart_curve.png", true, array("border" => 0, "alt" => "")) . ''; $graphCell .= " " . html_print_image('images/binary.png', true, array("border" => "0", "alt" => "")) . ""; } @@ -250,7 +254,7 @@ else { else $dataCell = "".substr(io_safe_output($module["datos"]),0,12).""; - if ($module['estado'] == 3){ + if ($module['estado'] == 3) { $option = array ("html_attr" => 'class="redb"'); } else { @@ -275,5 +279,5 @@ else { html_print_table ($table); unset($table); ui_pagination ($totalModules); -} -?> +} +?> \ No newline at end of file diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index dabadc8ff7..a444574143 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -102,9 +102,11 @@ if (isset ($_GET["modified"]) && !$view_mode) { $section = io_safe_output($upd_info["section"]); if (($section == 'Event list') || ($section == 'Group view') || ($section == 'Alert detail') || ($section == 'Tactical view') || ($section == 'Default')) { $upd_info["data_section"] = ''; - } else if ($section == 'Dashboard') { + } + else if ($section == 'Dashboard') { $upd_info["data_section"] = $dashboard; - } else if ($section == 'Visual console') { + } + else if ($section == 'Visual console') { $upd_info["data_section"] = $visual_console; }