From da3fc1fc8ca7516e740e86fa48947386036502c1 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 8 Sep 2024 14:48:42 +0200 Subject: [PATCH 01/20] Interesting update from opentibiabr (Uptime readable) --- system/status.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/system/status.php b/system/status.php index ee8b4317..835f204d 100644 --- a/system/status.php +++ b/system/status.php @@ -142,10 +142,14 @@ function updateStatus() { } } - $status['uptime'] = $serverStatus->getUptime(); - $h = floor($status['uptime'] / 3600); - $m = floor(($status['uptime'] - $h * 3600) / 60); - $status['uptimeReadable'] = $h . 'h ' . $m . 'm'; + $uptime = $status['uptime'] = $serverStatus->getUptime(); + $m = date('m', $uptime); + $m = $m > 1 ? "$m months, " : ($m == 1 ? 'month, ' : ''); + $d = date('d', $uptime); + $d = $d > 1 ? "$d days, " : ($d == 1 ? 'day, ' : ''); + $h = date('H', $uptime); + $min = date('i', $uptime); + $status['uptimeReadable'] = "{$m}{$d}{$h}h {$min}m"; $status['monsters'] = $serverStatus->getMonstersCount(); $status['motd'] = $serverStatus->getMOTD(); From ea7e808508364ddbcfc8b544efba871a57dd6509 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 8 Sep 2024 14:48:59 +0200 Subject: [PATCH 02/20] Add more clients (13.22+) --- system/clients.conf.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/clients.conf.php b/system/clients.conf.php index a7d2bf0c..fce41bb1 100644 --- a/system/clients.conf.php +++ b/system/clients.conf.php @@ -105,4 +105,8 @@ $config['clients'] = [ 1316, 1320, 1321, + 1322, + 1330, + 1332, + 1340, ]; From 93641fc68ac9a5f1479329e2bd41380c19534d5d Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 8 Sep 2024 15:03:18 +0200 Subject: [PATCH 03/20] New hooks in account manage + create --- system/pages/account/create.php | 6 ++++++ system/src/global.php | 6 ++++++ system/templates/account.management.html.twig | 4 ++++ templates/tibiacom/account.management.html.twig | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/system/pages/account/create.php b/system/pages/account/create.php index 0074f9e3..9fba8237 100644 --- a/system/pages/account/create.php +++ b/system/pages/account/create.php @@ -148,6 +148,10 @@ if($save) } } + /** + * two hooks for compatibility + */ + $hooks->trigger(HOOK_ACCOUNT_CREATE_AFTER_SUBMIT, $params); if (!$hooks->trigger(HOOK_ACCOUNT_CREATE_POST, $params)) { return; } @@ -187,6 +191,8 @@ if($save) $new_account->setEMail($email); $new_account->save(); + $hooks->trigger(HOOK_ACCOUNT_CREATE_AFTER_SAVED, ['account' => $new_account]); + if(USE_ACCOUNT_SALT) $new_account->setCustomField('salt', $salt); diff --git a/system/src/global.php b/system/src/global.php index d4bd0cc4..e106a57c 100644 --- a/system/src/global.php +++ b/system/src/global.php @@ -45,6 +45,12 @@ define('HOOK_ACCOUNT_CREATE_AFTER_TOWNS', ++$i); define('HOOK_ACCOUNT_CREATE_BEFORE_SUBMIT_BUTTON', ++$i); define('HOOK_ACCOUNT_CREATE_AFTER_FORM', ++$i); define('HOOK_ACCOUNT_CREATE_POST', ++$i); +define('HOOK_ACCOUNT_CREATE_AFTER_SUBMIT', ++$i); +define('HOOK_ACCOUNT_CREATE_AFTER_SAVED', ++$i); +define('HOOK_ACCOUNT_MANAGE_BEFORE_GENERAL_INFORMATION', ++$i); +define('HOOK_ACCOUNT_MANAGE_BEFORE_PUBLIC_INFORMATION', ++$i); +define('HOOK_ACCOUNT_MANAGE_BEFORE_ACCOUNT_LOGS', ++$i); +define('HOOK_ACCOUNT_MANAGE_BEFORE_CHARACTERS', ++$i); define('HOOK_ACCOUNT_LOGIN_BEFORE_PAGE', ++$i); define('HOOK_ACCOUNT_LOGIN_BEFORE_ACCOUNT', ++$i); define('HOOK_ACCOUNT_LOGIN_AFTER_ACCOUNT', ++$i); diff --git a/system/templates/account.management.html.twig b/system/templates/account.management.html.twig index db8c766f..87a33b6a 100644 --- a/system/templates/account.management.html.twig +++ b/system/templates/account.management.html.twig @@ -88,6 +88,7 @@

{% endif %} + {{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_GENERAL_INFORMATION') }}

General Information

@@ -127,6 +128,7 @@ {% endautoescape %}

+ {{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_PUBLIC_INFORMATION') }}

Public Information

@@ -145,6 +147,7 @@ {% include('buttons.base.html.twig') %}
+ {{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_ACCOUNT_LOGS') }}

Action Log

@@ -164,6 +167,7 @@ {% endautoescape %}

+ {{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_CHARACTERS') }}

Character list: {{ players|length }} characters.

diff --git a/templates/tibiacom/account.management.html.twig b/templates/tibiacom/account.management.html.twig index 773ce6c9..6ce10274 100644 --- a/templates/tibiacom/account.management.html.twig +++ b/templates/tibiacom/account.management.html.twig @@ -111,6 +111,7 @@

{% endif %} +{{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_GENERAL_INFORMATION') }}
@@ -221,6 +222,7 @@ {% endset %} {% include 'tables.headline.html.twig' %}
+{{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_PUBLIC_INFORMATION') }}
@@ -280,6 +282,7 @@ {% endset %} {% include 'tables.headline.html.twig' %}
+{{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_ACCOUNT_LOGS') }}
@@ -333,6 +336,7 @@ {% endset %} {% include 'tables.headline.html.twig' %}
+{{ hook('HOOK_ACCOUNT_MANAGE_BEFORE_CHARACTERS') }}
From 7161678c4bd47322735ef15fd7c87bfa6a0e5aea Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 12 Sep 2024 09:40:01 +0200 Subject: [PATCH 04/20] Add missing Validator::characterName check --- system/pages/account/characters/change-name.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/system/pages/account/characters/change-name.php b/system/pages/account/characters/change-name.php index 4a23131d..975369d1 100644 --- a/system/pages/account/characters/change-name.php +++ b/system/pages/account/characters/change-name.php @@ -40,8 +40,13 @@ else if(empty($errors)) { - if(!admin() && !Validator::newCharacterName($name)) + if(!Validator::characterName($name)) { $errors[] = Validator::getLastError(); + } + + if(!admin() && !Validator::newCharacterName($name)) { + $errors[] = Validator::getLastError(); + } } if(empty($errors)) { From 2568046a4d842018db33a39b1ee16b8a89a44ccf Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 14 Sep 2024 11:16:47 +0200 Subject: [PATCH 05/20] nothing important: brackets --- tools/validate.php | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tools/validate.php b/tools/validate.php index 0eb76e0c..b3546aad 100644 --- a/tools/validate.php +++ b/tools/validate.php @@ -23,32 +23,36 @@ if(isset($_GET['account'])) { $account = $_GET['account']; if(USE_ACCOUNT_NAME) { - if(!Validator::accountName($account)) + if(!Validator::accountName($account)) { error_(Validator::getLastError()); + } } - else if(!Validator::accountId($account)) + else if(!Validator::accountId($account)) { error_(Validator::getLastError()); + } $_account = new OTS_Account(); - if(USE_ACCOUNT_NAME || USE_ACCOUNT_NUMBER) + if(USE_ACCOUNT_NAME || USE_ACCOUNT_NUMBER) { $_account->find($account); - else + } else { $_account->load($account); + } $accountNameOrNumber = (USE_ACCOUNT_NAME ? ' name' : 'number'); - if($_account->isLoaded()) + if($_account->isLoaded()) { error_("Account with this $accountNameOrNumber already exist."); + } success_("Good account $accountNameOrNumber ($account)."); } else if(isset($_GET['email'])) { $email = $_GET['email']; - if(!Validator::email($email)) + if(!Validator::email($email)) { error_(Validator::getLastError()); + } - if(setting('core.account_mail_unique')) - { + if(setting('core.account_mail_unique')) { if(Account::where('email', '=', $email)->exists()) error_('Account with this e-mail already exist.'); } @@ -62,11 +66,13 @@ else if(isset($_GET['name'])) $name = strtolower(stripslashes($name)); } - if(!Validator::characterName($name)) + if(!Validator::characterName($name)) { error_(Validator::getLastError()); + } - if(!admin() && !Validator::newCharacterName($name)) + if(!admin() && !Validator::newCharacterName($name)) { error_(Validator::getLastError()); + } $createCharacter = new CreateCharacter(); if (!$createCharacter->checkName($name, $errors)) { @@ -83,16 +89,19 @@ else if(isset($_GET['password']) && isset($_GET['password_confirm'])) { error_('Please enter the password for your new account.'); } - if(!Validator::password($password)) + if(!Validator::password($password)) { error_(Validator::getLastError()); + } - if($password != $password_confirm) + if($password != $password_confirm) { error_('Passwords are not the same.'); + } success_(1); } -else +else { error_('Error: no input specified.'); +} /** * Output message & exit. From a7fe400614b933d2cc35ea7ed83cdb8124b70f15 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 14 Sep 2024 11:48:43 +0200 Subject: [PATCH 06/20] Use Validator::characterName --- system/src/CreateCharacter.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/system/src/CreateCharacter.php b/system/src/CreateCharacter.php index c54c515b..3d3ae8ff 100644 --- a/system/src/CreateCharacter.php +++ b/system/src/CreateCharacter.php @@ -23,32 +23,8 @@ class CreateCharacter */ public function checkName($name, &$errors) { - $minLength = setting('core.create_character_name_min_length'); - $maxLength = setting('core.create_character_name_max_length'); - - if(empty($name)) { - $errors['name'] = 'Please enter a name for your character!'; - return false; - } - - if(strlen($name) > $maxLength) { - $errors['name'] = 'Name is too long. Max. length ' . $maxLength . ' letters.'; - return false; - } - - if(strlen($name) < $minLength) { - $errors['name'] = 'Name is too short. Min. length ' . $minLength . ' letters.'; - return false; - } - - $name_length = strlen($name); - if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) { - $errors['name'] = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.'; - return false; - } - - if(!preg_match("/[A-z ']/", $name)) { - $errors['name'] = 'Your name contains illegal characters.'; + if (!\Validator::characterName($name)) { + $errors['name'] = \Validator::getLastError(); return false; } From 95a7c23a709b225a782b02a8bd5eab13c586fd23 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 14 Sep 2024 11:48:56 +0200 Subject: [PATCH 07/20] Use PHP 8 functions --- system/src/Validator.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/system/src/Validator.php b/system/src/Validator.php index 04c9b340..ad9e3e50 100644 --- a/system/src/Validator.php +++ b/system/src/Validator.php @@ -178,8 +178,7 @@ class Validator */ public static function characterName($name) { - if(!isset($name[0])) - { + if(empty($name)) { self::$lastError = 'Please enter character name.'; return false; } @@ -250,7 +249,7 @@ class Validator } } - if(substr($name_lower, -1) == "'" || substr($name_lower, -1) == "-") { + if(str_ends_with($name_lower, "'") || str_ends_with($name_lower, "-")) { self::$lastError = 'Your name contains illegal characters.'; return false; } @@ -285,7 +284,7 @@ class Validator $words_blocked = array_merge(['--', "''","' ", " '", '- ', ' -', "-'", "'-"], setting('core.create_character_name_blocked_words')); foreach($words_blocked as $word) { - if(!(strpos($name_lower, $word) === false)) { + if(str_contains($name_lower, $word)) { self::$lastError = 'Your name contains illegal words.'; return false; } @@ -335,7 +334,7 @@ class Validator NPCs::load(); if(NPCs::$npcs) { foreach (NPCs::$npcs as $npc) { - if(strpos($name_lower, $npc) !== false) { + if(str_contains($name_lower, $npc)) { self::$lastError = 'Your name cannot contains NPC name.'; return false; } From c6cc84a668c4b2ccfd6675bc65240df4fd73153d Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 19 Sep 2024 21:25:54 +0200 Subject: [PATCH 08/20] Fix RateLimit when cache is disabled --- system/src/RateLimit.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/system/src/RateLimit.php b/system/src/RateLimit.php index fbb97369..9bc32524 100644 --- a/system/src/RateLimit.php +++ b/system/src/RateLimit.php @@ -76,7 +76,7 @@ class RateLimit public function save(): void { global $cache; - if (!$this->enabled) { + if (!$this->enabled || !$cache->enabled()) { return; } @@ -92,7 +92,7 @@ class RateLimit } $data = []; - if ($this->enabled && $cache->enabled()) { + if ($cache->enabled()) { $tmp = ''; if ($cache->fetch($this->key, $tmp)) { $data = unserialize($tmp); @@ -110,8 +110,6 @@ class RateLimit $this->save(); } - } else { - $data = []; } } From 4e4739e8ab62942afe55ad981a667b71120f59c4 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 4 Oct 2024 21:23:41 +0200 Subject: [PATCH 09/20] Fix displaying players online record --- system/templates/online.html.twig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/templates/online.html.twig b/system/templates/online.html.twig index b2090327..9e42b77e 100644 --- a/system/templates/online.html.twig +++ b/system/templates/online.html.twig @@ -23,6 +23,9 @@ Currently {{ players|length }} players are online.
{% endif %} {% endif %} + {% if setting('core.online_record')) %} + {{ record }} + {% endif %}
From e8fedb8d16be6a4ecb0ce3f099b4afe6173f58c3 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 4 Oct 2024 21:26:28 +0200 Subject: [PATCH 10/20] One bracket to much.. --- system/templates/online.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/templates/online.html.twig b/system/templates/online.html.twig index 9e42b77e..0210d80f 100644 --- a/system/templates/online.html.twig +++ b/system/templates/online.html.twig @@ -23,7 +23,7 @@ Currently {{ players|length }} players are online.
{% endif %} {% endif %} - {% if setting('core.online_record')) %} + {% if setting('core.online_record') %} {{ record }} {% endif %} From f7c9a67a968e00fc66f0c147869d77273a6b1ff4 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 4 Oct 2024 21:36:13 +0200 Subject: [PATCH 11/20] More fixes to displaying online record --- system/pages/online.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/pages/online.php b/system/pages/online.php index 77f01a2a..deac5fd6 100644 --- a/system/pages/online.php +++ b/system/pages/online.php @@ -100,7 +100,7 @@ foreach($playersOnline as $player) { } $record = ''; -if($players > 0) { +if(count($players_data) > 0) { if( setting('core.online_record')) { $result = null; $timestamp = false; @@ -114,7 +114,7 @@ if($players > 0) { } } - if($record) { + if($result) { $record = 'The maximum on this game world was ' . $result['record'] . ' players' . ($timestamp ? ' on ' . date("M d Y, H:i:s", $result['timestamp']) . '.' : '.'); } } From 3100faa64552da10a88686fefc05e3409522f339 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 11 Oct 2024 20:35:12 +0200 Subject: [PATCH 12/20] Fix highscores skills for servers that use player_skills table --- system/pages/highscores.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/pages/highscores.php b/system/pages/highscores.php index a1e2567f..b52e7316 100644 --- a/system/pages/highscores.php +++ b/system/pages/highscores.php @@ -175,7 +175,7 @@ if (empty($highscores)) { $query ->join('player_skills', 'player_skills.player_id', '=', 'players.id') ->where('skillid', $skill) - ->addSelect('player_skills.skillid as value'); + ->addSelect('player_skills.value as value'); } } else if ($skill == SKILL_FRAGS) // frags { From b8c0215720c89664c915e3dd10f27bdbfb9f33ec Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 24 Oct 2024 15:55:32 +0200 Subject: [PATCH 13/20] Fix if loot is empty --- system/pages/monsters.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/pages/monsters.php b/system/pages/monsters.php index 988d15b5..1678291e 100644 --- a/system/pages/monsters.php +++ b/system/pages/monsters.php @@ -62,7 +62,9 @@ if ($monsterModel && isset($monsterModel->name)) { $elements = json_decode($monster['elements'], true); $immunities = json_decode($monster['immunities'], true); $loot = json_decode($monster['loot'], true); - usort($loot, 'sort_by_chance'); + if (!empty($loot)) { + usort($loot, 'sort_by_chance'); + } foreach ($loot as &$item) { $item['name'] = getItemNameById($item['id']); From 29b77035be8a09fbbbd946959938f49117fa23e6 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 25 Oct 2024 10:53:50 +0200 Subject: [PATCH 14/20] Update CHANGELOG.md --- CHANGELOG.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98dc3f4e..99fda8da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,28 @@ # Changelog -## [1.0-RC -23.07.2024] +## [1.0-RC.2 - 25.10.2024] + +Still waiting for your reports about bugs found in this release. We are very close to stable release. + +### Added +* feat: rate limit settings for blocking accounts login attempts (@gpedro, #266) +* search by email in accounts editor (https://github.com/slawkens/myaac/commit/c2ec46824621468f2a1cb4046805c485ed13fea5) +* New hooks in account manage + create (https://github.com/slawkens/myaac/commit/93641fc68ac9a5f1479329e2bd41380c19534d5d) + +### Changed +* chore: drop raw queries + accounts - search by email + accounts - required min size for search by account number (@gpedro, #266) +* Use https for outfit & item images (https://github.com/slawkens/myaac/commit/71c00aa5e01fbdfd88802912e200dd1025976231) +* Do not require players & guilds tables on install (https://github.com/slawkens/myaac/commit/779aa152fa940261c9b161533946f44e288597a2) +* Do not create player if there is no players table in db (https://github.com/slawkens/myaac/commit/201f95caa8b70e88fa651eac8c3c3aa7cd765bd0) + +### Fixed +* Highscore frags fixed for TFS 0.3 (@Scrollog, #263) +* Missing groups variable #262. thanks, @Scrollog for reporting (https://github.com/slawkens/myaac/commit/8d8bdb6dac6df21672ac77288fff2f2f8d6eb665) +* Verified email for login.php (@gpedro, #265) +* Warning if core.account_country is disabled (https://github.com/slawkens/myaac/commit/ab73d60c61e14a1cacdb6cfbf7f89f4bf3be0833) + + +## [1.0-RC.1 - 23.07.2024] Changes since 1.0-beta: From cb5fc84e2e46d61254c6f58e417940e9344ddb37 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 25 Oct 2024 10:54:03 +0200 Subject: [PATCH 15/20] Release v1.0-RC.2 --- common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.php b/common.php index a74a654b..5b12f749 100644 --- a/common.php +++ b/common.php @@ -26,7 +26,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is required.'); const MYAAC = true; -const MYAAC_VERSION = '1.0-RC'; +const MYAAC_VERSION = '1.0-RC.2'; const DATABASE_VERSION = 40; const TABLE_PREFIX = 'myaac_'; define('START_TIME', microtime(true)); From a0f1971583f0f790013e2145fb5ac573c59fbdef Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 25 Oct 2024 19:01:28 +0200 Subject: [PATCH 16/20] Fix login if limiter is disabled --- system/pages/account/login.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/pages/account/login.php b/system/pages/account/login.php index 98e85b46..3e8ebba3 100644 --- a/system/pages/account/login.php +++ b/system/pages/account/login.php @@ -42,7 +42,7 @@ if(!empty($login_account) && !empty($login_password)) } } - if($account_logged->isLoaded() && encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $login_password) == $account_logged->getPassword() && ($limiter->enabled && !$limiter->exceeded($ip)) + if($account_logged->isLoaded() && encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $login_password) == $account_logged->getPassword() && (!$limiter->enabled || !$limiter->exceeded($ip)) ) { if (setting('core.account_mail_verify') && (int)$account_logged->getCustomField('email_verified') !== 1) { @@ -82,10 +82,10 @@ if(!empty($login_account) && !empty($login_password)) $limiter->increment($ip); if ($limiter->exceeded($ip)) { $errorMessage = 'A wrong password has been entered ' . $limiter->max_attempts . ' times in a row. You are unable to log into your account for the next ' . $limiter->ttl . ' minutes. Please wait.'; - } + } $errors[] = $errorMessage; - + } } else { From c49c9d99a99629ce3270f74a520f7d03a04a6a78 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 27 Oct 2024 20:40:48 +0100 Subject: [PATCH 17/20] Fix PHP Fatal error --- system/src/RateLimit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/RateLimit.php b/system/src/RateLimit.php index 9bc32524..df4349e5 100644 --- a/system/src/RateLimit.php +++ b/system/src/RateLimit.php @@ -10,7 +10,7 @@ class RateLimit public int $max_attempts; public int $ttl; public $enabled = false; - protected array $data; + protected array $data = []; public function __construct(string $key, int $max_attempts, int $ttl) { From e96227fbe41ae281783b2d49edb169a603601813 Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 7 Nov 2024 14:44:08 +0100 Subject: [PATCH 18/20] Automatically set selected current one on highscores filters --- system/pages/highscores.php | 8 +++++--- system/templates/highscores.html.twig | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/system/pages/highscores.php b/system/pages/highscores.php index b52e7316..bba1dff6 100644 --- a/system/pages/highscores.php +++ b/system/pages/highscores.php @@ -35,11 +35,12 @@ $settingHighscoresVocationBox = setting('core.highscores_vocation_box'); $configVocations = config('vocations'); $configVocationsAmount = config('vocations_amount'); -if($settingHighscoresVocationBox && $vocation !== 'all') -{ +$vocationId = null; +if($settingHighscoresVocationBox && $vocation !== 'all') { foreach($configVocations as $id => $name) { if(strtolower($name) == $vocation) { - $add_vocs = array($id); + $vocationId = $id; + $add_vocs = [$id]; $i = $id + $configVocationsAmount; while(isset($configVocations[$i])) { @@ -287,6 +288,7 @@ $twig->display('highscores.html.twig', [ 'skillName' => ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))), 'levelName' => ($skill != SKILL_FRAGS && $skill != SKILL_BALANCE ? 'Level' : ($skill == SKILL_BALANCE ? 'Balance' : 'Frags')), 'vocation' => $vocation !== 'all' ? $vocation : null, + 'vocationId' => $vocationId, 'types' => $types, 'linkPreviousPage' => $linkPreviousPage, 'linkNextPage' => $linkNextPage, diff --git a/system/templates/highscores.html.twig b/system/templates/highscores.html.twig index 8a2c78a6..711264dd 100644 --- a/system/templates/highscores.html.twig +++ b/system/templates/highscores.html.twig @@ -11,7 +11,7 @@ @@ -21,7 +21,7 @@ {% set i = 0 %} {% for i in 1..config.vocations_amount %} - + {% endfor %} From 078e20a9a4f1dff87efea0def5930a5c27bcf4e6 Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 7 Nov 2024 14:44:18 +0100 Subject: [PATCH 19/20] cleanup --- system/templates/highscores.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/templates/highscores.html.twig b/system/templates/highscores.html.twig index 711264dd..cf2ef4ff 100644 --- a/system/templates/highscores.html.twig +++ b/system/templates/highscores.html.twig @@ -8,7 +8,7 @@ Filters - {% set i = 0 %} {% for link, name in types %} @@ -17,7 +17,7 @@ - {% set i = 0 %} {% for i in 1..config.vocations_amount %} From 18bd325a442ee6ed1bb0027a8f4465d5988c80cd Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 7 Nov 2024 14:44:46 +0100 Subject: [PATCH 20/20] fix label --- system/templates/highscores.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/templates/highscores.html.twig b/system/templates/highscores.html.twig index cf2ef4ff..d4d3dd55 100644 --- a/system/templates/highscores.html.twig +++ b/system/templates/highscores.html.twig @@ -7,7 +7,7 @@ Filters - +