Added support for both server vars

This commit is contained in:
Conner Harkness 2025-08-27 14:34:38 -06:00
parent c69ea79785
commit ec99235500
2 changed files with 32 additions and 1 deletions

9
app.sh Normal file → Executable file
View File

@ -14,4 +14,11 @@ fi
# Handle multiple simultaneous requests in Linux only:
export PHP_CLI_SERVER_WORKERS=4
php -S 0.0.0.0:$PORT index.php --enable-mbstring
FILTER=".*"
if [[ "$@" =~ "--quiet" ]]
then
FILTER="INFO"
fi
php -S 0.0.0.0:$PORT index.php --enable-mbstring 2>&1 | grep -E "${FILTER}"

View File

@ -15,6 +15,19 @@
if ($strParam == null)
$strParam = "";
error_log("INFO: " . json_encode($_SERVER, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
foreach (["REQUEST_URI", "PATH_INFO"] as $k)
if (strlen($strParam) < 1)
{
if (is_array($_SERVER))
if (array_key_exists($k, $_SERVER))
if (strlen($_SERVER[$k]) > 0)
$strParam = $_SERVER[$k];
}
$strParam = preg_replace("/\?.*$/", "", $strParam);
// REQUEST_URI method:
if (strlen($strParam) < 1)
{
@ -24,6 +37,8 @@
$strParam = $_SERVER["PATH_INFO"];
}
//error_log(json_encode($_SERVER, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$strPath = $strParam;
$strPath = preg_replace("/^\//", "", $strPath);
$strPath = preg_replace("/\/$/", "", $strPath);
@ -202,9 +217,18 @@
return null;
}
public static function log()
{
//$strPath = $_SERVER["PATH_INFO"];
error_log("[{$strPath}] INFO: " . implode(" ", func_get_args()));
}
}
// Call this no matter what to understand the request:
Request::process();
Request::processExtra();
Request::log("");
?>