/** * Get a setting from the config. * * @param string $key * @param mixed $alt if not set, return this alternative * @return string * @see psm_load_conf() */ function psm_get_conf($key, $alt = null) { if (!isset($GLOBALS['sm_config'])) { psm_load_conf(); } $result = isset($GLOBALS['sm_config'][$key]) ? $GLOBALS['sm_config'][$key] : $alt; return $result; }
$includes = glob(PSM_PATH_INC . '*.inc.php'); foreach ($includes as $file) { include_once $file; } // init db connection $db = new psm\Service\Database(); // sanity check! if (!defined('PSM_INSTALL') || !PSM_INSTALL) { if ($db->getDbHost() === null) { // no config file has been loaded, redirect the user to the install header('Location: install.php'); die; } // config file has been loaded, check if we have a connection if (!$db->status()) { die('Unable to establish database connection...'); } // attempt to load configuration from database if (!psm_load_conf()) { // unable to load from config table header('Location: install.php'); die; } // config load OK, make sure database version is up to date $installer = new \psm\Util\Install\Installer($db); if ($installer->isUpgradeRequired()) { die('Your database is for an older version and requires an upgrade, <a href="install.php">please click here</a> to update your database to the latest version.'); } } $lang = psm_get_conf('language', 'en_US'); psm_load_lang($lang);