route : when a relative baseURL is empty, push "./" to be in the current directory

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2081 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-04-27 18:34:30 +00:00
parent dc8f2d13df
commit f9a4e68e01

View File

@@ -45,9 +45,9 @@ class route
if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === "443")
$port = "";
$this->baseURL = "";
if ($absolute === true)
{
$this->baseURL = "";
if (isset ($_SERVER["SCRIPT_NAME"]))
$this->baseURL = dirname ($_SERVER["SCRIPT_NAME"]);
if (isset ($_SERVER["SERVER_NAME"]))
@@ -66,7 +66,10 @@ class route
$root = dirname ($_SERVER["SCRIPT_NAME"]);
$requestdir = substr ($request, 1+strlen ($root));
$this->baseURL = str_repeat ("../",
substr_count ($requestdir, "/")). $this->baseURL;
substr_count ($requestdir, "/")).
$this->baseURL;
if ($this->baseURL === "")
$this->baseURL = "./";
}
$this->baseURLmodule = $this->baseURL;
// Only != NOT !== (cause : $this->module can be converted in string "0")
@@ -134,12 +137,14 @@ class route
if (php_sapi_name () === "cli")
exit;
$destURL = trim ($destURL);
$baseURL = $this->baseURL ();
$baseURL = $this->baseURL ($module);
echo "baseURL=$baseURL,SCript=".$_SERVER["SCRIPT_NAME"];
if ($module !== "")
$baseURL .= $module."/";
$requestURL = $this->requestURL ();
if (substr ($requestURL, -1) !== "/")
$requestURL .= "/";
echo "destURL=$destURL,baseURL=$baseURL,module=$module";
if ($destURL[0] === "/")
{
// Absolute : return to project base