Small patch

This commit is contained in:
Pablo Ferreiro 2022-03-29 19:35:29 +02:00
parent 44ee065ec6
commit 1a86abeb2d
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24

View file

@ -2,6 +2,10 @@
namespace App\Helpers; namespace App\Helpers;
class Misc { class Misc {
static private function isSecure() {
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;
}
static public function getCursor(): int { static public function getCursor(): int {
return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0; return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0;
} }
@ -11,7 +15,7 @@ class Misc {
} }
static public function url(string $endpoint = ''): string { static public function url(string $endpoint = ''): string {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; $protocol = self::isSecure() ? 'https' : 'http';
$root = $protocol . '://' . $_SERVER['HTTP_HOST']; $root = $protocol . '://' . $_SERVER['HTTP_HOST'];
return $root . self::env('APP_PATH', '') . $endpoint; return $root . self::env('APP_PATH', '') . $endpoint;
} }