if (file_exists(DOC_ROOT . 'config.ini')) { //load main config so that we can connect to casebox db and read configuration for core $cfg = Config::loadConfigFile(DOC_ROOT . 'config.ini') + $cfg; if (isset($cfg['db_host']) && isset($cfg['db_user']) && isset($cfg['db_pass']) && isset($cfg['db_port'])) { //conect to db using global params from config.ini DB\connect($cfg); } } else { //Usually this appears when installing casebox and //a message instead of a complex error should be enough echo "Config file doesnt exist\n"; // trigger_error("WARNING: file not exists " . DOC_ROOT . 'config.ini', E_USER_WARNING); } //define global prefix used define('CB\\PREFIX', (empty($cfg['prefix']) ? 'cb' : $cfg['prefix']) . '_'); define('CB\\IS_DEBUG_HOST', empty($_SERVER['SERVER_NAME']) || !empty($cfg['debug_hosts']) && Util\isInValues($_SERVER['REMOTE_ADDR'], $cfg['debug_hosts']) || Util\is_cli()); define('CB\\IS_DEVEL_SERVER', !empty($cfg['_dev_mode']) && (strpos($_SERVER['SERVER_NAME'], '.d.') !== false || !empty($cfg['_dev_hosts']) && Util\isInValues($_SERVER['REMOTE_ADDR'], $cfg['_dev_hosts']))); //analize python option if (empty($cfg['PYTHON'])) { $cfg['PYTHON'] = 'python'; } //set unoconv path $cfg['UNOCONV'] = '"' . $cfg['PYTHON'] . '" "' . DOC_ROOT . 'libx' . DIRECTORY_SEPARATOR . 'unoconv"'; Cache::set('platformConfig', $cfg); /* config functions section */ /** * detect core from enviroment * @return varchar | false */ function detectCore() {
1. include platform config 4. Detect core name and initialize by defining specific params 5. based on loaded configs set casebox php options, session lifetime, error_reporting and define required casebox constants */ require_once 'config_platform.php'; $cfg = Cache::get('platformConfig'); //detect core and define core specific params $cfg['core_name'] = detectCore() or die('Cannot detect core'); //set default database name $cfg['db_name'] = PREFIX . $cfg['core_name']; //loading core defined params try { $cfg = array_merge($cfg, Config::getPlatformConfigForCore($cfg['core_name'])); } catch (\Exception $e) { //return http "not found" if cant load core config if (Util\is_cli()) { trigger_error("ERROR: Config::getPlatformConfigForCore(" . $cfg['core_name'] . ") cfg=" . print_r($cfg, true), E_USER_ERROR); } else { header(@$_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); } exit; } //echo '<pre>'.print_r($cfg,true).'</pre>'; DB\connectWithParams($cfg); //loading full config of the core $config = Config::load($cfg); //analize core status and display corresponding message if not active $status = Config::getCoreStatus(); if ($status != Config::$CORESTATUS_ACTIVE) { echo Config::getCoreStatusMessage($status); exit;