$section) { foreach($section as $key => $value) { // Skip unknown sections and keys if(array_key_exists($header, Configuration::$config) && array_key_exists($key, Configuration::$config[$header])) { Configuration::$config[$header][$key] = $value; } } } } if(!is_string(self::getConfig('system', 'timezone')) || !in_array(self::getConfig('system', 'timezone'), timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) die('Parameter [system] => "timezone" is invalid! Please check ' . FILE_CONFIG); date_default_timezone_set(self::getConfig('system', 'timezone')); if(!is_string(self::getConfig('proxy', 'url'))) die('Parameter [proxy] => "url" is not a valid string! Please check ' . FILE_CONFIG); if(!empty(self::getConfig('proxy', 'url'))) { /** URL of the proxy server */ define('PROXY_URL', self::getConfig('proxy', 'url')); } if(!is_bool(self::getConfig('proxy', 'by_bridge'))) die('Parameter [proxy] => "by_bridge" is not a valid Boolean! Please check ' . FILE_CONFIG); /** True if proxy usage can be enabled selectively for each bridge */ define('PROXY_BYBRIDGE', self::getConfig('proxy', 'by_bridge')); if(!is_string(self::getConfig('proxy', 'name'))) die('Parameter [proxy] => "name" is not a valid string! Please check ' . FILE_CONFIG); /** Name of the proxy server */ define('PROXY_NAME', self::getConfig('proxy', 'name')); if(!is_string(self::getConfig('cache', 'type'))) die('Parameter [cache] => "type" is not a valid string! Please check ' . FILE_CONFIG); if(!is_bool(self::getConfig('cache', 'custom_timeout'))) die('Parameter [cache] => "custom_timeout" is not a valid Boolean! Please check ' . FILE_CONFIG); /** True if the cache timeout can be specified by the user */ define('CUSTOM_CACHE_TIMEOUT', self::getConfig('cache', 'custom_timeout')); if(!is_bool(self::getConfig('authentication', 'enable'))) die('Parameter [authentication] => "enable" is not a valid Boolean! Please check ' . FILE_CONFIG); if(!is_string(self::getConfig('authentication', 'username'))) die('Parameter [authentication] => "username" is not a valid string! Please check ' . FILE_CONFIG); if(!is_string(self::getConfig('authentication', 'password'))) die('Parameter [authentication] => "password" is not a valid string! Please check ' . FILE_CONFIG); if(!empty(self::getConfig('admin', 'email')) && !filter_var(self::getConfig('admin', 'email'), FILTER_VALIDATE_EMAIL)) die('Parameter [admin] => "email" is not a valid email address! Please check ' . FILE_CONFIG); } /** * Returns the value of a parameter identified by section and key. * * @param string $section The section name. * @param string $key The property name (key). * @return mixed|null The parameter value. */ public static function getConfig($section, $key) { if(array_key_exists($section, self::$config) && array_key_exists($key, self::$config[$section])) { return self::$config[$section][$key]; } return null; } /** * Returns the current version string of RSS-Bridge. * * This function returns the contents of {@see Configuration::$VERSION} for * regular installations and the git branch name and commit id for instances * running in a git environment. * * @return string The version string. */ public static function getVersion() { $headFile = PATH_ROOT . '.git/HEAD'; // '@' is used to mute open_basedir warning if(@is_readable($headFile)) { $revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1); $branchName = explode('/', $revisionHashFile)[3]; if(file_exists($revisionHashFile)) { return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7); } } return Configuration::$VERSION; } }