summaryrefslogtreecommitdiff
path: root/inc/init.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/init.php')
-rw-r--r--inc/init.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/inc/init.php b/inc/init.php
index 1dc31a31f..f4c867935 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -421,14 +421,27 @@ function getBaseURL($abs=null){
if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir;
//split hostheader into host and port
- $addr = explode(':',$_SERVER['HTTP_HOST']);
- $host = $addr[0];
- $port = '';
- if (isset($addr[1])) {
- $port = $addr[1];
- } elseif (isset($_SERVER['SERVER_PORT'])) {
+ if(isset($_SERVER['HTTP_HOST'])){
+ $parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']);
+ $host = $parsed_host['host'];
+ $port = $parsed_host['port'];
+ }elseif(isset($_SERVER['SERVER_NAME'])){
+ $parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']);
+ $host = $parsed_host['host'];
+ $port = $parsed_host['port'];
+ }else{
+ $host = php_uname('n');
+ $port = '';
+ }
+
+ if(!$port && isset($_SERVER['SERVER_PORT'])) {
$port = $_SERVER['SERVER_PORT'];
}
+
+ if(is_null($port)){
+ $port = '';
+ }
+
if(!is_ssl()){
$proto = 'http://';
if ($port == '80') {