public function __construct($configEnvironment = NULL, $configFilePath = NULL, $autoStart = FALSE) { Saf_Kickstart::go(); try { $this->_config = Saf_Config::load(!is_null($configFilePath) ? $configFilePath : APPLICATION_CONFIG, !is_null($configEnvironment) ? $configEnvironment : APPLICATION_ENV); } catch (Saf_Config_Exception_InvalidEnv $e) { Saf_Debug::out("Requested configutation section \"{$configEnvironment}\" not found, trying default..."); $this->_config = Saf_Config::load($configFilePath, 'default'); } $this->_applyConfig(); if ('install' == APPLICATION_STATUS && !array_key_exists('install', $_REQUEST)) { //#TODO how to access install $e = new Exception('This application is Install Mode and currently unavailable.'); Saf_Status::set(Saf_Status::STATUS_503_UNAVAILABLE); Saf_Kickstart::exceptionDisplay($e); } if ('down' == APPLICATION_STATUS) { $e = new Exception('This application is in Maintenance Mode and currently unavailable.'); Saf_Status::set(Saf_Status::STATUS_503_UNAVAILABLE); Saf_Kickstart::exceptionDisplay($e); } if ('online' != APPLICATION_STATUS) { $e = new Exception('This application is an unrecognized mode: ' . APPLICATION_STATUS . ' and currently unavailable.'); Saf_Status::set(Saf_Status::STATUS_503_UNAVAILABLE); Saf_Kickstart::exceptionDisplay($e); } if ($autoStart) { $this->start(); } }
public static function handle($errorNo, $errorString, $errorFile = NULL, $errorLine = NULL, $errorContext = array()) { $lookupTable = array(1 => 'E_ERROR', 2 => 'E_WARNING', 4 => 'E_PARSE', 8 => 'E_NOTICE', 16 => 'E_CORE_ERROR', 32 => 'E_CORE_WARNING', 64 => 'E_COMPILE_ERROR', 128 => 'E_COMPILE_WARNING', 256 => 'E_USER_ERROR', 512 => 'E_USER_WARNING', 1024 => 'E_USER_NOTICE', 2048 => 'E_STRICT', 4096 => 'E_RECOVERABLE_ERROR', 8192 => 'E_DEPRECATED', 16384 => 'E_USER_DEPRECATED'); $simplifyTable = array('E_ERROR' => 'error', 'E_WARNING' => 'warning', 'E_PARSE' => 'error', 'E_NOTICE' => 'notice', 'E_CORE_ERROR' => 'error', 'E_CORE_WARNING' => 'warning', 'E_COMPILE_ERROR' => 'error', 'E_COMPILE_WARNING' => 'notice', 'E_USER_ERROR' => 'error', 'E_USER_WARNING' => 'warning', 'E_USER_NOTICE' => 'notice', 'E_STRICT' => 'warning', 'E_RECOVERABLE_ERROR' => 'error', 'E_DEPRECATED' => 'warning', 'E_USER_DEPRECATED' => 'warning'); $fatalErrorList = array(1, 4, 16, 64, 256); $fatal = in_array($errorNo, $fatalErrorList); $description = array_key_exists($errorNo, $lookupTable) ? $lookupTable[$errorNo] : (is_numeric($errorNo) ? 'ERROR_NO_' . $errorNo : $errorNo); $at = $errorLine ? " on line {$errorLine}" : ''; $in = $errorFile ? " in file {$errorFile}" . $at : $at; if ($fatal) { $caughtBy = self::$_shuttingDown ? 'SHUTDOWN' : 'DEBUG'; Saf_Status::set(Saf_Status::STATUS_500_ERROR); $e = new Exception("{$description} {$in}"); Saf_Kickstart::exceptionDisplay($e, $caughtBy, $errorString); } else { $show = self::$_enabledErrorLevel === -1 || $errorNo & self::$_enabledErrorLevel; if ($show && !self::$_muted) { $message = "<span class=\"phpErrorWhat\">{$description} - </span>" . "<span class=\"phpErrorMessage\">{$errorString}</span>" . "<span slass=\"phpErrorWhere\">{$in}</span> "; $trace = self::getTrace(); $level = array_key_exists($description, $simplifyTable) ? $simplifyTable[$description] : 'error'; $level = htmlentities(ucfirst(strtolower($level))); $icon = $trace ? ' <span class="debugExpand"> ' . Saf_Layout::getIcon('search') . '</span>' : ''; $output = "{$message}{$icon}{$trace}\n"; self::_out("<div class=\"debug{$level}\">" . '<div class="phpError">' . $output . '</div>' . '</div>'); } } return FALSE; /* $errorLog = Rd_Registry::get('root:errorLogPath'); try { $cmd = Rd_Registry::get('root:requestCommand'); } catch (Exception $e) { $cmd = ''; } try { $u = Rd_Registry::get('root:userInterface'); } catch (Exception $e) { $u = NULL; } $dt = date('Y-m-d H:i:s (T)'); $errortype = array ( E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice", E_STRICT => "Runtime Notice" ); // set of errors for which a var trace will be saved $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, E_USER_ERROR); $err = "<errorentry>\n" . "\t<datetime>" . $dt . "</datetime>\n" . "\t<errornum>" . $errno . "</errornum>\n" . "\t<errortype>" . (array_key_exists($errno,$errortype) ? $errortype[$errno] : '') . "</errortype>\n" . "\t<errormsg>" . $errmsg . "</errormsg>\n" . "\t<scriptname>" . $filename . "</scriptname>\n" . "\t<scriptlinenum>" . $linenum . "</scriptlinenum>\n"; if ($u instanceof user) { $err .= "\t<user><username>" . $u->getUsername() . "</username><userID>" . $u->getUserID() . "</userID></user>\n"; } $err .= "\t<cmd>$cmd</cmd>\n"; if (in_array($errno, $user_errors)) { //$err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n"; } $err .= "</errorentry>\n\n"; if(Rd_Debug::isEnabled()) { print('<pre>' . htmlentities($err) . '</pre>'); } if ($errno <> E_NOTICE && $errno <> E_STRICT && $errno <> E_WARNING) { // save to the error log, and e-mail me if there is a critical user error if('' != $errorLog) { error_log($err, 3, $errorLog); } include_once('error.php'); die; }*/ }