mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 06:40:33 -04:00
Fix PHPStan errors
This commit is contained in:
parent
6af2717773
commit
008ffc8ccd
5 changed files with 10 additions and 5 deletions
|
@ -184,7 +184,7 @@ class HttpInput{
|
|||
return $var;
|
||||
case HttpVariableType::Integer:
|
||||
// Can't use ctype_digit because we may want negative integers
|
||||
if(is_numeric($var) && mb_strpos($var, '.') === false){
|
||||
if(is_numeric($var) && mb_strpos(strval($var), '.') === false){
|
||||
try{
|
||||
return intval($var);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,8 @@ class Session{
|
|||
}
|
||||
|
||||
public static function SetSessionCookie(string $sessionId): void{
|
||||
setcookie('sessionid', $sessionId, ['expires' => (new DateTimeImmutable('+1 week'))->format('U'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks
|
||||
/** @throws void */
|
||||
setcookie('sessionid', $sessionId, ['expires' => intval((new DateTimeImmutable('+1 week'))->format('U')), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
use Safe\DateTimeImmutable;
|
||||
use function Safe\apcu_fetch;
|
||||
|
||||
// If the user is not logged in, or has less than some amount of downloads, show a thank-you page
|
||||
|
@ -60,7 +61,7 @@ try{
|
|||
|
||||
// Increment local download count, expires in 2 weeks
|
||||
$downloadCount++;
|
||||
setcookie('download-count', (string)$downloadCount, ['expires' => (new DateTimeImmutable('+2 week'))->format('U'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']);
|
||||
setcookie('download-count', (string)$downloadCount, ['expires' => intval((new DateTimeImmutable('+2 week'))->format('U')), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']);
|
||||
}
|
||||
catch(Exceptions\InvalidFileException | Exceptions\EbookNotFoundException){
|
||||
Template::Emit404();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?
|
||||
// See https://developers.google.com/search/docs/data-types/book for RDFa metadata details
|
||||
|
||||
use Safe\DateTimeImmutable;
|
||||
use function Safe\preg_match;
|
||||
use function Safe\preg_replace;
|
||||
use function Safe\apcu_fetch;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
$hideDonationAlert = HttpInput::Bool(POST, 'hide-donation-alert');
|
||||
$colorScheme = HttpInput::Str(POST, 'color-scheme');
|
||||
|
||||
if($hideDonationAlert !== null){
|
||||
setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', ['expires' => (new DateTimeImmutable('+1 month'))->format('U'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', ['expires' => intval((new DateTimeImmutable('+1 month'))->format('U')), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
}
|
||||
|
||||
if($colorScheme !== null){
|
||||
|
@ -16,7 +18,7 @@ if($colorScheme !== null){
|
|||
setcookie('color-scheme', '', ['expires' => 0, 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
}
|
||||
else{
|
||||
setcookie('color-scheme', $colorScheme, ['expires' => (new DateTimeImmutable('+1 year'))->format('U'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
setcookie('color-scheme', $colorScheme, ['expires' => intval((new DateTimeImmutable('+1 year'))->format('U')), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue