2015-04-30 14:12:49 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Sakura Management
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Declare Namespace
|
|
|
|
namespace Sakura;
|
2015-05-05 06:24:19 +00:00
|
|
|
|
2015-04-30 23:01:01 +00:00
|
|
|
// Define that we are in Management mode
|
|
|
|
define('SAKURA_MANAGE', true);
|
|
|
|
|
2015-04-30 14:12:49 +00:00
|
|
|
// Include components
|
2015-12-03 19:40:01 +00:00
|
|
|
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
|
2015-04-30 23:01:01 +00:00
|
|
|
|
2015-08-18 13:13:40 +00:00
|
|
|
// Make sure user has the permissions to view this
|
2015-11-07 22:58:02 +00:00
|
|
|
if (!$currentUser->checkPermission('MANAGE', 'USE_MANAGE')) {
|
2015-08-18 13:13:40 +00:00
|
|
|
header('Location: /');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-09-29 17:26:24 +00:00
|
|
|
// Modes
|
|
|
|
$modes = [
|
|
|
|
'dashboard' => [
|
|
|
|
'index',
|
2015-05-03 16:25:57 +00:00
|
|
|
],
|
2015-10-03 22:45:19 +00:00
|
|
|
'configuration' => [
|
|
|
|
'general',
|
|
|
|
'security',
|
|
|
|
'authentication',
|
|
|
|
'appearance',
|
|
|
|
'performance',
|
2015-09-29 17:26:24 +00:00
|
|
|
],
|
2015-12-09 20:21:08 +00:00
|
|
|
'logs' => [
|
|
|
|
'errors',
|
|
|
|
],
|
2015-09-29 17:26:24 +00:00
|
|
|
'error' => [
|
|
|
|
'index',
|
2015-09-14 20:51:23 +00:00
|
|
|
],
|
2015-04-30 23:01:01 +00:00
|
|
|
];
|
|
|
|
|
2015-09-29 17:26:24 +00:00
|
|
|
// Select mode
|
|
|
|
$category = isset($_GET['cat'])
|
|
|
|
? (
|
|
|
|
array_key_exists($_GET['cat'], $modes) ?
|
|
|
|
$_GET['cat'] :
|
|
|
|
'error'
|
|
|
|
)
|
|
|
|
: key($modes);
|
|
|
|
$mode = isset($_GET['mode'])
|
|
|
|
? (
|
|
|
|
in_array($_GET['mode'], $modes[$category]) ?
|
|
|
|
$_GET['mode'] :
|
|
|
|
'error'
|
|
|
|
)
|
|
|
|
: $modes[$category][0];
|
|
|
|
|
|
|
|
// Override category if mode is error
|
|
|
|
if ($mode == 'error') {
|
|
|
|
$category = 'error';
|
2015-10-03 22:45:19 +00:00
|
|
|
$mode = $modes[$category][0];
|
2015-09-29 17:26:24 +00:00
|
|
|
}
|
2015-04-30 23:01:01 +00:00
|
|
|
|
2015-10-03 22:45:19 +00:00
|
|
|
// Set page data
|
|
|
|
$renderData = array_merge($renderData, [
|
|
|
|
'manage' => [
|
|
|
|
'category' => $category,
|
|
|
|
'mode' => $mode,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
2015-09-29 17:26:24 +00:00
|
|
|
// Add special variables
|
|
|
|
switch ($category . '.' . $mode) {
|
2015-12-09 20:21:08 +00:00
|
|
|
case 'logs.errors':
|
|
|
|
$errorLog = Database::fetch('error_log', true, null, ['error_id', true]);
|
|
|
|
$renderData = array_merge($renderData, ['errors' => $errorLog]);
|
2015-10-03 22:45:19 +00:00
|
|
|
break;
|
2015-09-29 17:26:24 +00:00
|
|
|
}
|
2015-04-30 14:12:49 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Initialise templating engine
|
|
|
|
$template = new Template();
|
|
|
|
|
|
|
|
// Change templating engine
|
|
|
|
$template->setTemplate($templateName);
|
|
|
|
|
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
2015-04-30 14:12:49 +00:00
|
|
|
// Print page contents
|
2015-12-09 20:21:08 +00:00
|
|
|
echo $template->render('pages/' . $category . '/' . $mode . '.tpl');
|