| // +---------------------------------------------------------------------------+ // $Id: init.php,v 1.136 2005/06/25 08:41:51 demian Exp $ // fire off init tasks, run as fn to keep global namespace clean // - set constants // - config loading // - basic PHP config with ini_set() // - check if installed // - init error handler // - init DB_DataObject // load BC functions depending on PHP version detected if (!function_exists('version_compare') || version_compare(phpversion(), "4.3.0", 'lt')) { require_once 'etc/bc.php'; } require_once 'constants.php'; SGL_init(); function SGL_init() { $conf = $GLOBALS['_SGL']['CONF']; // load Base and init DB_DataObject require_once SGL_LIB_DIR . '/SGL.php'; // to overcome overload problem define('DB_DATAOBJECT_NO_OVERLOAD', true); // If we just copied conf.ini, execute bootstrap if (isset($GLOBALS['_SGL']['executeDbBootstrap']) || @$conf['db']['bootstrap'] == '1') { require_once SGL_CORE_DIR . '/SetupWizard.php'; $wizard = new SGL_SetupWizard($conf); $wizard->run(); } $options = &PEAR::getStaticProperty('DB_DataObject', 'options'); $options = array( 'database' => SGL_DB::getDsn(SGL_DSN_STRING), 'schema_location' => SGL_ENT_DIR, 'class_location' => SGL_ENT_DIR, 'require_prefix' => SGL_ENT_DIR . '/', 'class_prefix' => 'DataObjects_', 'debug' => 0, 'production' => 0, 'ignore_sequence_keys' => 'ALL', 'generator_strip_schema' => 1, ); // include Log.php if logging enabled if ($conf['log']['enabled']) { require_once 'Log.php'; } else { // define log levels to avoid notices, since Log.php not included define('PEAR_LOG_EMERG', 0); /** System is unusable */ define('PEAR_LOG_ALERT', 1); /** Immediately action */ define('PEAR_LOG_CRIT', 2); /** Critical conditions */ define('PEAR_LOG_ERR', 3); /** Error conditions */ define('PEAR_LOG_WARNING', 4); /** Warning conditions */ define('PEAR_LOG_NOTICE', 5); /** Normal but significant */ define('PEAR_LOG_INFO', 6); /** Informational */ define('PEAR_LOG_DEBUG', 7); /** Debug-level messages */ } // which degree of error severity before emailing admin define('SGL_EMAIL_ADMIN_THRESHOLD', constant($conf['debug']['emailAdminThreshold'])); // start PHP error handler if ($conf['debug']['customErrorHandler']) { require_once SGL_CORE_DIR . '/ErrorHandler.php'; $eh = & new SGL_ErrorHandler(); $eh->startHandler(); } // set PEAR error handler PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pearErrorHandler'); } /** * A callback fn that sets the default PEAR error behaviour. * * @access public * @static * @param object $oError the PEAR error object * @return void */ function pearErrorHandler($oError) { $conf = & $GLOBALS['_SGL']['CONF']; // log message $message = $oError->getMessage(); $debugInfo = $oError->getDebugInfo(); SGL::logMessage('PEAR' . " :: $message : $debugInfo", PEAR_LOG_ERR); // if sesssion debug, send error info to screen if (!$conf['debug']['production'] || SGL_HTTP_Session::get('debug')) { $GLOBALS['_SGL']['ERRORS'][] = $oError; if ($conf['debug']['showBacktrace']) { echo '
'; print_r($oError->getBacktrace()); print '
'; } } } ?>