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

* 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
This commit is contained in:
mdtrooper 2013-07-29 17:13:52 +00:00
parent f87510b3a8
commit 66b64b302b
3 changed files with 27 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2013-07-29 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php: a lot of tiny fixes.
* extensions/api_checker.php: some fixes.
2013-07-29 Miguel de Dios <miguel.dedios@artica.es>
* extensions/api_checker.php: a tiny extension to make more easy

View File

@ -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();

View File

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