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; }*/ }
public static function autodetect($mode = NULL) { $originalActivePlugin = self::$_activePlugin; if (self::$_supportsInternal && self::$_activePlugin) { $simulatedLockOn = isset($_SESSION) && array_key_exists('simulated_login_lock', $_SESSION); $currentSimulatedUser = array_key_exists('simulated_user', $_SESSION) ? $_SESSION['simulated_user'] : ''; if ($simulatedLockOn) { $mode = self::MODE_SIMULATED; Saf_Kickstart::defineLoad('AUTH_SIMULATED_USER', $currentSimulatedUser); } $userToLogin = $mode == self::MODE_SIMULATED && AUTH_SIMULATED_USER ? AUTH_SIMULATED_USER : self::USER_AUTODETECT; if (self::_login($userToLogin) && self::$_activePlugin->auth()) { if (self::$_authenticated && $mode == self::MODE_SIMULATED) { $_SESSION['simulated_login_lock'] = TRUE; $_SESSION['simulated_user'] = AUTH_SIMULATED_USER; } return self::$_authenticated; } } self::init(); $plugins = !array_key_exists('loginRealm', $_GET) || !in_array(trim($_GET['loginRealm']), self::$_loadedPlugins) ? self::$_defaultPlugins : array(trim($_GET['loginRealm'])); foreach ($plugins as $pluginName) { try { $plugin = self::_getPlugin($pluginName); self::$_activePlugin = $plugin; if ($plugin->auth()) { return self::_login($plugin->getProvidedUsername(), TRUE); } else { self::$_activePlugin = NULL; } /* $pluginClass = self::$_classMap[$pluginName]; $plugin = new $pluginClass(); self::$_activePlugin = $plugin; if($plugin->auth() && self::$_authenticated) { //#TODO #2.0.0 maybe too over zealous (artifact of old methods) return self::_login(self::$_userObject, TRUE); } else { self::$_activePlugin = NULL; } */ } catch (Exception $e) { self::$_activePlugin = NULL; if (Saf_Debug::isEnabled()) { self::$_errorMessages[] = "Exception in auth plugin {$pluginName} : " . $e->getMessage(); } } } if (count(self::$_errorMessages) > 0) { count(self::$_errorMessages) == 1 ? Saf_Layout::setMessage('loginError', self::$_errorMessages[0]) : Saf_Layout::setMessage('loginError', 'Multiple errors: <ul><li>' . implode('</li><li>', self::$_errorMessages) . '</li></ul>'); if (count($plugins) > 0 && $plugins[0] == 'Local' && self::$_credentialMissmatch) { Saf_Layout::setMessage('passwordResetPrompt', '<a href="?cmd=resetPasswordRequest">Forgotten/Lost Password</a>?'); } } //$usersObject = new users(); //Rd_Registry::set('root:userInterface',$usersObject->initUser('', '')); //Account_Rd::init(); if (is_null(self::$_activePlugin)) { self::$_activePlugin = $originalActivePlugin; } return FALSE; }
public function get($name, $cast = NULL) { /* self::_init(); */ $nameComponents = is_array($name) ? $name : explode(':', $name); $value = self::_get($nameComponents, $this->_configuration); return !is_null($cast) ? $value : Saf_Kickstart::cast($value, $cast); }
public function bootstrap($type = NULL) { if ($type === TRUE || $type === FALSE) { $type = NULL; //#TODO #2.0.0 allow valid class names and bootstrapObjects } if (is_null($type) && !is_null($this->_bootstrap)) { return $this->_bootstrap; } else { if (!is_null($this->_bootstrap)) { $bootstrapClass = get_class($this->_bootstrap); if ("Saf_Bootstrap_{$type}" == $bootstrapClass) { return $this->_bootstrap; } } } if (is_null($type)) { $type = defined('APPLICATION_PROTOCOL') ? APPLICATION_PROTOCOL != 'commandline' ? 'Http' : 'Commandline' : 'Http'; } try { $bootstrapClass = "Saf_Bootstrap_{$type}"; if (!$this->_autoLoad && !class_exists($bootstrapClass)) { Saf_Kickstart::autoload($bootstrapClass); } $this->_bootstrap = new $bootstrapClass($this, $this->_bootstrapConfig); } catch (Exception $e) { if (!class_exists($bootstrapClass, FALSE)) { //!in_array($bootstrapClass, get_declared_classes())) { //also seems to fail //#TODO #RAINYDAY for some reason if spl_autoload throws an exception for a class, //PHPseems to refuse try again, or even load the class manually... if ($this->_autoLoad) { throw new Exception('Unable to load the requested Bootstrap' . (Saf_Debug::isEnabled() ? " ({$bootstrapClass}) " : '') . '. Autoloading is enabled, but unable to find the bootstrap.', 0, $e); } else { throw new Exception('Unable to load the requested Bootstrap' . (Saf_Debug::isEnabled() ? " ({$bootstrapClass}) " : '') . '. Manually require this class, or enable autoloading.', 0, $e); } } else { throw $e; } } return $this->_bootstrap; }
/** * sets the path to the php script used by exceptionDisplay() * @param string $path */ public static function setExceptionDisplayScript($path) { self::$_exceptionView = realpath($path); }