mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-19 20:13:27 +02:00
Avoid globals where possible
$logged => logged() $account_logged => accountLogged()
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!$logged)
|
||||
if(!logged())
|
||||
{
|
||||
$title = 'Login';
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Change E-Mail';
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Change Info';
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Change Password';
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Change Comment';
|
||||
require PAGES . 'account/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Change Name';
|
||||
require PAGES . 'account/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Change Sex';
|
||||
require PAGES . 'account/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Create Character';
|
||||
require PAGES . 'account/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Delete Character';
|
||||
require PAGES . 'account/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -17,8 +17,7 @@ $title = 'Create Account';
|
||||
if (setting('core.account_country'))
|
||||
require SYSTEM . 'countries.conf.php';
|
||||
|
||||
if($logged)
|
||||
{
|
||||
if(logged()) {
|
||||
echo 'Please logout before attempting to create a new account.';
|
||||
return;
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ if(!empty($login_account) && !empty($login_password))
|
||||
$limiter->enabled = setting('core.account_login_ipban_protection');
|
||||
$limiter->load();
|
||||
|
||||
global $logged, $account_logged, $logged_flags;
|
||||
$account_logged = new OTS_Account();
|
||||
if (config('account_login_by_email')) {
|
||||
$account_logged->findByEMail($login_account);
|
||||
@@ -69,6 +70,9 @@ if(!empty($login_account) && !empty($login_password))
|
||||
$account_logged->setCustomField('web_lastlogin', time());
|
||||
}
|
||||
|
||||
app()->setLoggedIn($logged);
|
||||
app()->setAccountLogged($account_logged);
|
||||
|
||||
$hooks->trigger(HOOK_LOGIN, array('account' => $account_logged, 'password' => $login_password, 'remember_me' => $remember_me));
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ $title = 'Logout';
|
||||
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@ $title = 'Account Management';
|
||||
require __DIR__ . '/login.php';
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Register Account';
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Register Account';
|
||||
require __DIR__ . '/base.php';
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -168,10 +168,8 @@ class FAQ
|
||||
|
||||
static public function move($id, $i, &$errors)
|
||||
{
|
||||
global $db;
|
||||
$row = ModelsFAQ::find($id);
|
||||
if($row)
|
||||
{
|
||||
if($row) {
|
||||
$ordering = $row->ordering + $i;
|
||||
$old_record = ModelsFAQ::where('ordering', $ordering)->first();
|
||||
if($old_record) {
|
||||
@@ -182,8 +180,9 @@ class FAQ
|
||||
$row->ordering = $ordering;
|
||||
$row->save();
|
||||
}
|
||||
else
|
||||
else {
|
||||
$errors[] = 'FAQ with id ' . $id . ' does not exists.';
|
||||
}
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . urlencode(getLink('forum')) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . urlencode(getLink('forum')) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
$extra_url = '';
|
||||
if(isset($_GET['thread_id'])) {
|
||||
$extra_url = '?action=new_post&thread_id=' . $_GET['thread_id'];
|
||||
|
@@ -18,7 +18,7 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
$extra_url = '';
|
||||
if(isset($_GET['section_id'])) {
|
||||
$extra_url = '?action=new_thread§ion_id=' . $_GET['section_id'];
|
||||
|
@@ -18,7 +18,7 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
if(!logged()) {
|
||||
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . urlencode(getLink('forum')) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ for($i = 0; $i < $threads_count['threads_count'] / setting('core.forum_threads_p
|
||||
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>';
|
||||
|
||||
if($logged && (!$sections[$section_id]['closed'] || Forum::isModerator())) {
|
||||
if(logged() && (!$sections[$section_id]['closed'] || Forum::isModerator())) {
|
||||
echo '<br /><br />
|
||||
<a href="' . getLink('forum') . '?action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
@@ -94,7 +94,7 @@ if(isset($last_threads[0])) {
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
if($logged && (!$sections[$section_id]['closed'] || Forum::isModerator())) {
|
||||
if(logged() && (!$sections[$section_id]['closed'] || Forum::isModerator())) {
|
||||
echo '<br /><a href="' . getLink('forum') . '?action=new_thread§ion_id=' . $section_id . '"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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.';
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
|
@@ -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');
|
||||
|
@@ -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 {
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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.';
|
||||
}
|
||||
|
||||
|
@@ -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') {
|
||||
|
@@ -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);
|
||||
|
@@ -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))
|
||||
|
@@ -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);
|
||||
|
@@ -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.";
|
||||
}
|
||||
|
||||
|
@@ -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.';
|
||||
}
|
||||
|
||||
|
@@ -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.";
|
||||
}
|
||||
|
||||
|
@@ -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(),
|
||||
));
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)) {
|
||||
|
@@ -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())
|
||||
|
@@ -48,7 +48,7 @@ function getColorByPercent($percent)
|
||||
<tr BGCOLOR="'.$bgcolor.'">
|
||||
<td>
|
||||
<a href="';
|
||||
if($logged)
|
||||
if(logged())
|
||||
echo $link.'?id='.$poll['id'];
|
||||
else
|
||||
echo getLink('account/manage') . '?redirect=' . urlencode($link.'?id='.$poll['id']);
|
||||
@@ -77,7 +77,7 @@ function getColorByPercent($percent)
|
||||
<tr BGCOLOR="'.$bgcolor.'">
|
||||
<td>
|
||||
<a href="';
|
||||
if($logged)
|
||||
if(logged())
|
||||
echo $link.'?id='.$poll['id'];
|
||||
else
|
||||
echo getLink('account/manage') . '?redirect=' . urlencode($link.'?id='.$poll['id']);
|
||||
@@ -98,9 +98,8 @@ function getColorByPercent($percent)
|
||||
$showed=true;
|
||||
}
|
||||
|
||||
if(!$logged)
|
||||
{
|
||||
echo 'You are not logged in. <a href="?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=polls') . '">Log in</a> to vote in polls.<br /><br />';
|
||||
if(!logged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user