From cc9057324ae3e9390439f9fe15ff1ecc22a9acb1 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 2 Feb 2024 18:52:21 +0100 Subject: [PATCH 01/10] Fix maxlength for email input --- system/templates/account.login.html.twig | 2 +- system/templates/admin.login.html.twig | 2 +- templates/tibiacom/account.login.html.twig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/templates/account.login.html.twig b/system/templates/account.login.html.twig index aec1e222..6ab08df9 100644 --- a/system/templates/account.login.html.twig +++ b/system/templates/account.login.html.twig @@ -29,7 +29,7 @@ Please enter your account {{ account|lower }} and your password.
{{ account_login_by }}: - + {{ hook('HOOK_ACCOUNT_LOGIN_AFTER_ACCOUNT') }} diff --git a/system/templates/admin.login.html.twig b/system/templates/admin.login.html.twig index 4f766f9a..f31b8fad 100644 --- a/system/templates/admin.login.html.twig +++ b/system/templates/admin.login.html.twig @@ -24,7 +24,7 @@
- + {{ hook('HOOK_ADMIN_LOGIN_AFTER_ACCOUNT') }}
diff --git a/templates/tibiacom/account.login.html.twig b/templates/tibiacom/account.login.html.twig index 3e459a8b..9e9b65c2 100644 --- a/templates/tibiacom/account.login.html.twig +++ b/templates/tibiacom/account.login.html.twig @@ -38,7 +38,7 @@ {{ account_login_by }}: - + {{ hook('HOOK_ACCOUNT_LOGIN_AFTER_ACCOUNT') }} From 2faaa037ab9a1c0c06436904899131188c245716 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 2 Feb 2024 20:17:18 +0100 Subject: [PATCH 02/10] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8098fcc0..0ec16043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [1.0-beta - 28.01.2024] +## [1.0-beta - 02.02.2024] Minimum PHP version for this release is 8.1. From 58bb6093b0c807926775059f30c59ec013a71be2 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 2 Feb 2024 20:29:28 +0100 Subject: [PATCH 03/10] Update release.sh --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 2606cd5d..f2fa9c30 100644 --- a/release.sh +++ b/release.sh @@ -38,7 +38,7 @@ if [ $1 = "prepare" ]; then cd $dir || exit # dependencies - composer install --no-dev --prefer-dist --optimize-autoloader + composer install --prefer-dist --optimize-autoloader echo "Now you can make changes to $dir. When you are ready, type 'release.sh pack'" exit From 8f23c627085999bd125c63f868bee3232823f7c0 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 3 Feb 2024 18:42:35 +0100 Subject: [PATCH 04/10] Update list of contributors --- CONTRIBUTORS.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index dd7aafdd..50c6f2ff 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -8,7 +8,11 @@ Fernando Matos Lee <42119604+Leesneaks@users.noreply.github.com> caio slawkens -tobi132 <52947952+tobi132@users.noreply.github.com> +tobi132 vankk whiteblXK xitobuh +Danilo Pucci +gpedro +Matheus Collier +SRNT-GG <95472530+SRNT-GG@users.noreply.github.com> From bbe922a65d29088561f3ec46c0db3271f8b1719d Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 3 Feb 2024 18:58:20 +0100 Subject: [PATCH 05/10] New migration: update menu links --- common.php | 2 +- install/includes/schema.sql | 2 +- system/migrations/40.php | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 system/migrations/40.php diff --git a/common.php b/common.php index f64c5aee..5a19fdb3 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is const MYAAC = true; const MYAAC_VERSION = '1.0-beta'; -const DATABASE_VERSION = 39; +const DATABASE_VERSION = 40; const TABLE_PREFIX = 'myaac_'; define('START_TIME', microtime(true)); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/install/includes/schema.sql b/install/includes/schema.sql index ffbdf8d1..46347707 100644 --- a/install/includes/schema.sql +++ b/install/includes/schema.sql @@ -1,4 +1,4 @@ -SET @myaac_database_version = 39; +SET @myaac_database_version = 40; CREATE TABLE `myaac_account_actions` ( diff --git a/system/migrations/40.php b/system/migrations/40.php new file mode 100644 index 00000000..3287a6d0 --- /dev/null +++ b/system/migrations/40.php @@ -0,0 +1,11 @@ +update(['link' => 'last-kills']); +Menu::where('link', 'serverInfo')->update(['link' => 'server-info']); +Menu::where('link', 'experienceStages')->update(['link' => 'exp-stages']); +Menu::where('link', 'experienceTable')->update(['link' => 'exp-table']); From 00cbce20b000c702b4ef39eaf35ea0c07dac633f Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 3 Feb 2024 20:01:38 +0100 Subject: [PATCH 06/10] Various fixes in forum Add new access type: guest - all visitors, player will be now for logged players only Fixed default forum board access for guests --- system/pages/forum/admin.php | 173 ++++++++++--------- system/pages/forum/base.php | 8 +- system/pages/forum/edit_post.php | 5 + system/pages/forum/move_thread.php | 5 + system/pages/forum/new_post.php | 2 +- system/pages/forum/new_thread.php | 10 ++ system/pages/forum/remove_post.php | 5 + system/templates/forum.add_board.html.twig | 2 +- system/templates/forum.move_thread.html.twig | 2 +- 9 files changed, 127 insertions(+), 85 deletions(-) diff --git a/system/pages/forum/admin.php b/system/pages/forum/admin.php index d8a73eb3..6e35bba5 100644 --- a/system/pages/forum/admin.php +++ b/system/pages/forum/admin.php @@ -13,90 +13,107 @@ use MyAAC\Forum; defined('MYAAC') or exit('Direct access not allowed!'); -$canEdit = Forum::isModerator(); -if($canEdit) { - $groups = new OTS_Groups_List(); +if(!$canEdit) { + return; +} - if(!empty($action)) { - if($action == 'delete_board' || $action == 'edit_board' || $action == 'hide_board' || $action == 'moveup_board' || $action == 'movedown_board') - $id = $_REQUEST['id']; +$groupsList = new OTS_Groups_List(); +$groups = [ + ['id' => 0, 'name' => 'Guest'], +]; - if(isset($_REQUEST['access'])) { - $access = $_REQUEST['access']; - } +foreach ($groupsList as $group) { + $groups[] = [ + 'id' => $group->getId(), + 'name' => $group->getName() + ]; +} - if(isset($_REQUEST['guild'])) { - $guild = $_REQUEST['guild']; - } +if(!empty($action)) { + if($action == 'delete_board' || $action == 'edit_board' || $action == 'hide_board' || $action == 'moveup_board' || $action == 'movedown_board') + $id = $_REQUEST['id']; - if(isset($_REQUEST['name'])) { - $name = $_REQUEST['name']; - } - - if(isset($_REQUEST['description'])) { - $description = stripslashes($_REQUEST['description']); - } - - $errors = []; - - if($action == 'add_board') { - if(Forum::add_board($name, $description, $access, $guild, $errors)) { - $action = $name = $description = ''; - } - } - else if($action == 'delete_board') { - Forum::delete_board($id, $errors); - $action = ''; - } - else if($action == 'edit_board') - { - if(isset($id) && !isset($name)) { - $board = Forum::get_board($id); - $name = $board['name']; - $access = $board['access']; - $guild = $board['guild']; - $description = $board['description']; - } - else { - Forum::update_board($id, $name, $access, $guild, $description); - $action = $name = $description = ''; - $access = $guild = 0; - } - } - else if($action == 'hide_board') { - Forum::toggleHide_board($id, $errors); - $action = ''; - } - else if($action == 'moveup_board') { - Forum::move_board($id, -1, $errors); - $action = ''; - } - else if($action == 'movedown_board') { - Forum::move_board($id, 1, $errors); - $action = ''; - } - - if(!empty($errors)) { - $twig->display('error_box.html.twig', array('errors' => $errors)); - $action = ''; - } + if(isset($_REQUEST['access'])) { + $access = $_REQUEST['access']; } - if(empty($action) || $action == 'edit_board') { - $guilds = $db->query('SELECT `id`, `name` FROM `guilds`')->fetchAll(); - $twig->display('forum.add_board.html.twig', array( - 'link' => getLink('forum', ($action == 'edit_board' ? 'edit_board' : 'add_board')), - 'action' => $action, - 'id' => isset($id) ? $id : null, - 'name' => isset($name) ? $name : null, - 'description' => isset($description) ? $description : null, - 'access' => isset($access) ? $access : 0, - 'guild' => isset($guild) ? $guild : null, - 'groups' => $groups, - 'guilds' => $guilds - )); + if(isset($_REQUEST['guild'])) { + $guild = $_REQUEST['guild']; + } - if($action == 'edit_board') - $action = ''; + if(isset($_REQUEST['name'])) { + $name = $_REQUEST['name']; + } + + if(isset($_REQUEST['description'])) { + $description = stripslashes($_REQUEST['description']); + } + + $errors = []; + + if($action == 'add_board') { + if(Forum::add_board($name, $description, $access, $guild, $errors)) { + $action = $name = $description = ''; + header('Location: ' . getLink('forum')); + } + } + else if($action == 'delete_board') { + Forum::delete_board($id, $errors); + header('Location: ' . getLink('forum')); + $action = ''; + } + else if($action == 'edit_board') + { + if(isset($id) && !isset($name)) { + $board = Forum::get_board($id); + $name = $board['name']; + $access = $board['access']; + $guild = $board['guild']; + $description = $board['description']; + } + else { + Forum::update_board($id, $name, $access, $guild, $description); + header('Location: ' . getLink('forum')); + $action = $name = $description = ''; + $access = $guild = 0; + } + } + else if($action == 'hide_board') { + Forum::toggleHide_board($id, $errors); + header('Location: ' . getLink('forum')); + $action = ''; + } + else if($action == 'moveup_board') { + Forum::move_board($id, -1, $errors); + header('Location: ' . getLink('forum')); + $action = ''; + } + else if($action == 'movedown_board') { + Forum::move_board($id, 1, $errors); + header('Location: ' . getLink('forum')); + $action = ''; + } + + if(!empty($errors)) { + $twig->display('error_box.html.twig', array('errors' => $errors)); + $action = ''; } } + +if(empty($action) || $action == 'edit_board') { + $guilds = $db->query('SELECT `id`, `name` FROM `guilds`')->fetchAll(); + $twig->display('forum.add_board.html.twig', array( + 'link' => getLink('forum', ($action == 'edit_board' ? 'edit_board' : 'add_board')), + 'action' => $action, + 'id' => $id ?? null, + 'name' => $name ?? null, + 'description' => $description ?? null, + 'access' => $access ?? 0, + 'guild' => $guild ?? null, + 'groups' => $groups, + 'guilds' => $guilds + )); + + if($action == 'edit_board') + $action = ''; +} diff --git a/system/pages/forum/base.php b/system/pages/forum/base.php index 8da5b169..2463fa05 100644 --- a/system/pages/forum/base.php +++ b/system/pages/forum/base.php @@ -8,6 +8,9 @@ * @copyright 2021 MyAAC * @link https://my-aac.org */ + +use MyAAC\Forum; + defined('MYAAC') or die('Direct access not allowed!'); $title = 'Forum'; @@ -24,10 +27,7 @@ if(strtolower($forumSetting) != 'site') { return false; } -if(!$logged) { - echo 'You are not logged in. Log in to post on the forum.

'; - return false; -} +$canEdit = Forum::isModerator(); $sections = array(); foreach(getForumBoards() as $section) { diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php index 042081de..bc99d84a 100644 --- a/system/pages/forum/edit_post.php +++ b/system/pages/forum/edit_post.php @@ -18,6 +18,11 @@ if ($ret === false) { return; } +if(!$logged) { + echo 'You are not logged in. Log in to post on the forum.

'; + return; +} + if(Forum::canPost($account_logged)) { $post_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : false; diff --git a/system/pages/forum/move_thread.php b/system/pages/forum/move_thread.php index a66ddfce..75e9da18 100644 --- a/system/pages/forum/move_thread.php +++ b/system/pages/forum/move_thread.php @@ -18,6 +18,11 @@ if ($ret === false) { return; } +if(!$logged) { + echo 'You are not logged in. Log in to post on the forum.

'; + return; +} + if(!Forum::isModerator()) { echo 'You are not logged in or you are not moderator.'; } diff --git a/system/pages/forum/new_post.php b/system/pages/forum/new_post.php index 9be11343..7a9f35e4 100644 --- a/system/pages/forum/new_post.php +++ b/system/pages/forum/new_post.php @@ -24,7 +24,7 @@ if(!$logged) { $extra_url = '&action=new_post&thread_id=' . $_GET['thread_id']; } - header('Location: ' . BASE_URL . '?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=forum' . $extra_url)); + echo 'You are not logged in. Log in to post on the forum.

'; return; } diff --git a/system/pages/forum/new_thread.php b/system/pages/forum/new_thread.php index 0ce1270b..dff7da12 100644 --- a/system/pages/forum/new_thread.php +++ b/system/pages/forum/new_thread.php @@ -18,6 +18,16 @@ if ($ret === false) { return; } +if(!$logged) { + $extra_url = ''; + if(isset($_GET['section_id'])) { + $extra_url = '&action=new_thread§ion_id=' . $_GET['section_id']; + } + + echo 'You are not logged in. Log in to post on the forum.

'; + return; +} + if(Forum::canPost($account_logged)) { $players_from_account = $db->query('SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = '.(int) $account_logged->getId())->fetchAll(); $section_id = $_REQUEST['section_id'] ?? null; diff --git a/system/pages/forum/remove_post.php b/system/pages/forum/remove_post.php index 73535eae..d4926099 100644 --- a/system/pages/forum/remove_post.php +++ b/system/pages/forum/remove_post.php @@ -18,6 +18,11 @@ if ($ret === false) { return; } +if(!$logged) { + echo 'You are not logged in. Log in to post on the forum.

'; + return; +} + if(Forum::isModerator()) { $id = (int) $_REQUEST['id']; $post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . FORUM_TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch(); diff --git a/system/templates/forum.add_board.html.twig b/system/templates/forum.add_board.html.twig index 2dbfe963..39f39688 100644 --- a/system/templates/forum.add_board.html.twig +++ b/system/templates/forum.add_board.html.twig @@ -22,7 +22,7 @@ diff --git a/system/templates/forum.move_thread.html.twig b/system/templates/forum.move_thread.html.twig index 4a5981b2..be62d9c7 100644 --- a/system/templates/forum.move_thread.html.twig +++ b/system/templates/forum.move_thread.html.twig @@ -24,7 +24,7 @@ -
+ {{ csrf() }}
From b22dc0014a4d6da3607dc42571bed858b67c8879 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 3 Feb 2024 20:30:21 +0100 Subject: [PATCH 07/10] Change spaces to tabs --- system/pages/polls.php | 434 ++++++++++++++++++++--------------------- 1 file changed, 217 insertions(+), 217 deletions(-) diff --git a/system/pages/polls.php b/system/pages/polls.php index dcc781c2..b7bc0ba1 100644 --- a/system/pages/polls.php +++ b/system/pages/polls.php @@ -26,26 +26,26 @@ function getColorByPercent($percent) } $number_of_rows = 0; $showed = false; - $link = "polls"; // your link to polls in index.php - $dark = $config['darkborder']; - $light = $config['lightborder']; - $time = time(); - $POLLS = $db->query('SELECT * FROM '.$db->tableName('z_polls').''); - $level = 20; // need level to vote + $link = "polls"; // your link to polls in index.php + $dark = $config['darkborder']; + $light = $config['lightborder']; + $time = time(); + $POLLS = $db->query('SELECT * FROM '.$db->tableName('z_polls').''); + $level = 20; // need level to vote - if(empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) // list of polls - { - $active = $db->query('SELECT * FROM `z_polls` where `end` > '.$time.''); // active polls - $closed = $db->query('SELECT * FROM `z_polls` where `end` < '.$time.' order by `end` desc'); // closed polls - /* Active Polls */ - echo ''; - echo ''; - $bgcolor = getStyle($number_of_rows++); + if(empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) // list of polls + { + $active = $db->query('SELECT * FROM `z_polls` where `end` > '.$time.''); // active polls + $closed = $db->query('SELECT * FROM `z_polls` where `end` < '.$time.' order by `end` desc'); // closed polls + /* Active Polls */ + echo '
Active Polls
TopicEnd
'; + echo ''; + $bgcolor = getStyle($number_of_rows++); $empty_active = false; - foreach($active as $poll) - { - echo ' - + foreach($active as $poll) + { + echo ' + '; - $empty_active = true; - } + $empty_active = true; + } - if(!$empty_active) - { - echo ''; - } + if(!$empty_active) + { + echo ''; + } - echo "
Active Polls
TopicEnd
There are no active polls.
There are no active polls.


"; - /* Closed Polls */ - echo ''; - echo ''; + echo "
Closed Polls
TopicEnd


"; + /* Closed Polls */ + echo ''; + echo ''; $bgcolor = getStyle($number_of_rows++); $empty_closed = false; - foreach($closed as $poll) - { - echo ' - + foreach($closed as $poll) + { + echo ' + '; - $empty_closed = true; - } + $empty_closed = true; + } - if(!$empty_closed) - { - echo ''; - } + if(!$empty_closed) + { + echo ''; + } - echo "
Closed Polls
TopicEnd
There are no closed polls.
There are no closed polls.
"; - $showed=true; - } + echo ""; + $showed=true; + } if(!$logged) { @@ -104,43 +104,43 @@ function getColorByPercent($percent) return; } - /* Checking Account */ + /* Checking Account */ $allow = false; - $account_players = $account_logged->getPlayers(); - foreach($account_players as $player) - { - $player = $player->getLevel(); - if($player >= $level) - $allow=true; - } + $account_players = $account_logged->getPlayers(); + foreach($account_players as $player) + { + $player = $player->getLevel(); + if($player >= $level) + $allow=true; + } - if(!empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) - { - foreach($POLLS as $POLL) - { - if($_REQUEST['id'] == $POLL['id']) - { - $ANSWERS = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).' order by `answer_id`'); - $votes_all = $POLL['votes_all']; + if(!empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) + { + foreach($POLLS as $POLL) + { + if($_REQUEST['id'] == $POLL['id']) + { + $ANSWERS = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).' order by `answer_id`'); + $votes_all = $POLL['votes_all']; - if($votes_all == 0) - { - $i=1; - foreach($ANSWERS as $answer) - { - $percent[$i] = 0; - $i++; - } - } - else - { - $i=1; - foreach($ANSWERS as $answer) - { - $percent[$i] = round(((100*$answer['votes'])/$votes_all),2); - $i++; - } - } + if($votes_all == 0) + { + $i=1; + foreach($ANSWERS as $answer) + { + $percent[$i] = 0; + $i++; + } + } + else + { + $i=1; + foreach($ANSWERS as $answer) + { + $percent[$i] = round(((100*$answer['votes'])/$votes_all),2); + $i++; + } + } ?>