From d343cc4c38f1c64c180dcaae9c4209fb066ef15d Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 29 Jul 2013 17:13:52 +0000 Subject: [PATCH] 2013-07-29 Miguel de Dios * include/functions_api.php: a lot of tiny fixes. * extensions/api_checker.php: some fixes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8591 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++ pandora_console/extensions/api_checker.php | 7 +++-- pandora_console/include/functions_api.php | 32 ++++++++++++---------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6bdd2ebf8b..d5d19e32e7 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2013-07-29 Miguel de Dios + + * include/functions_api.php: a lot of tiny fixes. + + * extensions/api_checker.php: some fixes. + 2013-07-29 Miguel de Dios * extensions/api_checker.php: a tiny extension to make more easy diff --git a/pandora_console/extensions/api_checker.php b/pandora_console/extensions/api_checker.php index 8a1a160799..8714f7c922 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -68,7 +68,7 @@ function extension_api_checker() { $id2 = io_safe_output(get_parameter('id2', '')); $return_type = io_safe_output(get_parameter('return_type', '')); $other = io_safe_output(get_parameter('other', '')); - $other_mode = io_safe_output(get_parameter('other', 'url_encode_separator_|')); + $other_mode = io_safe_output(get_parameter('other_mode', 'url_encode_separator_|')); $api_execute = get_parameter('api_execute', 0); @@ -76,7 +76,8 @@ function extension_api_checker() { if ($api_execute) { $return_call_api = api_execute($url, $ip, $pandora_url, $apipass, $user, $password, - $op, $op2, $id, $id2, $return_type, $other, $other_mode); + $op, $op2, urlencode($id), urlencode($id2), + $return_type, urlencode($other), $other_mode); } ui_print_page_header (__("API checker"), @@ -130,7 +131,7 @@ function extension_api_checker() { $row = array(); $row[] = __("ID 2"); - $row[] = html_print_input_text('id', $id2, '', 50, 255, true); + $row[] = html_print_input_text('id2', $id2, '', 50, 255, true); $table2->data[] = $row; $row = array(); diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8ae99cbd6e..e65b7e4b2b 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -81,8 +81,8 @@ function returnError($typeError, $returnType = 'string') { array('type' => 'string', 'data' => __('Id does not exist in BD.'))); break; default: - returnData($returnType, - array('type' => 'string', 'data' => __($typeError))); + returnData("string", + array('type' => 'string', 'data' => __($returnType))); break; } } @@ -100,8 +100,10 @@ function returnData($returnType, $data, $separator = ';') { case 'string': if ($data['type'] == 'string') { echo $data['data']; - } else - ;//TODO + } + else { + //TODO + } break; case 'csv': case 'csv_head': @@ -4024,15 +4026,15 @@ function api_get_graph_module_data($id, $thrash1, $other, $thrash2) { $config['flash_charts'] = 0; $image = grafico_modulo_sparse ($id, $period, $draw_events, - $width, $height , '',null, - $draw_alerts, $avg_only, false, - $date, '', 0, 0,true, - false, $homeurl, $ttl); - + $width, $height , '',null, + $draw_alerts, $avg_only, false, + $date, '', 0, 0,true, + false, $homeurl, $ttl); + // Extract url of the image from img tag preg_match("/src='([^']*)'/i",$image, $match); - - if(empty($match[1])) { + + if (empty($match[1])) { echo "Error getting graph"; } else { @@ -4576,7 +4578,7 @@ function api_set_new_module($id, $id2, $other, $trash1) { } $values['id_modulo'] = 2; - + $return = modules_create_agent_module($values['id_agente'], $values['nombre'], $values); $data['type'] = 'string'; @@ -4587,7 +4589,7 @@ function api_set_new_module($id, $id2, $other, $trash1) { $data['data'] = $return; } returnData('string', $data); - return; + return; } } @@ -4813,7 +4815,7 @@ function api_set_event_validate_filter_pro($trash1, $trash2, $other, $trash3) { } else if ($other['type'] == 'array') { $filter = array(); - + if (($other['data'][1] != null) && ($other['data'][1] != -1) && ($other['data'][1] != '')) { $filter['criticity'] = $other['data'][1]; } @@ -5546,7 +5548,7 @@ function api_set_enable_module_alerts ($agent_name, $module_name, $thrash3, $thr returnData('string', array('type' => 'string', 'data' => "Correct alerts enable")); } -function get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) { +function api_get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) { if ($other['type'] == 'string') { if ($other['data'] != '') { returnError('error_parameter', 'Error in the parameters.');