diff --git a/app.sh b/app.sh old mode 100644 new mode 100755 index f698d21..d34e7a2 --- a/app.sh +++ b/app.sh @@ -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}" diff --git a/lib/Request.php b/lib/Request.php index 9bddddb..7a84fca 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -14,6 +14,19 @@ // PHP 5.3.9: 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) @@ -23,6 +36,8 @@ if (strlen($_SERVER["PATH_INFO"]) > 0) $strParam = $_SERVER["PATH_INFO"]; } + + //error_log(json_encode($_SERVER, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $strPath = $strParam; $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(""); ?>