From 265ffda21dec75e03d0a1bf71d67f72af87d74dc Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Sun, 10 Jul 2022 10:38:54 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BA=D1=80=D0=BE=D0=BD=D0=B0=20=D1=87=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=20cli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/cron.php | 3 +++ core/lib/Core/Helpers/SystemFunctions.class.php | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/cron.php b/core/cron.php index 32a1d98..2ea2bf5 100644 --- a/core/cron.php +++ b/core/cron.php @@ -2,6 +2,9 @@ @ignore_user_abort(true); set_time_limit(0); + if (empty($_SERVER['DOCUMENT_ROOT'])) { + $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/..'; + } require_once __DIR__ . '/bootstrap.php'; use Core\Helpers\SystemFunctions; diff --git a/core/lib/Core/Helpers/SystemFunctions.class.php b/core/lib/Core/Helpers/SystemFunctions.class.php index 1ce7902..2ef5e3c 100644 --- a/core/lib/Core/Helpers/SystemFunctions.class.php +++ b/core/lib/Core/Helpers/SystemFunctions.class.php @@ -65,7 +65,12 @@ */ public static function getOS(): string { - $userAgent = $_SERVER['HTTP_USER_AGENT']; + $undefinedOS = 'Unknown OS'; + + if(empty($_SERVER['HTTP_USER_AGENT'])) { + return $undefinedOS; + } + $oses = [ 'iOS' => '/(iPhone)|(iPad)/i', 'Windows 3.11' => '/Win16/i', @@ -93,11 +98,11 @@ ]; foreach ($oses as $os => $pattern) { - if (preg_match($pattern, $userAgent)) { + if (preg_match($pattern, $_SERVER['HTTP_USER_AGENT'])) { return $os; } } - return 'Unknown OS'; + return $undefinedOS; } /**