From 7dba06e47390d092993b2ee897f54181c9053e49 Mon Sep 17 00:00:00 2001 From: dignajar Date: Tue, 8 Dec 2015 21:56:31 -0300 Subject: [PATCH] Bug fixed, base url --- install.php | 5 +++-- kernel/boot/init.php | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/install.php b/install.php index b3aacfa9..3ec6ea5c 100644 --- a/install.php +++ b/install.php @@ -34,8 +34,9 @@ define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS); define('DOMAIN', $_SERVER['HTTP_HOST']); // HTML PATHs -$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; -$base = dirname($base); +//$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; +//$base = dirname($base); +$base = empty($_SERVER['REQUEST_URI']) ? dirname($_SERVER['SCRIPT_NAME']) : dirname($_SERVER['REQUEST_URI']); if($base!=DS) { $base = $base.'/'; diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 030db91f..20684580 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -153,12 +153,23 @@ $Url = new Url(); $Parsedown = new ParsedownExtra(); $Security = new Security(); -// HTML PATHs -$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; -$base = dirname($base); +// HTML PATHS +// The user can define the base URL. +// Left empty if you want to Bludit try to detect the base URL. +$base = ''; + +if( !empty($_SERVER['DOCUMENT_ROOT']) && !empty($_SERVER['SCRIPT_NAME']) && empty($base) ) { + $base = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_NAME']); + $base = dirname($base); +} +elseif( empty($base) ) { + $base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; + $base = dirname($base); +} if($base!=DS) { - $base = $base.'/'; + $base = trim($base, '/'); + $base = '/'.$base.'/'; } else { // Workaround for Windows Web Servers