Server : Apache/2.4.41 (Ubuntu) System : Linux journalup 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/lib/pkp/classes/config/ |
<?php /** * @defgroup config Config * Implements configuration concerns such as the configuration file parser. */ /** * @file classes/config/Config.inc.php * * Copyright (c) 2014-2020 Simon Fraser University * Copyright (c) 2000-2020 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class Config * @ingroup config * * @brief Config class for accessing configuration parameters. */ /** The path to the default configuration file */ define('CONFIG_FILE', Core::getBaseDir() . DIRECTORY_SEPARATOR . 'config.inc.php'); import('lib.pkp.classes.config.ConfigParser'); class Config { /** * Retrieve a specified configuration variable. * @param $section string * @param $key string * @param $default mixed Optional default if the var doesn't exist * @return mixed May return boolean (in case of "off"/"on"/etc), numeric, string, or null. */ static function getVar($section, $key, $default = null) { $configData =& Config::getData(); return isset($configData[$section][$key]) ? $configData[$section][$key] : $default; } /** * Get the current configuration data. * @return array the configuration data */ static function &getData() { $configData =& Registry::get('configData', true, null); if ($configData === null) { // Load configuration data only once per request, implicitly // sets config data by ref in the registry. $configData = Config::reloadData(); } return $configData; } /** * Load configuration data from a file. * The file is assumed to be formatted in php.ini style. * @return array the configuration data */ static function &reloadData() { if (($configData =& ConfigParser::readConfig(Config::getConfigFileName())) === false) { fatalError(sprintf('Cannot read configuration file %s', Config::getConfigFileName())); } return $configData; } /** * Set the path to the configuration file. * @param $configFile string */ static function setConfigFileName($configFile) { // Reset the config data $configData = null; Registry::set('configData', $configData); // Set the config file Registry::set('configFile', $configFile); } /** * Return the path to the configuration file. * @return string */ static function getConfigFileName() { return Registry::get('configFile', true, CONFIG_FILE); } /** * Get context base urls from config file. * @return array Empty array if none is set. */ static function &getContextBaseUrls() { $contextBaseUrls =& Registry::get('contextBaseUrls'); // Reference required. if (is_null($contextBaseUrls)) { $contextBaseUrls = array(); $configData = self::getData(); // Filter the settings. $matches = null; foreach ($configData['general'] as $settingName => $settingValue) { if (preg_match('/base_url\[(.*)\]/', $settingName, $matches)) { $workingContextPath = $matches[1]; $contextBaseUrls[$workingContextPath] = $settingValue; } } } return $contextBaseUrls; } }