2013-03-04 Miguel de Dios <miguel.dedios@artica.es>
* godmode/setup/setup_netflow.php, include/help/ja/help_snmp_trap_types.php, include/functions_extensions.php, include/functions_snmp_browser.php, include/functions_events.php, include/functions_api.php: improved the code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7772 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4b678aa371
commit
a9c29eb474
pandora_console
|
@ -1,3 +1,11 @@
|
|||
2013-03-04 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/setup/setup_netflow.php,
|
||||
include/help/ja/help_snmp_trap_types.php,
|
||||
include/functions_extensions.php,
|
||||
include/functions_snmp_browser.php, include/functions_events.php,
|
||||
include/functions_api.php: improved the code style.
|
||||
|
||||
2013-03-04 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/reporting/reporting_builder.item_editor.php,
|
||||
|
|
|
@ -774,13 +774,15 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) {
|
|||
if ($other['type'] == 'string') {
|
||||
returnError('error_parameter', 'Error in the parameters.');
|
||||
return;
|
||||
} else if ($other['type'] == 'array') {
|
||||
}
|
||||
else if ($other['type'] == 'array') {
|
||||
|
||||
$name = "";
|
||||
|
||||
if ($other['data'][0] != '') {
|
||||
$name = $other['data'][0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
returnError('error_parameter', 'Custom field name required');
|
||||
return;
|
||||
}
|
||||
|
@ -789,12 +791,14 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) {
|
|||
|
||||
if ($other['data'][1] != '') {
|
||||
$display_front = $other['data'][1];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
returnError('error_parameter', 'Custom field display flag required');
|
||||
return;
|
||||
}
|
||||
|
||||
$result = db_process_sql_insert('tagent_custom_fields', array('name' => $name, 'display_on_front' => $display_front));
|
||||
$result = db_process_sql_insert('tagent_custom_fields',
|
||||
array('name' => $name, 'display_on_front' => $display_front));
|
||||
|
||||
$data['type'] = "string";
|
||||
$data["data"] = $result;
|
||||
|
@ -5375,7 +5379,7 @@ function api_set_disable_module ($agent_name, $module_name, $thrast3, $thrash4)
|
|||
|
||||
$result = modules_change_disabled($id_agent_module, 1);
|
||||
|
||||
if($result === NOERR) {
|
||||
if ($result === NOERR) {
|
||||
returnData('string', array('type' => 'string', 'data' => __('Correct module disable')));
|
||||
}
|
||||
else {
|
||||
|
@ -5399,7 +5403,7 @@ function api_set_enable_module ($agent_name, $module_name, $thrast3, $thrash4) {
|
|||
|
||||
$result = modules_change_disabled($id_agent_module, 1);
|
||||
|
||||
if($result === NOERR) {
|
||||
if ($result === NOERR) {
|
||||
returnData('string', array('type' => 'string', 'data' => __('Correct module enable')));
|
||||
}
|
||||
else {
|
||||
|
@ -5425,7 +5429,10 @@ function api_set_disable_alert ($agent_name, $module_name, $template_name, $thra
|
|||
$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
|
||||
$id_template = db_get_value_filter('id', 'talert_templates', array('name' => $template_name["data"]));
|
||||
|
||||
db_process_sql("UPDATE talert_template_modules SET disabled = 1 WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template");
|
||||
db_process_sql("UPDATE talert_template_modules
|
||||
SET disabled = 1
|
||||
WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template");
|
||||
|
||||
returnData('string', array('type' => 'string', 'data' => "Correct alert disable"));
|
||||
}
|
||||
|
||||
|
@ -5446,7 +5453,10 @@ function api_set_enable_alert ($agent_name, $module_name, $template_name, $thras
|
|||
$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
|
||||
$id_template = db_get_value_filter('id', 'talert_templates', array('name' => $template_name["data"]));
|
||||
|
||||
db_process_sql("UPDATE talert_template_modules SET disabled = 0 WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template");
|
||||
db_process_sql("UPDATE talert_template_modules
|
||||
SET disabled = 0
|
||||
WHERE id_agent_module = $id_agent_module AND id_alert_template = $id_template");
|
||||
|
||||
returnData('string', array('type' => 'string', 'data' => "Correct alert enable"));
|
||||
}
|
||||
|
||||
|
@ -5466,7 +5476,10 @@ function api_set_disable_module_alerts ($agent_name, $module_name, $thrash3, $th
|
|||
$id_agent = agents_get_agent_id($agent_name);
|
||||
$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
|
||||
|
||||
db_process_sql("UPDATE talert_template_modules SET disabled = 1 WHERE id_agent_module = $id_agent_module");
|
||||
db_process_sql("UPDATE talert_template_modules
|
||||
SET disabled = 1
|
||||
WHERE id_agent_module = $id_agent_module");
|
||||
|
||||
returnData('string', array('type' => 'string', 'data' => "Correct alerts disable"));
|
||||
}
|
||||
|
||||
|
@ -5486,7 +5499,10 @@ function api_set_enable_module_alerts ($agent_name, $module_name, $thrash3, $thr
|
|||
$id_agent = agents_get_agent_id($agent_name);
|
||||
$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
|
||||
|
||||
db_process_sql("UPDATE talert_template_modules SET disabled = 0 WHERE id_agent_module = $id_agent_module");
|
||||
db_process_sql("UPDATE talert_template_modules
|
||||
SET disabled = 0
|
||||
WHERE id_agent_module = $id_agent_module");
|
||||
|
||||
returnData('string', array('type' => 'string', 'data' => "Correct alerts enable"));
|
||||
}
|
||||
|
||||
|
@ -5526,7 +5542,8 @@ function get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) {
|
|||
// http://localhost/pandora_console/include/api.php?op=get&op2=total_modules&id=1&apipass=1234&user=admin&pass=pandora
|
||||
function api_get_total_modules($id_group, $trash1, $trash2, $returnType) {
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM tagente_modulo
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM tagente_modulo
|
||||
WHERE id_module_group=$id_group";
|
||||
|
||||
$total = db_get_value_sql($sql);
|
||||
|
@ -5545,7 +5562,9 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType) {
|
|||
// http://localhost/pandora_console/include/api.php?op=get&op2=total_agents&id=2&apipass=1234&user=admin&pass=pandora
|
||||
function api_get_total_agents($id_group, $trash1, $trash2, $returnType) {
|
||||
|
||||
$sql = sprintf('SELECT COUNT(*) FROM tagente WHERE id_grupo=%d AND disabled=0', $id_group);
|
||||
$sql = sprintf('SELECT COUNT(*)
|
||||
FROM tagente
|
||||
WHERE id_grupo=%d AND disabled=0', $id_group);
|
||||
$total_agents = db_get_value_sql($sql);
|
||||
|
||||
$data = array('type' => 'string', 'data' => $total_agents);
|
||||
|
@ -5561,7 +5580,9 @@ function api_get_total_agents($id_group, $trash1, $trash2, $returnType) {
|
|||
// http://localhost/pandora_console/include/api.php?op=get&op2=agent_name&id=1&apipass=1234&user=admin&pass=pandora
|
||||
function api_get_agent_name($id_agent, $trash1, $trash2, $returnType) {
|
||||
|
||||
$sql = sprintf('SELECT nombre FROM tagente WHERE id_agente = %d', $id_agent);
|
||||
$sql = sprintf('SELECT nombre
|
||||
FROM tagente
|
||||
WHERE id_agente = %d', $id_agent);
|
||||
$value = db_get_value_sql($sql);
|
||||
if ($value === false) {
|
||||
returnError('id_not_found', $returnType);
|
||||
|
@ -5595,9 +5616,11 @@ function api_get_module_name($id_module, $trash1, $trash2, $returnType) {
|
|||
// http://localhost/pandora_console/include/api.php?op=get&op2=alert_action_by_group&id=3&id2=1&apipass=1234&user=admin&pass=pandora
|
||||
function api_get_alert_action_by_group($id_group, $id_action, $trash2, $returnType) {
|
||||
|
||||
$sql = "SELECT SUM(internal_counter) FROM talert_template_modules
|
||||
$sql = "SELECT SUM(internal_counter)
|
||||
FROM talert_template_modules
|
||||
WHERE id_alert_template IN
|
||||
(SELECT id FROM talert_templates
|
||||
(SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_group=$id_group AND id_alert_action = $id_action)";
|
||||
|
||||
$value = db_get_value_sql($sql);
|
||||
|
@ -5622,12 +5645,6 @@ function api_get_event_info($id_event, $trash1, $trash, $returnType) {
|
|||
|
||||
$i = 0;
|
||||
foreach ($event_data as $key => $data) {
|
||||
/*
|
||||
if ($i == 0)
|
||||
$result = $data;
|
||||
else
|
||||
$result .= ';'.$data;
|
||||
*/
|
||||
if ($i == 0)
|
||||
$result = $key.': '.$data.'<br>';
|
||||
else
|
||||
|
@ -5654,28 +5671,32 @@ function api_set_create_event($id, $trash1, $other, $returnType) {
|
|||
|
||||
if ($other['data'][0] != '') {
|
||||
$values['event'] = $other['data'][0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
returnError('error_parameter', 'Event text required.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][1] != '') {
|
||||
$values['id_grupo'] = $other['data'][1];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
returnError('error_parameter', 'Group ID required.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][2] != '') {
|
||||
$values['id_agente'] = $other['data'][2];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
returnError('error_parameter', 'Agent ID required.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][3] != '') {
|
||||
$values['status'] = $other['data'][3];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['status'] = 0;
|
||||
}
|
||||
|
||||
|
@ -5683,55 +5704,64 @@ function api_set_create_event($id, $trash1, $other, $returnType) {
|
|||
|
||||
if ($other['data'][5] != '') {
|
||||
$values['event_type'] = $other['data'][5];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['event_type'] = "unknown";
|
||||
}
|
||||
|
||||
if ($other['data'][6] != '') {
|
||||
$values['priority'] = $other['data'][6];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['priority'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][7] != '') {
|
||||
$values['id_agentmodule'] = $other['data'][7];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$value['id_agentemodule'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][8] != '') {
|
||||
$values['id_alert_am'] = $other['data'][8];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['id_alert_am'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][9] != '') {
|
||||
$values['critical_instructions'] = $other['data'][9];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['critical_instructions'] = '';
|
||||
}
|
||||
|
||||
if ($other['data'][10] != '') {
|
||||
$values['warning_instructions'] = $other['data'][10];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['warning_instructions'] = '';
|
||||
}
|
||||
|
||||
if ($other['data'][11] != '') {
|
||||
$values['unknown_instructions'] = $other['data'][11];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['unknown_instructions'] = '';
|
||||
}
|
||||
|
||||
if ($other['data'][14] != '') {
|
||||
$values['source'] = $other['data'][14];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['source'] = "Pandora";
|
||||
}
|
||||
|
||||
if ($other['data'][15] != '') {
|
||||
$values['tags'] = $other['data'][15];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$values['tags'] = "";
|
||||
}
|
||||
|
||||
|
|
|
@ -329,9 +329,10 @@ function extensions_add_godmode_menu_option ($name, $acl, $fatherId = null, $ico
|
|||
global $config;
|
||||
global $extension_file;
|
||||
|
||||
/* $config['extension_file'] is set in extensions_load_extensions(), since that function must
|
||||
be called before any function the extension call, we are sure it will
|
||||
be set. */
|
||||
/*
|
||||
$config['extension_file'] is set in extensions_load_extensions(),
|
||||
since that function must be called before any function the extension
|
||||
call, we are sure it will be set. */
|
||||
$option_menu['acl'] = $acl;
|
||||
$option_menu['name'] = $name;
|
||||
$extension = &$config['extensions'][$extension_file];
|
||||
|
|
Loading…
Reference in New Issue