From a4e76728acf4947869818cbd0d669c09568e4f66 Mon Sep 17 00:00:00 2001 From: vgilc Date: Tue, 18 Sep 2012 09:08:21 +0000 Subject: [PATCH] 2012-09-18 Vanessa Gil * include/functions_api.php: Fixed bug creating new agent. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6981 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++++ pandora_console/include/functions_api.php | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 60767618db..2ce88ba28f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2012-09-18 Vanessa Gil + + * include/functions_api.php: Fixed bug creating + new agent. + 2012-09-18 Sergio Martin * include/functions_graph.php diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 11f09abab1..ea7f18e5a2 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -683,11 +683,11 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType) * @param $thrash1 Don't use. * @param $thrash2 Don't use. * @param array $other it's array, $other as param is ;;;; - * ;;;;;;; in this order + * ;;;;;;; in this order * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_) * example: * - * api.php?op=set&op2=new_agent&other=pepito|1.1.1.1|0|4|0|30|8|miguel-portatil||0|0|nose%20nose&other_mode=url_encode_separator_| + * api.php?op=set&op2=new_agent&other=pepito|1.1.1.1|0|4|0|30|8|10||0|0|nose%20nose&other_mode=url_encode_separator_| * * @param $thrash3 Don't use. */ @@ -701,7 +701,7 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) { $cascadeProtection = $other['data'][4]; $intervalSeconds = $other['data'][5]; $idOS = $other['data'][6]; - $nameServer = $other['data'][7]; + $idServer = $other['data'][7]; $customId = $other['data'][8]; $learningMode = $other['data'][9]; $disabled = $other['data'][10]; @@ -709,14 +709,16 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) { switch ($config["dbtype"]) { case "mysql": - $sql1 = 'SELECT name FROM tserver WHERE name LIKE "' . $nameServer . '"'; + $sql1 = 'SELECT name FROM tserver WHERE id_server ='. $idServer; break; case "postgresql": case "oracle": - $sql1 = 'SELECT name FROM tserver WHERE name LIKE \'' . $nameServer . '\''; + $sql1 = 'SELECT name FROM tserver WHERE id_server ='. $idServer; break; } + $nameServer = db_get_value_sql($sql1); + if (agents_get_agent_id ($name)) { returnError('agent_name_exist', 'The name of agent yet exist in DB.'); }