From 2667d2b41ca17ffab65618665720de40da0caf6c Mon Sep 17 00:00:00 2001 From: Lee <42119604+Leesneaks@users.noreply.github.com> Date: Wed, 26 Dec 2018 10:32:58 +0000 Subject: [PATCH] Updates + Fixes (#66) * Updates +added account editor country list +added account editor website access flag editor. +added player blessing1-8 editor +added fav icon +added $account->setLastLogin +added $player->checkBlessings (for blessings 1-8) +bug fixes * Blessing Fix Should now detect the amount of blessings if blessings1 onwards exists. --- admin/template/template.php | 14 ++-- system/libs/pot/OTS_Account.php | 6 +- system/libs/pot/OTS_Player.php | 32 +++++++- system/pages/admin/accounts.php | 128 +++++++++++++++++-------------- system/pages/admin/logs.php | 2 +- system/pages/admin/players.php | 131 +++++++++++++++++--------------- 6 files changed, 189 insertions(+), 124 deletions(-) diff --git a/admin/template/template.php b/admin/template/template.php index f85b619e..5a1d26ba 100644 --- a/admin/template/template.php +++ b/admin/template/template.php @@ -2,12 +2,18 @@ - + + + <?php echo $title_full ?> + + + - @@ -16,13 +22,11 @@ -
- @@ -214,7 +218,7 @@
-data['country'] = (string) $country; } - + + public function setLastLogin($lastlogin) + { + $this->data['lastday'] = (int) $lastlogin; + } /** * Name. diff --git a/system/libs/pot/OTS_Player.php b/system/libs/pot/OTS_Player.php index c0bce619..84241d47 100644 --- a/system/libs/pot/OTS_Player.php +++ b/system/libs/pot/OTS_Player.php @@ -2231,6 +2231,36 @@ class OTS_Player extends OTS_Row_DAO $this->data['blessings'] = (int) $blessings; } + public function countBlessings() + { + if( !isset($this->db) ) + { + throw new E_OTS_NotLoaded(); + } + for( $i = 8; $i >= 1; $i-- ) { + if ($this->db->hasColumn('players', 'blessings' . $i)) { + break; + } + } + return $i; + } + + public function checkBlessings($count) + { + if( !isset($this->data['id']) ) + { + throw new E_OTS_NotLoaded(); + } + + $fields = array(); + for( $i = 1; $i <= $count; $i++ ) { + $fields[] = 'blessings'.$i; + } + + $value = $this->db->query('SELECT '. implode(', ', $fields) .' FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id'])->fetch(); + return $value; + } + public function getStamina() { if( !isset($this->data['stamina']) ) @@ -3608,4 +3638,4 @@ class OTS_Player extends OTS_Row_DAO /**#@-*/ -?> +?> \ No newline at end of file diff --git a/system/pages/admin/accounts.php b/system/pages/admin/accounts.php index 754d1986..c2973771 100644 --- a/system/pages/admin/accounts.php +++ b/system/pages/admin/accounts.php @@ -12,6 +12,9 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Account editor'; $base = BASE_URL . 'admin/?p=accounts'; +if ($config['account_country']) + require SYSTEM . 'countries.conf.php'; + function echo_success($message) { echo '

' . $message . '

'; @@ -35,6 +38,17 @@ function verify_number($number, $name, $max_length) } $hasCoinsColumn = $db->hasColumn('accounts', 'coins'); +$hasPointsColumn = $db->hasColumn('accounts', 'premium_points'); + +if ($config['account_country']) { + $countries = array(); + foreach (array('pl', 'se', 'br', 'us', 'gb') as $c) + $countries[$c] = $config['countries'][$c]; + + $countries['--'] = '----------'; + foreach ($config['countries'] as $code => $c) + $countries[$code] = $c; +} ?> @@ -69,7 +83,6 @@ else if (isset($_REQUEST['search_name'])) { } } - if ($id > 0) { $account = new OTS_Account(); $account->load($id); @@ -79,10 +92,6 @@ if ($id > 0) { $name = $_POST['name']; $_error = ''; - - //if (!Validator::check_account_name($name)) - // echo_error(Validator::getLastError()); - $account_db = new OTS_Account(); $account_db->find($name); if ($account_db->isLoaded() && $account->getName() != $name) @@ -94,7 +103,6 @@ if ($id > 0) { //type $group = $_POST['group']; - $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); if (!Validator::password($password)) { $errors['password'] = Validator::getLastError(); @@ -104,20 +112,18 @@ if ($id > 0) { $secret = $_POST['secret']; //key $key = $_POST['key']; - $email = $_POST['email']; if (!Validator::email($email)) $errors['email'] = Validator::getLastError(); - // prem days - $p_days = $_POST['p_days']; - verify_number($p_days, 'Prem days', 11); - //tibia coins if ($hasCoinsColumn) { $t_coins = $_POST['t_coins']; verify_number($t_coins, 'Tibia coins', 12); } + // prem days + $p_days = $_POST['p_days']; + verify_number($p_days, 'Prem days', 11); //prem points $p_points = $_POST['p_points']; @@ -132,18 +138,20 @@ if ($id > 0) { //country $rl_country = $_POST['rl_country']; + $web_flags = $_POST['web_flags']; + verify_number($web_flags, 'Web Flags', 1); + //created $created = $_POST['created']; - verify_number($created, 'Created', 20); + verify_number($created, 'Created', 11); //last login $lastlogin = $_POST['lastlogin']; - verify_number($lastlogin, 'Last login', 20); + verify_number($lastlogin, 'Last login', 11); //web last login $web_lastlogin = $_POST['web_lastlogin']; - verify_number($web_lastlogin, 'Web Last logout', 20); - + verify_number($web_lastlogin, 'Web Last logout', 11); if (!$error) { $account->setName($name); @@ -151,18 +159,21 @@ if ($id > 0) { $account->setCustomField('secret', $secret); $account->setCustomField('key', $key); $account->setEMail($email); - $account->setPremDays($p_days); if ($hasCoinsColumn) { $account->setCustomField('coins', $t_coins); } - + $account->setPremDays($p_days); + if ($hasPointsColumn) { + $account->setCustomField('premium_points', $p_points); + } $account->setRLName($rl_name); $account->setLocation($rl_loca); $account->setCountry($rl_country); + $account->setCustomField('created', $created); + $account->setLastLogin($lastlogin); + $account->setWebFlags($web_flags); + $account->setCustomField('web_lastlogin', $web_lastlogin); - if ($db->hasColumn('accounts', 'premium_points')) { - $account->setCustomField('premium_points', $p_points); - } if (isset($password)) { $config_salt_enabled = $db->hasColumn('accounts', 'salt'); @@ -178,9 +189,6 @@ if ($id > 0) { if ($config_salt_enabled) $account->setCustomField('salt', $salt); } - - $account->setEMail($email); - //$account->setCustomField('created', time()); $account->save(); @@ -205,38 +213,22 @@ else if ($id > 0 && isset($account) && $account->isLoaded()) ?> +
-
- +
+
-
- - -
-
-
-
- - -
-
+
- 0 && isset($account) && $account->isLoaded()) value=""/>
+
+ + +
+
+
+ +
+ + +
+
+ + +
@@ -271,12 +288,6 @@ else if ($id > 0 && isset($account) && $account->isLoaded()) autocomplete="off" maxlength="20" value="getEMail(); ?>"/>
-
- - -
@@ -285,9 +296,15 @@ else if ($id > 0 && isset($account) && $account->isLoaded()) value="getCustomField('coins') ?>"/>
- hasColumn('players', 'blessings')): ?> +
+ + +
+
- + @@ -309,12 +326,13 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
- +
-
diff --git a/system/pages/admin/logs.php b/system/pages/admin/logs.php index a927fba6..07f7f5a3 100644 --- a/system/pages/admin/logs.php +++ b/system/pages/admin/logs.php @@ -17,7 +17,7 @@ $title = 'Logs viewer';
-
+
diff --git a/system/pages/admin/players.php b/system/pages/admin/players.php index 715486ab..33c5825b 100644 --- a/system/pages/admin/players.php +++ b/system/pages/admin/players.php @@ -43,6 +43,10 @@ $skills = array( POT::SKILL_SHIELD => array('Shielding', 'shield'), POT::SKILL_FISH => array('Fishing', 'fish') ); + + +$hasBlessingsColumn = $db->hasColumn('players', 'blessings'); +$hasBlessingColumn = $db->hasColumn('players', 'blessings1'); ?> @@ -101,7 +105,6 @@ if ($id > 0) { if ($player_db->isLoaded() && $player->getName() != $name) echo_error('This name is already used. Please choose another name!'); - $account_id = $_POST['account_id']; verify_number($account_id, 'Account id', 11); @@ -181,13 +184,6 @@ if ($id > 0) { verify_number($lastlogin, 'Last login', 20); $lastlogout = $_POST['lastlogout']; verify_number($lastlogout, 'Last logout', 20); - /* $lastip = $_POST['lastip']; - $exp = explode(".", $lastip); - $lastip = $exp[3] . '.' . $exp[2] . '.' . $exp[1] . '.' . $exp[0]; - $lastip_length = strlen($lastip); - if ($lastip_length <= 0 || $lastip_length > 15) - echo_error('IP cannot be longer than 15 digits.'); - */ $skull = $_POST['skull']; verify_number($skull, 'Skull', 1); @@ -211,10 +207,11 @@ if ($id > 0) { verify_number($offlinetraining, 'Offline Training time', 11); } - if ($db->hasColumn('players', 'blessings')) { + if ($hasBlessingsColumn) { $blessings = $_POST['blessings']; verify_number($blessings, 'Blessings', 2); } + $balance = $_POST['balance']; verify_number($balance, 'Balance', 20); if ($db->hasColumn('players', 'stamina')) { @@ -235,6 +232,14 @@ if ($id > 0) { foreach ($_POST['skills_tries'] as $skill => $value) verify_number($value, $skills[$skill][0] . ' tries', 10); + $bless_count = $_POST['blesscount']; + if ($hasBlessingColumn) { + for ($i = 1; $i <= $bless_count; $i++) { + $a = 'blessing' . $i; + ${'blessing' . $i} = (isset($_POST[$a]) && $_POST[$a] == 'true'); + } + } + if (!$error) { $player->setName($name); $player->setAccount($account_db); @@ -278,6 +283,13 @@ if ($id > 0) { } if ($db->hasColumn('players', 'blessings')) $player->setBlessings($blessings); + + if ($hasBlessingColumn) { + for ($i = 1; $i <= $bless_count; $i++) { + $a = 'blessing' . $i; + $player->setCustomField('blessings' . $i, ${'blessing' . $i} ? '1' : '0'); + } + } $player->setBalance($balance); if ($db->hasColumn('players', 'stamina')) $player->setStamina($stamina); @@ -318,7 +330,6 @@ else if ($id > 0 && isset($player) && $player->isLoaded()) -
@@ -381,7 +392,7 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
- + +
+ +
+ ' . $i . ''; + } + ?> +
+
+ +
0 && isset($player) && $player->isLoaded())
- + @@ -492,29 +519,13 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
- -
-
- - -
-
-
-
-
- + 0 && isset($player) && $player->isLoaded())
-
- - -
0 && isset($player) && $player->isLoaded()) size="3" maxlength="11" style="cursor: auto;" value="getCap(); ?>"/>
+
+ + +
hasColumn('players', 'stamina')): ?>
@@ -546,6 +557,16 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
+ hasColumn('players', 'offlinetraining_time')): ?> +
+ + +
+
@@ -653,16 +674,13 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
- hasColumn('players', 'offlinetraining_time')): ?> -
- - -
- +
+ + +
0 && isset($player) && $player->isLoaded()) maxlength="10" value="getLastIP()); ?>" readonly/>
-
- - -
hasColumn('players', 'loss_experience')): ?>
@@ -727,14 +738,15 @@ else if ($id > 0 && isset($player) && $player->isLoaded()) maxlength="11" value="getLossItems(); ?>"/>
-

[max. - length: 2000 chars, 50 lines (ENTERs)] + wrap="virtual">getCustomField("comment"); ?> + [max. + length: 2000 chars, 50 lines (ENTERs)] +
@@ -784,7 +796,6 @@ else if ($id > 0 && isset($player) && $player->isLoaded())

Character List:

-
@@ -809,9 +820,7 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
-
-