diff --git a/admin/index.php b/admin/index.php index b371103b..f97056ac 100644 --- a/admin/index.php +++ b/admin/index.php @@ -6,11 +6,9 @@ use MyAAC\Services\StatusService; // few things we'll need require '../common.php'; -const ADMIN_PANEL = true; const MYAAC_ADMIN = true; -if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed'])) -{ +if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed'])) { header('Location: ' . BASE_URL . 'install/'); exit; } @@ -32,8 +30,11 @@ require __DIR__ . '/includes/debugbar.php'; $loginService = new LoginService(); $checkLogin = $loginService->checkLogin(); + $logged = $checkLogin['logged']; $account_logged = $checkLogin['account']; + +app()->setLoggedIn($logged); app()->setAccountLogged($account_logged); $statusService = new StatusService(); @@ -49,7 +50,7 @@ if (ACTION == 'logout') { } // if we're not logged in - show login box -if(!$logged || !admin()) { +if(!logged() || !admin()) { $page = 'login'; } diff --git a/admin/pages/login.php b/admin/pages/login.php index eb6466d3..3bb9505c 100644 --- a/admin/pages/login.php +++ b/admin/pages/login.php @@ -13,7 +13,7 @@ $title = 'Login'; csrfProtect(); require PAGES . 'account/login.php'; -if ($logged) { +if (logged()) { header('Location: ' . (admin() ? ADMIN_URL : BASE_URL)); return; } diff --git a/admin/pages/mass_account.php b/admin/pages/mass_account.php index 46c9bc9d..9b6a7727 100644 --- a/admin/pages/mass_account.php +++ b/admin/pages/mass_account.php @@ -57,13 +57,14 @@ function admin_give_coins($coins) function admin_give_premdays($days) { - global $db, $freePremium; + global $freePremium; if ($freePremium) { displayMessage('Premium days not supported. Free Premium enabled.'); return; } + $db = app()->get('database'); $value = $days * 86400; $now = time(); // othire @@ -174,10 +175,12 @@ else { } function displayMessage($message, $success = false) { - global $twig, $hasCoinsColumn, $hasPointsColumn, $freePremium; + global $hasCoinsColumn, $hasPointsColumn, $freePremium; $success ? success($message): error($message); + $twig = app()->get('twig'); + $twig->display('admin.tools.account.html.twig', array( 'hasCoinsColumn' => $hasCoinsColumn, 'hasPointsColumn' => $hasPointsColumn, diff --git a/admin/pages/mass_teleport.php b/admin/pages/mass_teleport.php index 5264914d..6dc0800b 100644 --- a/admin/pages/mass_teleport.php +++ b/admin/pages/mass_teleport.php @@ -99,9 +99,9 @@ else { } -function displayMessage($message, $success = false) { - global $twig; - +function displayMessage($message, $success = false) +{ + $twig = app()->get('twig'); $success ? success($message): error($message); $twig->display('admin.tools.teleport.html.twig', array()); } diff --git a/admin/pages/menus.php b/admin/pages/menus.php index 19d7b486..893ed9ff 100644 --- a/admin/pages/menus.php +++ b/admin/pages/menus.php @@ -203,7 +203,7 @@ if (isset($_POST['template'])) { function onTemplateMenusChange(): void { - $cache = Cache::getInstance(); + $cache = app()->get('cache'); if ($cache->enabled()) { $cache->delete('template_menus'); } diff --git a/admin/template/template.php b/admin/template/template.php index c6b8747b..7547e5ec 100644 --- a/admin/template/template.php +++ b/admin/template/template.php @@ -21,7 +21,7 @@
trigger(HOOK_ADMIN_BODY_START); ?> - +
';
}
@@ -94,7 +94,7 @@ if(isset($last_threads[0])) {
}
echo '';
- if($logged && (!$sections[$section_id]['closed'] || Forum::isModerator())) {
+ if(logged() && (!$sections[$section_id]['closed'] || Forum::isModerator())) {
echo '
';
}
}
diff --git a/system/pages/gallery.php b/system/pages/gallery.php
index cb854fca..a889f171 100644
--- a/system/pages/gallery.php
+++ b/system/pages/gallery.php
@@ -132,7 +132,7 @@ class Gallery
{
static public function add($comment, $image, $author, &$errors)
{
- global $db;
+ $db = app()->get('database');
if(isset($comment[0]) && isset($image[0]) && isset($author[0]))
{
$query =
@@ -225,7 +225,7 @@ class Gallery
static public function move($id, $i, &$errors)
{
- global $db;
+ $db = app()->get('database');
$query = self::get($id);
if($query !== false)
{
diff --git a/system/pages/guilds/accept_invite.php b/system/pages/guilds/accept_invite.php
index bc782480..294de2a7 100644
--- a/system/pages/guilds/accept_invite.php
+++ b/system/pages/guilds/accept_invite.php
@@ -15,7 +15,7 @@ require __DIR__ . '/base.php';
//set rights in guild
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null;
$name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : null;
-if(!$logged) {
+if(!logged()) {
$errors[] = 'You are not logged in. You can\'t accept invitations.';
}
diff --git a/system/pages/guilds/add_rank.php b/system/pages/guilds/add_rank.php
index e66ba49e..03ec6b12 100644
--- a/system/pages/guilds/add_rank.php
+++ b/system/pages/guilds/add_rank.php
@@ -22,7 +22,7 @@ if(empty($errors)) {
if(!Validator::rankName($rank_name)) {
$errors[] = 'Invalid rank name format.';
}
- if(!$logged) {
+ if(!logged()) {
$errors[] = 'You are not logged.';
}
$guild = new OTS_Guild();
diff --git a/system/pages/guilds/change_description.php b/system/pages/guilds/change_description.php
index 765665bf..600d96a8 100644
--- a/system/pages/guilds/change_description.php
+++ b/system/pages/guilds/change_description.php
@@ -26,7 +26,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
diff --git a/system/pages/guilds/change_logo.php b/system/pages/guilds/change_logo.php
index d8257e66..094ca43e 100644
--- a/system/pages/guilds/change_logo.php
+++ b/system/pages/guilds/change_logo.php
@@ -27,7 +27,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$guild_leader = false;
$account_players = $account_logged->getPlayers();
diff --git a/system/pages/guilds/change_motd.php b/system/pages/guilds/change_motd.php
index babb806c..e5280199 100644
--- a/system/pages/guilds/change_motd.php
+++ b/system/pages/guilds/change_motd.php
@@ -29,7 +29,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
diff --git a/system/pages/guilds/change_nick.php b/system/pages/guilds/change_nick.php
index bf773124..8f823d41 100644
--- a/system/pages/guilds/change_nick.php
+++ b/system/pages/guilds/change_nick.php
@@ -12,7 +12,7 @@ defined('MYAAC') or die('Direct access not allowed!');
require __DIR__ . '/base.php';
-if(!$logged) {
+if(!logged()) {
$errors[] = "You are not logged in. You can't change nick.";
$twig->display('error_box.html.twig', array('errors' => $errors));
$twig->display('guilds.back_button.html.twig');
diff --git a/system/pages/guilds/change_rank.php b/system/pages/guilds/change_rank.php
index 4341db16..9cea6f47 100644
--- a/system/pages/guilds/change_rank.php
+++ b/system/pages/guilds/change_rank.php
@@ -12,7 +12,7 @@ defined('MYAAC') or die('Direct access not allowed!');
require __DIR__ . '/base.php';
-if(!$logged) {
+if(!logged()) {
$errors[] = "You are not logged in. You can't change rank.";
}
else {
diff --git a/system/pages/guilds/cleanup_guilds.php b/system/pages/guilds/cleanup_guilds.php
index 302d81f9..058a969e 100644
--- a/system/pages/guilds/cleanup_guilds.php
+++ b/system/pages/guilds/cleanup_guilds.php
@@ -12,7 +12,7 @@ defined('MYAAC') or die('Direct access not allowed!');
require __DIR__ . '/base.php';
-if(!$logged)
+if(!logged())
{
echo "You are not logged in.";
$twig->display('guilds.back_button.html.twig');
diff --git a/system/pages/guilds/cleanup_players.php b/system/pages/guilds/cleanup_players.php
index 7e02fbeb..422c96d3 100644
--- a/system/pages/guilds/cleanup_players.php
+++ b/system/pages/guilds/cleanup_players.php
@@ -12,7 +12,7 @@ defined('MYAAC') or die('Direct access not allowed!');
require __DIR__ . '/base.php';
-if(!$logged)
+if(!logged())
{
echo "You are not logged in.";
$twig->display('guilds.back_button.html.twig');
diff --git a/system/pages/guilds/create.php b/system/pages/guilds/create.php
index b404c494..aaba6541 100644
--- a/system/pages/guilds/create.php
+++ b/system/pages/guilds/create.php
@@ -17,7 +17,7 @@ require __DIR__ . '/base.php';
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : NULL;
$name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : NULL;
$todo = isset($_REQUEST['todo']) ? $_REQUEST['todo'] : NULL;
-if(!$logged) {
+if(!logged()) {
$guild_errors[] = 'You are not logged in. You can\'t create guild.';
}
diff --git a/system/pages/guilds/delete_by_admin.php b/system/pages/guilds/delete_by_admin.php
index e403cbda..2f1abee5 100644
--- a/system/pages/guilds/delete_by_admin.php
+++ b/system/pages/guilds/delete_by_admin.php
@@ -26,7 +26,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
if(admin()) {
$saved = false;
if(isset($_POST['todo']) && $_POST['todo'] == 'save') {
diff --git a/system/pages/guilds/delete_guild.php b/system/pages/guilds/delete_guild.php
index 978ac513..bdbc27fa 100644
--- a/system/pages/guilds/delete_guild.php
+++ b/system/pages/guilds/delete_guild.php
@@ -26,7 +26,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
diff --git a/system/pages/guilds/delete_invite.php b/system/pages/guilds/delete_invite.php
index 7bf4067a..a4555fa1 100644
--- a/system/pages/guilds/delete_invite.php
+++ b/system/pages/guilds/delete_invite.php
@@ -15,7 +15,7 @@ require __DIR__ . '/base.php';
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null;
$name = stripslashes($_REQUEST['name']);
-if(!$logged)
+if(!logged())
$errors[] = 'You are not logged in. You can\'t delete invitations.';
if(!Validator::guildName($guild_name))
diff --git a/system/pages/guilds/delete_rank.php b/system/pages/guilds/delete_rank.php
index 56322cd9..3a468917 100644
--- a/system/pages/guilds/delete_rank.php
+++ b/system/pages/guilds/delete_rank.php
@@ -26,7 +26,7 @@ if(empty($guild_errors)) {
}
}
if(empty($guild_errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
diff --git a/system/pages/guilds/invite.php b/system/pages/guilds/invite.php
index 8fae8e27..528a5a5e 100644
--- a/system/pages/guilds/invite.php
+++ b/system/pages/guilds/invite.php
@@ -15,7 +15,7 @@ require __DIR__ . '/base.php';
//set rights in guild
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : NULL;
$name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : NULL;
-if(!$logged) {
+if(!logged()) {
$errors[] = "You are not logged in. You can't invite players.";
}
diff --git a/system/pages/guilds/kick_player.php b/system/pages/guilds/kick_player.php
index 5ce79187..8aa64c9c 100644
--- a/system/pages/guilds/kick_player.php
+++ b/system/pages/guilds/kick_player.php
@@ -16,7 +16,7 @@ require __DIR__ . '/base.php';
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null;
$name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : null;
-if(!$logged) {
+if(!logged()) {
$errors[] = 'You are not logged in. You can\'t kick characters.';
}
diff --git a/system/pages/guilds/leave.php b/system/pages/guilds/leave.php
index 9a11595d..3cdf5853 100644
--- a/system/pages/guilds/leave.php
+++ b/system/pages/guilds/leave.php
@@ -15,7 +15,7 @@ require __DIR__ . '/base.php';
//set rights in guild
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : NULL;
$name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : NULL;
-if(!$logged) {
+if(!logged()) {
$errors[] = "You are not logged in. You can't leave guild.";
}
diff --git a/system/pages/guilds/list.php b/system/pages/guilds/list.php
index 96d7bf08..d51f8fc7 100644
--- a/system/pages/guilds/list.php
+++ b/system/pages/guilds/list.php
@@ -39,6 +39,6 @@ if(count($guilds_list) > 0)
$twig->display('guilds.list.html.twig', array(
'guilds' => $guilds,
- 'logged' => isset($logged) ? $logged : false,
+ 'logged' => logged(),
'isAdmin' => admin(),
));
diff --git a/system/pages/guilds/manager.php b/system/pages/guilds/manager.php
index 4d59c22e..f2456653 100644
--- a/system/pages/guilds/manager.php
+++ b/system/pages/guilds/manager.php
@@ -26,7 +26,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
diff --git a/system/pages/guilds/pass_leadership.php b/system/pages/guilds/pass_leadership.php
index c09b4285..e490d06f 100644
--- a/system/pages/guilds/pass_leadership.php
+++ b/system/pages/guilds/pass_leadership.php
@@ -56,7 +56,7 @@ if(empty($guild_errors)) {
}
}
if(empty($guild_errors) && empty($guild_errors2)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$guild_leader = false;
$account_players = $account_logged->getPlayers();
diff --git a/system/pages/guilds/save_ranks.php b/system/pages/guilds/save_ranks.php
index e1483659..6b8f1143 100644
--- a/system/pages/guilds/save_ranks.php
+++ b/system/pages/guilds/save_ranks.php
@@ -26,7 +26,7 @@ if(empty($errors)) {
}
if(empty($errors)) {
- if($logged) {
+ if(logged()) {
$guild_leader_char = $guild->getOwner();
$rank_list = $guild->getGuildRanksList();
$rank_list->orderBy('level', POT::ORDER_DESC);
diff --git a/system/pages/guilds/show.php b/system/pages/guilds/show.php
index 33039ad3..69e38fc6 100644
--- a/system/pages/guilds/show.php
+++ b/system/pages/guilds/show.php
@@ -47,8 +47,7 @@ $level_in_guild = 0;
$players_from_account_in_guild = array();
$players_from_account_ids = array();
-if($logged)
-{
+if(logged()) {
$account_players = $account_logged->getPlayers();
foreach($account_players as $player)
{
@@ -127,7 +126,7 @@ include(SYSTEM . 'libs/pot/InvitesDriver.php');
new InvitesDriver($guild);
$invited_list = $guild->listInvites();
$show_accept_invite = 0;
-if($logged && count($invited_list) > 0)
+if(logged() && count($invited_list) > 0)
{
foreach($invited_list as $invited_player)
{
diff --git a/system/pages/highscores.php b/system/pages/highscores.php
index 91ba2e2b..a506d852 100644
--- a/system/pages/highscores.php
+++ b/system/pages/highscores.php
@@ -139,7 +139,7 @@ $highscores = [];
$needReCache = true;
$cacheKey = 'highscores_' . $skill . '_' . $vocation . '_' . $page . '_' . $configHighscoresPerPage;
-$cache = Cache::getInstance();
+$cache = app()->get('cache');
if ($cache->enabled()) {
$tmp = '';
if ($cache->fetch($cacheKey, $tmp)) {
diff --git a/system/pages/news.php b/system/pages/news.php
index dc8c700e..9baebc88 100644
--- a/system/pages/news.php
+++ b/system/pages/news.php
@@ -105,7 +105,7 @@ if(isset($_GET['archive']))
header('X-XSS-Protection: 0');
$title = 'Latest News';
-$cache = Cache::getInstance();
+$cache = app()->get('cache');
$news_cached = false;
if($cache->enabled())
diff --git a/system/pages/polls.php b/system/pages/polls.php
index 37372f25..c285aa0e 100644
--- a/system/pages/polls.php
+++ b/system/pages/polls.php
@@ -48,7 +48,7 @@ function getColorByPercent($percent)