diff --git a/admin/index.php b/admin/index.php index f97056ac..139fc50c 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,79 +1,8 @@ checkLogin(); - -$logged = $checkLogin['logged']; -$account_logged = $checkLogin['account']; - -app()->setLoggedIn($logged); -app()->setAccountLogged($account_logged); - -$statusService = new StatusService(); -$status = $statusService->checkStatus(); - -require __DIR__ . '/includes/functions.php'; - -$twig->addGlobal('config', $config); -$twig->addGlobal('status', $status); - -if (ACTION == 'logout') { - require SYSTEM . 'logout.php'; -} - -// if we're not logged in - show login box -if(!logged() || !admin()) { - $page = 'login'; -} - -// include our page -$file = __DIR__ . '/pages/' . $page . '.php'; -if(!@file_exists($file)) { - if (str_contains($page, 'plugins/')) { - $file = BASE . $page; - } - else { - $page = '404'; - $file = SYSTEM . 'pages/404.php'; - } -} - -ob_start(); -if($hooks->trigger(HOOK_ADMIN_BEFORE_PAGE)) { - require $file; -} - -$content .= ob_get_contents(); -ob_end_clean(); - -// template -$template_path = 'template/'; -require __DIR__ . '/' . $template_path . 'template.php'; +$admin = new \MyAAC\App\Admin(); +$admin->run(); diff --git a/admin/pages/changelog.php b/admin/pages/changelog.php index 3be99498..32452fea 100644 --- a/admin/pages/changelog.php +++ b/admin/pages/changelog.php @@ -110,7 +110,7 @@ if($action == 'edit' || $action == 'new') { $player->load($player_id); } - $account_players = $account_logged->getPlayersList(); + $account_players = accountLogged()->getPlayersList(); $account_players->orderBy('group_id', POT::ORDER_DESC); $twig->display('admin.changelog.form.html.twig', array( 'action' => $action, diff --git a/admin/pages/modules/statistics.php b/admin/pages/modules/statistics.php index b8a474f3..7e5d2607 100644 --- a/admin/pages/modules/statistics.php +++ b/admin/pages/modules/statistics.php @@ -7,6 +7,8 @@ use MyAAC\Models\Monster; use MyAAC\Models\Player; defined('MYAAC') or die('Direct access not allowed!'); + +global $eloquentConnection; $count = $eloquentConnection->query() ->select([ 'total_accounts' => Account::selectRaw('COUNT(id)'), diff --git a/admin/pages/news.php b/admin/pages/news.php index 61571597..7553ab75 100644 --- a/admin/pages/news.php +++ b/admin/pages/news.php @@ -50,7 +50,7 @@ if(!empty($action)) if (isRequestMethod('post')) { if ($action == 'new') { if (isset($forum_section) && $forum_section != '-1') { - $forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors); + $forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, accountLogged()->getId(), $errors); } if (isset($p_title) && News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) { @@ -113,7 +113,7 @@ if($action == 'edit' || $action == 'new') { $player->load($player_id); } - $account_players = $account_logged->getPlayersList(); + $account_players = accountLogged()->getPlayersList(); $account_players->orderBy('group_id', POT::ORDER_DESC); $twig->display('admin.news.form.html.twig', array( 'action' => $action, diff --git a/admin/pages/notepad.php b/admin/pages/notepad.php index 9587c7f1..cdb08d0a 100644 --- a/admin/pages/notepad.php +++ b/admin/pages/notepad.php @@ -15,21 +15,18 @@ $title = 'Notepad'; csrfProtect(); -/** - * @var OTS_Account $account_logged - */ $_content = ''; -$notepad = ModelsNotepad::where('account_id', $account_logged->getId())->first(); +$notepad = ModelsNotepad::where('account_id', accountLogged()->getId())->first(); if (isset($_POST['content'])) { $_content = html_entity_decode(stripslashes($_POST['content'])); if (!$notepad) { ModelsNotepad::create([ - 'account_id' => $account_logged->getId(), + 'account_id' => accountLogged()->getId(), 'content' => $_content ]); } else { - ModelsNotepad::where('account_id', $account_logged->getId())->update(['content' => $_content]); + ModelsNotepad::where('account_id', accountLogged()->getId())->update(['content' => $_content]); } success('Saved at ' . date('H:i')); diff --git a/admin/template/menus.php b/admin/template/menus.php index 0bcd7304..e92a09f5 100644 --- a/admin/template/menus.php +++ b/admin/template/menus.php @@ -1,5 +1,7 @@ 'Dashboard', 'icon' => 'tachometer-alt', 'order' => 10, 'link' => 'dashboard'], ['name' => 'Settings', 'icon' => 'edit', 'order' => 19, 'link' => diff --git a/admin/template/template.php b/admin/template/template.php index 7547e5ec..8363fdc3 100644 --- a/admin/template/template.php +++ b/admin/template/template.php @@ -21,7 +21,7 @@
trigger(HOOK_ADMIN_BODY_START); ?> - +