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-12-12 17:57:34 +00:00
|
|
|
// Initialise templating engine
|
|
|
|
$template = new Template();
|
|
|
|
|
|
|
|
// Change templating engine
|
|
|
|
$template->setTemplate($templateName);
|
|
|
|
|
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-12-12 17:57:34 +00:00
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('global/restricted');
|
2015-08-18 13:13:40 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-09-29 17:26:24 +00:00
|
|
|
// Modes
|
2015-12-12 17:57:34 +00:00
|
|
|
$pages = [
|
|
|
|
'general' => [
|
|
|
|
'title' => 'General',
|
|
|
|
'modes' => [
|
|
|
|
'dashboard' => [
|
|
|
|
'title' => 'Dashboard',
|
|
|
|
'description' => [
|
|
|
|
'Welcome to the Broomcloset! Here\'s a quick overview of the site.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'info' => [
|
|
|
|
'title' => 'Info pages',
|
|
|
|
'description' => [
|
|
|
|
'Manage and edit the info pages.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
2015-05-03 16:25:57 +00:00
|
|
|
],
|
2015-12-12 17:57:34 +00:00
|
|
|
'config' => [
|
|
|
|
'title' => 'Configuration',
|
|
|
|
'modes' => [
|
|
|
|
'general' => [
|
|
|
|
'title' => 'General',
|
|
|
|
'description' => [
|
|
|
|
'Manages the appearance of the site and most other options that don\'t need their own category.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'uploads' => [
|
|
|
|
'title' => 'Uploads',
|
|
|
|
'description' => [
|
|
|
|
'Settings regarding uploads like avatars and backgrounds.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'premium' => [
|
|
|
|
'title' => 'Premium',
|
|
|
|
'description' => [
|
|
|
|
'Alters the way the premium system works.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'user' => [
|
|
|
|
'title' => 'User',
|
|
|
|
'description' => [
|
|
|
|
'Settings regarding users such as registration.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'mail' => [
|
|
|
|
'title' => 'Mail',
|
|
|
|
'description' => [
|
|
|
|
'How will Sakura send e-mails.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
2015-09-29 17:26:24 +00:00
|
|
|
],
|
2015-12-12 17:57:34 +00:00
|
|
|
'forums' => [
|
|
|
|
'title' => 'Forums',
|
|
|
|
'modes' => [
|
|
|
|
'manage' => [
|
|
|
|
'title' => 'Manage',
|
|
|
|
'description' => [
|
|
|
|
'Change the forums.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'settings' => [
|
|
|
|
'title' => 'Settings',
|
|
|
|
'description' => [
|
|
|
|
'Alter settings specific to the forum.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
2015-12-09 20:21:08 +00:00
|
|
|
],
|
2015-12-12 17:57:34 +00:00
|
|
|
'comments' => [
|
|
|
|
'title' => 'Comments',
|
|
|
|
'modes' => [
|
|
|
|
'manage' => [
|
|
|
|
'title' => 'Manage',
|
|
|
|
'description' => [
|
|
|
|
'View all the comment categories.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'users' => [
|
|
|
|
'title' => 'Users',
|
|
|
|
'modes' => [
|
|
|
|
'manage-users' => [
|
|
|
|
'title' => 'Manage users',
|
|
|
|
'description' => [
|
|
|
|
'View and change users.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'manage-ranks' => [
|
|
|
|
'title' => 'Manage ranks',
|
|
|
|
'description' => [
|
|
|
|
'View and change ranks.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'profile-fields' => [
|
|
|
|
'title' => 'Profile fields',
|
|
|
|
'description' => [
|
|
|
|
'Manage the custom profile fields.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'option-fields' => [
|
|
|
|
'title' => 'Option fields',
|
|
|
|
'description' => [
|
|
|
|
'Manage the custom option fields.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'bans' => [
|
|
|
|
'title' => 'Bans',
|
|
|
|
'description' => [
|
|
|
|
'Banning users.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'warnings' => [
|
|
|
|
'title' => 'Warnings',
|
|
|
|
'description' => [
|
|
|
|
'Warn users.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'permissions' => [
|
|
|
|
'title' => 'Permissions',
|
|
|
|
'modes' => [
|
|
|
|
'site' => [
|
|
|
|
'title' => 'Manage site',
|
|
|
|
'description' => [
|
|
|
|
'Alter the global site perms.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'management' => [
|
|
|
|
'title' => 'Manage management',
|
|
|
|
'description' => [
|
|
|
|
'Alter the management/moderation perms.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'forum' => [
|
|
|
|
'title' => 'Manage forums',
|
|
|
|
'description' => [
|
|
|
|
'Alter the perms of the forums.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'logs' => [
|
|
|
|
'title' => 'Logs',
|
|
|
|
'modes' => [
|
|
|
|
'actions' => [
|
|
|
|
'title' => 'Actions',
|
|
|
|
'description' => [
|
|
|
|
'Viewing the global action logs.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'management' => [
|
|
|
|
'title' => 'Management',
|
|
|
|
'description' => [
|
|
|
|
'Viewing the management actions taken by staff.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
'errors' => [
|
|
|
|
'title' => 'Errors',
|
|
|
|
'description' => [
|
|
|
|
'Viewing the PHP error logs Sakura was able to log.',
|
|
|
|
],
|
|
|
|
'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED'),
|
|
|
|
'menu' => true,
|
|
|
|
],
|
|
|
|
],
|
2015-09-14 20:51:23 +00:00
|
|
|
],
|
2015-04-30 23:01:01 +00:00
|
|
|
];
|
|
|
|
|
2015-12-12 17:57:34 +00:00
|
|
|
// Current settings page
|
|
|
|
$category = isset($_GET['cat']) ? (
|
|
|
|
array_key_exists($_GET['cat'], $pages) ? $_GET['cat'] : false
|
|
|
|
) : array_keys($pages)[0];
|
|
|
|
$mode = false;
|
|
|
|
|
|
|
|
// Only continue setting mode if $category is true
|
|
|
|
if ($category) {
|
|
|
|
$mode = isset($_GET['mode']) && $category ? (
|
|
|
|
array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false
|
|
|
|
) : array_keys($pages[$category]['modes'])[0];
|
2015-09-29 17:26:24 +00:00
|
|
|
}
|
2015-04-30 23:01:01 +00:00
|
|
|
|
2015-12-12 17:57:34 +00:00
|
|
|
// Not found
|
|
|
|
if (!$category
|
|
|
|
|| empty($category)
|
|
|
|
|| !$mode
|
|
|
|
|| empty($mode)
|
|
|
|
|| !$pages[$category]['modes'][$mode]['access']) {
|
|
|
|
header('HTTP/1.0 404 Not Found');
|
|
|
|
|
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('global/notfound');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set templates directory
|
|
|
|
$renderData['templates'] = 'manage';
|
|
|
|
|
|
|
|
// Render data
|
|
|
|
$renderData['current'] = $category . '.' . $mode;
|
|
|
|
|
|
|
|
// Settings pages
|
|
|
|
$renderData['pages'] = $pages;
|
|
|
|
|
|
|
|
// Page data
|
|
|
|
$renderData['page'] = [
|
|
|
|
'category' => $pages[$category]['title'],
|
|
|
|
'mode' => $pages[$category]['modes'][$mode]['title'],
|
|
|
|
'description' => $pages[$category]['modes'][$mode]['description'],
|
|
|
|
];
|
2015-10-03 22:45:19 +00:00
|
|
|
|
2015-09-29 17:26:24 +00:00
|
|
|
// Add special variables
|
|
|
|
switch ($category . '.' . $mode) {
|
2015-12-12 17:57:34 +00:00
|
|
|
case 'general.dashboard':
|
|
|
|
$renderData = array_merge($renderData, [
|
|
|
|
'stats' => [
|
|
|
|
'postcount' => Database::count('posts')[0],
|
|
|
|
'threadcount' => Database::count('topics')[0],
|
|
|
|
'commentcount' => Database::count('comments')[0],
|
|
|
|
'userscount' => Database::count('users')[0],
|
|
|
|
'bancount' => Database::count('bans')[0],
|
|
|
|
'uploadcount' => count(glob(ROOT . Config::get('user_uploads') . '/*')) - 1,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
2015-04-30 14:12:49 +00:00
|
|
|
// Print page contents
|
2015-12-12 17:57:34 +00:00
|
|
|
echo $template->render('main/settings');
|