Optimisations & fixes.

This commit is contained in:
slawkens 2021-12-05 10:33:31 +01:00
parent 468f59fbec
commit 7008c9f4d8
5 changed files with 20 additions and 20 deletions

View File

@ -2,8 +2,8 @@
// few things we'll need // few things we'll need
require '../common.php'; require '../common.php';
define('ADMIN_PANEL', true); const ADMIN_PANEL = true;
define('MYAAC_ADMIN', true); const MYAAC_ADMIN = true;
if(file_exists(BASE . 'config.local.php')) { if(file_exists(BASE . 'config.local.php')) {
require_once BASE . 'config.local.php'; require_once BASE . 'config.local.php';
@ -18,7 +18,7 @@ if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['i
$content = ''; $content = '';
// validate page // validate page
$page = isset($_GET['p']) ? $_GET['p'] : ''; $page = $_GET['p'] ?? '';
if(empty($page) || preg_match("/[^a-zA-Z0-9_\-]/", $page)) if(empty($page) || preg_match("/[^a-zA-Z0-9_\-]/", $page))
$page = 'dashboard'; $page = 'dashboard';
@ -52,6 +52,9 @@ if(!$logged || !admin()) {
$page = 'login'; $page = 'login';
} }
// more pages have action, lets define it here
$action = $_REQUEST['action'] ?? '';
// include our page // include our page
$file = SYSTEM . 'pages/admin/' . $page . '.php'; $file = SYSTEM . 'pages/admin/' . $page . '.php';
if(!@file_exists($file)) { if(!@file_exists($file)) {
@ -68,4 +71,3 @@ ob_end_clean();
// template // template
$template_path = 'template/'; $template_path = 'template/';
require ADMIN . $template_path . 'template.php'; require ADMIN . $template_path . 'template.php';
?>

View File

@ -17,13 +17,13 @@ if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
$title = 'Changelog'; $title = 'Changelog';
$use_datatable = true; $use_datatable = true;
define('CL_LIMIT', 600); // maximum changelog body length const CL_LIMIT = 600; // maximum changelog body length
?> ?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ > <link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
<script src="<?php echo BASE_URL; ?>tools/js/jquery.datetimepicker.js"></script> <script src="<?php echo BASE_URL; ?>tools/js/jquery.datetimepicker.js"></script>
<?php <?php
$id = isset($_GET['id']) ? $_GET['id'] : 0; $id = $_GET['id'] ?? 0;
require_once LIBS . 'changelog.php'; require_once LIBS . 'changelog.php';
if(!empty($action)) if(!empty($action))
@ -111,14 +111,13 @@ if($action == 'edit' || $action == 'new') {
$twig->display('admin.changelog.form.html.twig', array( $twig->display('admin.changelog.form.html.twig', array(
'action' => $action, 'action' => $action,
'cl_link_form' => constant('ADMIN_URL').'?p=changelog&action=' . ($action == 'edit' ? 'edit' : 'add'), 'cl_link_form' => constant('ADMIN_URL').'?p=changelog&action=' . ($action == 'edit' ? 'edit' : 'add'),
'cl_id' => isset($id) ? $id : null, 'cl_id' => $id ?? null,
'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '', 'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '',
'create_date' => isset($create_date) ? $create_date : '', 'create_date' => $create_date ?? '',
'player' => isset($player) && $player->isLoaded() ? $player : null, 'player_id' => $player_id ?? null,
'player_id' => isset($player_id) ? $player_id : null,
'account_players' => $account_players, 'account_players' => $account_players,
'type' => isset($type) ? $type : 0, 'type' => $type ?? 0,
'where' => isset($where) ? $where : 0, 'where' => $where ?? 0,
'log_type' => $log_type, 'log_type' => $log_type,
'log_where' => $log_where, 'log_where' => $log_where,
)); ));

View File

@ -10,8 +10,8 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$title = 'Login'; $title = 'Login';
$twig->display('admin.login.html.twig', array( $twig->display('admin.login.html.twig', [
'logout' => ($action == 'logout' ? 'You have been logged out!' : ''), 'logout' => (ACTION == 'logout' ? 'You have been logged out!' : ''),
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number', 'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
'errors' => isset($errors)? $errors : '' 'errors' => $errors ?? ''
)); ]);

View File

@ -10,8 +10,8 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$title = 'Changelog'; $title = 'Changelog';
$_page = isset($_GET['page']) ? $_GET['page'] : 0; $_page = $_GET['page'] ?? 0;
$id = isset($_GET['id']) ? $_GET['id'] : 0; $id = $_GET['id'] ?? 0;
$limit = 30; $limit = 30;
$offset = $_page * $limit; $offset = $_page * $limit;
$next_page = false; $next_page = false;
@ -43,4 +43,3 @@ $twig->display('changelog.html.twig', array(
'next_page' => $next_page, 'next_page' => $next_page,
'canEdit' => $canEdit, 'canEdit' => $canEdit,
)); ));
?>

View File

@ -41,7 +41,7 @@ if($success) {
$page = $uri; $page = $uri;
} else { } else {
// old support for pages like /?subtopic=accountmanagement // old support for pages like /?subtopic=accountmanagement
$page = isset($_REQUEST['p']) ? $_REQUEST['p'] : (isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : ''); $page = $_REQUEST['p'] ?? ($_REQUEST['subtopic'] ?? '');
if(!empty($page) && preg_match('/^[A-z0-9\-]+$/', $page)) { if(!empty($page) && preg_match('/^[A-z0-9\-]+$/', $page)) {
if(config('backward_support')) { if(config('backward_support')) {
require SYSTEM . 'compat_pages.php'; require SYSTEM . 'compat_pages.php';