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

Размер файла: 3.08Kb
  1. <?php
  2. # Script by seg0ro http://mobilarts.ru
  3. # Not for sale!!!
  4.  
  5. # fixed
  6.  
  7. $set['title'] .= ' | Удаление';
  8. include H . 'engine/includes/head.php';
  9.  
  10. if (!$topic){
  11. echo Core::msg_show('Отсутствует идентификатор темы!<br /><a href="index.php">Форум</a>');
  12. include H . 'engine/includes/foot.php';
  13. }
  14.  
  15. if (!$moder){
  16. echo Core::msg_show('У вас недостаточно прав для просмотра этой страницы!<br /><a href="index.php">Форум</a>');
  17. include H . 'engine/includes/foot.php';
  18. }
  19.  
  20.  
  21. echo '<div class="fmenu"><a href="index.php">Форум</a> / <a href="index.php?topic='.$topic.'&amp;page=1">'.text::output($topicRes['name']).'</a> / Удаление темы</div>';
  22.  
  23. if (isset($_POST['yes'])){
  24.  
  25. $sql->query("SELECT `user_id` FROM `forum_posts` WHERE `refid` = '$topic' ");
  26. while ($postRes = $sql->fetch()){
  27. if ($postRes['rating'])
  28. $sql->query("DELETE FROM `forum_posts_rating` WHERE `refid` = '".$postRes['id']."' ", true);
  29. }
  30.  
  31. $sql->query("SELECT * FROM `forum_files` WHERE `topic` = '$topic' ");
  32. $i = 0;
  33. if ($sql->num_rows()){
  34. while ($fileRes = $sql->fetch()){
  35. unlink('../forum/files/attach/'.$fileRes['name']);
  36. }
  37. $sql->query("DELETE FROM `forum_files` WHERE `topic` = '$topic' ");
  38. $sql->query("OPTIMIZE TABLE `forum_files` ");
  39. }
  40.  
  41. if ($topicRes['poll_name']){
  42. $sql->query("DELETE FROM `forum_polls` WHERE `refid` = '$topic' ");
  43. $sql->query("DELETE FROM `forum_polled` WHERE `refid` = '$topic' ");
  44. $sql->query("OPTIMIZE TABLE `forum_polled` ");
  45. }
  46.  
  47. $sql->query("DELETE FROM `forum_posts` WHERE `refid` = '$topic' ");
  48. if ($topicRes['count'] > 100)
  49. $sql->query("OPTIMIZE TABLE `forum_posts` ");
  50. $sql->query("DELETE FROM `forum_topics` WHERE `id` = '$topic' LIMIT 1 ");
  51. $sql->query("DELETE FROM `forum_readed` WHERE `topic` = '$topic' ");
  52. $lastTopic = $sql->query("SELECT * FROM `forum_topics` WHERE `refid` = '".$topicRes['refid']."' ORDER BY `time` DESC LIMIT 1 ")->fetch();
  53. $sql = empty($lastTopic['name']) ? "" : $lastTopic['refid'].":|:".$lastTopic['name'].":|:".$lastTopic['time'];
  54. $sql->query("UPDATE `forum_forums` SET
  55. `last_topic` = '$sql',
  56. `count`= count - 1
  57. WHERE `id`='".$topicRes['refid']."' LIMIT 1 ");
  58.  
  59. journal_add($topicRes['user_id'], 'Ваша тема <strong>'.text::output($topicRes['name']).'</strong> удалена (удалил <a href="../users/profile.php?user='.$user_id.'">'.$user['nick'].'</a>)');
  60. header ('Refresh:1; URL=index.php?forum='.$topicRes['refid']);
  61. echo '<div class="msg">Тема удалена<br /><a href="index.php?forum='.$topicRes['refid'].'">Далее</a></div>';
  62.  
  63. }elseif(isset($_POST['no'])){
  64. header ('Location: index.php?topic='.$topic.'&page=end');
  65. }else{
  66. echo '<form action="index.php?act=deltopic&amp;topic='.$topic.'" method="post"><div class="rmenu">Вы хотите удалить тему?<br />
  67. <input type="submit" name="yes" value="Удалить" /> <input type="submit" name="no" value="Отмена" /></div></form>';
  68. }