From 691ec9c6bdff36daf783dd860abe5bcecad32625 Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Wed, 7 Sep 2011 08:49:22 +0000 Subject: [PATCH] 2011-09-07 Juan Manuel Ramon * godmode/setup/setup.php: Url and Integria password are checked and it is showed at advise in case of error. Fixes: #3396567 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4926 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++++ pandora_console/godmode/setup/setup.php | 53 ++++++++++++++++++------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 94cd43ffb1..8f9d1b6890 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2011-09-07 Juan Manuel Ramon + + * godmode/setup/setup.php: Url and Integria password are checked and + it is showed at advise in case of error. + + Fixes: #3396567 + 2011-09-06 Miguel de Dios * general/pandora_help.php: changet the text align of footer. diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 39f3b36548..6d0d4f6c0e 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -124,26 +124,49 @@ $table->data[18][1] = __('Yes').' '.html_print_radio_button ('integria_enab $table->data[18][1] .= __('No').' '.html_print_radio_button ('integria_enabled', 0, '', $config["integria_enabled"], true); if($config["integria_enabled"]) { + require_once('include/functions_incidents.php'); + $invent = incidents_call_api($config['integria_url']."/include/api.php?user=".$config['id_user']."&pass=".$config['integria_api_password']."&op=get_inventories"); + $bad_input = false; + // Wrong connection to api, bad password + if (empty($invent)){ + $bad_input = true; + } + + $inventories = array(); + // Right connection but theres is no inventories + if ($invent == 'false'){ + unset($invent); + $invent = array(); + } + // Checks if URL is right + else{ + $invent = explode("\n",$invent); + } + // Wrong URL + if ((strripos($config['integria_url'], '.php') !== false)){ + $bad_input = true; + } + // Check page result and detect errors + else{ + foreach($invent as $inv){ + if ((stristr($inv, 'ERROR 404') !== false) OR (stristr($inv, 'Status 404') !== false) OR (stristr($inv, 'Internal Server Error') !== false)){ + $inventories[""] = __('None'); + $bad_input = true; + break; + } + } + } $table->data[19][0] = __('Integria URL'); - $table->data[19][1] = html_print_input_text ('integria_url', $config["integria_url"], '', 25, 255, true); + $table->data[19][1] = html_print_input_text ('integria_url', $config["integria_url"], '', 25, 255, true); + // If something goes wrong + if ($bad_input){ + $table->data[19][1] .= html_print_image('images/error.png', true, array('title' => __('URL and/or Integria password are incorrect'))); + } $table->data[20][0] = __('Integria API password'); $table->data[20][1] = html_print_input_text ('integria_api_password', $config["integria_api_password"], '', 25, 25, true); - require_once('include/functions_incidents.php'); - $invent = incidents_call_api($config['integria_url']."/include/api.php?user=".$config['id_user']."&pass=".$config['integria_api_password']."&op=get_inventories"); - $invent = explode("\n",$invent); - $inventories = array(); - $bad_input = false; - foreach($invent as $inv){ - // This avoid wrong integria inventory object - if (stristr($inv, 'ERROR 404') !== false){ - $inventories[""] = __('None'); - $bad_input = true; - break; - } - } - if (!$bad_input){ + if (!$bad_input){ foreach($invent as $inv) { if($inv == '') { continue;