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

Размер файла: 4.74Kb
  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 (!$forum){
  11. echo Core::msg_show('Отсутствует идентиикатор форума!<br /><a href="index.php">Форум</a>');
  12. include H . 'engine/includes/foot.php';
  13. }
  14.  
  15. if (!$admin){
  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?forum='.$forumRes['id'].'">'.text::output($forumRes['name']).'</a> '. ($forumRes['refid'] ? 'Удалить подфорум' : 'Удалить форум').'</div>';
  22.  
  23. if (isset($_GET['movetopics']) && $forum){
  24. if (isset($_POST['send'])){
  25. if (empty($_POST['forum']))
  26. $error = 'Неверные данные!<br /><a href="index.php">Форум</a>';
  27. if (!isset($error)){
  28. $forumName = $sql->query("SELECT `name` FROM `forum_forums` WHERE `id` = '".abs(intval($_POST['forum']))."' LIMIT 1 ")->fetch();
  29. $sql->query("UPDATE `forum_topics` SET
  30. `refid` = '".abs(intval($_POST['forum']))."',
  31. `forum` = '".my_esc($forumName['name'])."'
  32. WHERE `refid` = '$forum' ");
  33. $lastTopic = $sql->query("SELECT * FROM `forum_topics` WHERE `refid` = '".abs(intval($_POST['forum']))."' ORDER BY `time` DESC LIMIT 1 ")->fetch();
  34. $sql->query("UPDATE `forum_forums` SET
  35. `last_topic` = '".$lastTopic['refid'].":|:".$lastTopic['name'].":|:".$lastTopic['time']."',
  36. `count` = count + ".$forumRes['count']." WHERE `id` = '".abs(intval($_POST['forum']))."' LIMIT 1 ");
  37. $sql->query("UPDATE `forum_forums` SET
  38. `last_topic` = '',
  39. `count` = '0' WHERE `id` = '$forum' LIMIT 1 ");
  40.  
  41. echo '<div class="post">Темы перенесены<br /><a href="index.php?act=delforum&amp;forum='.$forum.'&amp;yes">Далее (Удалить подфорум)</a></div>';
  42. }else{
  43. echo Core::msg_show($error);
  44. }
  45. }else{
  46. echo '<form name="form" action="index.php?act=delforum&amp;forum='.$forum.'&amp;movetopics" method="post"><div class="p_m">Переместить темы в: <select name="forum">';
  47. $sql->query("SELECT * FROM `forum_forums` WHERE `refid` = '0' ORDER BY `realid` ASC ");
  48. while ($res = $sql->fetch()){
  49. if ($res['type'] == 1){
  50. echo '<option value="'.$res['id'].'"'.($res['id'] == $forum ? ' selected="selected"' : '').'>- '.text::output($res['name']).'</option>';
  51. }else{
  52. echo '<option disabled="disabled">'.text::output($res['name']).'</option>';
  53. $subForumReq = mysqli_query($db, "SELECT * FROM `forum_forums` WHERE `refid` = '".$res['id']."' ORDER BY `realid` ASC ");
  54. while ($subForumRes = mysqli_fetch_assoc($subForumReq)){
  55. echo '<option value="'.$subForumRes['id'].'"'.($subForumRes['id'] == $forum ? ' selected="selected"' : '').'>- '.text::output($subForumRes['name']).'</option>';
  56. }
  57. }
  58. }
  59. echo '</select><br /><input type="submit" name="send" value="Переместить" /></div></form>';
  60. include H . 'engine/includes/foot.php';
  61. }
  62. }
  63.  
  64. if (isset($_POST['yes'])){
  65. if ($forumRes['type'] == 0 && $forumRes['count'])
  66. $error = 'Сначала удалите подфорумы!<br /><a href="index.php?forum='.$forum.'">Форум</a>';
  67.  
  68. if ($forumRes['type'] == 1 && $forumRes['count'])
  69. $error = 'Сначала удалите или перенесите темы!<br /><a href="index.php?act=delforum&amp;forum='.$forum.'&amp;movetopics">Перенести темы</a> | <a href="index.php">Форум</a>';
  70. if (!isset($error)){
  71. if ($forumRes['refid'])
  72. $sql->query("UPDATE `forum_forums` SET `count` = count - 1 WHERE `id` = '".$forumRes['refid']."' LIMIT 1 ");
  73. if (file_exists(('../forum/files/icons/'.$forum.'.png')))
  74. unlink('../forum/files/icons/'.$forum.'.png');
  75. $sql->query("DELETE FROM `forum_forums` WHERE `id` = '$forum' LIMIT 1 ");
  76. header ('Refresh:1; URL=index.php');
  77. echo '<div class="msg">Форум удален<br /><a href="index.php">Форум</a></div>';
  78. }else{
  79. echo Core::msg_show($error);
  80. }
  81. }elseif(isset($_POST['no'])){
  82. header ('Location: index.php');
  83. }else{
  84. echo '<form action="index.php?act=delforum&amp;forum='.$forum.'" method="post"><div class="rmenu">Вы действительно хотите удалить форум?<br />';
  85. echo '<input type="submit" name="yes" value="Удалить" /> <input type="submit" name="no" value="Отмена" /></div></form>';
  86. }