403

禁止入内! T_T

'; } UOJResponse::message($msg, '403'); } public static function page404($msg = null) { header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found", true, 404); if ($msg === null) { $msg = '
404

唔……未找到该页面……你是从哪里点进来的……>_<……

'; } self::message($msg, '404'); } public static function page406($msg = null) { header($_SERVER['SERVER_PROTOCOL'] . " 406 Not Acceptable", true, 406); if ($msg === null) { $msg = '
406

服务器对你提交的请求好像不太满意

'; } self::message($msg, '406'); } public static function page500($msg) { header($_SERVER['SERVER_PROTOCOL'] . " 500 Internal Server Error", true, 500); self::message($msg, '500'); } public static function page503($msg) { header($_SERVER['SERVER_PROTOCOL'] . " 503 Service Unavailable", true, 503); self::message($msg, '503'); } public static function xsendfile($path, $cfg = []) { $cfg += [ 'mimetype' => null, 'attachment' => null ]; $path = realpath($path); if (!is_file($path)) { self::page404(); } if ($cfg['mimetype'] === null) { $cfg['mimetype'] = (new finfo(FILEINFO_MIME))->file($path); if ($cfg['mimetype'] === false) { self::page404(); } } header("X-Sendfile: $path"); header("Content-type: {$cfg['mimetype']}"); if ($cfg['attachment'] !== null) { header("Content-Disposition: attachment; filename={$cfg['attachment']}"); } die(); } public static function echofile($echo_func, $cfg = []) { $cfg += [ 'mimetype' => 'text/plain', 'attachment' => null ]; header("Content-type: {$cfg['mimetype']}"); if ($cfg['attachment'] !== null) { header("Content-Disposition: attachment; filename={$cfg['attachment']}"); } $echo_func(); die(); } }