diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 5097006de..a3e6223f6 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -2,6 +2,7 @@ // Observium Includes include_once($config['install_dir'] . "/includes/dbFacile.php"); +include_once($config['install_dir'] . "/includes/mergecnf.inc.php"); // Connect to database $database_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']); @@ -13,53 +14,6 @@ if (!$database_link) } $database_db = mysql_select_db($config['db_name'], $database_link); -function mergecnf($obj) { -/* Copyright (C) 2014 Daniel Preussker - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ - -/** - * Merge config function - * @author f0o - * @copyright 2015 f0o, LibreNMS - * @license GPL - * @package LibreNMS - * @subpackage Config - */ - - $pointer = array(); - $val = $obj['config_value']; - $obj = $obj['config_name']; - $obj = explode('.',$obj,2); - if( !isset($obj[1]) ) { - if( filter_var($val,FILTER_VALIDATE_INT) ) { - $val = (int) $val; - } elseif( filter_var($val,FILTER_VALIDATE_FLOAT) ) { - $val = (float) $val; - } elseif( filter_var($val,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) !== NULL ) { - $val = filter_var($val,FILTER_VALIDATE_BOOLEAN); - } - if( !empty($obj[0]) ) { - return array($obj[0] => $val); - } else { - return array($val); - } - } else { - $pointer[$obj[0]] = mergecnf(array('config_name'=>$obj[1],'config_value'=>$val)); - } - return $pointer; -} - $clone = $config; foreach( dbFetchRows('select config_name,config_value from config') as $obj ) { $clone = array_replace_recursive($clone,mergecnf($obj)); diff --git a/includes/mergecnf.inc.php b/includes/mergecnf.inc.php new file mode 100644 index 000000000..05514cc4b --- /dev/null +++ b/includes/mergecnf.inc.php @@ -0,0 +1,47 @@ + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/** + * Merge config function + * @author f0o + * @copyright 2015 f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Config + */ + +function mergecnf($obj) { + $pointer = array(); + $val = $obj['config_value']; + $obj = $obj['config_name']; + $obj = explode('.',$obj,2); + if( !isset($obj[1]) ) { + if( filter_var($val,FILTER_VALIDATE_INT) ) { + $val = (int) $val; + } elseif( filter_var($val,FILTER_VALIDATE_FLOAT) ) { + $val = (float) $val; + } elseif( filter_var($val,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) !== NULL ) { + $val = filter_var($val,FILTER_VALIDATE_BOOLEAN); + } + if( !empty($obj[0]) ) { + return array($obj[0] => $val); + } else { + return array($val); + } + } else { + $pointer[$obj[0]] = mergecnf(array('config_name'=>$obj[1],'config_value'=>$val)); + } + return $pointer; +}