route : relative routes are now relative to site base and not relative to current directory. Due to bad coded crawlers and browser as they don't manage correctely the ../ in front of relative URL.

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5473 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-09-12 07:55:52 +00:00
parent 39e47d70c6
commit a01d704e85

View File

@@ -127,11 +127,29 @@ class route
{ {
// Calculate the root in relative // Calculate the root in relative
$request = $this->requestURL (); $request = $this->requestURL ();
if (substr ($_SERVER["REQUEST_URI"], -1 * strlen ($request)) === $request)
{
$this->baseURL = substr ($_SERVER["REQUEST_URI"], 0,
strlen ($_SERVER["REQUEST_URI"]) - strlen ($request));
}
elseif ($_SERVER["REQUEST_URI"] !== "")
{
$this->baseURL = $_SERVER["REQUEST_URI"];
}
else
{
$this->baseURL = "/";
}
/*
// This part was to get really relative to current directory (with ../)
// But it is not really well supported by the bad coded crawlers. So, the
// URL is now relative to base of URL
$this->baseURL = str_repeat ("../", $this->baseURL = str_repeat ("../",
substr_count ($request, "/")). substr_count ($request, "/")).
$this->baseURL; $this->baseURL;
if ($this->baseURL === "") if ($this->baseURL === "")
$this->baseURL = "./"; $this->baseURL = "./";
*/
} }
$this->baseURLmodule = $this->baseURL; $this->baseURLmodule = $this->baseURL;
// Only != NOT !== (cause : $this->module can be converted in string "0") // Only != NOT !== (cause : $this->module can be converted in string "0")