diff --git a/index.php b/index.php index 6fec0de8..be5ba4e4 100644 --- a/index.php +++ b/index.php @@ -20,15 +20,16 @@ $loadTime = microtime(true); // Security constant define('BLUDIT', true); +// Directory separator +define('DS', DIRECTORY_SEPARATOR); + // PHP paths -define('PATH_ROOT', __DIR__.'/'); -define('PATH_BOOT', PATH_ROOT.'kernel/boot/'); +define('PATH_ROOT', __DIR__.DS); +define('PATH_BOOT', PATH_ROOT.'kernel'.DS.'boot'.DS); // Init require(PATH_BOOT.'init.php'); - - // Admin area if($Url->whereAmI()==='admin') { diff --git a/install.php b/install.php index 8812670b..e19a6504 100644 --- a/install.php +++ b/install.php @@ -2,17 +2,20 @@ // Security constant define('BLUDIT', true); +// Directory separator +define('DS', DIRECTORY_SEPARATOR); + // PATHs -define('PATH_ROOT', __DIR__.'/'); -define('PATH_CONTENT', PATH_ROOT.'content/'); -define('PATH_POSTS', PATH_CONTENT.'posts/'); -define('PATH_UPLOADS', PATH_CONTENT.'uploads/'); -define('PATH_PAGES', PATH_CONTENT.'pages/'); -define('PATH_DATABASES', PATH_CONTENT.'databases/'); -define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases/plugins/'); +define('PATH_ROOT', __DIR__.DS); +define('PATH_CONTENT', PATH_ROOT.'content'.DS); +define('PATH_POSTS', PATH_CONTENT.'posts'.DS); +define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS); +define('PATH_PAGES', PATH_CONTENT.'pages'.DS); +define('PATH_DATABASES', PATH_CONTENT.'databases'.DS); +define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases'.DS.'plugins'.DS); define('DOMAIN', getenv('HTTP_HOST')); -$base = (dirname(getenv('SCRIPT_NAME'))=='/')?'/':dirname(getenv('SCRIPT_NAME')).'/'; +$base = (dirname(getenv('SCRIPT_NAME'))==DS)?DS:dirname(getenv('SCRIPT_NAME')).DS; define('HTML_PATH_ROOT', $base); if(!defined('JSON_PRETTY_PRINT')) { @@ -200,7 +203,7 @@ function install($adminPassword, $email) $data = 'Title: Error Content: The page has not been found.'; - file_put_contents(PATH_PAGES.'error/index.txt', $data, LOCK_EX); + file_put_contents(PATH_PAGES.'error'.DS.'index.txt', $data, LOCK_EX); // File index.txt for welcome post $data = 'title: First post @@ -217,7 +220,7 @@ What\'s next: - Read the documentation for more information - Share with your friend :D'; - file_put_contents(PATH_POSTS.$firstPostSlug.'/index.txt', $data, LOCK_EX); + file_put_contents(PATH_POSTS.$firstPostSlug.DS.'index.txt', $data, LOCK_EX); return true; } @@ -319,4 +322,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) - + \ No newline at end of file diff --git a/kernel/abstract/filecontent.class.php b/kernel/abstract/filecontent.class.php index e19eea4a..439635a6 100644 --- a/kernel/abstract/filecontent.class.php +++ b/kernel/abstract/filecontent.class.php @@ -38,7 +38,7 @@ class fileContent private function build($pathSlug) { - if( !Sanitize::pathFile($this->path.$pathSlug.'/', 'index.txt') ) { + if( !Sanitize::pathFile($this->path.$pathSlug.DS, 'index.txt') ) { return false; } @@ -49,7 +49,7 @@ class fileContent $this->setField('key', $pathSlug); $tmp = 0; - $lines = file($this->path.$pathSlug.'/index.txt'); + $lines = file($this->path.$pathSlug.DS.'index.txt'); foreach($lines as $lineNumber=>$line) { $parts = array_map('trim', explode(':', $line, 2)); diff --git a/kernel/boot/admin.php b/kernel/boot/admin.php index 8009cff7..ca65f8fb 100644 --- a/kernel/boot/admin.php +++ b/kernel/boot/admin.php @@ -50,14 +50,14 @@ else } // Admin theme init.php - if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().'/init.php') ) - include(PATH_ADMIN_THEMES.$Site->adminTheme().'/init.php'); + if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.'init.php') ) + include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.'init.php'); // Load controller if( Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'].'.php') ) include(PATH_ADMIN_CONTROLLERS.$layout['controller'].'.php'); // Load view and theme - if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().'/'.$layout['template']) ) - include(PATH_ADMIN_THEMES.$Site->adminTheme().'/'.$layout['template']); + if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.$layout['template']) ) + include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.$layout['template']); } diff --git a/kernel/boot/init.php b/kernel/boot/init.php index c84b6bc9..a27f6d32 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -1,32 +1,34 @@ theme().'/init.php') ) - include(PATH_THEMES.$Site->theme().'/init.php'); +if( Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'init.php') ) + include(PATH_THEMES.$Site->theme().DS.'init.php'); // Theme HTML -if( Sanitize::pathFile(PATH_THEMES, $Site->theme().'/index.php') ) - include(PATH_THEMES.$Site->theme().'/index.php'); +if( Sanitize::pathFile(PATH_THEMES, $Site->theme().DS.'index.php') ) + include(PATH_THEMES.$Site->theme().DS.'index.php'); diff --git a/kernel/page.class.php b/kernel/page.class.php index 5441bb0f..ea33db56 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -146,7 +146,7 @@ class Page extends fileContent public function children() { $tmp = array(); - $paths = glob(PATH_PAGES.$this->getField('key').'/*', GLOB_ONLYDIR); + $paths = glob(PATH_PAGES.$this->getField('key').DS.'*', GLOB_ONLYDIR); foreach($paths as $path) { array_push($tmp, basename($path)); }