From 884da19d719ddb6e368ffccefa0c287d4dbe209f Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 27 Jun 2014 11:56:27 +0000 Subject: [PATCH] route : Correct support of SERVER_PORT git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1500 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- route.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/route.php b/route.php index 31082f0..ab66c87 100644 --- a/route.php +++ b/route.php @@ -29,11 +29,19 @@ class route $this->module = $module; if ($this->baseURL !== "") return $this->baseURL; + + if (!isset ($_SERVER["SERVER_PORT"])) + $_SERVER["SERVER_PORT"] = 80; + $port = ":".$_SERVER["SERVER_PORT"]; + if (!isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 80) + $port = ""; + if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 443) + $port = ""; + if (isset ($_SERVER["SCRIPT_NAME"])) $this->baseURL = dirname ($_SERVER["SCRIPT_NAME"]); if (isset ($_SERVER["SERVER_NAME"])) - $this->baseURL = "//".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"] - .$this->baseURL; + $this->baseURL = "//".$_SERVER["SERVER_NAME"].$port.$this->baseURL; if (isset ($_SERVER["HTTPS"])) $this->baseURL = "https:".$this->baseURL; else @@ -75,8 +83,16 @@ class route $url = "https:"; else $url = "http:"; + if (!isset ($_SERVER["SERVER_PORT"])) + $_SERVER["SERVER_PORT"] = 80; + $port = ":".$_SERVER["SERVER_PORT"]; + if (!isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 80) + $port = ""; + if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 443) + $port = ""; + if (isset ($_SERVER["SERVER_NAME"])) - $url .= "//".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]; + $url .= "//".$_SERVER["SERVER_NAME"].$port; if (isset ($_SERVER["REQUEST_URI"])) $url .= $_SERVER["REQUEST_URI"]; return $url;