diff --git a/CHANGELOG.md b/CHANGELOG.md index 8098fcc0..cc04b286 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. @@ -57,7 +57,7 @@ Minimum PHP version for this release is 8.1. * Highscores * frags works for TFS 1.x * cached - * creatures + * Monsters * moved pages to Twig: * experience stages * update player_deaths entries on name change 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> 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/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 diff --git a/system/compat/base.php b/system/compat/base.php index 1a606be3..d29c9f3a 100644 --- a/system/compat/base.php +++ b/system/compat/base.php @@ -74,4 +74,7 @@ function fieldExist($field, $table) global $db; return $db->hasColumn($table, $field); } -?> + +function getCreatureImgPath($creature): string { + return getMonsterImgPath($creature); +} diff --git a/system/functions.php b/system/functions.php index 80a1b2a6..b1e49270 100644 --- a/system/functions.php +++ b/system/functions.php @@ -105,7 +105,7 @@ function getPlayerLink($name, $generate = true): string function getMonsterLink($name, $generate = true): string { - $url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'creatures/' . urlencode($name); + $url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'monsters/' . urlencode($name); if(!$generate) return $url; return generateLink($url, $name); @@ -1559,18 +1559,19 @@ function right($str, $length) { return substr($str, -$length); } -function getCreatureImgPath($creature){ - $creature_path = setting('core.monsters_images_url'); - $creature_gfx_name = trim(strtolower($creature)) . setting('core.monsters_images_extension'); - if (!file_exists($creature_path . $creature_gfx_name)) { - $creature_gfx_name = str_replace(" ", "", $creature_gfx_name); - if (file_exists($creature_path . $creature_gfx_name)) { - return $creature_path . $creature_gfx_name; +function getMonsterImgPath($monster): string +{ + $monster_path = setting('core.monsters_images_url'); + $monster_gfx_name = trim(strtolower($monster)) . setting('core.monsters_images_extension'); + if (!file_exists($monster_path . $monster_gfx_name)) { + $monster_gfx_name = str_replace(" ", "", $monster_gfx_name); + if (file_exists($monster_path . $monster_gfx_name)) { + return $monster_path . $monster_gfx_name; } else { - return $creature_path . 'nophoto.png'; + return $monster_path . 'nophoto.png'; } } else { - return $creature_path . $creature_gfx_name; + return $monster_path . $monster_gfx_name; } } diff --git a/system/migrations/40.php b/system/migrations/40.php new file mode 100644 index 00000000..7a7eb310 --- /dev/null +++ b/system/migrations/40.php @@ -0,0 +1,12 @@ +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']); +Menu::where('link', 'creatures')->update(['link' => 'monsters']); diff --git a/system/pages/account/change_email.php b/system/pages/account/change_email.php index 811cebb4..954d596b 100644 --- a/system/pages/account/change_email.php +++ b/system/pages/account/change_email.php @@ -106,7 +106,7 @@ else -
+ ' . csrf(true) . ' ' . $twig->render('buttons.back.html.twig') . '
@@ -164,7 +164,7 @@ if(isset($_POST['emailchangecancel']) && $_POST['emailchangecancel'] == 1) { $account_logged->setCustomField("email_new", ""); $account_logged->setCustomField("email_new_time", 0); - $custom_buttons = '
' . $twig->render('buttons.back.html.twig') . '
'; + $custom_buttons = '
' . $twig->render('buttons.back.html.twig') . '
'; $twig->display('success.html.twig', array( 'title' => 'Email Address Change Cancelled', diff --git a/system/pages/account/lost.php b/system/pages/account/lost.php index d01782cd..79c739cb 100644 --- a/system/pages/account/lost.php +++ b/system/pages/account/lost.php @@ -304,7 +304,7 @@ elseif($action == 'step3') $account->setCustomField('salt', $salt); echo 'Your account name, new password and new e-mail.
-
+ @@ -518,7 +518,7 @@ elseif($action == 'setnewpassword')
Your account name, new password and new e-mail

- +
'; } diff --git a/system/pages/creatures.php b/system/pages/creatures.php index adafa037..931e55cd 100644 --- a/system/pages/creatures.php +++ b/system/pages/creatures.php @@ -1,86 +1,3 @@ - * @author Slawkens - * @author Lee - * @copyright 2020 MyAAC - * @link https://my-aac.org - */ -use MyAAC\Models\Monster; - -defined('MYAAC') or die('Direct access not allowed!'); -$title = 'Creatures'; - -if (empty($_REQUEST['name'])) { - // display list of monsters - $preview = setting('core.monsters_images_preview'); - $creatures = Monster::where('hide', '!=', 1)->when(!empty($_REQUEST['boss']), function ($query) { - $query->where('rewardboss', 1); - })->get()->toArray(); - - if ($preview) { - foreach($creatures as $key => &$creature) - { - $creature['img_link'] = getCreatureImgPath($creature['name']); - } - } - - $twig->display('creatures.html.twig', array( - 'creatures' => $creatures, - 'preview' => $preview - )); - - return; -} - -// display monster -$creature_name = urldecode(stripslashes(ucwords(strtolower($_REQUEST['name'])))); -$creature = Monster::where('hide', '!=', 1)->where('name', $creature_name)->first()->toArray(); - -if (isset($creature['name'])) { - function sort_by_chance($a, $b) - { - if ($a['chance'] == $b['chance']) { - return 0; - } - return ($a['chance'] > $b['chance']) ? -1 : 1; - } - - $title = $creature['name'] . " - Creatures"; - - $creature['img_link']= getCreatureImgPath($creature_name); - - $voices = json_decode($creature['voices'], true); - $summons = json_decode($creature['summons'], true); - $elements = json_decode($creature['elements'], true); - $immunities = json_decode($creature['immunities'], true); - $loot = json_decode($creature['loot'], true); - usort($loot, 'sort_by_chance'); - - foreach ($loot as &$item) { - $item['name'] = getItemNameById($item['id']); - $item['rarity_chance'] = round($item['chance'] / 1000, 2); - $item['rarity'] = getItemRarity($item['chance']); - $item['tooltip'] = ucfirst($item['name']) . '
Chance: ' . $item['rarity'] . (setting('core.monsters_loot_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '
Max count: ' . $item['count']; - } - - $creature['loot'] = isset($loot) ? $loot : null; - $creature['voices'] = isset($voices) ? $voices : null; - $creature['summons'] = isset($summons) ? $summons : null; - $creature['elements'] = isset($elements) ? $elements : null; - $creature['immunities'] = isset($immunities) ? $immunities : null; - - $twig->display('creature.html.twig', array( - 'creature' => $creature, - )); - -} else { - echo "Creature with name " . $creature_name . " doesn't exist."; -} - -// back button -$twig->display('creatures.back_button.html.twig'); +require 'monsters.php'; 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..f42b743f 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..86305b4d 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..659b4037 100644 --- a/system/pages/forum/new_post.php +++ b/system/pages/forum/new_post.php @@ -21,10 +21,10 @@ if ($ret === false) { if(!$logged) { $extra_url = ''; if(isset($_GET['thread_id'])) { - $extra_url = '&action=new_post&thread_id=' . $_GET['thread_id']; + $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..7b97f30e 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..3e234e6f 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/pages/forum/show_board.php b/system/pages/forum/show_board.php index 710a0f05..5d61690a 100644 --- a/system/pages/forum/show_board.php +++ b/system/pages/forum/show_board.php @@ -46,7 +46,7 @@ echo 'Boards >> '.$sections[$section_i if(!$sections[$section_id]['closed'] || Forum::isModerator()) { echo '

- '; + '; } echo '

Page: '.$links_to_pages.'
'; @@ -67,8 +67,8 @@ if(isset($last_threads[0])) { foreach($last_threads as $thread) { echo ''; if(Forum::isModerator()) { - echo '[MOVE]'; - echo '[REMOVE] '; + echo '[MOVE]'; + echo '[REMOVE] '; } $player->load($thread['player_id']); @@ -95,7 +95,7 @@ if(isset($last_threads[0])) { echo ''; if(!$sections[$section_id]['closed'] || Forum::isModerator()) { - echo '
'; + echo '
'; } } else { diff --git a/system/pages/guilds/add_rank.php b/system/pages/guilds/add_rank.php index 0c510bb1..e66ba49e 100644 --- a/system/pages/guilds/add_rank.php +++ b/system/pages/guilds/add_rank.php @@ -49,7 +49,7 @@ if(empty($errors)) { $new_rank->setLevel(1); $new_rank->setName($rank_name); $new_rank->save(); - header("Location: ?subtopic=guilds&guild=".$guild->getName()."&action=manager"); + header("Location: " . getLink('guilds') . "?guild=".$guild->getName()."&action=manager"); echo 'New rank added. Redirecting...'; } else { @@ -61,7 +61,7 @@ if(empty($errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds&guild='.$guild_name.'&action=show' + 'action' => getLink('guilds') . '?guild='.$guild_name.'&action=show' )); } } diff --git a/system/pages/guilds/change_description.php b/system/pages/guilds/change_description.php index a1e7b1d7..765665bf 100644 --- a/system/pages/guilds/change_description.php +++ b/system/pages/guilds/change_description.php @@ -69,6 +69,6 @@ if(!empty($errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds' + 'action' => getLink('guilds') )); } diff --git a/system/pages/guilds/change_logo.php b/system/pages/guilds/change_logo.php index eee33582..d8257e66 100644 --- a/system/pages/guilds/change_logo.php +++ b/system/pages/guilds/change_logo.php @@ -121,7 +121,7 @@ if(!empty($errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds' + 'action' => getLink('guilds') )); } ?> diff --git a/system/pages/guilds/change_motd.php b/system/pages/guilds/change_motd.php index 7d546670..babb806c 100644 --- a/system/pages/guilds/change_motd.php +++ b/system/pages/guilds/change_motd.php @@ -72,6 +72,6 @@ if(!empty($errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds' + 'action' => getLink('guilds') )); } diff --git a/system/pages/guilds/delete_by_admin.php b/system/pages/guilds/delete_by_admin.php index 7da54aea..e403cbda 100644 --- a/system/pages/guilds/delete_by_admin.php +++ b/system/pages/guilds/delete_by_admin.php @@ -45,7 +45,7 @@ if(empty($errors)) { $twig->display('success.html.twig', array( 'title' => 'Delete Guild', 'description' => 'Are you sure you want delete guild ' . $guild_name . '?
-
', +
', 'custom_buttons' => $twig->render('guilds.back_button.html.twig') )); } @@ -63,6 +63,6 @@ if(!empty($errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds' + 'action' => getLink('guilds') )); } diff --git a/system/pages/guilds/delete_invite.php b/system/pages/guilds/delete_invite.php index 1bf5f730..7bf4067a 100644 --- a/system/pages/guilds/delete_invite.php +++ b/system/pages/guilds/delete_invite.php @@ -96,7 +96,7 @@ if(!empty($errors)) { $twig->display('error_box.html.twig', array('errors' => $errors)); - $twig->display('guilds.back_button.html.twig', array('action' => '?subtopic=guilds&action=show&guild=' . $guild_name)); + $twig->display('guilds.back_button.html.twig', array('action' => getLink('guilds') . '?action=show&guild=' . $guild_name)); } else { @@ -106,7 +106,7 @@ else $twig->display('success.html.twig', array( 'title' => 'Deleted player invitation', 'description' => 'Player with name ' . $player->getName() . ' has been deleted from invites list.', - 'custom_buttons' => $twig->render('guilds.back_button.html.twig', array('action' => '?subtopic=guilds&action=show&guild=' . $guild_name)) + 'custom_buttons' => $twig->render('guilds.back_button.html.twig', array('action' => getLink('guilds') . '?action=show&guild=' . $guild_name)) )); } else { diff --git a/system/pages/guilds/delete_rank.php b/system/pages/guilds/delete_rank.php index 48eeba4d..56322cd9 100644 --- a/system/pages/guilds/delete_rank.php +++ b/system/pages/guilds/delete_rank.php @@ -104,7 +104,7 @@ if(empty($guild_errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds&guild='.$guild->getName().'&action=manager' + 'action' => getLink('guilds') . '?guild='.$guild->getName().'&action=manager' )); } else @@ -122,6 +122,6 @@ if(!empty($guild_errors)) { $twig->display('guilds.back_button.html.twig', array( 'new_line' => true, - 'action' => '?subtopic=guilds' + 'action' => getLink('guilds') )); } diff --git a/system/pages/guilds/pass_leadership.php b/system/pages/guilds/pass_leadership.php index 065e4c3b..c09b4285 100644 --- a/system/pages/guilds/pass_leadership.php +++ b/system/pages/guilds/pass_leadership.php @@ -109,7 +109,7 @@ if(empty($guild_errors) && empty($guild_errors2)) { if(empty($guild_errors) && !empty($guild_errors2)) { $twig->display('error_box.html.twig', array('errors' => $guild_errors2)); - echo '
' . $twig->render('buttons.back.html.twig') . '
'; + echo '
' . $twig->render('buttons.back.html.twig') . '
'; } if(!empty($guild_errors)) { if(!empty($guild_errors2)) { @@ -117,5 +117,5 @@ if(!empty($guild_errors)) { } $twig->display('error_box.html.twig', array('errors' => $guild_errors)); - echo '
' . $twig->render('buttons.back.html.twig') . '
'; + echo '
' . $twig->render('buttons.back.html.twig') . '
'; } diff --git a/system/pages/guilds/save_ranks.php b/system/pages/guilds/save_ranks.php index 65e047bb..e1483659 100644 --- a/system/pages/guilds/save_ranks.php +++ b/system/pages/guilds/save_ranks.php @@ -63,7 +63,7 @@ if(empty($errors)) { } //show errors or redirect if(empty($errors)) { - header("Location: ?subtopic=guilds&action=manager&guild=".$guild->getName()); + header("Location: " . getLink('guilds') . "?action=manager&guild=".$guild->getName()); } } else diff --git a/system/pages/monsters.php b/system/pages/monsters.php new file mode 100644 index 00000000..17252438 --- /dev/null +++ b/system/pages/monsters.php @@ -0,0 +1,86 @@ + + * @author Slawkens + * @author Lee + * @copyright 2020 MyAAC + * @link https://my-aac.org + */ + +use MyAAC\Models\Monster; + +defined('MYAAC') or die('Direct access not allowed!'); +$title = 'Monsters'; + +if (empty($_REQUEST['name'])) { + // display list of monsters + $preview = setting('core.monsters_images_preview'); + $monsters = Monster::where('hide', '!=', 1)->when(!empty($_REQUEST['boss']), function ($query) { + $query->where('rewardboss', 1); + })->get()->toArray(); + + if ($preview) { + foreach($monsters as $key => &$monster) + { + $monster['img_link'] = getMonsterImgPath($monster['name']); + } + } + + $twig->display('monsters.html.twig', array( + 'monsters' => $monsters, + 'preview' => $preview + )); + + return; +} + +// display monster +$monster_name = urldecode(stripslashes(ucwords(strtolower($_REQUEST['name'])))); +$monster = Monster::where('hide', '!=', 1)->where('name', $monster_name)->first()->toArray(); + +if (isset($monster['name'])) { + function sort_by_chance($a, $b) + { + if ($a['chance'] == $b['chance']) { + return 0; + } + return ($a['chance'] > $b['chance']) ? -1 : 1; + } + + $title = $monster['name'] . " - Monsters"; + + $monster['img_link']= getMonsterImgPath($monster_name); + + $voices = json_decode($monster['voices'], true); + $summons = json_decode($monster['summons'], true); + $elements = json_decode($monster['elements'], true); + $immunities = json_decode($monster['immunities'], true); + $loot = json_decode($monster['loot'], true); + usort($loot, 'sort_by_chance'); + + foreach ($loot as &$item) { + $item['name'] = getItemNameById($item['id']); + $item['rarity_chance'] = round($item['chance'] / 1000, 2); + $item['rarity'] = getItemRarity($item['chance']); + $item['tooltip'] = ucfirst($item['name']) . '
Chance: ' . $item['rarity'] . (setting('core.monsters_loot_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '
Max count: ' . $item['count']; + } + + $monster['loot'] = $loot ?? null; + $monster['voices'] = $voices ?? null; + $monster['summons'] = $summons ?? null; + $monster['elements'] = $elements ?? null; + $monster['immunities'] = $immunities ?? null; + + $twig->display('monster.html.twig', array( + 'monster' => $monster, + )); + +} else { + echo "Monster with name " . $monster_name . " doesn't exist."; +} + +// back button +$twig->display('monsters.back_button.html.twig'); diff --git a/system/pages/polls.php b/system/pages/polls.php index dcc781c2..21549891 100644 --- a/system/pages/polls.php +++ b/system/pages/polls.php @@ -26,77 +26,77 @@ 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 = getLink('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
'.$poll['question'] . ' '.date("M j Y", $poll['end']).'
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
'.$poll['question'] . ' '.date("M j Y", $poll['end']).'
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++; + } + } ?>