2015-03-08 18:02:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// DEBUG:
|
|
|
|
$loadTime = microtime(true);
|
|
|
|
|
|
|
|
// SECURITY CONSTANT
|
|
|
|
define('BLUDIT', true);
|
|
|
|
|
|
|
|
// PHP PATHS
|
|
|
|
define('PATH_ROOT', __DIR__.'/');
|
|
|
|
define('PATH_LANGUAGES', PATH_ROOT.'languages/');
|
|
|
|
define('PATH_THEMES', PATH_ROOT.'themes/');
|
|
|
|
define('PATH_PLUGINS', PATH_ROOT.'plugins/');
|
|
|
|
|
|
|
|
define('PATH_KERNEL', PATH_ROOT.'kernel/');
|
|
|
|
define('PATH_ABSTRACT', PATH_ROOT.'kernel/abstract/');
|
|
|
|
define('PATH_BOOT', PATH_ROOT.'kernel/boot/');
|
|
|
|
define('PATH_RULES', PATH_ROOT.'kernel/boot/rules/');
|
|
|
|
define('PATH_HELPERS', PATH_ROOT.'kernel/helpers/');
|
|
|
|
|
2015-03-10 17:22:28 +01:00
|
|
|
define('PATH_CONTENT', PATH_ROOT.'content/');
|
2015-03-08 18:02:59 +01:00
|
|
|
define('PATH_POSTS', PATH_CONTENT.'posts/');
|
|
|
|
define('PATH_PAGES', PATH_CONTENT.'pages/');
|
|
|
|
define('PATH_DATABASES', PATH_CONTENT.'databases/');
|
|
|
|
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases/plugins/');
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
define('PATH_ADMIN_THEMES', PATH_ROOT.'admin/themes/');
|
|
|
|
define('PATH_ADMIN_CONTROLLERS', PATH_ROOT.'admin/controllers/');
|
|
|
|
define('PATH_ADMIN_VIEWS', PATH_ROOT.'admin/views/');
|
|
|
|
|
2015-03-08 18:02:59 +01:00
|
|
|
// BOOT
|
|
|
|
require(PATH_BOOT.'site.php');
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
// Admin area
|
|
|
|
if($Url->whereAmI()==='admin')
|
|
|
|
{
|
|
|
|
$layout = array(
|
|
|
|
'controller'=>null,
|
|
|
|
'view'=>null,
|
|
|
|
'template'=>'index.php'
|
|
|
|
);
|
|
|
|
|
|
|
|
$layout['controller'] = $layout['view'] = $Url->slug();
|
|
|
|
|
|
|
|
if($Url->notFound() || !$Login->isLogged() || ($Url->slug()==='login') )
|
|
|
|
{
|
|
|
|
$layout['controller'] = 'login';
|
|
|
|
$layout['view'] = 'login';
|
|
|
|
$layout['template'] = 'login.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Admin theme init.php
|
|
|
|
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().'/init.php') )
|
|
|
|
include(PATH_ADMIN_THEMES.$Site->adminTheme().'/init.php');
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
// Load controller
|
|
|
|
if( Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'].'.php') )
|
|
|
|
include(PATH_ADMIN_CONTROLLERS.$layout['controller'].'.php');
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
// Load view and theme
|
|
|
|
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().'/'.$layout['template']) )
|
|
|
|
include(PATH_ADMIN_THEMES.$Site->adminTheme().'/'.$layout['template']);
|
|
|
|
|
|
|
|
}
|
|
|
|
// Site
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($Url->notFound())
|
|
|
|
{
|
|
|
|
$Url->setWhereAmI('page');
|
|
|
|
$Page = new Page('error');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Theme init.php
|
|
|
|
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().'/init.php') )
|
|
|
|
include(PATH_THEMES.$Site->theme().'/init.php');
|
|
|
|
|
|
|
|
// Theme HTML
|
|
|
|
if( Sanitize::pathFile(PATH_THEMES, $Site->theme().'/index.php') )
|
|
|
|
include(PATH_THEMES.$Site->theme().'/index.php');
|
|
|
|
}
|
2015-03-08 18:02:59 +01:00
|
|
|
|
|
|
|
// DEBUG:
|
|
|
|
echo "Load time: ".(microtime(true) - $loadTime);
|