diff --git a/includes/core/page.inc.php b/includes/core/page.inc.php index f963a3b..d35a7d3 100644 --- a/includes/core/page.inc.php +++ b/includes/core/page.inc.php @@ -10,10 +10,7 @@ abstract class Page public function __construct( ) { - $this->baseURL = dirname( $_SERVER[ 'SCRIPT_NAME' ] ); - if ( $this->baseURL == '/' ) { - $this->baseURL = ''; - } + $this->baseURL = rtrim(dirname( $_SERVER[ 'SCRIPT_NAME' ] ), '/'); } public final function addController( Controller $controller ) @@ -29,6 +26,16 @@ abstract class Page return $this; } + public final function getServerRoot( ) + { + $root = Loader::PackageConfig( 'core' )->get( 'pages/baseURL' , null , false ); + if (is_null($root)) { + $root = ( ( $_SERVER[ 'HTTPS' ] ?: false ) ? 'https' : 'http' ) + . '://' . $_SERVER[ 'HTTP_HOST' ]; + } + return rtrim($root, '/'); + } + public final function getBaseURL( ) { return $this->baseURL; @@ -55,8 +62,7 @@ abstract class Page if ( $rc[0] != '/' ) { $rc = $this->baseURL . '/' . $rc; } - $rc = ( ( array_key_exists( 'HTTPS' , $_SERVER ) && $_SERVER[ 'HTTPS' ] ) ? 'https' : 'http' ) . '://' . $_SERVER[ 'SERVER_NAME' ] - . ':' . $_SERVER[ 'SERVER_PORT' ] . $rc; + $rc = $this->getServerRoot() . $rc; header( "Location: $rc" ); $rv = true; }