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

Размер файла: 4.13Kb
  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. if (isset($_GET['otherforum']))
  21. $sql2 = abs(intval($_GET['otherforum']));
  22. else
  23. $sql2 = $topic['refid'];
  24.  
  25. echo '<div class="fmenu"><a href="index.php">Форум</a> / <a href="index.php?topic='.$topicRes['id'].'&amp;page=end">'.text::output($topicRes['name']).'</a> / Перенести тему</div>';
  26.  
  27.  
  28. if (isset($_POST['send'])){
  29. if (empty($_POST['forum']))
  30. $error = 'Неверные данные!';
  31.  
  32. if (!isset($error)){
  33. $forumName = $sql->query("SELECT `name` FROM `forum_forums` WHERE `id`='".abs(intval($_POST['forum']))."' LIMIT 1 ")->fetch();
  34. $sql->query("INSERT INTO `forum_posts` SET
  35. `refid` = '$topic',
  36. `time` = '".time()."',
  37. `user_id` = '$user_id',
  38. `user` = '$user[nick]',
  39. `text` = 'Тема перенесена (из [b]".text::output($topicRes['forum'])."[/b])',
  40. `files` = '0'");
  41. $pid = mysqli_insert_id($sql->db);
  42. $sql->query("UPDATE `forum_topics` SET
  43. `refid`='".abs(intval($_POST['forum']))."',
  44. `time` = '".time()."',
  45. `forum`='".text::output($forumName['name'])."',
  46. `lastpost` = '$user[nick]:|:$pid',
  47. `count` = count + 1
  48. WHERE `id`='$topic' LIMIT 1 ");
  49. if ($topicRes['user_id'] != $user_id)
  50. journal::addEntry($topicRes['user_id'], 'Ваша <a href="index.php?post='.$pid.'">тема</a> перенесена (из <strong>'.text::output($topicRes['forum']).'</strong>)');
  51. $lastTopic = $sql->query("SELECT * FROM `forum_topics` WHERE `refid` = '".$topicRes['refid']."' ORDER BY `time` DESC LIMIT 1 ")->fetch();
  52. $sql2 = empty($lastTopic['name']) ? '' : $lastTopic['refid'].":|:".$lastTopic['name'].":|:".$lastTopic['time'];
  53. $sql->query("UPDATE `forum_forums` SET
  54. `last_topic`='$sql2',
  55. `count`= count - 1 WHERE `id`='".$topicRes['refid']."' LIMIT 1 ");
  56.  
  57. $lastTopic2 = $sql->query("SELECT * FROM `forum_topics` WHERE `refid` = '".abs(intval($_POST['forum']))."' ORDER BY `time` DESC LIMIT 1 ")->fetch();
  58. $sql->query("UPDATE `forum_forums` SET
  59. `last_topic`='".$lastTopic2['refid'].":|:".$lastTopic2['name'].":|:".$lastTopic2['time']."',
  60. `count`= count + 1 WHERE `id`='".abs(intval($_POST['forum']))."' LIMIT 1 ");
  61.  
  62. header ('Refresh:1; URL=index.php?topic='.$topic.'&page=end#p'.$pid);
  63. echo '<div class="msg">Тема перенесена<br /><a href="index.php?topic='.$topic.'&amp;page=end#p'.$pid.'">Далее</a></div>';
  64. include H . 'engine/includes/foot.php';
  65. }
  66. }
  67.  
  68. if (isset($error))
  69. echo Core::msg_show($error);
  70.  
  71. echo '<form name="form" action="index.php?act=movetopic&amp;topic='.$topic.'&amp;page=end" method="post"><div class="p_m">Переместить тему в: <select name="forum">';
  72. $sql->query("SELECT * FROM `forum_forums` WHERE `refid` = '0' ORDER BY `realid` ASC ");
  73. while ($res = $sql->fetch()){
  74. if ($res['type'] == 1){
  75. echo '<option value="'.$res['id'].'"'.($res['id'] == $topicRes['refid'] ? ' selected="selected"' : '').'>- '.text::output($res['name']).'</option>';
  76. }else{
  77. echo '<option disabled="disabled">'.text::output($res['name']).'</option>';
  78. $subForumReq = mysqli_query($sql->db, "SELECT * FROM `forum_forums` WHERE `refid` = '".$res['id']."' ORDER BY `realid` ASC ");
  79. while ($subForumRes = mysqli_fetch_assoc($subForumReq))
  80. {
  81. echo '<option value="'.$subForumRes['id'].'"'.($subForumRes['id'] == $topicRes['refid'] ? ' selected="selected"' : '').'>- '.text::output($subForumRes['name']).'</option>';
  82. }
  83. }
  84. }
  85. echo '</select><br /><input type="submit" name="send" value="Переместить" /></div></form>';