From 1859867039118e7ef18838b5f6228e0e5f4579a2 Mon Sep 17 00:00:00 2001 From: Lee <42119604+Leesneaks@users.noreply.github.com> Date: Sun, 30 Dec 2018 01:00:26 +0000 Subject: [PATCH] Bug Fixes -fix for getSkillTries as reported by whiteblXK -fix for login and account type as reported by vG- --- system/libs/pot/OTS_Account.php | 31 ++++++++++++++ system/pages/admin/accounts.php | 59 +++++++++++++++++--------- system/pages/admin/login.php | 6 --- system/pages/admin/players.php | 3 +- system/templates/admin.login.html.twig | 2 +- 5 files changed, 72 insertions(+), 29 deletions(-) diff --git a/system/libs/pot/OTS_Account.php b/system/libs/pot/OTS_Account.php index 94793c71..7e02af32 100644 --- a/system/libs/pot/OTS_Account.php +++ b/system/libs/pot/OTS_Account.php @@ -432,6 +432,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable $this->data['lastday'] = (int) $lastlogin; } + public function setWebFlags($webflags) + { + $this->data['web_flags'] = (int) $webflags; + } + /** * Name. * @@ -882,6 +887,32 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable return 0; } + public function getAccGroupId() + { + if(isset($this->data['group_id'])) { + return $this->data['group_id']; + } + + global $db; + if($db->hasColumn('accounts', 'group_id')) { + $query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch(); + // if anything was found + if(isset($query['group_id'])) { + $this->data['group_id'] = $query['group_id']; + return $query['group_id']; + } + } + if($db->hasColumn('accounts', 'type')) { + $query = $this->db->query('SELECT `type` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch(); + // if anything was found + if(isset($query['type'])) { + $this->data['type'] = $query['type']; + return $query['type']; + } + } + return 0; + } +/** /** * Checks highest access level of account in given guild. * diff --git a/system/pages/admin/accounts.php b/system/pages/admin/accounts.php index c2973771..a577d5de 100644 --- a/system/pages/admin/accounts.php +++ b/system/pages/admin/accounts.php @@ -39,6 +39,8 @@ function verify_number($number, $name, $max_length) $hasCoinsColumn = $db->hasColumn('accounts', 'coins'); $hasPointsColumn = $db->hasColumn('accounts', 'premium_points'); +$hasTypeColumn = $db->hasColumn('accounts', 'type'); +$hasGroupColumn = $db->hasColumn('accounts', 'group_id'); if ($config['account_country']) { $countries = array(); @@ -82,7 +84,7 @@ else if (isset($_REQUEST['search_name'])) { } } } - +$groups = new OTS_Groups_List(); if ($id > 0) { $account = new OTS_Account(); $account->load($id); @@ -101,7 +103,7 @@ if ($id > 0) { if (!$account_db->isLoaded()) echo_error('Account with this id doesn\'t exist.'); - //type + //type/group $group = $_POST['group']; $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); if (!Validator::password($password)) { @@ -155,7 +157,13 @@ if ($id > 0) { if (!$error) { $account->setName($name); - $account->setCustomField('type', $group); + + if ($hasTypeColumn) { + $account->setCustomField('type', $group); + } elseif ($hasGroupColumn) { + $account->setCustomField('group_id', $group); + } + $account->setCustomField('secret', $secret); $account->setCustomField('key', $key); $account->setEMail($email); @@ -174,7 +182,6 @@ if ($id > 0) { $account->setWebFlags($web_flags); $account->setCustomField('web_lastlogin', $web_lastlogin); - if (isset($password)) { $config_salt_enabled = $db->hasColumn('accounts', 'salt'); if ($config_salt_enabled) { @@ -189,7 +196,6 @@ if ($id > 0) { if ($config_salt_enabled) $account->setCustomField('salt', $salt); } - //$account->setCustomField('created', time()); $account->save(); echo_success('Account saved at: ' . date('G:i')); @@ -208,12 +214,8 @@ else if ($id > 0 && isset($account) && $account->isLoaded()) ?>