2013-01-29 Miguel de Dios <miguel.dedios@artica.es>

* 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
This commit is contained in:
mdtrooper 2013-01-29 18:03:08 +00:00
parent 3ccd6225d2
commit 3b22a943a8
4 changed files with 66 additions and 87 deletions

View File

@ -1,3 +1,8 @@
2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
* godmode/groups/group_list.php, include/ajax/events.php,
include/functions_api.php: improved the style code.
2013-01-29 Dario Rodriguez <dario@artica.es>
* images/pandora_report_logo.png: Added new images missed for

View File

@ -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] = '';

View File

@ -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", '<br>', $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 = "<br>> ";
switch($event_response['type']) {
case 'command':
echo "<div style='text-align:left'>";

View File

@ -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.'));
}