From b768a8eb3708c17d60ed1bf1c30259e221a72b98 Mon Sep 17 00:00:00 2001 From: fidian Date: Tue, 17 Oct 2000 18:29:01 +0000 Subject: [PATCH] Attempted to fix a bug where the port number was added twice to the URLs. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@803 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/strings.php | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/functions/strings.php b/functions/strings.php index e59f556e..3b1ea5a8 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -243,24 +243,34 @@ $proto = "https://"; } - $port = ""; - if (isset($SERVER_PORT)) { - if ($SERVER_PORT != 80) { - $port = sprintf(':%d', $SERVER_PORT); - } - } - // Get the hostname from the Host header or server config. + $host = ""; + if (isset($HTTP_HOST) && !empty($HTTP_HOST)) + { + $host = $HTTP_HOST; + } + else if (isset($SERVER_NAME) && !empty($SERVER_NAME)) + { + $host = $SERVER_NAME; + } + + // Workaround to possibly get rid of extra port definitions. + $port = ''; + if (! strstr($host, ':')) + { + if (isset($SERVER_PORT)) { + if ($SERVER_PORT != 80) { + $port = sprintf(':%d', $SERVER_PORT); + } + } + } + + if ($host) + return $proto . $host . $port . $path; + // Fallback is to omit the server name and use a relative URI, // although this is not RFC 2616 compliant. - if(isset($HTTP_HOST) && !empty($HTTP_HOST)) { - $location = $proto . $HTTP_HOST . $port . $path; - } else if(isset($SERVER_NAME) && !empty($SERVER_NAME)) { - $location = $proto . $SERVER_NAME . $port . $path; - } else { - $location = $path; - } - return $location; + return $path; } function sqStripSlashes($string) { -- 2.25.1