This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/public/manage.php

72 lines
1.4 KiB
PHP
Raw Normal View History

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
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/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
if (!Permissions::check('MANAGE', 'USE_MANAGE', Session::$userId, 1)) {
2015-08-18 13:13:40 +00:00
header('Location: /');
exit;
}
// Modes
$modes = [
'dashboard' => [
'index',
2015-05-03 16:25:57 +00:00
],
'system' => [
'index',
],
'error' => [
'index',
],
2015-04-30 23:01:01 +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';
$mode = key($modes[$category]);
}
2015-04-30 23:01:01 +00:00
// Add special variables
switch ($category . '.' . $mode) {
case 'system.index':
$renderData = array_merge($renderData, [
'uname' => [
'osn' => php_uname('s'),
'osv' => php_uname('v'),
'host' => php_uname('n'),
'arch' => php_uname('m'),
],
]);
break;
}
2015-04-30 14:12:49 +00:00
// Print page contents
print Templates::render('pages/' . $mode . '.' . $category . '.tpl', $renderData);