getTrace() as $frame) { $args = ""; if (isset($frame['args'])) { $args = array(); foreach ($frame['args'] as $arg) { if (is_string($arg)) { $args[] = "'" . $arg . "'"; } elseif (is_array($arg)) { $args[] = "Array"; } elseif (is_null($arg)) { $args[] = 'NULL'; } elseif (is_bool($arg)) { $args[] = ($arg) ? "true" : "false"; } elseif (is_object($arg)) { $args[] = get_class($arg); } elseif (is_resource($arg)) { $args[] = get_resource_type($arg); } else { $args[] = $arg; } } $args = join(", ", $args); } $rtn .= sprintf( "#%s %s(%s): %s(%s)\n", $count, isset($frame['file']) ? $frame['file'] : 'unknown file', isset($frame['line']) ? $frame['line'] : 'unknown line', (isset($frame['class'])) ? $frame['class'].$frame['type'].$frame['function'] : $frame['function'], $args ); $count++; } return $rtn; } function _log_exception($e) { $backtrace = getExceptionTraceAsString($e); $log_heading = sprintf("Exception '%s' with message '%s' in %s:%d", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()); error_log($log_heading."\n".$backtrace); } // The actual exception handler function _actual_exception_handler($e) { _log_exception($e); $display_errors = in_array(strtolower(ini_get('display_errors')), array('1', 'on', 'true', 'stdout')); $GLOBALS["is_error_page"] = true; $heading = "Internal Server Error"; $message = "
An unhandled error occured.
\n"; if ($display_errors) { $backtrace = getExceptionTraceAsString($e); $message .= ''.(str_replace(FCPATH, "./", $backtrace)).''; $message .= 'thrown in '.$e->getFile().' on line '.$e->getLine().'
More information can be found in syslog or by enabling display_errors.
"; } $message = "$message"; include APPPATH."/errors/error_general.php"; } set_exception_handler('_actual_exception_handler'); /** * Checks for a fatal error, work around for set_error_handler not working on fatal errors. */ function check_for_fatal() { $error = error_get_last(); if ($error["type"] == E_ERROR) { _actual_exception_handler(new ErrorException( $error["message"], 0, $error["type"], $error["file"], $error["line"])); } } register_shutdown_function("check_for_fatal"); /* * -------------------------------------------------------------------- * LOAD THE BOOTSTRAP FILE * -------------------------------------------------------------------- * * And away we go... * */ try { require_once BASEPATH.'core/CodeIgniter.php'; } catch (\exceptions\NotAuthenticatedException $e) { redirect("user/login"); } catch (\exceptions\UserInputException $e) { show_error(nl2br(htmlspecialchars($e->__toString())), $e->get_http_error_code()); } /* End of file index.php */ /* Location: ./index.php */