Просмотр файла wapbuilder/editpolls.php

Размер файла: 3.35Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');
require('includes/auth.php');

$max_answers = 10;

if(isset($_GET['action']) && $_GET['action'] == 'rename')
{
   mysql_query('UPDATE polls_questions SET question = "' . addslashes($_POST['question']) . '", date = CURRENT_TIMESTAMP WHERE id = "' . (int)$_GET['link_id'] . '"');
   // обновляем вопросы
   mysql_query('DELETE FROM polls_answers WHERE qid = "' .  (int)$_GET['link_id'] . '"');
   $qid = (int)$_GET['link_id'];
   for($i = 1; $i <= $max_answers; $i++)
   {
      if($_POST['answer' . $i] != '')
      {
         mysql_query('INSERT INTO polls_answers(qid, aid, answer, votes) VALUES ("' . $qid . '", "' . $i . '", "' . $_POST['answer' . $i] . '", "0")');
      }
   }
}
if(isset($_GET['action']) && $_GET['action'] == 'delete')
{
   mysql_query('DELETE FROM polls_questions WHERE id = "' . (int)$_GET['link_id'] . '"');
   mysql_query('DELETE FROM polls_answers WHERE qid = "' . (int)$_GET['link_id'] . '"');
?>
<wml>
<card id="added" title="added" ontimer="viewpolls.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>"><timer value="15"/>
<p>
Голосование удалено<br/>
</p>
</card>
</wml>
<?php
   exit;
}
?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="links" title="&#x041C;&#x0435;&#x043D;&#x0435;&#x0434;&#x0436;&#x0435;&#x0440; &#x0444;&#x0430;&#x0439;&#x043B;&#x043E;&#x0432;">
<do type="options" name="main" label="&#x041C;&#x0435;&#x043D;&#x044E;"><go href="main.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>"/></do>
<p>
<?php
   $links_list = '';

   $links = mysql_query('SELECT id, question FROM polls_questions WHERE user_id = "' . (int)($_GET['id']) . '" AND id = "' . (int)$_GET['link_id'] . '"');

   if(($n = mysql_num_rows($links)) > 0)
   {
      $link = mysql_fetch_array($links, MYSQL_ASSOC);
   }
?>
<br/>
Р’РѕРїСЂРѕСЃ:<br/>
<input name="question" type="text" maxlength="255" value="<?php echo $link['question']; ?>" title="page"/><br/>
<?php
   for($i = 1; $i <= $max_answers; $i++)
   {
?>
Ответ <?php echo $i; ?>:<br/>
<?php
   $answers = mysql_query('SELECT answer FROM polls_answers WHERE qid = "' . (int)$_GET['link_id'] . '" AND aid = "' . $i . '"');
   if(mysql_num_rows($answers) == 1)
   {
      list($answer) = mysql_fetch_array($answers);
   }
   else
   {
      $answer = '';
   }
?>
<input name="answer<?php echo $i; ?>" type="text" maxlength="255" value="<?php echo $answer; ?>" title="answer<?php echo $i; ?>"/><br/>
<?php
   }
?>
<anchor title="go">Ok<go href="editpolls.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>&amp;link_id=<?php echo $link['id']; ?>&amp;action=rename" method="post">
<postfield name="question" value="$(question)"/>
<?php
   for($i = 1; $i <= $max_answers; $i++)
   {
?>
<postfield name="answer<?php echo $i; ?>" value="$(answer<?php echo $i; ?>)"/>
<?php
   }
?>
</go></anchor><br/>
*********<br/>
<a href="editpolls.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>&amp;link_id=<?php echo $link['id']; ?>&amp;action=delete">&#x0423;&#x0434;&#x0430;&#x043B;&#x0438;&#x0442;&#x044C;</a><br/>
*********<br/>
<a href="viewpolls.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>">&#x041A; &#x0441;&#x043F;&#x0438;&#x0441;&#x043A;&#x0443;</a><br/>
</p>
</card>
</wml>