mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
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
3d00a76422
commit
345db8c2b4
@ -153,3 +153,7 @@ PRIMARY KEY (`id_filter`)
|
|||||||
-- Table `tconfig`
|
-- Table `tconfig`
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
ALTER TABLE tconfig MODIFY value TEXT NOT NULL;
|
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_%";
|
||||||
|
|
||||||
|
@ -146,7 +146,9 @@ if($config["integria_enabled"]) {
|
|||||||
// Check page result and detect errors
|
// Check page result and detect errors
|
||||||
else {
|
else {
|
||||||
foreach ($invent as $inv) {
|
foreach ($invent as $inv) {
|
||||||
if ((stristr($inv, 'ERROR 404') !== false) OR (stristr($inv, 'Status 404') !== false) OR (stristr($inv, 'Internal Server Error') !== false)){
|
if ((stristr($inv, 'ERROR 404') !== false)
|
||||||
|
OR (stristr($inv, 'Status 404') !== false)
|
||||||
|
OR (stristr($inv, 'Internal Server Error') !== false)) {
|
||||||
$inventories[""] = __('None');
|
$inventories[""] = __('None');
|
||||||
$bad_input = true;
|
$bad_input = true;
|
||||||
break;
|
break;
|
||||||
@ -169,7 +171,8 @@ if($config["integria_enabled"]) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$invexp = explode(',',$inv);
|
$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);
|
$invexp[1] = substr($invexp[1], 1, strlen($invexp[1])-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,53 +46,7 @@ function config_update_value ($token, $value) {
|
|||||||
|
|
||||||
switch ($token) {
|
switch ($token) {
|
||||||
case 'list_ACL_IPs_for_API':
|
case 'list_ACL_IPs_for_API':
|
||||||
$rows = db_get_all_rows_sql("SELECT id_config
|
return (bool) config_create_value ($token, $value);
|
||||||
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));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!isset ($config[$token])) {
|
if (!isset ($config[$token])) {
|
||||||
@ -391,21 +345,14 @@ function config_process_config () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*Parse the ACL IP list for access API that it's save in chunks as
|
*Parse the ACL IP list for access API
|
||||||
*list_ACL_IPs_for_API_<num>, because the value has a limit of 100
|
|
||||||
*characters.
|
|
||||||
*/
|
*/
|
||||||
|
$temp_list_ACL_IPs_for_API = array();
|
||||||
$config['list_ACL_IPs_for_API'] = array();
|
if (isset($config['list_ACL_IPs_for_API'])) {
|
||||||
$keysConfig = array_keys($config);
|
$temp_list_ACL_IPs_for_API = explode(';', $config['list_ACL_IPs_for_API']);
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
|
$config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API;
|
||||||
|
$keysConfig = array_keys($config);
|
||||||
|
|
||||||
|
|
||||||
// This is not set here. The first time, when no
|
// This is not set here. The first time, when no
|
||||||
|
Loading…
x
Reference in New Issue
Block a user