2012-02-14 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_config.php, godmode/setup/setup.php extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql: fixed the list of ACL ip in the table tconfig, before the data was in several rows, now it is in one row, and of course I have made in the SQL for the migration. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5594 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
27966c1e05
commit
4fc57e4a87
|
@ -153,3 +153,7 @@ PRIMARY KEY (`id_filter`)
|
|||
-- Table `tconfig`
|
||||
-- -----------------------------------------------------
|
||||
ALTER TABLE tconfig MODIFY value TEXT NOT NULL;
|
||||
--Join the all ips of "list_ACL_IPs_for_API_%" in one row (now We have a field "value" with hudge size)
|
||||
INSERT INTO tconfig (token, `value`) SELECT 'list_ACL_IPs_for_API', GROUP_CONCAT(`value` SEPARATOR ';') AS `value` FROM tconfig WHERE token LIKE "list_ACL_IPs_for_API%";
|
||||
DELETE FROM tconfig WHERE token LIKE "list_ACL_IPs_for_API_%";
|
||||
|
||||
|
|
|
@ -120,38 +120,40 @@ $table->data[19][0] = __('Enable Netflow');
|
|||
$table->data[19][1] = __('Yes').' '.html_print_radio_button ('activate_netflow', 1, '', $config["activate_netflow"], true).' ';
|
||||
$table->data[19][1] .= __('No').' '.html_print_radio_button ('activate_netflow', 0, '', $config["activate_netflow"], 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;
|
||||
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();
|
||||
if (empty($invent)) {
|
||||
$bad_input = true;
|
||||
}
|
||||
|
||||
$inventories = array();
|
||||
// Right connection but theres is no inventories
|
||||
if ($invent == 'false'){
|
||||
if ($invent == 'false') {
|
||||
unset($invent);
|
||||
$invent = array();
|
||||
}
|
||||
// Checks if URL is right
|
||||
else{
|
||||
else {
|
||||
$invent = explode("\n",$invent);
|
||||
}
|
||||
// Wrong URL
|
||||
if ((strripos($config['integria_url'], '.php') !== false)){
|
||||
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;
|
||||
}
|
||||
}
|
||||
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[20][0] = __('Integria URL') . ui_print_help_icon ("integria_url", true);
|
||||
$table->data[20][1] = html_print_input_text ('integria_url', $config["integria_url"], '', 25, 255, true);
|
||||
|
@ -163,16 +165,17 @@ if($config["integria_enabled"]) {
|
|||
$table->data[21][0] = __('Integria API password');
|
||||
$table->data[21][1] = html_print_input_text ('integria_api_password', $config["integria_api_password"], '', 25, 25, true);
|
||||
|
||||
if (!$bad_input){
|
||||
foreach($invent as $inv) {
|
||||
if($inv == '') {
|
||||
if (!$bad_input) {
|
||||
foreach ($invent as $inv) {
|
||||
if ($inv == '') {
|
||||
continue;
|
||||
}
|
||||
$invexp = explode(',',$inv);
|
||||
if(substr($invexp[1], 0, 1) == '"' && substr($invexp[1], strlen($invexp[1])-1, 1) == '"') {
|
||||
if (substr($invexp[1], 0, 1) == '"'
|
||||
&& substr($invexp[1], strlen($invexp[1])-1, 1) == '"') {
|
||||
$invexp[1] = substr($invexp[1], 1, strlen($invexp[1])-2);
|
||||
}
|
||||
|
||||
|
||||
$inventories[$invexp[0]] = $invexp[1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,57 +46,11 @@ function config_update_value ($token, $value) {
|
|||
|
||||
switch ($token) {
|
||||
case 'list_ACL_IPs_for_API':
|
||||
$rows = db_get_all_rows_sql("SELECT id_config
|
||||
FROM tconfig
|
||||
WHERE token LIKE '%list_ACL_IPs_for_API_%'");
|
||||
|
||||
if ($rows !== false) {
|
||||
foreach ($rows as $row)
|
||||
$idListACLofIP[] = $row['id_config'];
|
||||
|
||||
db_process_sql_delete('tconfig', 'id_config IN (' . implode(',', $idListACLofIP) . ')' );
|
||||
}
|
||||
|
||||
$value = io_safe_output($value);
|
||||
|
||||
if (strpos($value, "\r\n") !== false)
|
||||
$ips = explode("\r\n", $value);
|
||||
else
|
||||
$ips = explode("\n", $value);
|
||||
|
||||
$valueDB = '';
|
||||
$count = 0;
|
||||
$lastInsert = false;
|
||||
foreach ($ips as $ip) {
|
||||
$ip = trim($ip);
|
||||
|
||||
$lastInsert = false;
|
||||
if (strlen($valueDB . ';' . $ip) < 100) {
|
||||
//100 is the size of field 'value' in tconfig.
|
||||
if (strlen($valueDB) == 0)
|
||||
$valueDB .= $ip;
|
||||
else
|
||||
$valueDB .= ';' . $ip;
|
||||
}
|
||||
else {
|
||||
if (strlen($ip) > 100)
|
||||
return false;
|
||||
|
||||
db_process_sql_insert('tconfig',
|
||||
array('token' => 'list_ACL_IPs_for_API_' . $count , 'value' => $valueDB));
|
||||
$valueDB = $ip;
|
||||
$count++;
|
||||
$lastInsert = true;
|
||||
}
|
||||
}
|
||||
if (!$lastInsert)
|
||||
db_process_sql_insert('tconfig',
|
||||
array('token' => 'list_ACL_IPs_for_API_' . $count , 'value' => $valueDB));
|
||||
|
||||
return (bool) config_create_value ($token, $value);
|
||||
break;
|
||||
default:
|
||||
if (!isset ($config[$token])){
|
||||
$config[$token] = $value;
|
||||
if (!isset ($config[$token])) {
|
||||
$config[$token] = $value;
|
||||
return (bool) config_create_value ($token, $value);
|
||||
}
|
||||
|
||||
|
@ -389,25 +343,18 @@ function config_process_config () {
|
|||
if (!isset ($config["font_size"])) {
|
||||
config_update_value ('font_size', 7);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*Parse the ACL IP list for access API that it's save in chunks as
|
||||
*list_ACL_IPs_for_API_<num>, because the value has a limit of 100
|
||||
*characters.
|
||||
*Parse the ACL IP list for access API
|
||||
*/
|
||||
|
||||
$config['list_ACL_IPs_for_API'] = array();
|
||||
$temp_list_ACL_IPs_for_API = array();
|
||||
if (isset($config['list_ACL_IPs_for_API'])) {
|
||||
$temp_list_ACL_IPs_for_API = explode(';', $config['list_ACL_IPs_for_API']);
|
||||
}
|
||||
$config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API;
|
||||
$keysConfig = array_keys($config);
|
||||
foreach($keysConfig as $keyConfig)
|
||||
if (strpos($keyConfig, 'list_ACL_IPs_for_API_') !== false) {
|
||||
$ips = explode(';',$config[$keyConfig]);
|
||||
$config['list_ACL_IPs_for_API'] =
|
||||
array_merge($config['list_ACL_IPs_for_API'], $ips);
|
||||
|
||||
unset($config[$keyConfig]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This is not set here. The first time, when no
|
||||
// setup is done, update_manager extension manage it
|
||||
// the first time make a conenction and disable itself
|
||||
|
|
Loading…
Reference in New Issue