From d5aa44decee777c74335edacc368afae6e53312a Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Mon, 4 Nov 2024 10:28:08 -0300 Subject: [PATCH] Function update --- locale/save.php | 2 +- objects/functions.php | 16 ++++++++++++++-- objects/functionsExec.php | 8 ++++---- objects/functionsFile.php | 2 +- plugin/AI/AI.php | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/locale/save.php b/locale/save.php index a7541c23b2..05d97daa11 100644 --- a/locale/save.php +++ b/locale/save.php @@ -18,7 +18,7 @@ if(empty($_REQUEST['custom'])){ $dir = "{$global['systemRootPath']}videos/locale/"; make_path($dir); } -if (!is_writable($dir) && !isWindows()) { +if (!is_writable($dir) && !isWindowsServer()) { $obj->status = 0; $obj->error = sprintf(__("Your %s locale dir is not writable"), $global['systemRootPath']); die(json_encode($obj)); diff --git a/objects/functions.php b/objects/functions.php index 9e28cc512d..84f1a422e7 100644 --- a/objects/functions.php +++ b/objects/functions.php @@ -5225,11 +5225,23 @@ function getCurrentTheme() } } -function isWindows() +function isWindowsServer() { return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; } +function isWindows() { + global $global; + // Check if the HTTP_USER_AGENT is set + if (isset($_SERVER['HTTP_USER_AGENT'])) { + // Look for 'Windows' in the user agent string + if (stripos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { + return true; + } + } + return !empty($global['isWindows']); +} + function isURL200($url, $forceRecheck = false) { global $_isURL200; @@ -5854,7 +5866,7 @@ function getSystemTimezone() return $_getSystemTimezoneName; } - if (isWindows()) { + if (isWindowsServer()) { $cmd = 'tzutil /g'; } else { $cmd = 'cat /etc/timezone'; diff --git a/objects/functionsExec.php b/objects/functionsExec.php index 970307a14d..b677ab1171 100644 --- a/objects/functionsExec.php +++ b/objects/functionsExec.php @@ -120,7 +120,7 @@ function getDirSize($dir, $forceNew = false) _error_log("getDirSize: start {$dir}"); - if (isWindows()) { + if (isWindowsServer()) { $return = foldersize($dir); $_getDirSize[$dir] = $return; return $return; @@ -155,7 +155,7 @@ function rrmdirCommandLine($dir, $async = false) { if (is_dir($dir)) { $dir = escapeshellarg($dir); - if (isWindows()) { + if (isWindowsServer()) { $command = ('rd /s /q ' . $dir); } else { $command = ('rm -fR ' . $dir); @@ -347,7 +347,7 @@ function execAsync($command, $keyword = null) $keyword = preg_replace('/[^a-zA-Z0-9_-]/', '_', $keyword); } - if (isWindows()) { + if (isWindowsServer()) { if ($keyword) { // Add the keyword as a comment to the command for Windows $commandWithKeyword = "start /B cmd /c \"$command & REM $keyword\" > NUL 2>&1"; @@ -464,7 +464,7 @@ function killProcess($pid) _error_log("killProcess($pid)"); - if (isWindows()) { + if (isWindowsServer()) { $cmd = "taskkill /F /PID $pid"; } else { $cmd = "kill -9 $pid"; diff --git a/objects/functionsFile.php b/objects/functionsFile.php index c400bb4e8d..d648f451be 100644 --- a/objects/functionsFile.php +++ b/objects/functionsFile.php @@ -1032,7 +1032,7 @@ function fixPath($path, $addLastSlash = false) if (empty($path)) { return false; } - if (isWindows()) { + if (isWindowsServer()) { $path = str_replace('/', DIRECTORY_SEPARATOR, $path); $path = str_replace('\\\\\\', DIRECTORY_SEPARATOR, $path); } else { diff --git a/plugin/AI/AI.php b/plugin/AI/AI.php index f4678784c7..21857bf73b 100644 --- a/plugin/AI/AI.php +++ b/plugin/AI/AI.php @@ -108,6 +108,7 @@ class AI extends PluginAbstract $domain = parse_url($global['webSiteRootURL'], PHP_URL_HOST); } self::$isTest = ($domain == "vlu.me"); + //return self::$url; return self::$isTest ? self::$url_test : self::$url; }