mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Remove last traces of date functions in favor of DateTimeImmutable
This commit is contained in:
parent
c6d2d77537
commit
97821d0dc3
4 changed files with 7 additions and 13 deletions
|
@ -188,7 +188,7 @@ class HttpInput{
|
|||
try{
|
||||
return intval($var);
|
||||
}
|
||||
catch(Exception){
|
||||
catch(\Exception){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ class HttpInput{
|
|||
try{
|
||||
return floatval($var);
|
||||
}
|
||||
catch(Exception){
|
||||
catch(\Exception){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +215,7 @@ class HttpInput{
|
|||
try{
|
||||
return new DateTimeImmutable($var);
|
||||
}
|
||||
catch(Exception){
|
||||
vdd('q');
|
||||
catch(\Exception){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
use Ramsey\Uuid\Uuid;
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
use function Safe\strtotime;
|
||||
|
||||
/**
|
||||
* @property User $User
|
||||
* @property string $Url
|
||||
|
@ -100,7 +98,7 @@ class Session{
|
|||
}
|
||||
|
||||
public static function SetSessionCookie(string $sessionId): void{
|
||||
setcookie('sessionid', $sessionId, ['expires' => strtotime('+1 week'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks
|
||||
setcookie('sessionid', $sessionId, ['expires' => (new DateTimeImmutable('+1 week'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']); // Expires in two weeks
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?
|
||||
use function Safe\apcu_fetch;
|
||||
use function Safe\strtotime;
|
||||
|
||||
// If the user is not logged in, or has less than some amount of downloads, show a thank-you page
|
||||
|
||||
|
@ -61,7 +60,7 @@ try{
|
|||
|
||||
// Increment local download count, expires in 2 weeks
|
||||
$downloadCount++;
|
||||
setcookie('download-count', (string)$downloadCount, ['expires' => strtotime('+2 week'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']);
|
||||
setcookie('download-count', (string)$downloadCount, ['expires' => (new DateTimeImmutable('+2 week'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => false, 'samesite' => 'Lax']);
|
||||
}
|
||||
catch(Exceptions\InvalidFileException | Exceptions\EbookNotFoundException){
|
||||
Template::Emit404();
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?
|
||||
use function Safe\strtotime;
|
||||
|
||||
$hideDonationAlert = HttpInput::Bool(POST, 'hide-donation-alert');
|
||||
$colorScheme = HttpInput::Str(POST, 'color-scheme');
|
||||
|
||||
if($hideDonationAlert !== null){
|
||||
setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', ['expires' => strtotime('+1 month'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
setcookie('hide-donation-alert', $hideDonationAlert ? 'true' : 'false', ['expires' => (new DateTimeImmutable('+1 month'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
}
|
||||
|
||||
if($colorScheme !== null){
|
||||
|
@ -18,7 +16,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' => strtotime('+1 year'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
setcookie('color-scheme', $colorScheme, ['expires' => (new DateTimeImmutable('+1 year'))->format('@'), 'path' => '/', 'domain' => SITE_DOMAIN, 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue