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