Currently the function looks like this:
function httpPrefix() {
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']
== 'on')) {
$rv = 'https://' . $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != 443)
$rv .= ':' . $_SERVER['SERVER_PORT'];
} else {
$rv = 'http://' . $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT'] != 80)
$rv .= ':' . $_SERVER['SERVER_PORT'];
}
return $rv;
}
$_SERVER['HTTP_HOST'] also includes the port number.
This results in a httpPrefix for a non-standard http port
like this: http://myserver:8080:8080
So you need to change $_SERVER['HTTP_HOST'] to
$_SERVER['SERVER_NAME'].
Since the method is called quite often I would propose
this code instead of the one above:
function httpPrefix() {
if (isset($_SERVER['HTTPS']) && (strtolower($_SERVER
['HTTPS']) == 'on')) {
return 'https://' . $_SERVER['SERVER_NAME'] .
($_SERVER['SERVER_PORT'] == 443 ? "" : ":" . $_SERVER
['SERVER_PORT']);
} else {
return 'http://' . $_SERVER['SERVER_NAME'] .
($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . $_SERVER
['SERVER_PORT']);
}
}
This eliminates the need for a local variable and saves
the call $rv .= ':' . $_SERVER['SERVER_PORT'];
Logged In: YES
user_id=341856
As you see in the proposed method you should also use
(strtolower($_SERVER
['HTTPS']) == 'on')) instead of $_SERVER
['HTTPS']) == 'on') because there are servers reporting 'ON'
instead of 'on'