Define some constants to make HTTP input code less wordy

This commit is contained in:
Alex Cabal 2024-05-12 12:29:30 -05:00
parent ee7c8343dd
commit 110c091a7b
36 changed files with 87 additions and 86 deletions

View file

@ -4,7 +4,7 @@ $author = '';
$authorUrl = '';
try{
$urlPath = trim(str_replace('.', '', HttpInput::Str(HttpVariableSource::Get, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after https://standardebooks.org/ebooks/
$urlPath = trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after https://standardebooks.org/ebooks/
$wwwFilesystemPath = EBOOKS_DIST_PATH . $urlPath; // Path to the deployed WWW files for this ebook
if($urlPath == '' || mb_stripos($wwwFilesystemPath, EBOOKS_DIST_PATH) !== 0 || !is_dir($wwwFilesystemPath)){

View file

@ -10,8 +10,8 @@ $showThankYouPage = $GLOBALS['User'] === null && $downloadCount < 5;
$downloadUrl = null;
try{
$urlPath = HttpInput::Str(HttpVariableSource::Get, 'url-path') ?? null;
$format = EbookFormat::tryFrom(HttpInput::Str(HttpVariableSource::Get, 'format') ?? '') ?? EbookFormat::Epub;
$urlPath = HttpInput::Str(GET, 'url-path') ?? null;
$format = EbookFormat::tryFrom(HttpInput::Str(GET, 'format') ?? '') ?? EbookFormat::Epub;
$wwwFilesystemPath = EBOOKS_DIST_PATH . $urlPath;
// Do we have the ebook cached?

View file

@ -14,7 +14,7 @@ $carousel = [];
$carouselTag = null;
try{
$urlPath = trim(str_replace('.', '', HttpInput::Str(HttpVariableSource::Get, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after https://standardebooks.org/ebooks/
$urlPath = trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after https://standardebooks.org/ebooks/
$wwwFilesystemPath = EBOOKS_DIST_PATH . $urlPath; // Path to the deployed WWW files for this ebook
if($urlPath == '' || mb_stripos($wwwFilesystemPath, EBOOKS_DIST_PATH) !== 0){

View file

@ -1,13 +1,13 @@
<?
use function Safe\preg_replace;
$page = HttpInput::Int(HttpVariableSource::Get, 'page') ?? 1;
$page = HttpInput::Int(GET, 'page') ?? 1;
$pages = 0;
$perPage = HttpInput::Int(HttpVariableSource::Get, 'per-page') ?? EBOOKS_PER_PAGE;
$query = HttpInput::Str(HttpVariableSource::Get, 'query') ?? '';
$tags = HttpInput::Array(HttpVariableSource::Get, 'tags') ?? [];
$view = ViewType::tryFrom(HttpInput::Str(HttpVariableSource::Get, 'view') ?? '');
$sort = EbookSort::tryFrom(HttpInput::Str(HttpVariableSource::Get, 'sort') ?? '');
$perPage = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
$query = HttpInput::Str(GET, 'query') ?? '';
$tags = HttpInput::Array(GET, 'tags') ?? [];
$view = ViewType::tryFrom(HttpInput::Str(GET, 'view') ?? '');
$sort = EbookSort::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
$queryString = '';
$queryStringParams = [];
$queryStringWithoutPage = '';