bludit/kernel/boot/admin.php

93 lines
2.6 KiB
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
$layout = array(
'controller'=>null,
'view'=>null,
'template'=>'index.php',
'slug'=>null,
2015-07-07 00:22:03 +02:00
'parameters'=>null,
'title'=>'Bludit'
2015-05-05 03:00:01 +02:00
);
// Get the view, controller, and the parameters from the URL.
$explodeSlug = $Url->explodeSlug();
$layout['controller'] = $layout['view'] = $layout['slug'] = $explodeSlug[0];
unset($explodeSlug[0]);
$layout['parameters'] = implode('/', $explodeSlug);
// Disable Magic Quotes.
2015-05-15 00:07:45 +02:00
// Thanks, http://stackoverflow.com/questions/517008/how-to-turn-off-magic-quotes-on-shared-hosting
if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) )
{
2015-08-17 04:33:49 +02:00
$_POST = array_map('stripslashes', $_POST);
$_GET = array_map('stripslashes', $_GET);
2015-05-15 00:07:45 +02:00
$_COOKIE = array_map('stripslashes', $_COOKIE);
}
// --- AJAX ---
2015-08-18 04:02:19 +02:00
if( $layout['slug']==='ajax' )
2015-05-05 03:00:01 +02:00
{
// Check if the user is loggued.
2015-08-18 04:02:19 +02:00
if($Login->isLogged())
{
// Load the ajax file.
2015-08-18 04:02:19 +02:00
if( Sanitize::pathFile(PATH_AJAX, $layout['parameters'].'.php') ) {
include(PATH_AJAX.$layout['parameters'].'.php');
}
2015-08-17 04:33:49 +02:00
}
2015-05-05 03:00:01 +02:00
}
// --- ADMIN AREA ---
2015-05-05 03:00:01 +02:00
else
{
// Boot rules
2016-01-08 00:43:09 +01:00
include(PATH_RULES.'60.plugins.php');
2015-08-31 03:18:06 +02:00
include(PATH_RULES.'70.posts.php');
include(PATH_RULES.'70.pages.php');
2015-05-05 03:00:01 +02:00
include(PATH_RULES.'99.header.php');
2015-07-20 05:14:12 +02:00
include(PATH_RULES.'99.paginator.php');
2015-08-02 04:47:45 +02:00
include(PATH_RULES.'99.themes.php');
2015-09-08 02:51:48 +02:00
include(PATH_RULES.'99.security.php');
2015-05-05 03:00:01 +02:00
// Page not found.
// User not logged.
// Slug is login.
// Slug is login-email.
2015-10-19 00:45:58 +02:00
if($Url->notFound() || !$Login->isLogged() || ($Url->slug()==='login') || ($Url->slug()==='login-email') )
2015-05-05 03:00:01 +02:00
{
$layout['controller'] = 'login';
2015-08-07 23:33:43 +02:00
$layout['view'] = 'login';
$layout['template'] = 'login.php';
2015-09-08 02:51:48 +02:00
2015-10-19 00:45:58 +02:00
if($Url->slug()==='login-email')
{
$layout['controller'] = 'login-email';
$layout['view'] = 'login-email';
}
// Generate the tokenCSRF for the user not logged, when the user log-in the token will be change.
$Security->generateTokenCSRF();
2015-05-05 03:00:01 +02:00
}
// Load plugins before the admin area will be load.
2015-08-08 02:39:10 +02:00
Theme::plugins('beforeAdminLoad');
// Load init.php if the theme has one.
2015-08-17 04:33:49 +02:00
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.'init.php') ) {
2015-06-22 00:01:07 +02:00
include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.'init.php');
2015-08-17 04:33:49 +02:00
}
2015-05-05 03:00:01 +02:00
// Load controller.
2015-08-17 04:33:49 +02:00
if( Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'].'.php') ) {
2015-05-05 03:00:01 +02:00
include(PATH_ADMIN_CONTROLLERS.$layout['controller'].'.php');
2015-08-17 04:33:49 +02:00
}
2015-05-05 03:00:01 +02:00
// Load view and theme.
2015-08-17 04:33:49 +02:00
if( Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme().DS.$layout['template']) ) {
2015-06-22 00:01:07 +02:00
include(PATH_ADMIN_THEMES.$Site->adminTheme().DS.$layout['template']);
2015-08-17 04:33:49 +02:00
}
2015-08-08 02:39:10 +02:00
// Load plugins after the admin area is loaded.
2015-08-08 02:39:10 +02:00
Theme::plugins('afterAdminLoad');
}