route : base URL is now in complete relative !

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2078 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-04-27 17:03:05 +00:00
parent 11106afc7c
commit 166fa33c7a

View File

@@ -45,19 +45,29 @@ class route
if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === "443")
$port = "";
if (isset ($_SERVER["SCRIPT_NAME"]))
$this->baseURL = dirname ($_SERVER["SCRIPT_NAME"]);
$this->baseURL = "";
if ($absolute === true)
{
if (isset ($_SERVER["SCRIPT_NAME"]))
$this->baseURL = dirname ($_SERVER["SCRIPT_NAME"]);
if (isset ($_SERVER["SERVER_NAME"]))
$this->baseURL = "//".$_SERVER["SERVER_NAME"].$port.$this->baseURL;
if (isset ($_SERVER["HTTPS"]))
$this->baseURL = "https:".$this->baseURL;
else
$this->baseURL = "http:".$this->baseURL;
if (substr ($this->baseURL, -1) !== "/")
$this->baseURL .= "/";
}
else
{
// Calculate the root in relative
$request = $this->requestURL ();
$root = dirname ($_SERVER["SCRIPT_NAME"]);
$requestdir = substr ($request, 1+strlen ($root));
$this->baseURL = str_repeat ("../",
substr_count ($requestdir, "/")). $this->baseURL;
}
if (substr ($this->baseURL, -1) !== "/")
$this->baseURL .= "/";
$this->baseURLmodule = $this->baseURL;
// Only != NOT !== (cause : $this->module can be converted in string "0")
if ($this->module != FALSE)
@@ -302,6 +312,7 @@ file_put_contents ("/tmp/csrf.log", date ("Y-m-d H:i:s")." DELETE route->map ($r
public function map ($route, $function)
{
$url = substr ($this->requestURL (), strlen ($this->baseURLmodule ()));
$url = substr ($this->requestURL (), 1+ strlen (dirname ($_SERVER["SCRIPT_NAME"])));
if ($this->debug)
echo "$url ";
if ($url === $route)