Add cover art database

Co-authored-by: Job Curtis <job.curtis@gmail.com>
Co-authored-by: Alex Cabal <alex@standardebooks.org>
This commit is contained in:
Mike Colagrosso 2023-12-28 16:38:39 -06:00 committed by Alex Cabal
parent 74f747df76
commit 6a5c05511a
92 changed files with 3174 additions and 146 deletions

View file

@ -1,5 +1,7 @@
<?
use function Safe\ini_get;
use function Safe\preg_match;
use function Safe\substr;
class HttpInput{
public static function RequestMethod(): int{
@ -21,6 +23,29 @@ class HttpInput{
return HTTP_GET;
}
public static function GetMaxPostSize(): int{ // bytes
$post_max_size = ini_get('post_max_size');
$unit = substr($post_max_size, -1);
$size = (int) substr($post_max_size, 0, -1);
return match ($unit){
'g', 'G' => $size * 1024 * 1024 * 1024,
'm', 'M' => $size * 1024 * 1024,
'k', 'K' => $size * 1024,
default => $size
};
}
public static function IsRequestTooLarge(): bool{
if(empty($_POST) || empty($_FILES)){
if($_SERVER['CONTENT_LENGTH'] > self::GetMaxPostSize()){
return true;
}
}
return false;
}
public static function RequestType(): int{
return preg_match('/\btext\/html\b/ius', $_SERVER['HTTP_ACCEPT'] ?? '') ? WEB : REST;
}
@ -60,7 +85,7 @@ class HttpInput{
return self::GetHttpVar($variable, HTTP_VAR_ARRAY, GET, $default);
}
private static function GetHttpVar(string $variable, int $type, string $set, $default){
private static function GetHttpVar(string $variable, int $type, string $set, mixed $default): mixed{
$vars = [];
switch($set){