mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 11:13:27 +02:00
Merge branch 'develop' into feature/phpstan
This commit is contained in:
@@ -106,7 +106,7 @@ else
|
||||
</form>
|
||||
</td>
|
||||
<td align=right>
|
||||
<form action="?subtopic=accountmanagement" method="post" >
|
||||
<form action="' . getLink('account/manage') . '" method="post" >
|
||||
' . csrf(true) . '
|
||||
' . $twig->render('buttons.back.html.twig') . '
|
||||
</form>
|
||||
@@ -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 = '<div style="text-align:center"><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" >' . $twig->render('buttons.back.html.twig') . '</td></tr></form></table></div>';
|
||||
$custom_buttons = '<div style="text-align:center"><table border="0" cellspacing="0" cellpadding="0" ><form action="' . getLink('account/manage') . '" method="post" ><tr><td style="border:0px;" >' . $twig->render('buttons.back.html.twig') . '</td></tr></form></table></div>';
|
||||
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Email Address Change Cancelled',
|
||||
|
@@ -304,7 +304,7 @@ elseif($action == 'step3')
|
||||
$account->setCustomField('salt', $salt);
|
||||
|
||||
echo 'Your account name, new password and new e-mail.<BR>
|
||||
<FORM ACTION="?subtopic=accountmanagement" onsubmit="return validate_form(this)" METHOD=post>
|
||||
<FORM ACTION="' . getLink('account/manage') . '" onsubmit="return validate_form(this)" METHOD=post>
|
||||
<INPUT TYPE=hidden NAME="character" VALUE="">
|
||||
<TABLE CELLSPACING=1 CELLPADDING=4 BORDER=0 WIDTH=100%>
|
||||
<TR><TD BGCOLOR="'.$config['vdarkborder'].'" class="white"><B>Your account name, new password and new e-mail</B></TD></TR>
|
||||
@@ -518,7 +518,7 @@ elseif($action == 'setnewpassword')
|
||||
</TABLE>
|
||||
<BR>
|
||||
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%><TR><TD><div style="text-align:center">
|
||||
<FORM ACTION="?subtopic=accountmanagement" METHOD=post>
|
||||
<FORM ACTION="' . getLink('account/manage') . '" METHOD=post>
|
||||
<INPUT TYPE=image NAME="Login" ALT="Login" SRC="'.$template_path.'/images/global/buttons/sbutton_login.gif" BORDER=0 WIDTH=120 HEIGHT=18></div>
|
||||
</TD></TR></FORM></TABLE></TABLE>';
|
||||
}
|
||||
|
@@ -1,86 +1,3 @@
|
||||
<?php
|
||||
/**
|
||||
* Creatures
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @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']) . '<br/>Chance: ' . $item['rarity'] . (setting('core.monsters_loot_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '<br/>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 <b>" . $creature_name . "</b> doesn't exist.";
|
||||
}
|
||||
|
||||
// back button
|
||||
$twig->display('creatures.back_button.html.twig');
|
||||
require 'monsters.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 = '';
|
||||
}
|
||||
|
@@ -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. <a href="?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=forum') . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return false;
|
||||
}
|
||||
$canEdit = Forum::isModerator();
|
||||
|
||||
$sections = array();
|
||||
foreach(getForumBoards() as $section) {
|
||||
|
@@ -18,6 +18,11 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . BASE_URL . urlencode(getLink('forum')) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return;
|
||||
}
|
||||
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$post_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : false;
|
||||
|
@@ -18,6 +18,11 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . BASE_URL . urlencode(getLink('forum')) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Forum::isModerator()) {
|
||||
echo 'You are not logged in or you are not moderator.';
|
||||
}
|
||||
|
@@ -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. <a href="' . getLink('account/manage') . '?redirect=' . BASE_URL . urlencode(getLink('forum') . $extra_url) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -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. <a href="' . getLink('account/manage') . '?redirect=' . BASE_URL . urlencode(getLink('forum') . $extra_url) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
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;
|
||||
|
@@ -18,6 +18,11 @@ if ($ret === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$logged) {
|
||||
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . BASE_URL . urlencode(getLink('forum')) . '">Log in</a> to post on the forum.<br /><br />';
|
||||
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();
|
||||
|
@@ -46,7 +46,7 @@ echo '<a href="' . getLink('forum') . '">Boards</a> >> <b>'.$sections[$section_i
|
||||
|
||||
if(!$sections[$section_id]['closed'] || Forum::isModerator()) {
|
||||
echo '<br /><br />
|
||||
<a href="?subtopic=forum&action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
<a href="' . getLink('forum') . '?action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
|
||||
echo '<br /><br />Page: '.$links_to_pages.'<br />';
|
||||
@@ -67,8 +67,8 @@ if(isset($last_threads[0])) {
|
||||
foreach($last_threads as $thread) {
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td>';
|
||||
if(Forum::isModerator()) {
|
||||
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><span style="color: red">[REMOVE]</span></a> ';
|
||||
echo '<a href="' . getLink('forum') . '?action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<a href="' . getLink('forum') . '?action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><span style="color: red">[REMOVE]</span></a> ';
|
||||
}
|
||||
|
||||
$player->load($thread['player_id']);
|
||||
@@ -95,7 +95,7 @@ if(isset($last_threads[0])) {
|
||||
|
||||
echo '</table>';
|
||||
if(!$sections[$section_id]['closed'] || Forum::isModerator()) {
|
||||
echo '<br /><a href="?subtopic=forum&action=new_thread§ion_id=' . $section_id . '"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
echo '<br /><a href="' . getLink('forum') . '?action=new_thread§ion_id=' . $section_id . '"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -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'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -69,6 +69,6 @@ if(!empty($errors)) {
|
||||
|
||||
$twig->display('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => '?subtopic=guilds'
|
||||
'action' => getLink('guilds')
|
||||
));
|
||||
}
|
||||
|
@@ -121,7 +121,7 @@ if(!empty($errors)) {
|
||||
|
||||
$twig->display('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => '?subtopic=guilds'
|
||||
'action' => getLink('guilds')
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
@@ -72,6 +72,6 @@ if(!empty($errors)) {
|
||||
|
||||
$twig->display('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => '?subtopic=guilds'
|
||||
'action' => getLink('guilds')
|
||||
));
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ if(empty($errors)) {
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Delete Guild',
|
||||
'description' => 'Are you sure you want delete guild <b>' . $guild_name . '</b>?<br/>
|
||||
<form action="?subtopic=guilds&guild=' . $guild->getName() . '&action=delete_by_admin" METHOD="post"><input type="hidden" name="todo" value="save"><input type="submit" value="Yes, delete"></form>',
|
||||
<form action="' . getLink('guilds') . '?guild=' . $guild->getName() . '&action=delete_by_admin" METHOD="post"><input type="hidden" name="todo" value="save"><input type="submit" value="Yes, delete"></form>',
|
||||
'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')
|
||||
));
|
||||
}
|
||||
|
@@ -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 <b>' . $player->getName() . '</b> 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 {
|
||||
|
@@ -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')
|
||||
));
|
||||
}
|
||||
|
@@ -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 '<br/><div style="text-align:center"><form action="?subtopic=guilds&guild='.$guild->getName().'&action=pass_leadership" method="post">' . $twig->render('buttons.back.html.twig') . '</form></div>';
|
||||
echo '<br/><div style="text-align:center"><form action="' . getLink('guilds') . '?guild='.$guild->getName().'&action=pass_leadership" method="post">' . $twig->render('buttons.back.html.twig') . '</form></div>';
|
||||
}
|
||||
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 '<br/><div style="text-align:center"><form action="?subtopic=guilds" method="post">' . $twig->render('buttons.back.html.twig') . '</form></div>';
|
||||
echo '<br/><div style="text-align:center"><form action="' . getLink('guilds') . '" method="post">' . $twig->render('buttons.back.html.twig') . '</form></div>';
|
||||
}
|
||||
|
@@ -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
|
||||
|
86
system/pages/monsters.php
Normal file
86
system/pages/monsters.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Monsters
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @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']) . '<br/>Chance: ' . $item['rarity'] . (setting('core.monsters_loot_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '<br/>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 <b>" . $monster_name . "</b> doesn't exist.";
|
||||
}
|
||||
|
||||
// back button
|
||||
$twig->display('monsters.back_button.html.twig');
|
@@ -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 '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 class=white><B>Active Polls</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><td width=75%><b>Topic</b></td><td><b>End</b></td></tr>';
|
||||
$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 '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 class=white><B>Active Polls</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><td width=75%><b>Topic</b></td><td><b>End</b></td></tr>';
|
||||
$bgcolor = getStyle($number_of_rows++);
|
||||
$empty_active = false;
|
||||
foreach($active as $poll)
|
||||
{
|
||||
echo '
|
||||
<tr BGCOLOR="'.$bgcolor.'">
|
||||
foreach($active as $poll)
|
||||
{
|
||||
echo '
|
||||
<tr BGCOLOR="'.$bgcolor.'">
|
||||
<td>
|
||||
<a href="';
|
||||
if($logged)
|
||||
echo '?subtopic='.$link.'&id='.$poll['id'];
|
||||
echo $link.'?id='.$poll['id'];
|
||||
else
|
||||
echo '?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic='.$link.'&id='.$poll['id']);
|
||||
echo getLink('account/manage') . '?redirect=' . BASE_URL . urlencode($link.'?id='.$poll['id']);
|
||||
|
||||
echo '">'.$poll['question'] . '</a>
|
||||
</td>
|
||||
<td>'.date("M j Y", $poll['end']).'</td>
|
||||
</tr>';
|
||||
$empty_active = true;
|
||||
}
|
||||
$empty_active = true;
|
||||
}
|
||||
|
||||
if(!$empty_active)
|
||||
{
|
||||
echo '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><div style="text-align:center"><i>There are no active polls.</i></div></td></tr>';
|
||||
}
|
||||
if(!$empty_active)
|
||||
{
|
||||
echo '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><div style="text-align:center"><i>There are no active polls.</i></div></td></tr>';
|
||||
}
|
||||
|
||||
echo "</table><br><br>";
|
||||
/* Closed Polls */
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 class=white><B>Closed Polls</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><td width=75%><b>Topic</b></td><td><b>End</b></td></tr>';
|
||||
echo "</table><br><br>";
|
||||
/* Closed Polls */
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 class=white><B>Closed Polls</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><td width=75%><b>Topic</b></td><td><b>End</b></td></tr>';
|
||||
$bgcolor = getStyle($number_of_rows++);
|
||||
$empty_closed = false;
|
||||
foreach($closed as $poll)
|
||||
{
|
||||
echo '
|
||||
<tr BGCOLOR="'.$bgcolor.'">
|
||||
foreach($closed as $poll)
|
||||
{
|
||||
echo '
|
||||
<tr BGCOLOR="'.$bgcolor.'">
|
||||
<td>
|
||||
<a href="';
|
||||
if($logged)
|
||||
echo '?subtopic='.$link.'&id='.$poll['id'];
|
||||
echo $link.'?id='.$poll['id'];
|
||||
else
|
||||
echo '?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic='.$link.'&id='.$poll['id']);
|
||||
echo getLink('account/manage') . '?redirect=' . BASE_URL . urlencode($link.'?id='.$poll['id']);
|
||||
|
||||
echo '">'.$poll['question'] . '</a>
|
||||
</td>
|
||||
<td>'.date("M j Y", $poll['end']).'</td>
|
||||
</tr>';
|
||||
$empty_closed = true;
|
||||
}
|
||||
$empty_closed = true;
|
||||
}
|
||||
|
||||
if(!$empty_closed)
|
||||
{
|
||||
echo '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><div style="text-align:center"><i>There are no closed polls.</i></div></td></tr>';
|
||||
}
|
||||
if(!$empty_closed)
|
||||
{
|
||||
echo '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><div style="text-align:center"><i>There are no closed polls.</i></div></td></tr>';
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
$showed=true;
|
||||
}
|
||||
echo "</table>";
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<style type="text/css" media="screen">
|
||||
div.progress-container {
|
||||
@@ -166,51 +166,51 @@ function getColorByPercent($percent)
|
||||
</div>';
|
||||
}
|
||||
|
||||
if($POLL['end'] > $time) // active poll
|
||||
{
|
||||
if(isset($_REQUEST['vote']) && $_REQUEST['vote'] == true and $allow == true)
|
||||
{
|
||||
if($account_logged->getCustomField('vote') < $_REQUEST['id'] and !empty($_POST['answer']))
|
||||
{
|
||||
if(isset($_POST['continue']))
|
||||
{
|
||||
$vote = addslashes(htmlspecialchars(trim($_REQUEST['id'])));
|
||||
$account_logged->setCustomField("vote", $vote);
|
||||
$UPDATE_poll = $db->query('UPDATE `z_polls` SET `votes_all` = `votes_all` + 1 where `id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).'');
|
||||
$UPDATE_answer = $db->query('UPDATE `z_polls_answers` SET `votes` = `votes` + 1 where `answer_id` = '.addslashes(htmlspecialchars($_POST['answer'])).' and`poll_id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).'');
|
||||
header('Location: ?subtopic='.$link.'&id='.$_REQUEST['id'].'');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: ?subtopic='.$link.'&id='.$_REQUEST['id'].'');
|
||||
}
|
||||
}
|
||||
if($POLL['end'] > $time) // active poll
|
||||
{
|
||||
if(isset($_REQUEST['vote']) && $_REQUEST['vote'] == true and $allow == true)
|
||||
{
|
||||
if($account_logged->getCustomField('vote') < $_REQUEST['id'] and !empty($_POST['answer']))
|
||||
{
|
||||
if(isset($_POST['continue']))
|
||||
{
|
||||
$vote = addslashes(htmlspecialchars(trim($_REQUEST['id'])));
|
||||
$account_logged->setCustomField("vote", $vote);
|
||||
$UPDATE_poll = $db->query('UPDATE `z_polls` SET `votes_all` = `votes_all` + 1 where `id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).'');
|
||||
$UPDATE_answer = $db->query('UPDATE `z_polls_answers` SET `votes` = `votes` + 1 where `answer_id` = '.addslashes(htmlspecialchars($_POST['answer'])).' and`poll_id` = '.addslashes(htmlspecialchars(trim($_REQUEST['id']))).'');
|
||||
header('Location: ' . $link.'?id='.$_REQUEST['id'].'');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: ' . $link.'?id='.$_REQUEST['id'].'');
|
||||
}
|
||||
}
|
||||
|
||||
if($account_logged->getCustomField('vote') < $_REQUEST['id'] and $allow == true)
|
||||
{
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 class=white><B>Vote</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="'.$dark.'"><td COLSPAN=2><b>'.$POLL['question'].'</b><br/>' . $POLL['description'] . '</td></tr>
|
||||
<form action="?subtopic='.$link.'&id='.$_REQUEST['id'].'&vote=true" method="POST"> ';
|
||||
$ANSWERS_input = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`');
|
||||
$i=1;
|
||||
foreach($ANSWERS_input as $answer)
|
||||
{
|
||||
if(is_int($i / 2)) {
|
||||
$bgcolor = $dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgcolor = $light;
|
||||
}
|
||||
echo '<tr BGCOLOR="'.$bgcolor.'"><td><input type=radio name=answer value="'.$i.'">'.$answer['answer'].'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
echo '</table><input type="submit" name="continue" value="Submit" class="input2" /></form><br><br>';
|
||||
}
|
||||
elseif($account_logged->getCustomField('vote') >= $_REQUEST['id'])
|
||||
{
|
||||
$result[] = '<br><b>You have already voted.</b><br>';
|
||||
if($account_logged->getCustomField('vote') < $_REQUEST['id'] and $allow == true)
|
||||
{
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 class=white><B>Vote</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="'.$dark.'"><td COLSPAN=2><b>'.$POLL['question'].'</b><br/>' . $POLL['description'] . '</td></tr>
|
||||
<form action="' . $link . '?id='.$_REQUEST['id'].'&vote=true" method="POST"> ';
|
||||
$ANSWERS_input = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`');
|
||||
$i=1;
|
||||
foreach($ANSWERS_input as $answer)
|
||||
{
|
||||
if(is_int($i / 2)) {
|
||||
$bgcolor = $dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgcolor = $light;
|
||||
}
|
||||
echo '<tr BGCOLOR="'.$bgcolor.'"><td><input type=radio name=answer value="'.$i.'">'.$answer['answer'].'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
echo '</table><input type="submit" name="continue" value="Submit" class="input2" /></form><br><br>';
|
||||
}
|
||||
elseif($account_logged->getCustomField('vote') >= $_REQUEST['id'])
|
||||
{
|
||||
$result[] = '<br><b>You have already voted.</b><br>';
|
||||
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=3 class=white><B>Results</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="'.$dark.'"><td COLSPAN=3><b>'.$POLL['question'].'</b><br/>' . $POLL['description'] . '</td></tr>';
|
||||
@@ -239,31 +239,31 @@ function getColorByPercent($percent)
|
||||
}
|
||||
|
||||
$result[] = '<br>All players with a character of at least level ' . $level . ' may vote.<br>';
|
||||
foreach($result as $error)
|
||||
{
|
||||
echo $error;
|
||||
}
|
||||
foreach($result as $error)
|
||||
{
|
||||
echo $error;
|
||||
}
|
||||
|
||||
echo '<br>The poll started at '.date("M j Y", $POLL['start']).'<br>';
|
||||
echo 'The poll will end at '.date("M j Y", $POLL['end']).'<br>';
|
||||
echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>';
|
||||
echo '<br>The poll started at '.date("M j Y", $POLL['start']).'<br>';
|
||||
echo 'The poll will end at '.date("M j Y", $POLL['end']).'<br>';
|
||||
echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>';
|
||||
|
||||
}
|
||||
else // closed poll
|
||||
{
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=3 class=white><B>Results</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="'.$dark.'"><td COLSPAN=3><b>'.$POLL['question'].'</b></td></tr>';
|
||||
$ANSWERS_show = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`');
|
||||
$i=1;
|
||||
foreach($ANSWERS_show as $answer)
|
||||
{
|
||||
if(is_int($i / 2)) {
|
||||
$bgcolor = $dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgcolor = $light;
|
||||
}
|
||||
}
|
||||
else // closed poll
|
||||
{
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=3 class=white><B>Results</B></TD></TR>';
|
||||
echo '<TR BGCOLOR="'.$dark.'"><td COLSPAN=3><b>'.$POLL['question'].'</b></td></tr>';
|
||||
$ANSWERS_show = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`');
|
||||
$i=1;
|
||||
foreach($ANSWERS_show as $answer)
|
||||
{
|
||||
if(is_int($i / 2)) {
|
||||
$bgcolor = $dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgcolor = $light;
|
||||
}
|
||||
|
||||
echo '<TR BGCOLOR="'.$bgcolor.'">
|
||||
<td width=60%>'.$answer['answer'].'</td>
|
||||
@@ -272,64 +272,64 @@ function getColorByPercent($percent)
|
||||
</td>
|
||||
<td>' . $answer['votes'] . '(<span style="color:' . getColorByPercent($percent[$i]) . '"><b>' . $percent[$i] . '%</b></span>)</td>
|
||||
</tr>';
|
||||
$i++;
|
||||
}
|
||||
echo '</table><br><br>';
|
||||
$i++;
|
||||
}
|
||||
echo '</table><br><br>';
|
||||
|
||||
echo '<br>The poll started at '.date("M j Y", $POLL['start']).'<br>';
|
||||
echo 'The poll ended at '.date("M j Y", $POLL['end']).'<br>';
|
||||
echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>';
|
||||
echo '<br>The poll started at '.date("M j Y", $POLL['start']).'<br>';
|
||||
echo 'The poll ended at '.date("M j Y", $POLL['end']).'<br>';
|
||||
echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>';
|
||||
|
||||
}
|
||||
$showed=true;
|
||||
echo '<div class=\'hr1\'></div><a href="?subtopic='.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$showed=true;
|
||||
echo '<div class=\'hr1\'></div><a href="'.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(admin() && (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true"))
|
||||
{
|
||||
echo '<br><a href="?subtopic='.$link.'&control=true"><b>Panel Control</b></a><br><br>';
|
||||
}
|
||||
if(admin() && (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true"))
|
||||
{
|
||||
echo '<br><a href="'.$link.'?control=true"><b>Panel Control</b></a><br><br>';
|
||||
}
|
||||
|
||||
/* Control Panel - Only Add Poll Function */
|
||||
/* Control Panel - Only Add Poll Function */
|
||||
|
||||
if(admin() && isset($_REQUEST['control']) && $_REQUEST['control'] == "true")
|
||||
{
|
||||
if(admin() && isset($_REQUEST['control']) && $_REQUEST['control'] == "true")
|
||||
{
|
||||
$show = false;
|
||||
if(isset($_POST['submit']))
|
||||
{
|
||||
setSession('answers', $_POST['answers']);
|
||||
echo '<form method="post" action=""><b><span style="font-size: 16px">Adding Poll</span></b><br><br>
|
||||
<input type=text name=question value="" /> Question<br>
|
||||
<input type=text name=description value="" /> Description<br>
|
||||
<input type=text name=end value="" /> Time to end, in days<br>';
|
||||
if(isset($_POST['submit']))
|
||||
{
|
||||
setSession('answers', $_POST['answers']);
|
||||
echo '<form method="post" action=""><b><span style="font-size: 16px">Adding Poll</span></b><br><br>
|
||||
<input type=text name=question value="" /> Question<br>
|
||||
<input type=text name=description value="" /> Description<br>
|
||||
<input type=text name=end value="" /> Time to end, in days<br>';
|
||||
|
||||
for( $x = 1; $x <= getSession('answers'); $x++ )
|
||||
{
|
||||
echo '<input type=text name='.$x.' value="" /> Answer no. '.$x.'<br>';
|
||||
}
|
||||
echo '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
|
||||
$show=true;
|
||||
}
|
||||
for( $x = 1; $x <= getSession('answers'); $x++ )
|
||||
{
|
||||
echo '<input type=text name='.$x.' value="" /> Answer no. '.$x.'<br>';
|
||||
}
|
||||
echo '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
|
||||
$show=true;
|
||||
}
|
||||
|
||||
if(isset($_POST['finish']))
|
||||
{
|
||||
$id = $db->query('SELECT MAX(id) FROM `z_polls`')->fetch();
|
||||
$id_next = $id[0] + 1;
|
||||
if(isset($_POST['finish']))
|
||||
{
|
||||
$id = $db->query('SELECT MAX(id) FROM `z_polls`')->fetch();
|
||||
$id_next = $id[0] + 1;
|
||||
|
||||
for( $x = 1; $x <= getSession('answers'); $x++ )
|
||||
{
|
||||
$db->insert('z_polls_answers', array(
|
||||
'poll_id' => $id_next,
|
||||
for( $x = 1; $x <= getSession('answers'); $x++ )
|
||||
{
|
||||
$db->insert('z_polls_answers', array(
|
||||
'poll_id' => $id_next,
|
||||
'answer_id' => $x,
|
||||
'answer' => $_POST[$x],
|
||||
'votes' => 0
|
||||
));
|
||||
}
|
||||
$end = $time+24*60*60*$_POST['end'];
|
||||
$db->insert('z_polls', array(
|
||||
'id' => $id_next,
|
||||
}
|
||||
$end = $time+24*60*60*$_POST['end'];
|
||||
$db->insert('z_polls', array(
|
||||
'id' => $id_next,
|
||||
'question' => $_POST['question'],
|
||||
'description' => $_POST['description'],
|
||||
'end' => $end,
|
||||
@@ -337,35 +337,35 @@ function getColorByPercent($percent)
|
||||
'start' => $time,
|
||||
'votes_all' => 0
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$POLLS_check = $db->query('SELECT MAX(end) FROM '.$db->tableName('z_polls').'');
|
||||
foreach($POLLS_check as $checked)
|
||||
{
|
||||
if($checked[0] > $time)
|
||||
$check=true;
|
||||
else
|
||||
$check=false;
|
||||
}
|
||||
if(!$show)
|
||||
{
|
||||
if(!$check)
|
||||
{
|
||||
echo '<form method="post" action=""><b><span style="font-size: 16px">Adding Poll</span></b><br><br>
|
||||
<input type=text name=answers value="" /> Number of Answers<br>
|
||||
<input type="submit" name="submit" value="Submit" class="input2"/></form><br><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<b><span style="font-size: 16px"><br>Cannot be two and more active polls.<br><br></span></b>';
|
||||
}
|
||||
}
|
||||
$showed=true;
|
||||
echo '<br><div class=\'hr1\'></div><a href="?subtopic='.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
|
||||
}
|
||||
$POLLS_check = $db->query('SELECT MAX(end) FROM '.$db->tableName('z_polls').'');
|
||||
foreach($POLLS_check as $checked)
|
||||
{
|
||||
if($checked[0] > $time)
|
||||
$check=true;
|
||||
else
|
||||
$check=false;
|
||||
}
|
||||
if(!$show)
|
||||
{
|
||||
if(!$check)
|
||||
{
|
||||
echo '<form method="post" action=""><b><span style="font-size: 16px">Adding Poll</span></b><br><br>
|
||||
<input type=text name=answers value="" /> Number of Answers<br>
|
||||
<input type="submit" name="submit" value="Submit" class="input2"/></form><br><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<b><span style="font-size: 16px"><br>Cannot be two and more active polls.<br><br></span></b>';
|
||||
}
|
||||
}
|
||||
$showed=true;
|
||||
echo '<br><div class=\'hr1\'></div><a href="'.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
|
||||
}
|
||||
|
||||
if(!$showed)
|
||||
{
|
||||
echo 'This poll doesn\'t exist.<br>';
|
||||
echo '<div class=\'hr1\'></div><a href="?subtopic='.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
|
||||
}
|
||||
if(!$showed)
|
||||
{
|
||||
echo 'This poll doesn\'t exist.<br>';
|
||||
echo '<div class=\'hr1\'></div><a href="'.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
|
||||
}
|
||||
|
Reference in New Issue
Block a user