From 3b22a943a8428d2b3e1de15d0fbb8a43c3eacb8a Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 29 Jan 2013 18:03:08 +0000 Subject: [PATCH] 2013-01-29 Miguel de Dios * godmode/groups/group_list.php, include/ajax/events.php, include/functions_api.php: improved the style code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7547 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++ pandora_console/godmode/groups/group_list.php | 45 ++-------- pandora_console/include/ajax/events.php | 16 ++-- pandora_console/include/functions_api.php | 87 ++++++++++--------- 4 files changed, 66 insertions(+), 87 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2475b477a6..c25f49232a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-01-29 Miguel de Dios + + * godmode/groups/group_list.php, include/ajax/events.php, + include/functions_api.php: improved the style code. + 2013-01-29 Dario Rodriguez * images/pandora_report_logo.png: Added new images missed for diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 94c2b36cdc..fd2c8824ac 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -76,48 +76,19 @@ if (is_ajax ()) { echo json_encode (false); return; } - + if($filter_agents_json != '') { $filter['id_agente'] = json_decode(io_safe_output($filter_agents_json), true); } - + $filter['disabled'] = $disabled; if($search != '') { $filter['string'] = $search; } - /*if ($config['metaconsole'] == 1) { - enterprise_include_once('include/functions_metaconsole.php'); - - $connection_names = enterprise_hook('metaconsole_get_connection_names'); - if ($connection_names === false) - $connection_names = array(); - $agents_tmp = array(); - $agents = array(); - foreach ($connection_names as $connection) { - $connection_data = enterprise_hook('metaconsole_get_connection', array($connection)); - - $connection_result = enterprise_hook('metaconsole_load_external_db', array($connection_data)); - - if ($connection_result == NOERR) { - $agents_tmp = agents_get_group_agents ($id_group, $filter, "none", false, $recursion); - - if ($agents_tmp === false) - $agents_tmp = array(); - - foreach ($agents_tmp as $agent_key => $agent_name) { - $agents[$connection_data['server_name'] . '|' . $agent_key] = $agent_name; - } - } - - enterprise_hook('metaconsole_restore_db'); - } - } - else { */ - $agents = agents_get_group_agents ($id_group, $filter, "none", false, $recursion); - //} + $agents = agents_get_group_agents ($id_group, $filter, "none", false, $recursion); echo json_encode ($agents); return; @@ -163,8 +134,8 @@ if ($create_group) { $description = (string) get_parameter ('description'); $contact = (string) get_parameter ('contact'); $other = (string) get_parameter ('other'); -$check = db_get_value('nombre', 'tgrupo', 'nombre', $name); - + $check = db_get_value('nombre', 'tgrupo', 'nombre', $name); + /*Check if name field is empty*/ if ($name != "") { @@ -213,9 +184,9 @@ if ($update_group) { $description = (string) get_parameter ('description'); $contact = (string) get_parameter ('contact'); $other = (string) get_parameter ('other'); - + /*Check if name field is empty*/ - if( $name != "") { + if( $name != "") { switch ($config["dbtype"]) { case "mysql": $sql = sprintf ('UPDATE tgrupo SET nombre = "%s", @@ -291,7 +262,7 @@ if (!empty($groups)) { $table->data = array (); $iterator = 0; - + foreach ($groups as $id_group => $group) { if ($group['deep'] == 0) { $table->rowstyle[$iterator] = ''; diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 3ff874cf77..ed61ac0f6b 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -37,7 +37,7 @@ $get_event_name = (bool) get_parameter ('get_event_name'); $meta = get_parameter ('meta', 0); $history = get_parameter ('history', 0); -if($get_event_name) { +if ($get_event_name) { $event_id = get_parameter ('event_id'); if($meta) { @@ -56,24 +56,24 @@ if($get_event_name) { return; } -if($get_response_description) { +if ($get_response_description) { $response_id = get_parameter ('response_id'); $description = db_get_value('description','tevent_response','id',$response_id); - if($description === false) { + if ($description === false) { return; } $description = io_safe_output($description); $description = str_replace("\r\n", '
', $description); - + echo $description; return; } -if($get_response_params) { +if ($get_response_params) { $response_id = get_parameter ('response_id'); $params = db_get_value('params','tevent_response','id',$response_id); @@ -87,7 +87,7 @@ if($get_response_params) { return; } -if($get_response_target) { +if($get_response_target) { $response_id = get_parameter ('response_id'); $event_id = get_parameter ('event_id'); $server_id = get_parameter ('server_id', 0); @@ -103,7 +103,7 @@ if($get_response_target) { return; } -if($get_response) { +if($get_response) { $response_id = get_parameter ('response_id'); $event_response = db_get_row('tevent_response','id',$response_id); @@ -138,7 +138,7 @@ if($dialogue_event_response) { $event = db_get_row('tevento','id_evento',$event_id); $prompt = "
> "; - + switch($event_response['type']) { case 'command': echo "
"; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index d6dbd7eb6d..a9bf193a03 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -802,7 +802,7 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) { $where .= " AND tconfig_os.id_os = " . $other['data'][0]; } } - if (isset($other['data'][1])){ + if (isset($other['data'][1])) { // Filter by group if ($other['data'][1] != "") { $where .= " AND id_grupo = " . $other['data'][1]; @@ -2316,11 +2316,11 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) { $template = alerts_get_alert_templates($filter_templates, array('id', 'name', 'description', 'id_alert_action', 'type', 'id_group')); - if ($template !== false) { + if ($template !== false) { $data['type'] = 'array'; - $data['data'] = $template; - } - + $data['data'] = $template; + } + if (!$template) { returnError('error_get_alert_template', __('Error getting alert template.')); } @@ -2605,14 +2605,14 @@ function api_set_validate_all_alerts($id, $thrash1, $other, $thrash3) { $total_alerts = count($alerts); $count_results = 0; - foreach ($alerts as $alert) { + foreach ($alerts as $alert) { $result = alerts_validate_alert_agent_module($alert['id'], true); - if ($result){ + if ($result) { $count_results++; } } - + if ($total_alerts > $count_results){ $errors = $total_alerts - $count_results; returnError('error_validate_all_alerts', __('Error validate all alerts. Failed ' . $errors . '.')); @@ -2684,7 +2684,7 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) { } // Validate alerts of these modules - foreach ($result_alerts as $result_alert){ + foreach ($result_alerts as $result_alert) { $result = alerts_validate_alert_agent_module($result_alert, true); if ($result) { @@ -2719,7 +2719,7 @@ function api_set_validate_all_policy_alerts($id, $thrash1, $other, $thrash3) { * @param $thrash3 Don't use */ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) { - if ($id == ""){ + if ($id == "") { returnError('error_stop_downtime', __('Error stopping downtime. Id_downtime cannot be left blank.')); return; } @@ -2727,7 +2727,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) { $date_stop = date ("Y-m-j",get_system_time ()); $time_stop = date ("h:iA",get_system_time ()); $date_time_stop = strtotime ($date_stop.' '.$time_stop); - + $values = array(); $values['date_to'] = $date_time_stop; @@ -3270,11 +3270,11 @@ function api_set_add_module_in_conf($id_agent, $module_name, $configuration_data * * @return string Module data when success, empty when error */ -function api_get_module_from_conf($id_agent, $module_name, $thrash2, $thrash3) { +function api_get_module_from_conf($id_agent, $module_name, $thrash2, $thrash3) { $result = enterprise_hook('config_agents_get_module_from_conf', array($id_agent, io_safe_output($module_name))); - - if($result !== ENTERPRISE_NOT_HOOK) { - returnData('string', array('type' => 'string', 'data' => $result)); + + if ($result !== ENTERPRISE_NOT_HOOK) { + returnData('string', array('type' => 'string', 'data' => $result)); } else { returnError('error_adding_module_conf', ''); @@ -3299,7 +3299,7 @@ function api_set_delete_module_in_conf($id_agent, $module_name, $thrash2, $thras $result = config_agents_delete_module_in_conf($id_agent, $module_name); $result = enterprise_hook('config_agents_delete_module_in_conf', array($id_agent, $module_name)); - + if($result && $result !== ENTERPRISE_NOT_HOOK) { returnData('string', array('type' => 'string', 'data' => '0')); } @@ -3526,33 +3526,36 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { # SNMP version 3 - if ($other['data'][12] == "3"){ + if ($other['data'][12] == "3") { if ($other['data'][21] != "AES" and $other['data'][21] != "DES"){ returnError('error_update_snmp_module_policy', __('Error updating SNMP module. snmp3_priv_method doesn\'t exists. Set it to \'AES\' or \'DES\'. ')); - return; + + return; } if ($other['data'][23] != "authNoPriv" and $other['data'][23] != "authPriv" and $other['data'][23] != "noAuthNoPriv"){ returnError('error_update_snmp_module_policy', __('Error updating SNMP module. snmp3_sec_level doesn\'t exists. Set it to \'authNoPriv\' or \'authPriv\' or \'noAuthNoPriv\'. ')); - return; - } + + return; + } if ($other['data'][24] != "MD5" and $other['data'][24] != "SHA"){ returnError('error_update_snmp_module_policy', __('Error updating SNMP module. snmp3_auth_method doesn\'t exists. Set it to \'MD5\' or \'SHA\'. ')); - return; - } - + + return; + } + $fields_snmp_module = array('id','disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', 'min_critical', - 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', - 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description', 'custom_string_1', - 'custom_string_2', 'custom_string_3', 'plugin_parameter', 'plugin_user', 'plugin_pass'); + 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', + 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description', 'custom_string_1', + 'custom_string_2', 'custom_string_3', 'plugin_parameter', 'plugin_user', 'plugin_pass'); } - else { + else { $fields_snmp_module = array('id','disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', 'min_critical', - 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', - 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description'); - } + 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'tcp_send', 'snmp_community', + 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description'); + } $cont = 0; foreach ($fields_snmp_module as $field){ @@ -3562,7 +3565,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { $cont++; } - + $result_update = enterprise_hook('policies_update_module', array($other['data'][0], $values, false)); @@ -3774,12 +3777,12 @@ function api_set_create_group($id, $thrash1, $other, $thrash3) { * * @param $thrash3 Don't use */ -function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) { +function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) { if ($other['data'][0] == "") { returnError('error_create_netflow_filter', __('Error in netflow filter creation. Filter name cannot be left blank.')); return; } - + if ($other['data'][1] == "") { returnError('error_create_netflow_filter', __('Error in netflow filter creation. Group id cannot be left blank.')); return; @@ -3792,12 +3795,12 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) { return; } } - + if ($other['data'][2] == "") { returnError('error_create_netflow_filter', __('Error in netflow filter creation. Filter cannot be left blank.')); return; } - + if ($other['data'][3] == "") { returnError('error_create_netflow_filter', __('Error in netflow filter creation. Aggregate_by cannot be left blank.')); return; @@ -3807,20 +3810,20 @@ function api_set_create_netflow_filter($thrash1, $thrash2, $other, $thrash3) { returnError('error_create_netflow_filter', __('Error in netflow filter creation. Output_format cannot be left blank.')); return; } - + $values = array ( - 'id_name'=> $other['data'][0], - 'id_group' => $other['data'][1], - 'advanced_filter'=> $other['data'][2], - 'aggregate'=> $other['data'][3], - 'output'=> $other['data'][4] + 'id_name'=> $other['data'][0], + 'id_group' => $other['data'][1], + 'advanced_filter'=> $other['data'][2], + 'aggregate'=> $other['data'][3], + 'output'=> $other['data'][4] ); // Save filter args $values['filter_args'] = netflow_get_filter_arguments ($values); $id = db_process_sql_insert('tnetflow_filter', $values); - + if ($id === false) { returnError('error_create_netflow_filter', __('Error in netflow filter creation.')); }