示例#1
0
 protected function log(\Exception $e, $contextInfo = NULL)
 {
     if ($e instanceof \ErrorException) {
         $errorType = self::$errors[$e->getSeverity()];
     } else {
         $errorType = Code::getClass($e);
     }
     // wir müssen hier den error selbst loggen, da php nichts mehr macht (die faule banane)
     $php = NULL;
     $php .= 'PHP ' . $errorType . ': ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
     $php .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     error_log($php, 0);
     /* Debug-Mail */
     $debug = NULL;
     $debug .= '[' . date('d.M.Y H:i:s') . "] ";
     $debug .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     if ($e instanceof \Psc\Code\ErrorException) {
         $debug .= "\n" . $e->contextDump;
     }
     if (isset($contextInfo)) {
         $debug .= "\nContextInfo: \n" . $contextInfo;
     }
     if (isset($this->recipient) && !PSC::inTests()) {
         if ($ret = @mail($this->recipient, '[Psc-ErrorHandler] [' . $e->getCode() . '] ' . $e->getMessage(), $debug, 'From: www@' . PSC::getEnvironment()->getHostName() . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n") === FALSE) {
             error_log('[\\Psc\\Code\\ErrorHandler.php:' . __LINE__ . '] Die Fehlerinformationen konnten nicht an den lokalen Mailer übergeben werden.', 0);
         }
     }
 }
 private function getMessage(\Exception $exception)
 {
     if ($exception instanceof \ErrorException) {
         return ErrorHandler::getErrNoString($exception->getSeverity()) . ' - ' . $exception->getMessage();
     }
     return $exception->getMessage();
 }
示例#3
0
 /**
  * Creates an error from an exception.
  *
  * @param \Exception $exception
  *
  * @return Error
  */
 public function createError(\Exception $exception)
 {
     $severity = E_RECOVERABLE_ERROR;
     if ($exception instanceof \ErrorException) {
         $severity = $exception->getSeverity();
     }
     return new Error($exception->getMessage(), $severity, get_class($exception), $this->createTrace($exception));
 }
示例#4
0
 /**
  * Tries to handle the exception.
  *
  * @param Exception $e
  * @return true
  */
 function handle(Exception $e)
 {
     if (!$e instanceof ErrorException || $e->getSeverity() & $this->level) {
         echo '<pre>', $e, '</pre>';
         $this->doExit();
     }
     return false;
 }
示例#5
0
 /**
  * Tries to handle the exception.
  *
  * @param Exception $e
  * @return true
  */
 function handle(Exception $e)
 {
     if (!$e instanceof ErrorException || $e->getSeverity() & $this->level) {
         fwrite(STDERR, $e->__toString());
         $this->doExit($e->getCode());
     }
     return false;
 }
示例#6
0
文件: logger.php 项目: staabm/redaxo
 /**
  * Shorthand: Logs the given Exception.
  *
  * @param Exception $exception The Exception to log
  */
 public static function logException(Exception $exception)
 {
     if ($exception instanceof ErrorException) {
         self::logError($exception->getSeverity(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     } else {
         $logger = self::factory();
         $logger->log(get_class($exception), $exception->getMessage(), [], $exception->getFile(), $exception->getLine());
     }
 }
示例#7
0
 /**
  * Renders blue screen.
  * @param  \Exception
  * @return void
  */
 public function render(\Exception $exception)
 {
     $panels = $this->panels;
     $info = array_filter($this->info);
     $source = Helpers::getSource();
     $sourceIsUrl = preg_match('#^https?://#', $source);
     $title = $exception instanceof \ErrorException ? Helpers::errorTypeToString($exception->getSeverity()) : get_class($exception);
     $skipError = $sourceIsUrl && $exception instanceof \ErrorException && !empty($exception->skippable) ? $source . (strpos($source, '?') ? '&' : '?') . '_tracy_skip_error' : NULL;
     require __DIR__ . '/templates/bluescreen.phtml';
 }
 /**
  *
  *
  * @param Exception $e
  *
  * @return
  */
 protected function ignoreError(Exception $e)
 {
     $code = $e->getCode();
     if (empty($code) && $e instanceof ErrorException) {
         $code = $e->getSeverity();
     }
     if (in_array($code, $this->options['ignore_errors'])) {
         $this->logIgnored($e);
         return true;
     }
     return false;
 }
示例#9
0
 /**
  * @param Exception $exception
  */
 public function handleException(Exception $exception)
 {
     $printException = true;
     if ($exception instanceof CM_Exception) {
         $printException = $exception->getSeverity() >= $this->_getPrintSeverityMin();
     }
     try {
         $this->logException($exception);
     } catch (Exception $e) {
         $printException = true;
     }
     if ($printException) {
         $this->_printException($exception);
     }
     if (!$exception instanceof CM_Exception || $exception->getSeverity() >= CM_Exception::ERROR) {
         CM_Service_Manager::getInstance()->getNewrelic()->setNoticeError($exception);
     }
 }
示例#10
0
 /**
  * Gets the backgrace from an exception.
  *
  * If xdebug is installed
  *
  * @param Exception $e
  * @return array
  */
 protected function getTrace(\Exception $e)
 {
     $traces = $e->getTrace();
     // Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
     if (!$e instanceof \ErrorException) {
         return $traces;
     }
     if (!Misc::isLevelFatal($e->getSeverity())) {
         return $traces;
     }
     if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
         return array();
     }
     // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
     $stack = array_reverse(xdebug_get_function_stack());
     $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     $traces = array_diff_key($stack, $trace);
     return $traces;
 }
 /**
  * The render function will take an Exception and output a HTML page
  *
  * @param Exception $e
  *  The Exception object
  * @return string
  *  An HTML string
  */
 public static function render(Exception $e)
 {
     $lines = null;
     foreach (self::__nearByLines($e->getLine(), $e->getFile()) as $line => $string) {
         $lines .= sprintf('<li%s><strong>%d</strong> <code>%s</code></li>', $line + 1 == $e->getLine() ? ' class="error"' : null, ++$line, str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', htmlspecialchars($string)));
     }
     $trace = null;
     foreach ($e->getTrace() as $t) {
         $trace .= sprintf('<li><code><em>[%s:%d]</em></code></li><li><code>&#160;&#160;&#160;&#160;%s%s%s();</code></li>', isset($t['file']) ? $t['file'] : null, isset($t['line']) ? $t['line'] : null, isset($t['class']) ? $t['class'] : null, isset($t['type']) ? $t['type'] : null, $t['function']);
     }
     $queries = null;
     if (is_object(Symphony::Database())) {
         $debug = Symphony::Database()->debug();
         if (!empty($debug)) {
             foreach ($debug as $query) {
                 $queries .= sprintf('<li><em>[%01.4f]</em><code> %s;</code> </li>', isset($query['execution_time']) ? $query['execution_time'] : null, htmlspecialchars($query['query']));
             }
         }
     }
     return self::renderHtml('fatalerror.generic', $e instanceof ErrorException ? GenericErrorHandler::$errorTypeStrings[$e->getSeverity()] : 'Fatal Error', $e->getMessage(), $e->getFile(), $e->getLine(), $lines, $trace, $queries);
 }
示例#12
0
 /**
  * Log exception
  *
  * @param \Exception $exception
  * @return \Consumerr\Entities\Error
  */
 public static function addError(\Exception $exception)
 {
     if ($exception instanceof \ErrorException && self::$configuration->isErrorDisabled($exception->getSeverity())) {
         self::log("Error handler - severity {$exception->getSeverity()} is ignored by current disabled-severity setting.");
         return NULL;
     }
     $error = new Entities\Error($exception);
     self::getAccess()->addError($error);
     self::log("Added error - '" . get_class($exception) . " - " . $exception->getMessage() . "'");
     return $error;
 }
示例#13
0
文件: Shell.php 项目: jivoo/jivoo
 public static function dumpException(\Exception $exception, $stream = STDERR)
 {
     if ($exception instanceof \ErrorException) {
         $title = 'Fatal error (' . ErrorHandler::toString($exception->getSeverity()) . ')';
     } else {
         $title = get_class($exception);
     }
     fwrite($stream, $title . ': ' . $exception->getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine() . PHP_EOL . PHP_EOL);
     fwrite($stream, 'Stack trace:' . PHP_EOL);
     $trace = $exception->getTrace();
     foreach ($trace as $i => $call) {
         $message = '  ' . sprintf('% 2d', $i) . '. ';
         if (isset($call['file'])) {
             $message .= $call['file'] . ':';
             $message .= $call['line'] . ' ';
         }
         if (isset($call['class'])) {
             $message .= $call['class'] . '::';
         }
         $message .= $call['function'] . '(';
         $arglist = array();
         if (isset($call['args'])) {
             foreach ($call['args'] as $arg) {
                 $arglist[] = is_scalar($arg) ? var_export($arg, true) : gettype($arg);
             }
             $message .= implode(', ', $arglist);
         }
         $message .= ')' . PHP_EOL;
         fwrite($stream, $message);
     }
     $previous = $exception->getPrevious();
     if (isset($previous)) {
         fwrite($stream, 'Caused by:' . PHP_EOL);
         self::dumpException($previous);
     }
     fflush($stream);
 }
示例#14
0
文件: App.php 项目: jivoo/jivoo
 /**
  * Output an HTML crash report based on an exception. Can use a custom
  * template stored in 'app/templates/error/exception.php'.
  * @param \Exception $exception \Exception to report.
  */
 public function crashReport($exception)
 {
     $app = $this->name;
     $version = $this->version;
     if ($exception instanceof \ErrorException) {
         $title = tr('Fatal error (%1)', ErrorHandler::toString($exception->getSeverity()));
     } else {
         $title = tr('Uncaught exception');
     }
     $log = array();
     if ($this->logger instanceof \Jivoo\Core\Log\Logger) {
         $log = $this->logger->getLog();
     }
     $custom = null;
     try {
         if (isset($this->errorPaths['exceptionTemplate'])) {
             include $this->errorPaths['exceptionTemplate'];
             $custom = true;
         }
     } catch (\Exception $e) {
         $this->logger->alert(tr('Exception template (%1) failed: %2', '{template}', $e->getMessage()), array('template' => $this->errorPaths['exceptionTemplate'], 'exception' => $e));
     }
     if (!isset($custom)) {
         include \Jivoo\PATH . '/Core/templates/error/exception.php';
     }
 }
示例#15
0
 /**
  * Catches an exception. Non-fatal and fatal exceptions are handled
  * differently:
  *    - fatal: Re-thrown so they abort the current request. Fatal
  *             exceptions are later passed on to catchFinalException().
  *    - non-fatal: Processed using aggregateException(). Additionally
  *                 they are logged by calling api_exceptionhandler::log().
  *
  * Exceptions of type api_exceptions (and subclasses) have a getSeverity()
  * method which indicates if the exception is fatal. All other exceptions
  * are assumed to always be fatal.
  *
  * @param $e api_exception: Thrown exception.
  * @param $prms array: Parameters to give more context to the exception.
  */
 private function catchException(Exception $e, $prms = array())
 {
     if ($e instanceof api_exception && $e->getSeverity() === api_exception::THROW_NONE) {
         $this->aggregateException($e, $prms);
         api_exceptionhandler::log($e);
     } else {
         throw $e;
     }
 }
示例#16
0
 /**
 	Function called when an exception is thrown and isn't catched by the script.
 
 	It gets the exception's details and send them to the error page.
 	It does not stop the script execution, since PHP does it itself after calling this function.
 
 	If the request is an HTTP request, and:
 		* If the exception is an instance of RouteNotFoundException, send a 404 Not Found error
 		* If the exception is an instance of NotPermittedException, send a 403 Forbidden error
 		* Otherwise, send a 500 Internal Server Error
 
 	When DEBUG is enabled and the request is an HTTP request, send the exception to FirePHP
 	to ease debug through Firebug.
 
 	@param $eException The exception object.
 	@see http://php.net/set_exception_handler
 	@see http://www.firephp.org/
 	@see http://getfirebug.com/
 */
 public static function handleException(Exception $eException)
 {
     try {
         if (defined('WEE_CLI')) {
             if ($eException instanceof ErrorException) {
                 $sBase = _WT("Error: %s\nMessage: %s\n\nTrace:\n%s");
                 $sName = self::getLevelName($eException->getSeverity());
             } else {
                 $sBase = _WT("Exception: %s\nMessage: %s\n\nTrace:\n%s");
                 $sName = get_class($eException);
             }
             self::printError(sprintf($sBase, $sName, $eException->getMessage(), self::formatTrace(self::filterTrace($eException->getTrace()))));
         } else {
             if (!headers_sent()) {
                 if ($eException instanceof RouteNotFoundException) {
                     header('HTTP/1.0 404 Not Found');
                 } elseif ($eException instanceof NotPermittedException) {
                     header('HTTP/1.0 403 Forbidden');
                 } else {
                     header('HTTP/1.0 500 Internal Server Error');
                 }
                 if (defined('DEBUG')) {
                     FirePHP::getInstance(true)->error($eException);
                 }
             }
             $aTrace = self::filterTrace($eException->getTrace());
             if ($eException instanceof ErrorException) {
                 $aError = array('type' => 'error', 'name' => self::getLevelName($eException->getSeverity()));
             } else {
                 $aError = array('type' => 'exception', 'name' => get_class($eException));
             }
             if ($eException->getFile() == __FILE__ || !substr_compare($eException->getFile(), "eval()'d code", -13)) {
                 foreach ($aTrace as $a) {
                     if (substr_compare($a['file'], "eval()'d code", -13)) {
                         $aError += array('file' => $a['file'], 'line' => $a['line']);
                         break;
                     }
                 }
             } else {
                 $aError += array('file' => $eException->getFile(), 'line' => $eException->getLine());
             }
             self::printErrorPage($aError + array('message' => $eException->getMessage(), 'trace' => self::formatTrace($aTrace)));
         }
     } catch (Exception $e) {
         if (defined('DEBUG')) {
             echo $e;
         }
     }
 }
 /**
  * Save log in log file
  * @param \Exception $error
  * @return string
  */
 function logException(\Exception $error)
 {
     $severity = $error->getSeverity();
     // set error data
     $this->errorData = ['exception_name' => get_class($error), 'name' => $this->errorCode[$error->getSeverity()], 'error_message' => $error->getMessage(), 'error_file' => $error->getFile(), 'error_line' => $error->getLine()];
     // log template message
     $message = '[' . date('d-m-Y H:i:s') . '] ';
     $message .= '[' . get_class($error) . ']';
     $message .= 'Message: ' . $error->getMessage() . '; ';
     $message .= 'File: ' . $error->getFile() . '; ';
     $message .= 'Line: ' . $error->getLine() . ';';
     // check error dir exist
     if (!file_exists(ERROR_PATH)) {
         mkdir(ERROR_PATH, 0777, true);
     }
     // save log
     file_put_contents(ERROR_PATH . $this->errorCode[$severity] . '.log', $message . PHP_EOL, FILE_APPEND);
     return $this->showError();
 }
示例#18
0
 /** @internal */
 public static function dumpException(\Exception $e)
 {
     $trace = $e->getTrace();
     array_splice($trace, 0, $e instanceof \ErrorException ? 1 : 0, array(array('file' => $e->getFile(), 'line' => $e->getLine())));
     $testFile = NULL;
     foreach (array_reverse($trace) as $item) {
         if (isset($item['file'])) {
             // in case of shutdown handler, we want to skip inner-code blocks and debugging calls
             $testFile = $item['file'];
             break;
         }
     }
     if ($e instanceof AssertException) {
         if (is_object($e->expected) || is_array($e->expected) || is_string($e->expected) && strlen($e->expected) > self::$maxLength || is_object($e->actual) || is_array($e->actual) || is_string($e->actual) && strlen($e->actual) > self::$maxLength) {
             $args = isset($_SERVER['argv'][1]) ? '.[' . preg_replace('#[^a-z0-9-. ]+#i', '_', $_SERVER['argv'][1]) . ']' : '';
             $stored[] = self::saveOutput($testFile, $e->expected, $args . '.expected');
             $stored[] = self::saveOutput($testFile, $e->actual, $args . '.actual');
         }
         if (is_string($e->actual) && is_string($e->expected)) {
             for ($i = 0; $i < strlen($e->actual) && isset($e->expected[$i]) && $e->actual[$i] === $e->expected[$i]; $i++) {
             }
             $i = max(0, min($i, max(strlen($e->actual), strlen($e->expected)) - self::$maxLength + 3));
             for (; $i && $i < count($e->actual) && $e->actual[$i - 1] >= "€" && $e->actual[$i] >= "€" && $e->actual[$i] < "À"; $i--) {
             }
             if ($i) {
                 $e->expected = substr_replace($e->expected, '...', 0, $i);
                 $e->actual = substr_replace($e->actual, '...', 0, $i);
             }
         }
         $message = 'Failed: ' . $e->getMessage();
         if (is_string($e->actual) && is_string($e->expected) || is_array($e->actual) && is_array($e->expected)) {
             preg_match('#^(.*)(%\\d)(.*)(%\\d.*)\\z#', $message, $m);
             if (($delta = strlen($m[1]) - strlen($m[3])) >= 3) {
                 $message = "{$m['1']}{$m['2']}\n" . str_repeat(' ', $delta - 3) . "...{$m['3']}{$m['4']}";
             } else {
                 $message = "{$m['1']}{$m['2']}{$m['3']}\n" . str_repeat(' ', strlen($m[1]) - 4) . "... {$m['4']}";
             }
         }
         $message = strtr($message, array('%1' => "" . Dumper::toLine($e->actual) . "", '%2' => "" . Dumper::toLine($e->expected) . ""));
     } else {
         $message = ($e instanceof \ErrorException ? Helpers::errorTypeToString($e->getSeverity()) : get_class($e)) . ": {$e->getMessage()}";
     }
     $s = "{$message}\n\n" . (isset($stored) ? "diff " . escapeshellarg($stored[0]) . " " . escapeshellarg($stored[1]) . "\n\n" : '');
     foreach ($trace as $item) {
         $item += array('file' => NULL);
         $s .= 'in ' . ($item['file'] === $testFile ? "" : '') . ($item['file'] ? implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, $item['file']), -3)) . "({$item['line']})" : '[internal function]') . " " . (isset($item['class']) ? $item['class'] . $item['type'] : '') . (isset($item['function']) ? $item['function'] . '()' : '') . "\n";
     }
     if ($e->getPrevious()) {
         $s .= "\n(previous) " . static::dumpException($e->getPrevious());
     }
     return $s;
 }
示例#19
0
 /**
  * @param \Exception $e
  *
  * @return mixed
  */
 protected function runFormatters($e)
 {
     if ($e instanceof ErrorException) {
         $severity = $e->getSeverity();
     } else {
         $severity = E_ERROR;
     }
     /** @var \Myerror\Formatter\FormatterInterface $formatter */
     foreach (array_reverse($this->formatterStack) as $formatter) {
         if ($severity & $formatter->getErrorLimit()) {
             return $formatter->format($e);
         }
     }
 }
 /**
  *
  * @param Exception $e
  *
  * @return array
  */
 public function formatException(Exception $e)
 {
     return array('class' => $e instanceof ErrorException ? fpErrorNotifierErrorCode::getName($e->getSeverity()) : get_class($e), 'code' => $e->getCode(), 'severity' => $e instanceof ErrorException ? $e->getSeverity() : 'null', 'message' => $e->getMessage(), 'file' => "File: {$e->getFile()}, Line: {$e->getLine()}", 'trace' => $e->getTraceAsString());
 }
 /**
  * Exception handler.
  *
  * Log exceptions in the application log file and print them to the screen
  * if "display_errors" is set. Callback to a custom exception handler defined
  * in the application file "config/error.php".
  *
  * @param \Exception $exception The exception.
  *
  * @return void
  */
 public static function handleException($exception)
 {
     if ($exception instanceof \ErrorException && $exception->getSeverity() !== E_NOTICE) {
         error_log(sprintf("PHP Fatal error: Uncaught exception '%s' with message '%s' thrown in %s on line %s\n%s", get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTraceAsString()));
     }
     self::addException($exception);
 }
 /**
  * @param Exception $exception
  * @param string $messageSuffix
  * @return bool
  */
 public function reportError(Exception $exception, $messageSuffix = '')
 {
     $log = $this->getLogInstance();
     if (!$log) {
         return false;
     }
     $logContext = array('exception' => $exception);
     if ($exception instanceof EngineBlock_Exception) {
         $severity = $exception->getSeverity();
     } else {
         $severity = EngineBlock_Exception::CODE_ERROR;
     }
     // add previous exceptions to log context
     $prevException = $exception;
     while ($prevException = $prevException->getPrevious()) {
         if (!isset($logContext['previous_exceptions'])) {
             $logContext['previous_exceptions'] = array();
         }
         $logContext['previous_exceptions'][] = (string) $prevException;
     }
     $message = $exception->getMessage();
     if (empty($message)) {
         $message = 'Exception without message "' . get_class($exception) . '"';
     }
     if ($messageSuffix) {
         $message .= ' | ' . $messageSuffix;
     }
     $log->log($severity, $message, $logContext);
     // Store some valuable debug info in session so it can be displayed on feedback pages
     session_start();
     $_SESSION['feedbackInfo'] = $this->collectFeedbackInfo();
     // flush all messages in queue, something went wrong!
     $this->flushLog('An error was caught');
     return true;
 }
示例#23
0
 /**
  * Try to translate the error message
  * and then if the request is Ajax request, sends
  * out the json message containing error, otherwise
  * formats the error string, depending of debug
  * option, will include extra backtrace of exception
  *
  * @deprecated
  *
  * @param \Exception|object $e        Exception
  *
  * @param string            $sMessage [optional]
  *
  * @return string formatted error message made
  *
  * from data in Exception object
  */
 public static function _formatException(\Exception $e, $sMessage = '')
 {
     $sMessage = !empty($sMessage) ? $sMessage : $e->getMessage();
     //$sMessage = $e->getMessage();
     //$bHtml = ($e instanceof \Lampcms\Exception) ? $e->getHtmlFlag() : false;
     if ($e instanceof \Lampcms\DevException) {
         $sMessage = defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG ? $e->getMessage() : 'Error occurred';
         //$oTr->get('generic_error', 'exceptions');
     }
     $sMessage = strip_tags($sMessage);
     $aArgs = $e instanceof \Lampcms\Exception ? $e->getArgs() : null;
     $sMessage = !empty($aArgs) ? vsprintf($sMessage, $aArgs) : $sMessage;
     $sError = '';
     $sTrace = $e->getTraceAsString();
     $strFile = $e->getFile();
     $intLine = $e->getLine();
     $intCode = $e instanceof \ErrorException ? $e->getSeverity() : $e->getCode();
     $strLogMessage = 'Lampcms Exception caught: ' . $sMessage . "\n" . 'error code: ' . $intCode . "\n" . 'file: ' . $strFile . "\n" . 'line: ' . $intLine . "\n" . 'stack: ' . $sTrace . "\n";
     d('vars: ' . print_r($_REQUEST, true) . "\n" . $strLogMessage);
     if (!empty($_SESSION)) {
         d('$_SESSION: ' . print_r($_SESSION, 1));
     }
     $sError .= $sMessage . "\n";
     if (defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG) {
         $sError .= 'error code: ' . $intCode . "\n";
         $sError .= 'file: ' . $strFile . "\n";
         $sError .= 'line: ' . $intLine . "\n";
         if (!empty($sTrace)) {
             $sError .= 'trace: ' . $sTrace . "\n";
         }
     }
     d('cp');
     /**
      * If this exception has E_USER_WARNING error code
      * then it was thrown when parsing some ajax-based
      * request.
      *
      * We then need to only send json array with
      * only one key 'exception'
      */
     if (E_USER_NOTICE === $e->getCode() || Request::isAjax()) {
         /**
          * if this exception was thrown when uploading
          * file to iframe, then we need to add 'true' as
          * the last (2nd arg) to fnSendJson
          */
         $a = array('exception' => $sError, 'errHeader' => 'Error', 'type' => get_class($e));
         if ($e instanceof \Lampcms\FormException) {
             $a['fields'] = $e->getFormFields();
         }
         d('json array of exception: ' . print_r($a, 1));
         Responder::sendJSON($a);
     }
     d('$sError: ' . $sError);
     return $sError;
 }
示例#24
0
文件: Error.php 项目: gg1122/think
 /**
  * 获取错误编码
  * ErrorException则使用错误级别作为错误编码
  * @param  \Exception $exception 
  * @return integer                错误编码
  */
 private static function getCode(\Exception $exception)
 {
     $code = $exception->getCode();
     if (!$code && $exception instanceof ErrorException) {
         $code = $exception->getSeverity();
     }
     return $code;
 }
示例#25
0
文件: Debug.php 项目: kravco/dibi
    public static function paintBlueScreen(Exception $exception)
    {
        if (class_exists('Environment', FALSE)) {
            $application = Environment::getContext()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getContext()->getService('Nette\\Application\\Application') : NULL;
        }
        if (!function_exists('_netteDebugPrintCode')) {
            function _netteDebugPrintCode($file, $line, $count = 15)
            {
                if (function_exists('ini_set')) {
                    ini_set('highlight.comment', '#999; font-style: italic');
                    ini_set('highlight.default', '#000');
                    ini_set('highlight.html', '#06B');
                    ini_set('highlight.keyword', '#D24; font-weight: bold');
                    ini_set('highlight.string', '#080');
                }
                $start = max(1, $line - floor($count / 2));
                $source = @file_get_contents($file);
                if (!$source) {
                    return;
                }
                $source = explode("\n", highlight_string($source, TRUE));
                $spans = 1;
                echo $source[0];
                $source = explode('<br />', $source[1]);
                array_unshift($source, NULL);
                $i = $start;
                while (--$i >= 1) {
                    if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
                        if ($m[1] !== '</span>') {
                            $spans++;
                            echo $m[1];
                        }
                        break;
                    }
                }
                $source = array_slice($source, $start, $count, TRUE);
                end($source);
                $numWidth = strlen((string) key($source));
                foreach ($source as $n => $s) {
                    $spans += substr_count($s, '<span') - substr_count($s, '</span');
                    $s = str_replace(array("\r", "\n"), array('', ''), $s);
                    if ($n === $line) {
                        printf("<span class='highlight'>Line %{$numWidth}s:    %s\n</span>%s", $n, strip_tags($s), preg_replace('#[^>]*(<[^>]+>)[^<]*#', '$1', $s));
                    } else {
                        printf("<span class='line'>Line %{$numWidth}s:</span>    %s\n", $n, $s);
                    }
                }
                echo str_repeat('</span>', $spans), '</code>';
            }
            function _netteDump($dump)
            {
                return '<pre class="nette-dump">' . preg_replace_callback('#^( *)((?>[^(]{1,200}))\\((\\d+)\\) <code>#m', create_function('$m', '
			return "$m[1]<a href=\'#\' onclick=\'return !netteToggle(this)\'>$m[2]($m[3]) " . (trim($m[1]) || $m[3] < 7 ? \'<abbr>&#x25bc;</abbr> </a><code>\' : \'<abbr>&#x25ba;</abbr> </a><code class="collapsed">\');
		'), $dump) . '</pre>';
            }
            function _netteOpenPanel($name, $collapsed)
            {
                static $id;
                $id++;
                ?>
	<div class="panel">
		<h2><a href="#" onclick="return !netteToggle(this, 'netteBsPnl<?php 
                echo $id;
                ?>
')"><?php 
                echo htmlSpecialChars($name);
                ?>
 <abbr><?php 
                echo $collapsed ? '&#x25ba;' : '&#x25bc;';
                ?>
</abbr></a></h2>

		<div id="netteBsPnl<?php 
                echo $id;
                ?>
" class="<?php 
                echo $collapsed ? 'collapsed ' : '';
                ?>
inner">
	<?php 
            }
            function _netteClosePanel()
            {
                ?>
		</div>
	</div>
	<?php 
            }
        }
        static $errorTypes = array(E_ERROR => 'Fatal Error', E_USER_ERROR => 'User Error', E_RECOVERABLE_ERROR => 'Recoverable Error', E_CORE_ERROR => 'Core Error', E_COMPILE_ERROR => 'Compile Error', E_PARSE => 'Parse Error', E_WARNING => 'Warning', E_CORE_WARNING => 'Core Warning', E_COMPILE_WARNING => 'Compile Warning', E_USER_WARNING => 'User Warning', E_NOTICE => 'Notice', E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
        $title = $exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()]) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
        $expandPath = NETTE_DIR . DIRECTORY_SEPARATOR;
        if (headers_sent()) {
            echo '</pre></xmp></table>';
        }
        ?>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="robots" content="noindex,noarchive">
	<meta name="generator" content="Nette Framework">

	<title><?php 
        echo htmlspecialchars($title);
        ?>
</title><!-- <?php 
        $ex = $exception;
        echo $ex->getMessage(), $ex->getCode() ? ' #' . $ex->getCode() : '';
        while (method_exists($ex, 'getPrevious') && ($ex = $ex->getPrevious()) || isset($ex->previous) && ($ex = $ex->previous)) {
            echo '; caused by ', get_class($ex), ' ', $ex->getMessage(), $ex->getCode() ? ' #' . $ex->getCode() : '';
        }
        ?>
 -->

	<style type="text/css" class="nette">body{margin:0 0 2em;padding:0}#netteBluescreen{font:9pt/1.5 Verdana,sans-serif;background:white;color:#333;position:absolute;left:0;top:0;width:100%;z-index:23178;text-align:left}#netteBluescreen *{font:inherit;color:inherit;background:transparent;border:none;margin:0;padding:0;text-align:inherit;text-indent:0}#netteBluescreen b{font-weight:bold}#netteBluescreen i{font-style:italic}#netteBluescreenIcon{position:absolute;right:.5em;top:.5em;z-index:23179;text-decoration:none;background:#CD1818;padding:3px}#netteBluescreenError{background:#CD1818;color:white;font:13pt/1.5 Verdana,sans-serif!important;display:block}#netteBluescreen h1{font-size:18pt;font-weight:normal;text-shadow:1px 1px 0 rgba(0,0,0,.4);margin:.7em 0}#netteBluescreen h2{font:14pt/1.5 sans-serif!important;color:#888;margin:.6em 0}#netteBluescreen a{text-decoration:none;color:#328ADC;padding:2px 4px;margin:-2px -4px}#netteBluescreen a abbr{font-family:sans-serif;color:#BBB}#netteBluescreen h3{font:bold 10pt/1.5 Verdana,sans-serif!important;margin:1em 0;padding:0}#netteBluescreen p,#netteBluescreen pre{margin:.8em 0}#netteBluescreen pre,#netteBluescreen code,#netteBluescreen table{font:9pt/1.5 Consolas,monospace!important}#netteBluescreen pre,#netteBluescreen table{background:#FDF5CE;padding:.4em .7em;border:1px dotted silver;overflow:auto}#netteBluescreen table pre{padding:0;margin:0;border:none}#netteBluescreen pre.nette-dump span{color:#C22}#netteBluescreen pre.nette-dump a{color:#333}#netteBluescreen div.panel{padding:1px 25px}#netteBluescreen div.inner{background:#F4F3F1;padding:.1em 1em 1em;border-radius:8px;-moz-border-radius:8px;-webkit-border-radius:8px}#netteBluescreen table{border-collapse:collapse;width:100%}#netteBluescreen .outer{overflow:auto}#netteBluescreen td,#netteBluescreen th{vertical-align:top;text-align:left;padding:2px 6px;border:1px solid #e6dfbf}#netteBluescreen th{width:10%;font-weight:bold}#netteBluescreen tr:nth-child(2n),#netteBluescreen tr:nth-child(2n) pre{background-color:#F7F0CB}#netteBluescreen ol{margin:1em 0;padding-left:2.5em}#netteBluescreen ul{font:7pt/1.5 Verdana,sans-serif!important;padding:2em 4em;margin:1em 0 0;color:#777;background:#F6F5F3 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFEAAAAjCAMAAADbuxbOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRF/fz24d7Y7Onj5uLd9vPu3drUzMvG09LN39zW8e7o2NbQ3NnT29jS0M7J1tXQAAAApvmsFgAAABB0Uk5T////////////////////AOAjXRkAAAKlSURBVHja7FbbsqQgDAwENEgc//9vN+SCWDtbtXPmZR/Wc6o02mlC58LA9ckFAOszvMV8xNgyUjyXhojfMVKvRL0ZHavxXYy5JrmchMdzou8YlTClxajtK8ZGGpWRoBr1+gFjKfHkJPbizabLgzE3pH7Iu4K980xgFvlrVzMZoVBWhtvouCDdcTDmTgMCJdVxJ9MKO6XxnliM7hxi5lbj2ZVM4l8DqYyKoNLYcfqBB1/LpHYxEcfVG6ZpMDgyFUVWY/Q1sSYPpIdSAKWqLWL0XqWiMWc4hpH0OQOMOAgdycY4N9Sb7wWANQs3rsDSdLAYiuxi5siVfOhBWIrtH0G3kNaF/8Q4kCPE1kMucG/ZMUBUCOgiKJkPuWWTLGVgLGpwns1DraUayCtoBqERyaYtVsm85NActRooezvSLO/sKZP/nq8n4+xcyjNsRu8zW6KWpdb7wjiQd4WrtFZYFiKHENSmWp6xshh96c2RQ+c7Lt+qbijyEjHWUJ/pZsy8MGIUuzNiPySK2Gqoh6ZTRF6ko6q3nVTkaA//itIrDpW6l3SLo8juOmqMXkYknu5FdQxWbhCfKHEGDhxxyTVaXJF3ZjSl3jMksjSOOKmne9pI+mcG5QvaUJhI9HpkmRo2NpCrDJvsktRhRE2MM6F2n7dt4OaMUq8bCctk0+PoMRzL+1l5PZ2eyM/Owr86gf8z/tOM53lom5+nVcFuB+eJVzlXwAYy9TZ9s537tfqcsJWbEU4nBngZo6FfO9T9CdhfBtmk2dLiAy8uS4zwOpMx2HqYbTC+amNeAYTpsP4SIgvWfUBWXxn3CMHW3ffd7k3+YIkx7w0t/CVGvcPejoeOlzOWzeGbawOHqXQGUTMZRcfj4XPCgW9y/fuvVn8zD9P1QHzv80uAAQA0i3Jer7Jr7gAAAABJRU5ErkJggg==') 99% 10px no-repeat;border-top:1px solid #DDD}#netteBluescreen .highlight{background:#CD1818;color:white;font-weight:bold;font-style:normal;display:block;padding:0 .4em;margin:0 -.4em}#netteBluescreen .line{color:#9F9C7F;font-weight:normal;font-style:normal}#netteBluescreen a[href^=editor\:]{color:inherit;border-bottom:1px dotted #328ADC}</style>


	<script type="text/javascript">/*<![CDATA[*/document.write('<style class="nette"> .collapsed { display: none; } </style>');
function netteToggle(c,e){for(var b=c.getElementsByTagName("abbr")[0],a=e?document.getElementById(e):c.nextSibling;a.nodeType!==1;)a=a.nextSibling;var d=a.currentStyle?a.currentStyle.display=="none":getComputedStyle(a,null).display=="none";try{b.innerHTML=String.fromCharCode(d?9660:9658)}catch(f){}a.style.display=d?a.tagName.toLowerCase()==="code"?"inline":"block":"none";if(c.id==="netteBluescreenIcon"){b=0;for(a=document.styleSheets;b<a.length;b++)if((a[b].owningElement||a[b].ownerNode).className!==
"nette")a[b].disabled=d?true:a[b].oldDisabled}return true};/*]]>*/</script>
</head>



<body>
<div id="netteBluescreen">
	<a id="netteBluescreenIcon" href="#" onclick="return !netteToggle(this)"><abbr>&#x25bc;</abbr></a

	><div>
		<div id="netteBluescreenError" class="panel">
			<h1><?php 
        echo htmlspecialchars($title), $exception->getCode() ? ' #' . $exception->getCode() : '';
        ?>
</h1>

			<p><?php 
        echo htmlspecialchars($exception->getMessage());
        ?>
</p>
		</div>



		<?php 
        $ex = $exception;
        $level = 0;
        ?>
		<?php 
        do {
            ?>

			<?php 
            if ($level++) {
                ?>
				<?php 
                _netteOpenPanel('Caused by', $level > 2);
                ?>
				<div class="panel">
					<h1><?php 
                echo htmlspecialchars(get_class($ex)), $ex->getCode() ? ' #' . $ex->getCode() : '';
                ?>
</h1>

					<p><b><?php 
                echo htmlspecialchars($ex->getMessage());
                ?>
</b></p>
				</div>
			<?php 
            }
            ?>

			<?php 
            $stack = $ex->getTrace();
            $expanded = NULL;
            ?>
			<?php 
            if (strpos($ex->getFile(), $expandPath) === 0) {
                foreach ($stack as $key => $row) {
                    if (isset($row['file']) && strpos($row['file'], $expandPath) !== 0) {
                        $expanded = $key;
                        break;
                    }
                }
            }
            ?>
			<?php 
            if (is_file($ex->getFile())) {
                ?>
			<?php 
                _netteOpenPanel('Source file', $expanded !== NULL);
                ?>
				<p><b>File:</b> <?php 
                if (self::$editor) {
                    echo '<a href="', htmlspecialchars(strtr(self::$editor, array('%file' => rawurlencode($ex->getFile()), '%line' => $ex->getLine()))), '">';
                }
                ?>
				<?php 
                echo htmlspecialchars($ex->getFile()), self::$editor ? '</a>' : '';
                ?>
 &nbsp; <b>Line:</b> <?php 
                echo $ex->getLine();
                ?>
</p>
				<pre><?php 
                _netteDebugPrintCode($ex->getFile(), $ex->getLine());
                ?>
</pre>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>



			<?php 
            if (isset($stack[0]['class']) && $stack[0]['class'] === 'Debug' && ($stack[0]['function'] === '_shutdownHandler' || $stack[0]['function'] === '_errorHandler')) {
                unset($stack[0]);
            }
            ?>
			<?php 
            if ($stack) {
                ?>
			<?php 
                _netteOpenPanel('Call stack', FALSE);
                ?>
				<ol>
					<?php 
                foreach ($stack as $key => $row) {
                    ?>
					<li><p>

					<?php 
                    if (isset($row['file']) && is_file($row['file'])) {
                        ?>
						<?php 
                        echo self::$editor ? '<a href="' . htmlspecialchars(strtr(self::$editor, array('%file' => rawurlencode($row['file']), '%line' => $row['line']))) . '"' : '<span';
                        ?>
 title="<?php 
                        echo htmlSpecialChars($row['file']);
                        ?>
">
						<?php 
                        echo htmlSpecialChars(basename(dirname($row['file']))), '/<b>', htmlSpecialChars(basename($row['file'])), '</b>', self::$editor ? '</a>' : '</span>', ' (', $row['line'], ')';
                        ?>
					<?php 
                    } else {
                        ?>
						<i>inner-code</i><?php 
                        if (isset($row['line'])) {
                            echo ' (', $row['line'], ')';
                        }
                        ?>
					<?php 
                    }
                    ?>

					<?php 
                    if (isset($row['file']) && is_file($row['file'])) {
                        ?>
<a href="#" onclick="return !netteToggle(this, 'netteBsSrc<?php 
                        echo "{$level}-{$key}";
                        ?>
')">source <abbr>&#x25ba;</abbr></a>&nbsp; <?php 
                    }
                    ?>

					<?php 
                    if (isset($row['class'])) {
                        echo $row['class'] . $row['type'];
                    }
                    ?>
					<?php 
                    echo $row['function'];
                    ?>

					(<?php 
                    if (!empty($row['args'])) {
                        ?>
<a href="#" onclick="return !netteToggle(this, 'netteBsArgs<?php 
                        echo "{$level}-{$key}";
                        ?>
')">arguments <abbr>&#x25ba;</abbr></a><?php 
                    }
                    ?>
)
					</p>

					<?php 
                    if (!empty($row['args'])) {
                        ?>
						<div class="collapsed outer" id="netteBsArgs<?php 
                        echo "{$level}-{$key}";
                        ?>
">
						<table>
						<?php 
                        try {
                            $r = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
                            $params = $r->getParameters();
                        } catch (Exception $e) {
                            $params = array();
                        }
                        foreach ($row['args'] as $k => $v) {
                            echo '<tr><th>', isset($params[$k]) ? '$' . $params[$k]->name : "#{$k}", '</th><td>';
                            echo _netteDump(self::_dump($v, 0));
                            echo "</td></tr>\n";
                        }
                        ?>
						</table>
						</div>
					<?php 
                    }
                    ?>


					<?php 
                    if (isset($row['file']) && is_file($row['file'])) {
                        ?>
						<pre <?php 
                        if ($expanded !== $key) {
                            echo 'class="collapsed"';
                        }
                        ?>
 id="netteBsSrc<?php 
                        echo "{$level}-{$key}";
                        ?>
"><?php 
                        _netteDebugPrintCode($row['file'], $row['line']);
                        ?>
</pre>
					<?php 
                    }
                    ?>

					</li>
					<?php 
                }
                ?>
				</ol>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>



			<?php 
            if ($ex instanceof IDebugPanel && ($tab = $ex->getTab()) && ($panel = $ex->getPanel())) {
                ?>
			<?php 
                _netteOpenPanel($tab, FALSE);
                ?>
				<?php 
                echo $panel;
                ?>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>



			<?php 
            if (isset($ex->context) && is_array($ex->context)) {
                ?>
			<?php 
                _netteOpenPanel('Variables', TRUE);
                ?>
			<div class="outer">
			<table>
			<?php 
                foreach ($ex->context as $k => $v) {
                    echo '<tr><th>$', htmlspecialchars($k), '</th><td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
                }
                ?>
			</table>
			</div>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>

		<?php 
        } while (method_exists($ex, 'getPrevious') && ($ex = $ex->getPrevious()) || isset($ex->previous) && ($ex = $ex->previous));
        ?>
		<?php 
        while (--$level) {
            _netteClosePanel();
        }
        ?>



		<?php 
        if (!empty($application)) {
            ?>
		<?php 
            _netteOpenPanel('Nette Application', TRUE);
            ?>
			<h3>Requests</h3>
			<?php 
            $tmp = $application->getRequests();
            echo _netteDump(self::_dump($tmp, 0));
            ?>

			<h3>Presenter</h3>
			<?php 
            $tmp = $application->getPresenter();
            echo _netteDump(self::_dump($tmp, 0));
            ?>
		<?php 
            _netteClosePanel();
            ?>
		<?php 
        }
        ?>



		<?php 
        _netteOpenPanel('Environment', TRUE);
        ?>
			<?php 
        $list = get_defined_constants(TRUE);
        if (!empty($list['user'])) {
            ?>
			<h3><a href="#" onclick="return !netteToggle(this, 'netteBsPnl-env-const')">Constants <abbr>&#x25bc;</abbr></a></h3>
			<div class="outer">
			<table id="netteBsPnl-env-const">
			<?php 
            foreach ($list['user'] as $k => $v) {
                echo '<tr><th>', htmlspecialchars($k), '</th>';
                echo '<td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
            }
            ?>
			</table>
			</div>
			<?php 
        }
        ?>


			<h3><a href="#" onclick="return !netteToggle(this, 'netteBsPnl-env-files')">Included files <abbr>&#x25ba;</abbr></a> (<?php 
        echo count(get_included_files());
        ?>
)</h3>
			<div class="outer">
			<table id="netteBsPnl-env-files" class="collapsed">
			<?php 
        foreach (get_included_files() as $v) {
            echo '<tr><td>', htmlspecialchars($v), "</td></tr>\n";
        }
        ?>
			</table>
			</div>


			<h3>$_SERVER</h3>
			<?php 
        if (empty($_SERVER)) {
            ?>
			<p><i>empty</i></p>
			<?php 
        } else {
            ?>
			<div class="outer">
			<table>
			<?php 
            foreach ($_SERVER as $k => $v) {
                echo '<tr><th>', htmlspecialchars($k), '</th><td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
            }
            ?>
			</table>
			</div>
			<?php 
        }
        ?>
		<?php 
        _netteClosePanel();
        ?>



		<?php 
        _netteOpenPanel('HTTP request', TRUE);
        ?>
			<?php 
        if (function_exists('apache_request_headers')) {
            ?>
			<h3>Headers</h3>
			<div class="outer">
			<table>
			<?php 
            foreach (apache_request_headers() as $k => $v) {
                echo '<tr><th>', htmlspecialchars($k), '</th><td>', htmlspecialchars($v), "</td></tr>\n";
            }
            ?>
			</table>
			</div>
			<?php 
        }
        ?>


			<?php 
        foreach (array('_GET', '_POST', '_COOKIE') as $name) {
            ?>
			<h3>$<?php 
            echo $name;
            ?>
</h3>
			<?php 
            if (empty($GLOBALS[$name])) {
                ?>
			<p><i>empty</i></p>
			<?php 
            } else {
                ?>
			<div class="outer">
			<table>
			<?php 
                foreach ($GLOBALS[$name] as $k => $v) {
                    echo '<tr><th>', htmlspecialchars($k), '</th><td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
                }
                ?>
			</table>
			</div>
			<?php 
            }
            ?>
			<?php 
        }
        ?>
		<?php 
        _netteClosePanel();
        ?>



		<?php 
        _netteOpenPanel('HTTP response', TRUE);
        ?>
			<h3>Headers</h3>
			<?php 
        if (headers_list()) {
            ?>
			<pre><?php 
            foreach (headers_list() as $s) {
                echo htmlspecialchars($s), '<br>';
            }
            ?>
</pre>
			<?php 
        } else {
            ?>
			<p><i>no headers</i></p>
			<?php 
        }
        ?>
		<?php 
        _netteClosePanel();
        ?>


		<ul>
			<li>Report generated at <?php 
        echo @date('Y/m/d H:i:s', self::$time);
        ?>
</li>
			<?php 
        if (preg_match('#^https?://#', self::$source)) {
            ?>
				<li><a href="<?php 
            echo htmlSpecialChars(self::$source);
            ?>
"><?php 
            echo htmlSpecialChars(self::$source);
            ?>
</a></li>
			<?php 
        } elseif (self::$source) {
            ?>
				<li><?php 
            echo htmlSpecialChars(self::$source);
            ?>
</li>
			<?php 
        }
        ?>
			<li>PHP <?php 
        echo htmlSpecialChars(PHP_VERSION);
        ?>
</li>
			<?php 
        if (isset($_SERVER['SERVER_SOFTWARE'])) {
            ?>
<li><?php 
            echo htmlSpecialChars($_SERVER['SERVER_SOFTWARE']);
            ?>
</li><?php 
        }
        ?>
			<?php 
        if (class_exists('Framework')) {
            ?>
<li><?php 
            echo htmlSpecialChars('Nette Framework ' . Framework::VERSION);
            ?>
 <i>(revision <?php 
            echo htmlSpecialChars(Framework::REVISION);
            ?>
)</i></li><?php 
        }
        ?>
		</ul>
	</div>
</div>

<script type="text/javascript">/*<![CDATA[*/document.body.appendChild(document.getElementById("netteBluescreen"));document.onkeyup=function(a){a=a||window.event;if(a.keyCode==27)return document.getElementById("netteBluescreenIcon").onclick()};for(var i=0,styles=document.styleSheets;i<styles.length;i++)if((styles[i].owningElement||styles[i].ownerNode).className!=="nette"){styles[i].oldDisabled=styles[i].disabled;styles[i].disabled=true};/*]]>*/</script>
</body>
</html><?php 
    }
示例#26
0
文件: Debug.php 项目: vrana/dibi
    public static function _paintBlueScreen(Exception $exception)
    {
        $internals = array();
        foreach (array('Object', 'ObjectMixin') as $class) {
            if (class_exists($class, FALSE)) {
                $rc = new ReflectionClass($class);
                $internals[$rc->getFileName()] = TRUE;
            }
        }
        if (class_exists('Environment', FALSE)) {
            $application = Environment::getServiceLocator()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getServiceLocator()->getService('Nette\\Application\\Application') : NULL;
        }
        if (!function_exists('_netteDebugPrintCode')) {
            function _netteDebugPrintCode($file, $line, $count = 15)
            {
                if (function_exists('ini_set')) {
                    ini_set('highlight.comment', '#999; font-style: italic');
                    ini_set('highlight.default', '#000');
                    ini_set('highlight.html', '#06b');
                    ini_set('highlight.keyword', '#d24; font-weight: bold');
                    ini_set('highlight.string', '#080');
                }
                $start = max(1, $line - floor($count / 2));
                $source = @file_get_contents($file);
                if (!$source) {
                    return;
                }
                $source = explode("\n", highlight_string($source, TRUE));
                $spans = 1;
                echo $source[0];
                $source = explode('<br />', $source[1]);
                array_unshift($source, NULL);
                $i = $start;
                while (--$i >= 1) {
                    if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
                        if ($m[1] !== '</span>') {
                            $spans++;
                            echo $m[1];
                        }
                        break;
                    }
                }
                $source = array_slice($source, $start, $count, TRUE);
                end($source);
                $numWidth = strlen((string) key($source));
                foreach ($source as $n => $s) {
                    $spans += substr_count($s, '<span') - substr_count($s, '</span');
                    $s = str_replace(array("\r", "\n"), array('', ''), $s);
                    if ($n === $line) {
                        printf("<span class='highlight'>Line %{$numWidth}s:    %s\n</span>%s", $n, strip_tags($s), preg_replace('#[^>]*(<[^>]+>)[^<]*#', '$1', $s));
                    } else {
                        printf("<span class='line'>Line %{$numWidth}s:</span>    %s\n", $n, $s);
                    }
                }
                echo str_repeat('</span>', $spans), '</code>';
            }
            function _netteDump($dump)
            {
                return '<pre class="nette-dump">' . preg_replace_callback('#(^|\\s+)?(.*)\\((\\d+)\\) <code>#', '_netteDumpCb', $dump) . '</pre>';
            }
            function _netteDumpCb($m)
            {
                return "{$m['1']}<a href='#' onclick='return !netteToggle(this)'>{$m['2']}({$m['3']}) " . (trim($m[1]) || $m[3] < 7 ? '<abbr>&#x25bc;</abbr> </a><code>' : '<abbr>&#x25ba;</abbr> </a><code class="collapsed">');
            }
            function _netteOpenPanel($name, $collapsed)
            {
                static $id;
                $id++;
                ?>
	<div class="panel">
		<h2><a href="#" onclick="return !netteToggle(this, 'pnl<?php 
                echo $id;
                ?>
')"><?php 
                echo htmlSpecialChars($name);
                ?>
 <abbr><?php 
                echo $collapsed ? '&#x25ba;' : '&#x25bc;';
                ?>
</abbr></a></h2>

		<div id="pnl<?php 
                echo $id;
                ?>
" class="<?php 
                echo $collapsed ? 'collapsed ' : '';
                ?>
inner">
	<?php 
            }
            function _netteClosePanel()
            {
                ?>
		</div>
	</div>
	<?php 
            }
        }
        static $errorTypes = array(E_ERROR => 'Fatal Error', E_USER_ERROR => 'User Error', E_RECOVERABLE_ERROR => 'Recoverable Error', E_CORE_ERROR => 'Core Error', E_COMPILE_ERROR => 'Compile Error', E_PARSE => 'Parse Error', E_WARNING => 'Warning', E_CORE_WARNING => 'Core Warning', E_COMPILE_WARNING => 'Compile Warning', E_USER_WARNING => 'User Warning', E_NOTICE => 'Notice', E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
        $title = $exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()]) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
        $rn = 0;
        if (headers_sent()) {
            echo '</pre></xmp></table>';
        }
        ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="robots" content="noindex,noarchive">
	<meta name="generator" content="Nette Framework">

	<title><?php 
        echo htmlspecialchars($title);
        ?>
</title><!-- <?php 
        echo $exception->getMessage(), $exception->getCode() ? ' #' . $exception->getCode() : '';
        ?>
 -->

	<style type="text/css">/* <![CDATA[ */body{margin:0 0 2em;padding:0}#netteBluescreen{font:9pt/1.5 Verdana,sans-serif;background:white;color:#333;position:absolute;left:0;top:0;width:100%;z-index:23178;text-align:left}#netteBluescreen *{color:inherit;background:inherit;text-align:inherit}#netteBluescreenIcon{position:absolute;right:.5em;top:.5em;z-index:23179;text-decoration:none;background:red;padding:3px}#netteBluescreenIcon abbr{color:black!important}#netteBluescreen h1{font:18pt/1.5 Verdana,sans-serif!important;margin:.6em 0}#netteBluescreen h2{font:14pt/1.5 sans-serif!important;color:#888;margin:.6em 0}#netteBluescreen a{text-decoration:none;color:#4197E3}#netteBluescreen a abbr{font-family:sans-serif;color:#999}#netteBluescreen h3{font:bold 10pt/1.5 Verdana,sans-serif!important;margin:1em 0;padding:0}#netteBluescreen p{margin:.8em 0}#netteBluescreen pre,#netteBluescreen code,#netteBluescreen table{font:9pt/1.5 Consolas,monospace!important}#netteBluescreen pre,#netteBluescreen table{background:#fffbcc;padding:.4em .7em;border:1px dotted silver}#netteBluescreen table pre{padding:0;margin:0;border:none}#netteBluescreen pre.nette-dump span{color:#c16549}#netteBluescreen pre.nette-dump a{color:#333}#netteBluescreen div.panel{border-bottom:1px solid #eee;padding:1px 2em}#netteBluescreen div.inner{padding:.1em 1em 1em;background:#f5f5f5}#netteBluescreen table{border-collapse:collapse;width:100%}#netteBluescreen td,#netteBluescreen th{vertical-align:top;text-align:left;padding:2px 3px;border:1px solid #eeb}#netteBluescreen th{width:10%;font-weight:bold}#netteBluescreen .odd,#netteBluescreen .odd pre{background-color:#faf5c3}#netteBluescreen ul{font:7pt/1.5 Verdana,sans-serif!important;padding:1em 2em 50px}#netteBluescreen .highlight,#netteBluescreenError{background:red;color:white;font-weight:bold;font-style:normal;display:block}#netteBluescreen .line{color:#9e9e7e;font-weight:normal;font-style:normal}/* ]]> */</style>


	<script type="text/javascript">/* <![CDATA[ */document.write("<style> .collapsed { display: none; } </style>");function netteToggle(a,b){var c=a.getElementsByTagName("abbr")[0];for(a=b?document.getElementById(b):a.nextSibling;a.nodeType!==1;)a=a.nextSibling;b=a.currentStyle?a.currentStyle.display=="none":getComputedStyle(a,null).display=="none";c.innerHTML=String.fromCharCode(b?9660:9658);a.style.display=b?a.tagName.toLowerCase()==="code"?"inline":"block":"none";return true};
/* ]]> */</script>
</head>



<body>
<div id="netteBluescreen">
	<a id="netteBluescreenIcon" href="#" onclick="return !netteToggle(this)"><abbr>&#x25bc;</abbr></a

	><div>
		<div id="netteBluescreenError" class="panel">
			<h1><?php 
        echo htmlspecialchars($title), $exception->getCode() ? ' #' . $exception->getCode() : '';
        ?>
</h1>

			<p><?php 
        echo htmlspecialchars($exception->getMessage());
        ?>
</p>
		</div>



		<?php 
        $ex = $exception;
        $level = 0;
        ?>
		<?php 
        do {
            ?>

			<?php 
            if ($level++) {
                ?>
				<?php 
                _netteOpenPanel('Caused by', $level > 2);
                ?>
				<div class="panel">
					<h1><?php 
                echo htmlspecialchars(get_class($ex)), $ex->getCode() ? ' #' . $ex->getCode() : '';
                ?>
</h1>

					<p><?php 
                echo htmlspecialchars($ex->getMessage());
                ?>
</p>
				</div>
			<?php 
            }
            ?>

			<?php 
            $collapsed = isset($internals[$ex->getFile()]);
            ?>
			<?php 
            if (is_file($ex->getFile())) {
                ?>
			<?php 
                _netteOpenPanel('Source file', $collapsed);
                ?>
				<p><strong>File:</strong> <?php 
                echo htmlspecialchars($ex->getFile());
                ?>
 &nbsp; <strong>Line:</strong> <?php 
                echo $ex->getLine();
                ?>
</p>
				<pre><?php 
                _netteDebugPrintCode($ex->getFile(), $ex->getLine());
                ?>
</pre>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>



			<?php 
            _netteOpenPanel('Call stack', FALSE);
            ?>
				<ol>
					<?php 
            foreach ($ex->getTrace() as $key => $row) {
                ?>
					<li><p>

					<?php 
                if (isset($row['file'])) {
                    ?>
						<span title="<?php 
                    echo htmlSpecialChars($row['file']);
                    ?>
"><?php 
                    echo htmlSpecialChars(basename(dirname($row['file']))), '/<b>', htmlSpecialChars(basename($row['file'])), '</b></span> (', $row['line'], ')';
                    ?>
					<?php 
                } else {
                    ?>
						&lt;PHP inner-code&gt;
					<?php 
                }
                ?>

					<?php 
                if (isset($row['file']) && is_file($row['file'])) {
                    ?>
<a href="#" onclick="return !netteToggle(this, 'src<?php 
                    echo "{$level}-{$key}";
                    ?>
')">source <abbr>&#x25ba;</abbr></a>&nbsp; <?php 
                }
                ?>

					<?php 
                if (isset($row['class'])) {
                    echo $row['class'] . $row['type'];
                }
                ?>
					<?php 
                echo $row['function'];
                ?>

					(<?php 
                if (!empty($row['args'])) {
                    ?>
<a href="#" onclick="return !netteToggle(this, 'args<?php 
                    echo "{$level}-{$key}";
                    ?>
')">arguments <abbr>&#x25ba;</abbr></a><?php 
                }
                ?>
)
					</p>

					<?php 
                if (!empty($row['args'])) {
                    ?>
						<div class="collapsed" id="args<?php 
                    echo "{$level}-{$key}";
                    ?>
">
						<table>
						<?php 
                    try {
                        $r = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
                        $params = $r->getParameters();
                    } catch (Exception $e) {
                        $params = array();
                    }
                    foreach ($row['args'] as $k => $v) {
                        echo '<tr><th>', isset($params[$k]) ? '$' . $params[$k]->name : "#{$k}", '</th><td>';
                        echo _netteDump(self::_dump($v, 0));
                        echo "</td></tr>\n";
                    }
                    ?>
						</table>
						</div>
					<?php 
                }
                ?>


					<?php 
                if (isset($row['file']) && is_file($row['file'])) {
                    ?>
						<pre <?php 
                    if (!$collapsed || isset($internals[$row['file']])) {
                        echo 'class="collapsed"';
                    } else {
                        $collapsed = FALSE;
                    }
                    ?>
 id="src<?php 
                    echo "{$level}-{$key}";
                    ?>
"><?php 
                    _netteDebugPrintCode($row['file'], $row['line']);
                    ?>
</pre>
					<?php 
                }
                ?>

					</li>
					<?php 
            }
            ?>

					<?php 
            if (!isset($row)) {
                ?>
					<li><i>empty</i></li>
					<?php 
            }
            ?>
				</ol>
			<?php 
            _netteClosePanel();
            ?>



			<?php 
            if ($ex instanceof IDebugPanel && ($panel = $ex->getPanel())) {
                ?>
			<?php 
                _netteOpenPanel($ex->getTab(), FALSE);
                ?>
				<?php 
                echo $panel;
                ?>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>



			<?php 
            if (isset($ex->context) && is_array($ex->context)) {
                ?>
			<?php 
                _netteOpenPanel('Variables', TRUE);
                ?>
			<table>
			<?php 
                foreach ($ex->context as $k => $v) {
                    echo '<tr><th>$', htmlspecialchars($k), '</th><td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
                }
                ?>
			</table>
			<?php 
                _netteClosePanel();
                ?>
			<?php 
            }
            ?>

		<?php 
        } while (method_exists($ex, 'getPrevious') && ($ex = $ex->getPrevious()) || isset($ex->previous) && ($ex = $ex->previous));
        ?>
		<?php 
        while (--$level) {
            _netteClosePanel();
        }
        ?>



		<?php 
        if (!empty($application)) {
            ?>
		<?php 
            _netteOpenPanel('Nette Application', TRUE);
            ?>
			<h3>Requests</h3>
			<?php 
            $tmp = $application->getRequests();
            echo _netteDump(self::_dump($tmp, 0));
            ?>

			<h3>Presenter</h3>
			<?php 
            $tmp = $application->getPresenter();
            echo _netteDump(self::_dump($tmp, 0));
            ?>
		<?php 
            _netteClosePanel();
            ?>
		<?php 
        }
        ?>



		<?php 
        _netteOpenPanel('Environment', TRUE);
        ?>
			<?php 
        $list = get_defined_constants(TRUE);
        if (!empty($list['user'])) {
            ?>
			<h3><a href="#" onclick="return !netteToggle(this, 'pnl-env-const')">Constants <abbr>&#x25bc;</abbr></a></h3>
			<table id="pnl-env-const">
			<?php 
            foreach ($list['user'] as $k => $v) {
                echo '<tr' . ($rn++ % 2 ? ' class="odd"' : '') . '><th>', htmlspecialchars($k), '</th>';
                echo '<td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
            }
            ?>
			</table>
			<?php 
        }
        ?>


			<h3><a href="#" onclick="return !netteToggle(this, 'pnl-env-files')">Included files <abbr>&#x25ba;</abbr></a>(<?php 
        echo count(get_included_files());
        ?>
)</h3>
			<table id="pnl-env-files" class="collapsed">
			<?php 
        foreach (get_included_files() as $v) {
            echo '<tr' . ($rn++ % 2 ? ' class="odd"' : '') . '><td>', htmlspecialchars($v), "</td></tr>\n";
        }
        ?>
			</table>


			<h3>$_SERVER</h3>
			<?php 
        if (empty($_SERVER)) {
            ?>
			<p><i>empty</i></p>
			<?php 
        } else {
            ?>
			<table>
			<?php 
            foreach ($_SERVER as $k => $v) {
                echo '<tr' . ($rn++ % 2 ? ' class="odd"' : '') . '><th>', htmlspecialchars($k), '</th><td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
            }
            ?>
			</table>
			<?php 
        }
        ?>
		<?php 
        _netteClosePanel();
        ?>



		<?php 
        _netteOpenPanel('HTTP request', TRUE);
        ?>
			<?php 
        if (function_exists('apache_request_headers')) {
            ?>
			<h3>Headers</h3>
			<table>
			<?php 
            foreach (apache_request_headers() as $k => $v) {
                echo '<tr' . ($rn++ % 2 ? ' class="odd"' : '') . '><th>', htmlspecialchars($k), '</th><td>', htmlspecialchars($v), "</td></tr>\n";
            }
            ?>
			</table>
			<?php 
        }
        ?>


			<?php 
        foreach (array('_GET', '_POST', '_COOKIE') as $name) {
            ?>
			<h3>$<?php 
            echo $name;
            ?>
</h3>
			<?php 
            if (empty($GLOBALS[$name])) {
                ?>
			<p><i>empty</i></p>
			<?php 
            } else {
                ?>
			<table>
			<?php 
                foreach ($GLOBALS[$name] as $k => $v) {
                    echo '<tr' . ($rn++ % 2 ? ' class="odd"' : '') . '><th>', htmlspecialchars($k), '</th><td>', _netteDump(self::_dump($v, 0)), "</td></tr>\n";
                }
                ?>
			</table>
			<?php 
            }
            ?>
			<?php 
        }
        ?>
		<?php 
        _netteClosePanel();
        ?>



		<?php 
        _netteOpenPanel('HTTP response', TRUE);
        ?>
			<h3>Headers</h3>
			<?php 
        if (headers_list()) {
            ?>
			<pre><?php 
            foreach (headers_list() as $s) {
                echo htmlspecialchars($s), '<br>';
            }
            ?>
</pre>
			<?php 
        } else {
            ?>
			<p><i>no headers</i></p>
			<?php 
        }
        ?>
		<?php 
        _netteClosePanel();
        ?>


		<ul>
			<li>Report generated at <?php 
        echo @date('Y/m/d H:i:s', self::$time);
        ?>
</li>
			<?php 
        if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
            ?>
				<li><a href="<?php 
            $url = (isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://') . htmlSpecialChars($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            ?>
"><?php 
            echo $url;
            ?>
</a></li>
			<?php 
        }
        ?>
			<li>PHP <?php 
        echo htmlSpecialChars(PHP_VERSION);
        ?>
</li>
			<?php 
        if (isset($_SERVER['SERVER_SOFTWARE'])) {
            ?>
<li><?php 
            echo htmlSpecialChars($_SERVER['SERVER_SOFTWARE']);
            ?>
</li><?php 
        }
        ?>
			<?php 
        if (class_exists('Framework')) {
            ?>
<li><?php 
            echo htmlSpecialChars('Nette Framework ' . Framework::VERSION);
            ?>
 <i>(revision <?php 
            echo htmlSpecialChars(Framework::REVISION);
            ?>
)</i></li><?php 
        }
        ?>
		</ul>
	</div>
</div>

<script type="text/javascript">/* <![CDATA[ */document.body.appendChild(document.getElementById("netteBluescreen"));
/* ]]> */</script>
</body>
</html><?php 
    }
示例#27
0
    public function render(Exception $exception)
    {
        $panels = $this->panels;
        static $errorTypes = array(E_ERROR => 'Fatal Error', E_USER_ERROR => 'User Error', E_RECOVERABLE_ERROR => 'Recoverable Error', E_CORE_ERROR => 'Core Error', E_COMPILE_ERROR => 'Compile Error', E_PARSE => 'Parse Error', E_WARNING => 'Warning', E_CORE_WARNING => 'Core Warning', E_COMPILE_WARNING => 'Compile Warning', E_USER_WARNING => 'User Warning', E_NOTICE => 'Notice', E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
        $title = $exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()]) ? $errorTypes[$exception->getSeverity()] : get_class($exception);
        $expandPath = NETTE_DIR . DIRECTORY_SEPARATOR;
        $counter = 0;
        ?>
<!DOCTYPE html><!-- "' --></script></style></pre></xmp></table>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="robots" content="noindex,noarchive">
	<meta name="generator" content="Nette Framework">

	<title><?php 
        echo htmlspecialchars($title);
        ?>
</title><!-- <?php 
        $ex = $exception;
        echo htmlspecialchars($ex->getMessage() . ($ex->getCode() ? ' #' . $ex->getCode() : ''));
        while (method_exists($ex, 'getPrevious') && ($ex = $ex->getPrevious()) || isset($ex->previous) && ($ex = $ex->previous)) {
            echo htmlspecialchars('; caused by ' . get_class($ex) . ' ' . $ex->getMessage() . ($ex->getCode() ? ' #' . $ex->getCode() : ''));
        }
        ?>
 -->

	<style type="text/css" class="nette">html{overflow-y:scroll}body{margin:0 0 2em;padding:0}#netteBluescreen{font:9pt/1.5 Verdana,sans-serif;background:white;color:#333;position:absolute;left:0;top:0;width:100%;z-index:23178;text-align:left}#netteBluescreen *{font:inherit;color:inherit;background:transparent;border:none;margin:0;padding:0;text-align:inherit;text-indent:0}#netteBluescreen b{font-weight:bold}#netteBluescreen i{font-style:italic}#netteBluescreen a{text-decoration:none;color:#328ADC;padding:2px 4px;margin:-2px -4px}#netteBluescreen a:hover,#netteBluescreen a:active,#netteBluescreen a:focus{color:#085AA3}#netteBluescreen a abbr{font-family:sans-serif;color:#BBB}#netteBluescreenIcon{position:absolute;right:.5em;top:.5em;z-index:23179;text-decoration:none;background:#CD1818;padding:3px}#netteBluescreenError{background:#CD1818;color:white;font:13pt/1.5 Verdana,sans-serif!important;display:block}#netteBluescreenError #netteBsSearch{color:#CD1818;font-size:.7em}#netteBluescreenError:hover #netteBsSearch{color:#ED8383}#netteBluescreen h1{font-size:18pt;font-weight:normal;text-shadow:1px 1px 0 rgba(0,0,0,.4);margin:.7em 0}#netteBluescreen h2{font:14pt/1.5 sans-serif!important;color:#888;margin:.6em 0}#netteBluescreen h3{font:bold 10pt/1.5 Verdana,sans-serif!important;margin:1em 0;padding:0}#netteBluescreen p,#netteBluescreen pre{margin:.8em 0}#netteBluescreen pre,#netteBluescreen code,#netteBluescreen table{font:9pt/1.5 Consolas,monospace!important}#netteBluescreen pre,#netteBluescreen table{background:#FDF5CE;padding:.4em .7em;border:1px dotted silver;overflow:auto}#netteBluescreen pre div{min-width:100%;float:left;_float:none}#netteBluescreen table pre{padding:0;margin:0;border:none}#netteBluescreen pre .php-array,#netteBluescreen pre .php-object{color:#C22}#netteBluescreen pre .php-string{color:#080}#netteBluescreen pre .php-int,#netteBluescreen pre .php-float,#netteBluescreen pre .php-null,#netteBluescreen pre .php-bool{color:#328ADC}#netteBluescreen pre .php-visibility{font-size:85%;color:#998}#netteBluescreen pre.nette-dump a{color:#333}#netteBluescreen div.panel{padding:1px 25px}#netteBluescreen div.inner{background:#F4F3F1;padding:.1em 1em 1em;border-radius:8px;-moz-border-radius:8px;-webkit-border-radius:8px}#netteBluescreen table{border-collapse:collapse;width:100%}#netteBluescreen .outer{overflow:auto}#netteBluescreen td,#netteBluescreen th{vertical-align:top;text-align:left;padding:2px 6px;border:1px solid #e6dfbf}#netteBluescreen th{font-weight:bold}#netteBluescreen tr>:first-child{width:20%}#netteBluescreen tr:nth-child(2n),#netteBluescreen tr:nth-child(2n) pre{background-color:#F7F0CB}#netteBluescreen ol{margin:1em 0;padding-left:2.5em}#netteBluescreen ul{font:7pt/1.5 Verdana,sans-serif!important;padding:2em 4em;margin:1em 0 0;color:#777;background:#F6F5F3 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFEAAAAjCAMAAADbuxbOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRF/fz24d7Y7Onj5uLd9vPu3drUzMvG09LN39zW8e7o2NbQ3NnT29jS0M7J1tXQAAAApvmsFgAAABB0Uk5T////////////////////AOAjXRkAAAKlSURBVHja7FbbsqQgDAwENEgc//9vN+SCWDtbtXPmZR/Wc6o02mlC58LA9ckFAOszvMV8xNgyUjyXhojfMVKvRL0ZHavxXYy5JrmchMdzou8YlTClxajtK8ZGGpWRoBr1+gFjKfHkJPbizabLgzE3pH7Iu4K980xgFvlrVzMZoVBWhtvouCDdcTDmTgMCJdVxJ9MKO6XxnliM7hxi5lbj2ZVM4l8DqYyKoNLYcfqBB1/LpHYxEcfVG6ZpMDgyFUVWY/Q1sSYPpIdSAKWqLWL0XqWiMWc4hpH0OQOMOAgdycY4N9Sb7wWANQs3rsDSdLAYiuxi5siVfOhBWIrtH0G3kNaF/8Q4kCPE1kMucG/ZMUBUCOgiKJkPuWWTLGVgLGpwns1DraUayCtoBqERyaYtVsm85NActRooezvSLO/sKZP/nq8n4+xcyjNsRu8zW6KWpdb7wjiQd4WrtFZYFiKHENSmWp6xshh96c2RQ+c7Lt+qbijyEjHWUJ/pZsy8MGIUuzNiPySK2Gqoh6ZTRF6ko6q3nVTkaA//itIrDpW6l3SLo8juOmqMXkYknu5FdQxWbhCfKHEGDhxxyTVaXJF3ZjSl3jMksjSOOKmne9pI+mcG5QvaUJhI9HpkmRo2NpCrDJvsktRhRE2MM6F2n7dt4OaMUq8bCctk0+PoMRzL+1l5PZ2eyM/Owr86gf8z/tOM53lom5+nVcFuB+eJVzlXwAYy9TZ9s537tfqcsJWbEU4nBngZo6FfO9T9CdhfBtmk2dLiAy8uS4zwOpMx2HqYbTC+amNeAYTpsP4SIgvWfUBWXxn3CMHW3ffd7k3+YIkx7w0t/CVGvcPejoeOlzOWzeGbawOHqXQGUTMZRcfj4XPCgW9y/fuvVn8zD9P1QHzv80uAAQA0i3Jer7Jr7gAAAABJRU5ErkJggg==') 99% 10px no-repeat;border-top:1px solid #DDD}#netteBluescreen .highlight{background:#CD1818;color:white;font-weight:bold;font-style:normal;display:block;padding:0 .4em;margin:0 -.4em}#netteBluescreen .line{color:#9F9C7F;font-weight:normal;font-style:normal}#netteBluescreen a[href^=editor\:]{color:inherit;border-bottom:1px dotted #C1D2E1}</style>
</head>


<body>
<div id="netteBluescreen">
	<a id="netteBluescreenIcon" href="#" rel="next"><abbr>&#x25bc;</abbr></a

	><div>
		<div id="netteBluescreenError" class="panel">
			<h1><?php 
        echo htmlspecialchars($title), $exception->getCode() ? ' #' . $exception->getCode() : '';
        ?>
</h1>

			<p><?php 
        echo htmlspecialchars($exception->getMessage());
        ?>
 <a href="http://www.google.cz/search?sourceid=nette&amp;q=<?php 
        echo urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage()));
        ?>
" id="netteBsSearch">search&#x25ba;</a></p>
		</div>


		<?php 
        $ex = $exception;
        $level = 0;
        ?>
		<?php 
        do {
            ?>

			<?php 
            if ($level++) {
                ?>
			<div class="panel">
			<h2><a href="#" rel="netteBsPnl<?php 
                echo ++$counter;
                ?>
">Caused by <abbr><?php 
                echo ($collapsed = $level > 2) ? '&#x25ba;' : '&#x25bc;';
                ?>
</abbr></a></h2>

			<div id="netteBsPnl<?php 
                echo $counter;
                ?>
" class="<?php 
                echo $collapsed ? 'nette-collapsed ' : '';
                ?>
inner">
				<div class="panel">
					<h1><?php 
                echo htmlspecialchars(get_class($ex) . ($ex->getCode() ? ' #' . $ex->getCode() : ''));
                ?>
</h1>

					<p><b><?php 
                echo htmlspecialchars($ex->getMessage());
                ?>
</b></p>
				</div>
			<?php 
            }
            ?>


			<?php 
            foreach ($panels as $panel) {
                ?>
			<?php 
                $panel = call_user_func($panel, $ex);
                if (empty($panel['tab']) || empty($panel['panel'])) {
                    continue;
                }
                ?>
			<?php 
                if (!empty($panel['bottom'])) {
                    continue;
                }
                ?>
			<div class="panel">
				<h2><a href="#" rel="netteBsPnl<?php 
                echo ++$counter;
                ?>
"><?php 
                echo htmlSpecialChars($panel['tab']);
                ?>
 <abbr>&#x25bc;</abbr></a></h2>

				<div id="netteBsPnl<?php 
                echo $counter;
                ?>
" class="inner">
				<?php 
                echo $panel['panel'];
                ?>
			</div></div>
			<?php 
            }
            ?>


			<?php 
            $stack = $ex->getTrace();
            $expanded = NULL;
            ?>
			<?php 
            if (strpos($ex->getFile(), $expandPath) === 0) {
                foreach ($stack as $key => $row) {
                    if (isset($row['file']) && strpos($row['file'], $expandPath) !== 0) {
                        $expanded = $key;
                        break;
                    }
                }
            }
            ?>

			<div class="panel">
			<h2><a href="#" rel="netteBsPnl<?php 
            echo ++$counter;
            ?>
">Source file <abbr><?php 
            echo ($collapsed = $expanded !== NULL) ? '&#x25ba;' : '&#x25bc;';
            ?>
</abbr></a></h2>

			<div id="netteBsPnl<?php 
            echo $counter;
            ?>
" class="<?php 
            echo $collapsed ? 'nette-collapsed ' : '';
            ?>
inner">
				<p><b>File:</b> <?php 
            echo NDebugHelpers::editorLink($ex->getFile(), $ex->getLine());
            ?>
 &nbsp; <b>Line:</b> <?php 
            echo $ex->getLine();
            ?>
</p>
				<?php 
            if (is_file($ex->getFile())) {
                echo self::highlightFile($ex->getFile(), $ex->getLine(), 15, isset($ex->context) ? $ex->context : NULL);
            }
            ?>
			</div></div>


			<?php 
            if (isset($stack[0]['class']) && $stack[0]['class'] === 'NDebugger' && ($stack[0]['function'] === '_shutdownHandler' || $stack[0]['function'] === '_errorHandler')) {
                unset($stack[0]);
            }
            ?>
			<?php 
            if ($stack) {
                ?>
			<div class="panel">
				<h2><a href="#" rel="netteBsPnl<?php 
                echo ++$counter;
                ?>
">Call stack <abbr>&#x25bc;</abbr></a></h2>

				<div id="netteBsPnl<?php 
                echo $counter;
                ?>
" class="inner">
				<ol>
					<?php 
                foreach ($stack as $key => $row) {
                    ?>
					<li><p>

					<?php 
                    if (isset($row['file']) && is_file($row['file'])) {
                        ?>
						<?php 
                        echo NDebugHelpers::editorLink($row['file'], $row['line']), ':', $row['line'];
                        ?>
					<?php 
                    } else {
                        ?>
						<i>inner-code</i><?php 
                        if (isset($row['line'])) {
                            echo ':', $row['line'];
                        }
                        ?>
					<?php 
                    }
                    ?>

					<?php 
                    if (isset($row['file']) && is_file($row['file'])) {
                        ?>
<a href="#" rel="netteBsSrc<?php 
                        echo "{$level}-{$key}";
                        ?>
">source <abbr>&#x25ba;</abbr></a>&nbsp; <?php 
                    }
                    ?>

					<?php 
                    if (isset($row['class'])) {
                        echo htmlspecialchars($row['class'] . $row['type']);
                    }
                    ?>
					<?php 
                    echo htmlspecialchars($row['function']);
                    ?>

					(<?php 
                    if (!empty($row['args'])) {
                        ?>
<a href="#" rel="netteBsArgs<?php 
                        echo "{$level}-{$key}";
                        ?>
">arguments <abbr>&#x25ba;</abbr></a><?php 
                    }
                    ?>
)
					</p>

					<?php 
                    if (!empty($row['args'])) {
                        ?>
						<div class="nette-collapsed outer" id="netteBsArgs<?php 
                        echo "{$level}-{$key}";
                        ?>
">
						<table>
						<?php 
                        try {
                            $r = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
                            $params = $r->getParameters();
                        } catch (Exception $e) {
                            $params = array();
                        }
                        foreach ($row['args'] as $k => $v) {
                            echo '<tr><th>', htmlspecialchars(isset($params[$k]) ? '$' . $params[$k]->name : "#{$k}"), '</th><td>';
                            echo NDebugHelpers::clickableDump($v);
                            echo "</td></tr>\n";
                        }
                        ?>
						</table>
						</div>
					<?php 
                    }
                    ?>


					<?php 
                    if (isset($row['file']) && is_file($row['file'])) {
                        ?>
						<div <?php 
                        if ($expanded !== $key) {
                            echo 'class="nette-collapsed"';
                        }
                        ?>
 id="netteBsSrc<?php 
                        echo "{$level}-{$key}";
                        ?>
"><?php 
                        echo self::highlightFile($row['file'], $row['line']);
                        ?>
</div>
					<?php 
                    }
                    ?>

					</li>
					<?php 
                }
                ?>
				</ol>
			</div></div>
			<?php 
            }
            ?>


			<?php 
            if (isset($ex->context) && is_array($ex->context)) {
                ?>
			<div class="panel">
			<h2><a href="#" rel="netteBsPnl<?php 
                echo ++$counter;
                ?>
">Variables <abbr>&#x25ba;</abbr></a></h2>

			<div id="netteBsPnl<?php 
                echo $counter;
                ?>
" class="nette-collapsed inner">
			<div class="outer">
			<table>
			<?php 
                foreach ($ex->context as $k => $v) {
                    echo '<tr><th>$', htmlspecialchars($k), '</th><td>', NDebugHelpers::clickableDump($v), "</td></tr>\n";
                }
                ?>
			</table>
			</div>
			</div></div>
			<?php 
            }
            ?>

		<?php 
        } while (method_exists($ex, 'getPrevious') && ($ex = $ex->getPrevious()) || isset($ex->previous) && ($ex = $ex->previous));
        ?>
		<?php 
        while (--$level) {
            echo '</div></div>';
        }
        ?>


		<?php 
        $bottomPanels = array();
        ?>
		<?php 
        foreach ($panels as $panel) {
            ?>
		<?php 
            $panel = call_user_func($panel, NULL);
            if (empty($panel['tab']) || empty($panel['panel'])) {
                continue;
            }
            ?>
		<?php 
            if (!empty($panel['bottom'])) {
                $bottomPanels[] = $panel;
                continue;
            }
            ?>
		<div class="panel">
			<h2><a href="#" rel="netteBsPnl<?php 
            echo ++$counter;
            ?>
"><?php 
            echo htmlSpecialChars($panel['tab']);
            ?>
 <abbr>&#x25ba;</abbr></a></h2>

			<div id="netteBsPnl<?php 
            echo $counter;
            ?>
" class="nette-collapsed inner">
			<?php 
            echo $panel['panel'];
            ?>
		</div></div>
		<?php 
        }
        ?>


		<div class="panel">
		<h2><a href="#" rel="netteBsPnl<?php 
        echo ++$counter;
        ?>
">Environment <abbr>&#x25ba;</abbr></a></h2>

		<div id="netteBsPnl<?php 
        echo $counter;
        ?>
" class="nette-collapsed inner">
			<?php 
        $list = get_defined_constants(TRUE);
        if (!empty($list['user'])) {
            ?>
			<h3><a href="#" rel="netteBsPnl<?php 
            echo ++$counter;
            ?>
">Constants <abbr>&#x25bc;</abbr></a></h3>
			<div id="netteBsPnl<?php 
            echo $counter;
            ?>
" class="outer">
			<table>
			<?php 
            foreach ($list['user'] as $k => $v) {
                echo '<tr><th>', htmlspecialchars($k), '</th>';
                echo '<td>', NDebugHelpers::clickableDump($v), "</td></tr>\n";
            }
            ?>
			</table>
			</div>
			<?php 
        }
        ?>


			<h3><a href="#" rel="netteBsPnl<?php 
        echo ++$counter;
        ?>
">Included files <abbr>&#x25ba;</abbr></a> (<?php 
        echo count(get_included_files());
        ?>
)</h3>
			<div id="netteBsPnl<?php 
        echo $counter;
        ?>
" class="outer nette-collapsed">
			<table>
			<?php 
        foreach (get_included_files() as $v) {
            echo '<tr><td>', htmlspecialchars($v), "</td></tr>\n";
        }
        ?>
			</table>
			</div>


			<h3><a href="#" rel="netteBsPnl<?php 
        echo ++$counter;
        ?>
">Configuration options <abbr>&#x25ba;</abbr></a></h3>
			<div id="netteBsPnl<?php 
        echo $counter;
        ?>
" class="outer nette-collapsed">
			<?php 
        ob_start();
        @phpinfo(INFO_CONFIGURATION | INFO_MODULES);
        echo preg_replace('#^.+<body>|</body>.+$#s', '', ob_get_clean());
        ?>
			</div>


			<h3><a href="#" rel="netteBsPnl<?php 
        echo ++$counter;
        ?>
">$_SERVER <abbr>&#x25bc;</abbr></a></h3>
			<div id="netteBsPnl<?php 
        echo $counter;
        ?>
" class="outer">
			<table>
			<?php 
        foreach ($_SERVER as $k => $v) {
            echo '<tr><th>', htmlspecialchars($k), '</th><td>', NDebugHelpers::clickableDump($v), "</td></tr>\n";
        }
        ?>
			</table>
			</div>
		</div></div>


		<div class="panel">
		<h2><a href="#" rel="netteBsPnl<?php 
        echo ++$counter;
        ?>
">HTTP request <abbr>&#x25ba;</abbr></a></h2>

		<div id="netteBsPnl<?php 
        echo $counter;
        ?>
" class="nette-collapsed inner">
			<?php 
        if (function_exists('apache_request_headers')) {
            ?>
			<h3>Headers</h3>
			<div class="outer">
			<table>
			<?php 
            foreach (apache_request_headers() as $k => $v) {
                echo '<tr><th>', htmlspecialchars($k), '</th><td>', htmlspecialchars($v), "</td></tr>\n";
            }
            ?>
			</table>
			</div>
			<?php 
        }
        ?>


			<?php 
        foreach (array('_GET', '_POST', '_COOKIE') as $name) {
            ?>
			<h3>$<?php 
            echo htmlspecialchars($name);
            ?>
</h3>
			<?php 
            if (empty($GLOBALS[$name])) {
                ?>
			<p><i>empty</i></p>
			<?php 
            } else {
                ?>
			<div class="outer">
			<table>
			<?php 
                foreach ($GLOBALS[$name] as $k => $v) {
                    echo '<tr><th>', htmlspecialchars($k), '</th><td>', NDebugHelpers::clickableDump($v), "</td></tr>\n";
                }
                ?>
			</table>
			</div>
			<?php 
            }
            ?>
			<?php 
        }
        ?>
		</div></div>


		<div class="panel">
		<h2><a href="#" rel="netteBsPnl<?php 
        echo ++$counter;
        ?>
">HTTP response <abbr>&#x25ba;</abbr></a></h2>

		<div id="netteBsPnl<?php 
        echo $counter;
        ?>
" class="nette-collapsed inner">
			<h3>Headers</h3>
			<?php 
        if (headers_list()) {
            ?>
			<pre><?php 
            foreach (headers_list() as $s) {
                echo htmlspecialchars($s), '<br>';
            }
            ?>
</pre>
			<?php 
        } else {
            ?>
			<p><i>no headers</i></p>
			<?php 
        }
        ?>
		</div></div>


		<?php 
        foreach ($bottomPanels as $panel) {
            ?>
		<div class="panel">
			<h2><a href="#" rel="netteBsPnl<?php 
            echo ++$counter;
            ?>
"><?php 
            echo htmlSpecialChars($panel['tab']);
            ?>
 <abbr>&#x25bc;</abbr></a></h2>

			<div id="netteBsPnl<?php 
            echo $counter;
            ?>
" class="inner">
			<?php 
            echo $panel['panel'];
            ?>
		</div></div>
		<?php 
        }
        ?>


		<ul>
			<li>Report generated at <?php 
        echo @date('Y/m/d H:i:s', NDebugger::$time);
        ?>
</li>
			<?php 
        if (preg_match('#^https?://#', NDebugger::$source)) {
            ?>
				<li><a href="<?php 
            echo htmlSpecialChars(NDebugger::$source);
            ?>
"><?php 
            echo htmlSpecialChars(NDebugger::$source);
            ?>
</a></li>
			<?php 
        } elseif (NDebugger::$source) {
            ?>
				<li><?php 
            echo htmlSpecialChars(NDebugger::$source);
            ?>
</li>
			<?php 
        }
        ?>
			<li>PHP <?php 
        echo htmlSpecialChars(PHP_VERSION);
        ?>
</li>
			<?php 
        if (isset($_SERVER['SERVER_SOFTWARE'])) {
            ?>
<li><?php 
            echo htmlSpecialChars($_SERVER['SERVER_SOFTWARE']);
            ?>
</li><?php 
        }
        ?>
			<?php 
        if (class_exists('NFramework')) {
            ?>
<li><?php 
            echo htmlSpecialChars('Nette Framework ' . NFramework::VERSION);
            ?>
 <i>(revision <?php 
            echo htmlSpecialChars(NFramework::REVISION);
            ?>
)</i></li><?php 
        }
        ?>
		</ul>
	</div>
</div>

<script type="text/javascript">/*<![CDATA[*/var bs=document.getElementById("netteBluescreen");document.body.appendChild(bs);document.onkeyup=function(b){b=b||window.event;if(27==b.keyCode&&!b.shiftKey&&!b.altKey&&!b.ctrlKey&&!b.metaKey)bs.onclick({target:document.getElementById("netteBluescreenIcon")})};
for(var i=0,styles=document.styleSheets;i<styles.length;i++)"nette"!==(styles[i].owningElement||styles[i].ownerNode).className?(styles[i].oldDisabled=styles[i].disabled,styles[i].disabled=!0):styles[i].addRule?styles[i].addRule(".nette-collapsed","display: none"):styles[i].insertRule(".nette-collapsed { display: none }",0);
bs.onclick=function(b){for(var b=b||window.event,a=b.target||b.srcElement;a&&a.tagName&&"a"!==a.tagName.toLowerCase();)a=a.parentNode;if(!a||!a.rel)return!0;for(var d=a.getElementsByTagName("abbr")[0],c="next"===a.rel?a.nextSibling:document.getElementById(a.rel);1!==c.nodeType;)c=c.nextSibling;b=c.currentStyle?"none"==c.currentStyle.display:"none"==getComputedStyle(c,null).display;try{d.innerHTML=String.fromCharCode(b?9660:9658)}catch(e){}c.style.display=b?"code"===c.tagName.toLowerCase()?"inline":
"block":"none";if("netteBluescreenIcon"===a.id){a=0;for(d=document.styleSheets;a<d.length;a++)if("nette"!==(d[a].owningElement||d[a].ownerNode).className)d[a].disabled=b?!0:d[a].oldDisabled}return!1};/*]]>*/</script>
</body>
</html>
<?php 
    }
示例#28
0
 /**
  * @param Metadata   $metadata
  * @param \Exception $exception
  *
  * @return Metadata
  */
 public function getMetadata(Metadata $metadata = null, \Exception $exception = null)
 {
     $metadata = isset($metadata) ? $metadata : new Metadata();
     if (!$metadata->getSeverity()) {
         if ($exception instanceof ErrorException) {
             $metadata->setSeverity($exception->getSeverity());
         } elseif ($exception instanceof \Exception) {
             $metadata->setSeverity(Severity::ERROR);
         } else {
             $metadata->setSeverity(Severity::NOTICE);
         }
     }
     foreach ($this->processorManager->all() as $processor) {
         $processor->process($metadata, $exception);
     }
     return $metadata;
 }
示例#29
0
 public static function trace(Exception $exception, $output = self::EXCEPTION_TRACE_HTML)
 {
     if (Ajde::app()->hasDocument() && Ajde::app()->getDocument()->getFormat() == 'json') {
         $output = self::EXCEPTION_TRACE_LOG;
     }
     if ($exception instanceof ErrorException) {
         $type = "PHP Error " . self::getErrorType($exception->getSeverity());
     } elseif ($exception instanceof Ajde_Exception) {
         $type = "Uncaught application exception" . ($exception->getCode() ? ' ' . $exception->getCode() : '');
     } else {
         $type = "Uncaught PHP exception " . $exception->getCode();
     }
     switch ($output) {
         case self::EXCEPTION_TRACE_HTML:
             if (ob_get_level()) {
                 ob_clean();
             }
             $traceMessage = '<ol reversed="reversed">';
             self::$firstApplicationFileExpanded = false;
             foreach ($exception->getTrace() as $item) {
                 $arguments = null;
                 if (!empty($item['args'])) {
                     ob_start();
                     var_dump($item['args']);
                     $dump = ob_get_clean();
                     $arguments = sprintf(' with arguments: %s', $dump);
                 }
                 $traceMessage .= sprintf("<li><em>%s</em>%s<strong>%s</strong><br/>in %s<br/>&nbsp;\n", !empty($item['class']) ? $item['class'] : '&lt;unknown class&gt;', !empty($item['type']) ? $item['type'] : '::', !empty($item['function']) ? $item['function'] : '&lt;unknown function&gt;', self::embedScript(issetor($item['file'], null), issetor($item['line'], null), $arguments, false));
                 $traceMessage .= '</li>';
             }
             $traceMessage .= '</ol>';
             $exceptionDocumentation = '';
             if ($exception instanceof Ajde_Exception && $exception->getCode()) {
                 $exceptionDocumentation = sprintf("<div style='margin-top: 4px;'><img src='//" . Config::get('site_root') . "public/images/_core/globe_16.png' style='vertical-align: bottom;' title='Primary key' width='16' height='16' /> <a href='%s'>Documentation on error %s</a>&nbsp;</div>", Ajde_Core_Documentation::getUrl($exception->getCode()), $exception->getCode());
             }
             $exceptionMessage = sprintf("<div style='background-color:#F1F1F1;background-image: url(\"//" . Config::get('site_root') . "public/images/_core/warning_48.png\"); background-repeat: no-repeat; background-position: 10px 10px; border: 1px solid silver; padding: 10px 10px 10px 70px;'><h3 style='margin:0;'>%s:</h3><h2 style='margin:0;'>%s</h2> Exception thrown in %s%s</div><h3>Trace:</h3>\n", $type, $exception->getMessage(), self::embedScript($exception->getFile(), $exception->getLine(), $arguments, false), $exceptionDocumentation);
             $exceptionDump = '';
             if (class_exists("Ajde_Dump")) {
                 if ($dumps = Ajde_Dump::getAll()) {
                     $exceptionDump .= '<h2>Dumps</h2>';
                     foreach ($dumps as $dump) {
                         ob_start();
                         var_dump($dump[0]);
                         $exceptionDump .= ob_get_clean();
                     }
                 }
             }
             $style = false;
             if (file_exists(MODULE_DIR . '_core/res/css/debugger/handler.css')) {
                 $style = file_get_contents(MODULE_DIR . '_core/res/css/debugger/handler.css');
             }
             if ($style === false) {
                 // For shutdown() call
                 $style = 'body {font: 13px sans-serif;} a {color: #005D9A;} a:hover {color: #9A0092;} h2 {color: #005D9A;} span > a {color: #9A0092;}';
             }
             $style = '<style>' . $style . '</style>';
             $message = $style . $exceptionDump . $exceptionMessage . $traceMessage;
             break;
         case self::EXCEPTION_TRACE_LOG:
             $message = 'Request ' . $_SERVER["REQUEST_URI"] . " triggered:" . PHP_EOL;
             $message .= sprintf("%s: %s in %s on line %s", $type, $exception->getMessage(), $exception->getFile(), $exception->getLine());
             foreach (array_reverse($exception->getTrace()) as $i => $line) {
                 $message .= PHP_EOL;
                 $message .= $i . '. ' . issetor($line['file']) . ' on line ' . issetor($line['line']);
             }
             break;
     }
     return $message;
 }
示例#30
0
 /**
  * The render function will take an Exception and output a HTML page
  *
  * @param Exception $e
  *  The Exception object
  * @return string
  *  An HTML string
  */
 public static function render(Exception $e)
 {
     $lines = NULL;
     $odd = true;
     $markdown = "\t" . $e->getMessage() . "\n";
     $markdown .= "\t" . $e->getFile() . " line " . $e->getLine() . "\n\n";
     foreach (self::__nearByLines($e->getLine(), $e->getFile()) as $line => $string) {
         $markdown .= "\t" . ($line + 1) . $string;
     }
     foreach (self::__nearByLines($e->getLine(), $e->getFile()) as $line => $string) {
         $lines .= sprintf('<li%s%s><strong>%d:</strong> <code>%s</code></li>', $odd == true ? ' class="odd"' : NULL, $line + 1 == $e->getLine() ? ' id="error"' : NULL, ++$line, str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', htmlspecialchars($string)));
         $odd = !$odd;
     }
     $trace = NULL;
     $odd = true;
     foreach ($e->getTrace() as $t) {
         $trace .= sprintf('<li%s><code>[%s:%d] <strong>%s%s%s();</strong></code></li>', $odd == true ? ' class="odd"' : NULL, isset($t['file']) ? $t['file'] : NULL, isset($t['line']) ? $t['line'] : NULL, isset($t['class']) ? $t['class'] : NULL, isset($t['type']) ? $t['type'] : NULL, $t['function']);
         $odd = !$odd;
     }
     $queries = NULL;
     $odd = true;
     if (is_object(Symphony::Database())) {
         $debug = Symphony::Database()->debug();
         if (count($debug['query']) > 0) {
             foreach ($debug['query'] as $query) {
                 $queries .= sprintf('<li%s><code>%s;</code> <small>[%01.4f]</small></li>', $odd == true ? ' class="odd"' : NULL, htmlspecialchars($query['query']), isset($query['time']) ? $query['time'] : NULL);
                 $odd = !$odd;
             }
         }
     }
     return sprintf(file_get_contents(TEMPLATE . '/errorhandler.tpl'), $e instanceof ErrorException ? GenericErrorHandler::$errorTypeStrings[$e->getSeverity()] : 'Fatal Error', $e->getMessage(), $e->getFile(), $e->getLine(), $markdown, $lines, $trace, $queries);
 }