Ejemplo n.º 1
0
    public static function error($e)
    {
        $isException = is_object($e);
        if ($isException) {
            $code = $e->getCode();
            $message = $e->getMessage();
        } else {
            $code = $e;
        }
        switch ($code) {
            case 500:
                $message = 'Internal Server Error!';
                break;
            case 404:
                // $message = "Not Found! <!--$code-->";
                $code = 404;
                break;
            case 403:
                $message = 'Forbidden';
                break;
            default:
                $message = 'Error!';
        }
        @ob_end_clean();
        ob_start();
        header('Content-Type: text/html; charset=utf-8', true);
        if (is_numeric($code) && $code > 200) {
            Response::setStatus($code);
        }
        $message = nl2br($message);
        print <<<EOF
<!doctype html><html><head><meta charset="utf-8" />
<title>{$code}</title>
<meta http-equiv="refresh" content="5; url=/" />
<style type="text/css">
body{background: #f7fbe9;font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;}
#error {background: #333;width: 360px;margin: 0 auto;margin-top: 100px;color: #fff;padding: 10px;
}
a{color:#fff;text-decoration:none}
h1 {padding: 10px;margin: 0;font-size: 36px;}
p {padding: 0 20px 20px 20px;margin: 0;font-size: 12px;}
img {padding: 0 0 5px 260px;}
</style>
</head>
<body>
<div id="error">
<h1>{$code}</h1>
<p>{$message}</p>
<p><a href="/">请访问首页</a></p>
</div>
</body>
</html>

EOF;
    }