Example #1
0
 /**
  * Catches errors that are not caught by the error handler, such as E_PARSE.
  *
  * @uses    self::exception_handler
  * @return  void
  */
 public static function shutdown_handler()
 {
     $error = error_get_last();
     if ($error) {
         static $run = null;
         if (true === $run) {
             return;
         }
         $run = true;
         if (((E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR) & $error['type']) !== 0) {
             $run = true;
             self::exception_handler(new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']));
             exit(1);
         }
     }
     if (isset($_REQUEST['debug'])) {
         if (Core::debug()->profiler('output')->is_open()) {
             Core::debug()->profiler('output')->start('Views', 'Global Data');
             Core::debug()->profiler('output')->stop(array('Global Data' => View::get_global_data()));
         }
         // 输出debug信息
         $file = Core::find_file('views', IS_CLI ? 'debug/profiler_cli' : 'debug/profiler');
         if ($file) {
             ob_start();
             include $file;
             $out = ob_get_clean();
             if (stripos(Core::$output, '</body>') !== false) {
                 Core::$output = str_ireplace('</body>', $out . '</body>', Core::$output);
             } else {
                 Core::$output .= $out;
             }
         }
     }
 }
Example #2
0
 /**
  * Catches errors that are not caught by the error handler, such as E_PARSE.
  *
  * @uses	Kohana::exception_handler
  * @return  void
  */
 public static function shutdown_handler()
 {
     $error = error_get_last();
     if ($error) {
         static $run = null;
         if (true === $run) {
             return;
         }
         $run = true;
         if (((\E_ERROR | \E_PARSE | \E_CORE_ERROR | \E_COMPILE_ERROR | \E_USER_ERROR | \E_RECOVERABLE_ERROR) & $error['type']) !== 0) {
             $run = true;
             static::exception_handler(new \ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']));
             exit(1);
         }
     }
     if (isset($_REQUEST['debug'])) {
         if (\Core::debug()->profiler('output')->is_open()) {
             \Core::debug()->profiler('output')->start('Views', 'Global Data');
             \Core::debug()->profiler('output')->stop(array('Global Data' => \View::get_global_data()));
         }
         // 输出debug信息
         $file = \Core::find_view('debug/profiler');
         if ($file) {
             if (\IS_CLI) {
                 include $file;
             } else {
                 \ob_start();
                 include $file;
                 $out = \ob_get_clean();
                 if (\stripos(\HttpIO::$body, '</body>') !== false) {
                     \HttpIO::$body = \str_ireplace('</body>', $out . '</body>', \HttpIO::$body);
                 } else {
                     \HttpIO::$body .= $out;
                 }
             }
         }
     }
 }