* [misc] adjust webRoot get for container.

This commit is contained in:
caoyanyi
2024-12-17 10:03:33 +08:00
committed by 刘刚
parent f9c5d8b602
commit 2ed5f416a5
+4 -3
View File
@@ -1232,10 +1232,11 @@ function isLocalIP()
*/
function getWebRoot($full = false)
{
if(getenv('ZT_WEB_ROOT')) return '/' . trim(getenv('ZT_WEB_ROOT'), '/') . '/';
$envWebRoot = (string)getenv('ZT_WEB_ROOT');
if($envWebRoot) $envWebRoot = '/' . trim($envWebRoot, '/') . '/';
if(!$full && $envWebRoot) return $envWebRoot;
$path = $_SERVER['SCRIPT_NAME'];
if(PHP_SAPI == 'cli')
{
if(isset($_SERVER['argv'][1]))
@@ -1249,7 +1250,7 @@ function getWebRoot($full = false)
if($full)
{
$http = (isset($_SERVER['HTTPS']) and strtolower((string) $_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
return $http . $_SERVER['HTTP_HOST'] . substr((string) $path, 0, (strrpos((string) $path, '/') + 1));
return $http . $_SERVER['HTTP_HOST'] . substr((string) $path, 0, (strrpos((string) $path, '/') + 1)) . trim($envWebRoot, '/');
}
$pos = strrpos((string) $path, '/');