i forgot about HEAD existing

This commit is contained in:
flash 2020-08-31 15:43:18 +00:00
parent 5449aa99a4
commit 2864f66377
7 changed files with 40 additions and 7 deletions

View file

@ -12,6 +12,9 @@ if($reqPath === '/blog-elements.json') {
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
if($reqHead)
return FM_HIT;
$title = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_STRING); $title = filter_input(INPUT_GET, 'title', FILTER_SANITIZE_STRING);
ob_start(); ob_start();

View file

@ -17,6 +17,8 @@ if($reqPath === '/now-listening.json') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
if($reqHead)
return FM_HIT;
$lfmInfo = cache_output('lastfm', 10, function() { $lfmInfo = cache_output('lastfm', 10, function() {
return json_decode(file_get_contents('https://now.flash.moe/get.php?u=flashwave_')); 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($reqPath === '/contact') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
$contact = [ $contact = [
[ [

View file

@ -9,6 +9,10 @@ if($reqPath === '/etc.php' || $reqPath === 'etc.html'
} }
if($reqPath === '/etc') { if($reqPath === '/etc') {
if($reqMethod !== 'GET')
return FM_ERR | 405;
if($reqHead)
return FM_HIT;
$links = [ $links = [
[ [
'title' => 'ASCII Table', 'title' => 'ASCII Table',

View file

@ -12,6 +12,8 @@ if($reqPath === '/header-bgs.json') {
return FM_ERR | 405; return FM_ERR | 405;
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
if($reqHead)
return FM_HIT;
echo json_encode(FM_BGS); echo json_encode(FM_BGS);
return FM_HIT; return FM_HIT;
@ -20,6 +22,8 @@ if($reqPath === '/header-bgs.json') {
if($reqPath === '/now-listening') { if($reqPath === '/now-listening') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
$offset = (int)filter_input(INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT); $offset = (int)filter_input(INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT);
@ -41,6 +45,8 @@ if($reqPath === '/now-listening') {
if($reqPath === '/home') { if($reqPath === '/home') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
fm_component('header', [ fm_component('header', [
'title' => 'flash.moe / homepage', 'title' => 'flash.moe / homepage',
@ -86,6 +92,8 @@ if($reqPath === '/home') {
if($reqPath === '/test') { if($reqPath === '/test') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
header('Content-Type: text/plain'); header('Content-Type: text/plain');
@ -97,6 +105,8 @@ if($reqPath === '/test') {
if($reqPath === '/') { if($reqPath === '/') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
$legacyPage = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_STRING); $legacyPage = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_STRING);
if(!empty($legacyPage)) { if(!empty($legacyPage)) {

View file

@ -10,6 +10,8 @@ if($reqPath === '/projects.php' || $reqPath === '/projects.html'
if($reqPath === '/projects') { if($reqPath === '/projects') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
$projInfo = cache_output('projects', 300, function() { $projInfo = cache_output('projects', 300, function() {
return json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit')); return json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit'));

View file

@ -10,6 +10,8 @@ if($reqPath === '/related.php' || $reqPath === '/related.html'
if($reqPath === '/related') { if($reqPath === '/related') {
if($reqMethod !== 'GET') if($reqMethod !== 'GET')
return FM_ERR | 405; return FM_ERR | 405;
if($reqHead)
return FM_HIT;
$related = [ $related = [
[ [

View file

@ -122,6 +122,12 @@ ob_start();
$reqMethod = filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING); $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), '/'); $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/') { if(substr($reqPath, 0, 7) === '/error/') {
$statusCode = intval(substr($reqPath, 7, 3)); $statusCode = intval(substr($reqPath, 7, 3));
@ -142,6 +148,7 @@ if(substr($reqPath, 0, 7) === '/error/') {
$errorInfo = FM_ERRS[$statusCode ?? 404] ?? FM_ERRS[404]; $errorInfo = FM_ERRS[$statusCode ?? 404] ?? FM_ERRS[404];
http_response_code($errorInfo['code']); http_response_code($errorInfo['code']);
if(!$reqHead) {
fm_component('header', ['title' => $errorInfo['title']]); fm_component('header', ['title' => $errorInfo['title']]);
?> ?>
<div class="http-error"> <div class="http-error">
@ -151,3 +158,4 @@ fm_component('header', ['title' => $errorInfo['title']]);
</div> </div>
<?php <?php
fm_component('footer'); fm_component('footer');
}