i forgot about HEAD existing
This commit is contained in:
parent
5449aa99a4
commit
2864f66377
7 changed files with 40 additions and 7 deletions
|
@ -12,6 +12,9 @@ if($reqPath === '/blog-elements.json') {
|
|||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$title = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_STRING);
|
||||
|
||||
ob_start();
|
||||
|
|
|
@ -17,6 +17,8 @@ if($reqPath === '/now-listening.json') {
|
|||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$lfmInfo = cache_output('lastfm', 10, function() {
|
||||
return json_decode(file_get_contents('https://now.flash.moe/get.php?u=flashwave_'));
|
||||
|
@ -44,6 +46,8 @@ if($reqPath === '/now-listening.json') {
|
|||
if($reqPath === '/contact') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$contact = [
|
||||
[
|
||||
|
|
|
@ -9,6 +9,10 @@ if($reqPath === '/etc.php' || $reqPath === 'etc.html'
|
|||
}
|
||||
|
||||
if($reqPath === '/etc') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
$links = [
|
||||
[
|
||||
'title' => 'ASCII Table',
|
||||
|
|
|
@ -12,6 +12,8 @@ if($reqPath === '/header-bgs.json') {
|
|||
return FM_ERR | 405;
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
echo json_encode(FM_BGS);
|
||||
|
||||
return FM_HIT;
|
||||
|
@ -20,6 +22,8 @@ if($reqPath === '/header-bgs.json') {
|
|||
if($reqPath === '/now-listening') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$offset = (int)filter_input(INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
|
@ -41,6 +45,8 @@ if($reqPath === '/now-listening') {
|
|||
if($reqPath === '/home') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
fm_component('header', [
|
||||
'title' => 'flash.moe / homepage',
|
||||
|
@ -86,6 +92,8 @@ if($reqPath === '/home') {
|
|||
if($reqPath === '/test') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
|
@ -97,6 +105,8 @@ if($reqPath === '/test') {
|
|||
if($reqPath === '/') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$legacyPage = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_STRING);
|
||||
if(!empty($legacyPage)) {
|
||||
|
|
|
@ -10,6 +10,8 @@ if($reqPath === '/projects.php' || $reqPath === '/projects.html'
|
|||
if($reqPath === '/projects') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$projInfo = cache_output('projects', 300, function() {
|
||||
return json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit'));
|
||||
|
|
|
@ -10,6 +10,8 @@ if($reqPath === '/related.php' || $reqPath === '/related.html'
|
|||
if($reqPath === '/related') {
|
||||
if($reqMethod !== 'GET')
|
||||
return FM_ERR | 405;
|
||||
if($reqHead)
|
||||
return FM_HIT;
|
||||
|
||||
$related = [
|
||||
[
|
||||
|
|
|
@ -122,6 +122,12 @@ ob_start();
|
|||
|
||||
$reqMethod = filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING);
|
||||
$reqPath = '/' . trim(parse_url(filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING), PHP_URL_PATH), '/');
|
||||
$reqHead = false;
|
||||
|
||||
if($reqMethod == 'HEAD') {
|
||||
$reqMethod = 'GET';
|
||||
$reqHead = true;
|
||||
}
|
||||
|
||||
if(substr($reqPath, 0, 7) === '/error/') {
|
||||
$statusCode = intval(substr($reqPath, 7, 3));
|
||||
|
@ -142,12 +148,14 @@ if(substr($reqPath, 0, 7) === '/error/') {
|
|||
$errorInfo = FM_ERRS[$statusCode ?? 404] ?? FM_ERRS[404];
|
||||
http_response_code($errorInfo['code']);
|
||||
|
||||
fm_component('header', ['title' => $errorInfo['title']]);
|
||||
if(!$reqHead) {
|
||||
fm_component('header', ['title' => $errorInfo['title']]);
|
||||
?>
|
||||
<div class="http-error">
|
||||
<h2 class="http-error-head"><?=$errorInfo['title'];?></h2>
|
||||
<img src="<?=$errorInfo['image'];?>" alt="<?=$errorInfo['image'];?>" class="http-error-image"/>
|
||||
<div class="http-error-desc"><?=$errorInfo['desc'];?></div>
|
||||
</div>
|
||||
<div class="http-error">
|
||||
<h2 class="http-error-head"><?=$errorInfo['title'];?></h2>
|
||||
<img src="<?=$errorInfo['image'];?>" alt="<?=$errorInfo['image'];?>" class="http-error-image"/>
|
||||
<div class="http-error-desc"><?=$errorInfo['desc'];?></div>
|
||||
</div>
|
||||
<?php
|
||||
fm_component('footer');
|
||||
fm_component('footer');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue