Beispiel #1
0
 /**
  * Default error 500 output Handler
  */
 public static function error500()
 {
     $args_ = func_get_args();
     $template = Template::singleton();
     $template_dir = $template->getActiveTemplateDirectory();
     static::$x_is_fatal = true;
     if ($template_dir && $template->x_500_file && is_string($template->x_500_file)) {
         if (is_file("{$template_dir}/{$template->x_500_file}")) {
             $message = (array) reset($args_);
             // using callback to prevent direct access
             return call_user_func(function ($a) use($message) {
                 ob_start();
                 require $a;
                 $content = ob_get_clean();
                 Response::setBody($content);
                 static::displayRender();
                 exit(1);
                 // and then exit here
             }, "{$template_dir}/{$template->x_500_file}");
         }
     }
     /**
      * Body container
      * @var string
      */
     $body = "<h1 class=\"big\">500</h1>\n";
     if (Config::get('debug', true)) {
         $args_ = current($args_);
         $strlen_doc_root = strlen(Path::documentRoot());
         // safe output show replaced document root to {DOCUMENT ROOT}
         $args_['file'] = substr_replace($args_['file'], '<span class="x_error_doc_root">{DOCUMENT ROOT}</span>', 0, $strlen_doc_root);
         $body .= "    <div class=\"x_error_section\">\n" . "      <table class=\"x_error_table\">\n" . "        <tr class=\"x_error_type\">\n" . "          <td class=\"x_error_label\"><span>Error Type</span></td>\n" . "          <td class=\"x_error_value\"><span><span class=\"x_error_type_code\">{$args_['type']}</span>" . "<span class=\"x_error_type_string\">{$args_['type_string']}</span></span></td>\n" . "        </tr>\n" . "        <tr class=\"x_error_message\">\n" . "          <td class=\"x_error_label\"><span>Error Message</span></td>\n" . "          <td class=\"x_error_value\"><span>{$args_['message']}</span></td>\n" . "        </tr>\n" . "        <tr class=\"x_error_file\">\n" . "          <td class=\"x_error_label\"><span>Error File</span></td>\n" . "          <td class=\"x_error_value\"><span>{$args_['file']}</span></td>\n" . "        </tr>\n" . "        <tr class=\"x_error_line\">\n" . "          <td class=\"x_error_label\"><span>Error Line</span></td>\n" . "          <td class=\"x_error_value\"><span>{$args_['line']}</span></td>\n" . "        </tr>\n" . "      </table>\n" . "    </div>\n";
     } else {
         $body .= "<h2 class=\"desc\">Internal Server Error</h2>\n" . "<p>We are sorry for inconvenience</p>";
     }
     /**
      * Set Body
      */
     Response::setBody(Html::create('Internal Server Error', $body, array('style' => "body{font-size: 14px;font-family: helvetica, arial, sans-serif;color: #555;line-height: normal;background: #f1f1f1;}\n" . ".wrap{margin: 0 auto;max-width: 700px;text-align: center;}\n" . (Config::get('debug', false) ? ".x_error_section{display:block;padding: 10px;background: #fff;border: 1px solid #ddd;}\n" . ".x_error_table{border-collapse: collapse;border:0;border-spacing:0;}\n" . ".x_error_label{padding: 5px 10px;text-align: left;border-right: 2px solid #bbb;}\n" . ".x_error_value{padding: 5px 10px;text-align: left;border-right: 0px solid #ddd;}\n" . ".x_error_type .x_error_type_string{background: #f18181;padding: 3px 5px;color:#fff;font-weight: bold;margin-left:0px;}\n" . ".x_error_type .x_error_type_code{background: #4359fe;margin-right: 0px;padding: 3px 6px;color:#fff;font-weight: bold;}\n" : '') . ".big{font-size: 180px;margin: .7em 0 20px;}\n.desc{font-size: 28px;margin: .3em 0 0;}")));
     // doing display
     static::displayRender();
     exit(1);
     // and then exit here
 }