diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index db284dba58..61ce05d265 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-06-08 Junichi Satoh + + * include/functions_config.php, godmode/setup/setup.php: Fixed that + ACL with API access cannot be removed after once configured. (Merged + from 4.0.2) + Fixed multiple recording of list_ACL_IPs_for_API. + 2012-06-07 Miguel de Dios * godmode/reporting/visual_console_builder.wizard.php, diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 48ce02ad61..1e3986c931 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -120,7 +120,12 @@ $table->data[14][0] = __('Attachment store') . ui_print_help_tip (__("Directory $table->data[14][1] = html_print_input_text ('attachment_store', $config["attachment_store"], '', 50, 255, true); $table->data[15][0] = __('IP list with API access') . ui_print_help_icon ("ip_api_list", true); -$list_ACL_IPs_for_API = get_parameter('list_ACL_IPs_for_API', implode("\n", $config['list_ACL_IPs_for_API'])); +if (isset($_POST["list_ACL_IPs_for_API"])) { + $list_ACL_IPs_for_API = get_parameter_post('list_ACL_IPs_for_API'); +} +else { + $list_ACL_IPs_for_API = get_parameter_get('list_ACL_IPs_for_API', implode("\n", $config['list_ACL_IPs_for_API'])); +} $table->data[15][1] = html_print_textarea('list_ACL_IPs_for_API', 2, 25, $list_ACL_IPs_for_API, 'style="height: 50px; width: 300px"', true); $table->data[16][0] = __('API password') . diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 4e535401d0..de47d12c0f 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -44,27 +44,23 @@ function config_create_value ($token, $value) { function config_update_value ($token, $value) { global $config; - switch ($token) { - case 'list_ACL_IPs_for_API': - return (bool) config_create_value ($token, $value); - break; - default: - if (!isset ($config[$token])) { - $config[$token] = $value; - return (bool) config_create_value ($token, $value); - } - - /* If it has not changed */ - if ($config[$token] == $value) - return true; - - $config[$token] = $value; - - return (bool) db_process_sql_update ('tconfig', - array ('value' => $value), - array ('token' => $token)); - break; + if ($token == 'list_ACL_IPs_for_API') + $value = str_replace(array("\r\n", "\r", "\n"), ";", io_safe_output($value)); + + if (!isset ($config[$token])) { + $config[$token] = $value; + return (bool) config_create_value ($token, $value); } + + /* If it has not changed */ + if ($config[$token] == $value) + return true; + + $config[$token] = $value; + + return (bool) db_process_sql_update ('tconfig', + array ('value' => $value), + array ('token' => $token)); } /** @@ -128,7 +124,7 @@ function config_update_config () { config_update_value ('agentaccess', (int) get_parameter ('agentaccess', $config['agentaccess'])); config_update_value ('flash_charts', (bool) get_parameter ('flash_charts', $config["flash_charts"])); config_update_value ('attachment_store', (string) get_parameter ('attachment_store', $config["attachment_store"])); - config_update_value ('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API', implode("\n", $config['list_ACL_IPs_for_API']))); + config_update_value ('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API')); config_update_value ('custom_logo', (string) get_parameter ('custom_logo', $config["custom_logo"])); config_update_value ('history_db_enabled', (bool) get_parameter ('history_db_enabled', $config['history_db_enabled']));