Просмотр файла forum/includes/poll.php

Размер файла: 2.37Kb
  1. <?php
  2. # Script by seg0ro http://mobilarts.ru
  3. # Not for sale!!!
  4.  
  5. $set['title'] .= ' | Отдать голос';
  6. include H.'engine/includes/head.php';
  7.  
  8. if (!$topic){
  9. echo Core::msg_show('Отсутствует идентификатор темы!<br /><a href="index.php">Форум</a>');
  10. include H . 'engine/includes/foot.php';
  11. }
  12.  
  13. if (!$user_id || $topicRes['close']){
  14. echo Core::msg_show('У вас недостаточно прав для просмотра этой страницы!<br /><a href="index.php">Форум</a>');
  15. include H . 'engine/includes/foot.php';
  16. }
  17.  
  18. if (!$topicRes['poll_name'] && !isset($_POST['poll'])){
  19. echo Core::msg_show('Ошибка!<br /><a href="index.php?topic='.$topicRes['id'].'&amp;page=1">Назад</a>');
  20. include H . 'engine/includes/foot.php';
  21. }
  22.  
  23. echo '<div class="fmenu"><a href="index.php">Форум</a> / <a href="index.php?topic='.$topicRes['id'].'&amp;page=1">'.text::output($topicRes['name']).'</a> / Голосование</div>';
  24.  
  25. if (empty($_POST['var'])){
  26. echo Core::msg_show('Вы ничего не выбрали!<br /><a href="index.php?topic='.$topicRes['id'].'&amp;page=1">Назад</a>');
  27. include H . 'engine/includes/foot.php';
  28. }
  29.  
  30. $pollCheck = $sql->query("SELECT COUNT(*) FROM `forum_polled` WHERE `refid` = '$topic' AND `user_id` = '$user_id' LIMIT 1 ")->result();
  31. if (!$pollCheck){
  32. foreach ($_POST['var'] as $var){
  33. $sql->query("UPDATE `forum_polls` SET `count` = count + 1 WHERE `id` = '".intval($var)."' LIMIT 1 ");
  34. $sql->query("INSERT INTO `forum_polled` SET
  35. `refid` = '$topic',
  36. `poll` = '".intval($var)."',
  37. `user_id` = '$user_id' ");
  38. ++$i;
  39. }
  40. $pollSet = array('poll_close' => $pollSet['poll_close'], 'poll_mod' => $pollSet['poll_mod'], 'total_polls' => ($pollSet['total_polls'] + $i), 'total_polled' => ($pollSet['total_polled'] + 1));
  41. $sql->query("UPDATE `forum_topics` SET
  42. `poll_set` = '".serialize($pollSet)."'
  43. WHERE `id` = '$topic' LIMIT 1 ");
  44. header ('Refresh:1; URL=index.php?topic='.$topicRes['id'].'&page=end');
  45. echo '<div class="msg">Ваш голос принят, спасибо<br /><a href="index.php?topic='.$topicRes['id'].'&amp;page=1">Далее</a></div>';
  46. }else{
  47. echo Core::msg_show('Вы уже отдавали голос!<br /><a href="index.php?topic='.$topicRes['id'].'&amp;page=1">Назад</a>');
  48. }