2
0
mirror of https://github.com/slawkens/myaac.git synced 2025-05-03 12:49:20 +02:00

Change spaces to tabs

This commit is contained in:
slawkens 2024-02-03 20:30:21 +01:00
parent 00cbce20b0
commit b22dc0014a

@ -26,26 +26,26 @@ function getColorByPercent($percent)
} }
$number_of_rows = 0; $number_of_rows = 0;
$showed = false; $showed = false;
$link = "polls"; // your link to polls in index.php $link = "polls"; // your link to polls in index.php
$dark = $config['darkborder']; $dark = $config['darkborder'];
$light = $config['lightborder']; $light = $config['lightborder'];
$time = time(); $time = time();
$POLLS = $db->query('SELECT * FROM '.$db->tableName('z_polls').''); $POLLS = $db->query('SELECT * FROM '.$db->tableName('z_polls').'');
$level = 20; // need level to vote $level = 20; // need level to vote
if(empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) // list of polls 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 $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 $closed = $db->query('SELECT * FROM `z_polls` where `end` < '.$time.' order by `end` desc'); // closed polls
/* Active 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 '<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>'; 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++); $bgcolor = getStyle($number_of_rows++);
$empty_active = false; $empty_active = false;
foreach($active as $poll) foreach($active as $poll)
{ {
echo ' echo '
<tr BGCOLOR="'.$bgcolor.'"> <tr BGCOLOR="'.$bgcolor.'">
<td> <td>
<a href="'; <a href="';
if($logged) if($logged)
@ -57,24 +57,24 @@ function getColorByPercent($percent)
</td> </td>
<td>'.date("M j Y", $poll['end']).'</td> <td>'.date("M j Y", $poll['end']).'</td>
</tr>'; </tr>';
$empty_active = true; $empty_active = true;
} }
if(!$empty_active) 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 '<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>"; echo "</table><br><br>";
/* Closed Polls */ /* 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 '<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 '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><td width=75%><b>Topic</b></td><td><b>End</b></td></tr>';
$bgcolor = getStyle($number_of_rows++); $bgcolor = getStyle($number_of_rows++);
$empty_closed = false; $empty_closed = false;
foreach($closed as $poll) foreach($closed as $poll)
{ {
echo ' echo '
<tr BGCOLOR="'.$bgcolor.'"> <tr BGCOLOR="'.$bgcolor.'">
<td> <td>
<a href="'; <a href="';
if($logged) if($logged)
@ -86,17 +86,17 @@ function getColorByPercent($percent)
</td> </td>
<td>'.date("M j Y", $poll['end']).'</td> <td>'.date("M j Y", $poll['end']).'</td>
</tr>'; </tr>';
$empty_closed = true; $empty_closed = true;
} }
if(!$empty_closed) 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 '<tr BGCOLOR="'.$bgcolor.'"><td colspan=2><div style="text-align:center"><i>There are no closed polls.</i></div></td></tr>';
} }
echo "</table>"; echo "</table>";
$showed=true; $showed=true;
} }
if(!$logged) if(!$logged)
{ {
@ -104,43 +104,43 @@ function getColorByPercent($percent)
return; return;
} }
/* Checking Account */ /* Checking Account */
$allow = false; $allow = false;
$account_players = $account_logged->getPlayers(); $account_players = $account_logged->getPlayers();
foreach($account_players as $player) foreach($account_players as $player)
{ {
$player = $player->getLevel(); $player = $player->getLevel();
if($player >= $level) if($player >= $level)
$allow=true; $allow=true;
} }
if(!empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) if(!empty($_REQUEST['id']) and (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true"))
{ {
foreach($POLLS as $POLL) foreach($POLLS as $POLL)
{ {
if($_REQUEST['id'] == $POLL['id']) 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`'); $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']; $votes_all = $POLL['votes_all'];
if($votes_all == 0) if($votes_all == 0)
{ {
$i=1; $i=1;
foreach($ANSWERS as $answer) foreach($ANSWERS as $answer)
{ {
$percent[$i] = 0; $percent[$i] = 0;
$i++; $i++;
} }
} }
else else
{ {
$i=1; $i=1;
foreach($ANSWERS as $answer) foreach($ANSWERS as $answer)
{ {
$percent[$i] = round(((100*$answer['votes'])/$votes_all),2); $percent[$i] = round(((100*$answer['votes'])/$votes_all),2);
$i++; $i++;
} }
} }
?> ?>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
div.progress-container { div.progress-container {
@ -166,51 +166,51 @@ function getColorByPercent($percent)
</div>'; </div>';
} }
if($POLL['end'] > $time) // active poll if($POLL['end'] > $time) // active poll
{ {
if(isset($_REQUEST['vote']) && $_REQUEST['vote'] == true and $allow == true) if(isset($_REQUEST['vote']) && $_REQUEST['vote'] == true and $allow == true)
{ {
if($account_logged->getCustomField('vote') < $_REQUEST['id'] and !empty($_POST['answer'])) if($account_logged->getCustomField('vote') < $_REQUEST['id'] and !empty($_POST['answer']))
{ {
if(isset($_POST['continue'])) if(isset($_POST['continue']))
{ {
$vote = addslashes(htmlspecialchars(trim($_REQUEST['id']))); $vote = addslashes(htmlspecialchars(trim($_REQUEST['id'])));
$account_logged->setCustomField("vote", $vote); $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_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']))).''); $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'].''); header('Location: ?subtopic='.$link.'&id='.$_REQUEST['id'].'');
} }
} }
else else
{ {
header('Location: ?subtopic='.$link.'&id='.$_REQUEST['id'].''); header('Location: ?subtopic='.$link.'&id='.$_REQUEST['id'].'');
} }
} }
if($account_logged->getCustomField('vote') < $_REQUEST['id'] and $allow == true) 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 '<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> 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"> '; <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`'); $ANSWERS_input = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`');
$i=1; $i=1;
foreach($ANSWERS_input as $answer) foreach($ANSWERS_input as $answer)
{ {
if(is_int($i / 2)) { if(is_int($i / 2)) {
$bgcolor = $dark; $bgcolor = $dark;
} }
else else
{ {
$bgcolor = $light; $bgcolor = $light;
} }
echo '<tr BGCOLOR="'.$bgcolor.'"><td><input type=radio name=answer value="'.$i.'">'.$answer['answer'].'</td></tr>'; echo '<tr BGCOLOR="'.$bgcolor.'"><td><input type=radio name=answer value="'.$i.'">'.$answer['answer'].'</td></tr>';
$i++; $i++;
} }
echo '</table><input type="submit" name="continue" value="Submit" class="input2" /></form><br><br>'; echo '</table><input type="submit" name="continue" value="Submit" class="input2" /></form><br><br>';
} }
elseif($account_logged->getCustomField('vote') >= $_REQUEST['id']) elseif($account_logged->getCustomField('vote') >= $_REQUEST['id'])
{ {
$result[] = '<br><b>You have already voted.</b><br>'; $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 '<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>'; 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>'; $result[] = '<br>All players with a character of at least level ' . $level . ' may vote.<br>';
foreach($result as $error) foreach($result as $error)
{ {
echo $error; echo $error;
} }
echo '<br>The poll started at '.date("M j Y", $POLL['start']).'<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 'The poll will end at '.date("M j Y", $POLL['end']).'<br>';
echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>'; echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>';
} }
else // closed poll 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 '<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>'; 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`'); $ANSWERS_show = $db->query('SELECT * FROM '.$db->tableName('z_polls_answers').' where `poll_id` = '.$_REQUEST['id'].' order by `answer_id`');
$i=1; $i=1;
foreach($ANSWERS_show as $answer) foreach($ANSWERS_show as $answer)
{ {
if(is_int($i / 2)) { if(is_int($i / 2)) {
$bgcolor = $dark; $bgcolor = $dark;
} }
else else
{ {
$bgcolor = $light; $bgcolor = $light;
} }
echo '<TR BGCOLOR="'.$bgcolor.'"> echo '<TR BGCOLOR="'.$bgcolor.'">
<td width=60%>'.$answer['answer'].'</td> <td width=60%>'.$answer['answer'].'</td>
@ -272,64 +272,64 @@ function getColorByPercent($percent)
</td> </td>
<td>' . $answer['votes'] . '(<span style="color:' . getColorByPercent($percent[$i]) . '"><b>' . $percent[$i] . '%</b></span>)</td> <td>' . $answer['votes'] . '(<span style="color:' . getColorByPercent($percent[$i]) . '"><b>' . $percent[$i] . '%</b></span>)</td>
</tr>'; </tr>';
$i++; $i++;
} }
echo '</table><br><br>'; echo '</table><br><br>';
echo '<br>The poll started at '.date("M j Y", $POLL['start']).'<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 'The poll ended at '.date("M j Y", $POLL['end']).'<br>';
echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>'; echo '<br>Total votes <b>'.$POLL['votes_all'].'</b><br>';
} }
$showed=true; $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>'; echo '<div class=\'hr1\'></div><a href="?subtopic='.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
} }
} }
} }
if(admin() && (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true")) if(admin() && (!isset($_REQUEST['control']) || $_REQUEST['control'] != "true"))
{ {
echo '<br><a href="?subtopic='.$link.'&control=true"><b>Panel Control</b></a><br><br>'; echo '<br><a href="?subtopic='.$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; $show = false;
if(isset($_POST['submit'])) if(isset($_POST['submit']))
{ {
setSession('answers', $_POST['answers']); setSession('answers', $_POST['answers']);
echo '<form method="post" action=""><b><span style="font-size: 16px">Adding Poll</span></b><br><br> 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=question value="" /> Question<br>
<input type=text name=description value="" /> Description<br> <input type=text name=description value="" /> Description<br>
<input type=text name=end value="" /> Time to end, in days<br>'; <input type=text name=end value="" /> Time to end, in days<br>';
for( $x = 1; $x <= getSession('answers'); $x++ ) for( $x = 1; $x <= getSession('answers'); $x++ )
{ {
echo '<input type=text name='.$x.' value="" /> Answer no. '.$x.'<br>'; echo '<input type=text name='.$x.' value="" /> Answer no. '.$x.'<br>';
} }
echo '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>'; echo '<input type="submit" name="finish" value="Submit" class="input2"/></form><br><br>';
$show=true; $show=true;
} }
if(isset($_POST['finish'])) if(isset($_POST['finish']))
{ {
$id = $db->query('SELECT MAX(id) FROM `z_polls`')->fetch(); $id = $db->query('SELECT MAX(id) FROM `z_polls`')->fetch();
$id_next = $id[0] + 1; $id_next = $id[0] + 1;
for( $x = 1; $x <= getSession('answers'); $x++ ) for( $x = 1; $x <= getSession('answers'); $x++ )
{ {
$db->insert('z_polls_answers', array( $db->insert('z_polls_answers', array(
'poll_id' => $id_next, 'poll_id' => $id_next,
'answer_id' => $x, 'answer_id' => $x,
'answer' => $_POST[$x], 'answer' => $_POST[$x],
'votes' => 0 'votes' => 0
)); ));
} }
$end = $time+24*60*60*$_POST['end']; $end = $time+24*60*60*$_POST['end'];
$db->insert('z_polls', array( $db->insert('z_polls', array(
'id' => $id_next, 'id' => $id_next,
'question' => $_POST['question'], 'question' => $_POST['question'],
'description' => $_POST['description'], 'description' => $_POST['description'],
'end' => $end, 'end' => $end,
@ -337,35 +337,35 @@ function getColorByPercent($percent)
'start' => $time, 'start' => $time,
'votes_all' => 0 'votes_all' => 0
)); ));
} }
$POLLS_check = $db->query('SELECT MAX(end) FROM '.$db->tableName('z_polls').''); $POLLS_check = $db->query('SELECT MAX(end) FROM '.$db->tableName('z_polls').'');
foreach($POLLS_check as $checked) foreach($POLLS_check as $checked)
{ {
if($checked[0] > $time) if($checked[0] > $time)
$check=true; $check=true;
else else
$check=false; $check=false;
} }
if(!$show) if(!$show)
{ {
if(!$check) if(!$check)
{ {
echo '<form method="post" action=""><b><span style="font-size: 16px">Adding Poll</span></b><br><br> 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=text name=answers value="" /> Number of Answers<br>
<input type="submit" name="submit" value="Submit" class="input2"/></form><br><br>'; <input type="submit" name="submit" value="Submit" class="input2"/></form><br><br>';
} }
else else
{ {
echo '<b><span style="font-size: 16px"><br>Cannot be two and more active polls.<br><br></span></b>'; echo '<b><span style="font-size: 16px"><br>Cannot be two and more active polls.<br><br></span></b>';
} }
} }
$showed=true; $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>'; echo '<br><div class=\'hr1\'></div><a href="?subtopic='.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
} }
if(!$showed) if(!$showed)
{ {
echo 'This poll doesn\'t exist.<br>'; 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>'; echo '<div class=\'hr1\'></div><a href="?subtopic='.$link.'"><span style="font-size: 13px"><b>Go to list of polls</b></span></a>';
} }