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

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