*/ class Utils { /** * The error handler. * * @param int $errno The error ID. * @param string $errstr Quick description of the event. * @param string $errfile File the error occurred in. * @param int $errline Line the error occurred on. */ public static function errorHandler($errno, $errstr, $errfile, $errline) { // Remove ROOT path from the error string and file location $errstr = str_replace(ROOT, '', $errstr); $errfile = str_replace(ROOT, '', $errfile); switch ($errno) { case E_ERROR: case E_USER_ERROR: $error = 'FATAL ERROR: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; break; case E_WARNING: case E_USER_WARNING: $error = 'WARNING: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; break; case E_NOTICE: case E_USER_NOTICE: $error = 'NOTICE: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; break; default: $error = 'Unknown error type [' . $errno . ']: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; } // Truncate all previous outputs ob_clean(); ob_end_clean(); // Check for dev mode $detailed = Config::local('dev', 'show_errors'); // Build page $errorPage = '
To prevent potential security risks or data loss Sakura has stopped execution of the script.
'; if (isset($errid)) { $errorPage .= 'The error and surrounding data has been logged.
' . $errid . ''; } else { $errorPage .= '
Sakura was not able to log this error which could mean that there was an error with the database connection. If you\'re the system administrator check the database credentials and make sure the server is running and if you\'re not please let the system administrator know about this error if it occurs again.
'; } if ($detailed) { $errorPage .= '' . $error . '
'; foreach ($trace as $key => $val) { $errorPage .= str_pad( '[' . $key . ']', 12 ) . '=> ' . ( is_array($val) || is_object($val) ? json_encode($val) : $val ) . "\r\n"; } $errorPage .= ''; } } $errorPage .= '