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

Размер файла: 4.69Kb
  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. $max_size = include H.'engine/includes/max_file_size.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 (!$user_id){
  18. echo Core::msg_show('У вас недостаточно прав для просмотра этой страницы!<br /><a href="index.php?topic='.$topic.'">Назад</a>');
  19. include H . 'engine/includes/foot.php';
  20. }
  21.  
  22. $check = '';
  23. $text = isset($_POST['text']) ? $_POST['text'] : $postRes['text'];
  24.  
  25. echo '<div class="fmenu"><a href="index.php">Форум</a> / <a href="index.php?topic='.$topic.'&amp;page=end">'.text::output($topicRes['name']).'</a> / Изменить пост</div>';
  26.  
  27. if (!$moder){
  28. if ($postRes['user_id'] != $user_id)
  29. $check = true;
  30.  
  31. $firstPost = $sql->query("SELECT `id`, `user_id` FROM `forum_posts` WHERE `refid` = '".$postRes['refid']."' ORDER BY `time` ASC LIMIT 1 ")->fetch();
  32. if ($firstPost['id'] != $post && $postRes['time'] < time() - 300)
  33. $check = true;
  34.  
  35. if ($topicRes['close'])
  36. $check = true;
  37.  
  38. if ($check){
  39. echo Core::msg_show('У вас недостаточно прав для просмотра этой страницы!<br /><a href="index.php?topic='.$topic.'&amp;page=end#p'.$post.'">Назад</a>');
  40. include H . 'engine/includes/foot.php';
  41. }
  42. }
  43.  
  44. if (isset($_POST['addfile'], $_FILES['file']['name'])){
  45. $postId = $post;
  46. $topicId = $topicRes['id'];
  47. $user_id = $postRes['user_id'];
  48. $tempId = '';
  49. // Core::get('class_upload', 'classes');
  50.  
  51. require_once ('includes/fileupload.php');
  52.  
  53. $sql->query("UPDATE `forum_posts` SET
  54. `edit` = '$user[nick]:|:".time()."',
  55. `files`= `files` + 1
  56. WHERE `id` = '$post'
  57. ");
  58. $user_id = $user['id'];
  59. }
  60.  
  61. elseif (isset($_POST['delfile']))
  62. {
  63. $array = $_POST['delfile'];
  64. if (is_array($array)){
  65. foreach ($array as $file => $val){
  66. require_once ('includes/delfile.php');
  67. }
  68. if (!isset($error))
  69. $sql->query("UPDATE `forum_posts` SET `files` = files - 1 WHERE `id` = '$post' LIMIT 1 ");
  70. }else{
  71. $error = 'Возникла ошибка при удалении файла!';
  72. }
  73. }
  74.  
  75. $fileReq = mysqli_query($sql->db, "SELECT * FROM `forum_files` WHERE `refid` = '".$postRes['id']."' LIMIT 11 ");
  76. $total = mysqli_num_rows($fileReq);
  77.  
  78. if (isset($_POST['send'])){
  79. if (empty($text))
  80. $error = 'Не введен текст сообщения!<br />';
  81.  
  82. if (!isset($error)){
  83. $sql->query("UPDATE `forum_posts` SET
  84. `text` = '".my_esc($text)."',
  85. `edit` = '$user[nick]:|:".time()."'
  86. WHERE `id` = '$post'
  87. ");
  88.  
  89. header ('Refresh:1; URL=index.php?topic='.$topic.'&page=end#p'.$post);
  90. echo '<div class="msg">Сообщение изменено<br /><a href="index.php?topic='.$topic.'&amp;page=end#p'.$post.'">Далее</a></div>';
  91. include H . 'engine/includes/foot.php';
  92. unset ($_POST['addfile'], $_POST['delfile'], $_SESSION['filename']);
  93. }
  94. }
  95.  
  96. if (isset($error))
  97. echo Core::msg_show($error);
  98.  
  99. if ($text && isset($_POST['preview'])){
  100. $textPreview = quote(text::output($text));
  101. echo '<div class="p_m"><strong>Предпросмотр:</strong><br />'.$textPreview.'</div>';
  102. }
  103.  
  104. echo '<form id="form" name="form" action="index.php?act=editpost&amp;topic='.$topic.'&amp;post='.$post.'&amp;page=end" method="post" enctype="multipart/form-data">';
  105. echo '<div class="rmenu">Текст:<br /><textarea name="text">'.text($text).'</textarea><br />';
  106. echo '<input type="submit" name="send" value="Сохранить" /> <input type="submit" name="preview" value="Предпросм." /></div>';
  107.  
  108. echo '<div class="fmenu">Файлы: '.$total.' из 10</div>';
  109. if ($total){
  110. while ($fileRes = mysqli_fetch_assoc($fileReq)){
  111. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  112. echo show_file($fileRes);
  113. echo '<div class="sub"><input type="submit" name="delfile['.$fileRes['id'].']" onclick="return confirm(\'Вы действительно хотите удалить файл?\');" value="Удалить" /></div></div>';
  114. ++$i;
  115. }
  116. }
  117. if ($total < 10){
  118. echo '<div class="msg">';
  119. echo 'Файл <img style="cursor: pointer;" onclick="alert(this.title);" src="images/question.png" alt="?" title="Максимально '.text::size_data($max_size).'." />:<br /><input type="file" name="file" />';
  120. echo '<br /><input type="submit" name="addfile" value="Прикрепить" /></div>';
  121. }
  122. echo '</form>';