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

Размер файла: 4.61Kb
  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. $sql->query("UPDATE `forum_posts` SET
  52. `edit` = '$user[nick]:|:".time()."',
  53. `files`= files + 1
  54. WHERE `id` = '$post'
  55. ");
  56.  
  57. }
  58.  
  59. if (isset($_POST['delfile'])){
  60. $array = $_POST['delfile'];
  61. if (is_array($array)){
  62. foreach ($array as $file => $val){
  63. require_once ('includes/delfile.php');
  64. }
  65. if (!$error)
  66. $sql->query("UPDATE `forum_posts` SET `files` = files - 1 WHERE `id` = '$post' LIMIT 1 ");
  67. }else{
  68. $error = 'Возникла ошибка при удалении файла!';
  69. }
  70. }
  71.  
  72. $fileReq = mysqli_query($sql->db, "SELECT * FROM `forum_files` WHERE `refid` = '".$postRes['id']."' LIMIT 11 ");
  73. $total = mysqli_num_rows($fileReq);
  74.  
  75. if (isset($_POST['send'])){
  76. if (empty($text))
  77. $error = 'Не введен текст сообщения!<br />';
  78.  
  79. if (!isset($error)){
  80. $sql->query("UPDATE `forum_posts` SET
  81. `text` = '".my_esc($text)."',
  82. `edit` = '$user[nick]:|:".time()."'
  83. WHERE `id` = '$post'
  84. ");
  85.  
  86. header ('Refresh:1; URL=index.php?topic='.$topic.'&page=end#p'.$post);
  87. echo '<div class="msg">Сообщение изменено<br /><a href="index.php?topic='.$topic.'&amp;page=end#p'.$post.'">Далее</a></div>';
  88. include H . 'engine/includes/foot.php';
  89. unset ($_POST['addfile'], $_POST['delfile'], $_SESSION['filename']);
  90. }
  91. }
  92.  
  93. if (isset($error))
  94. echo Core::msg_show($error);
  95.  
  96. if ($text && isset($_POST['preview'])){
  97. $textPreview = quote(text::output($text));
  98. echo '<div class="p_m"><strong>Предпросмотр:</strong><br />'.$textPreview.'</div>';
  99. }
  100.  
  101. 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">';
  102. echo '<div class="rmenu">Текст:<br /><textarea name="text">'.text($text).'</textarea><br />';
  103. echo '<input type="submit" name="send" value="Сохранить" /> <input type="submit" name="preview" value="Предпросм." /></div>';
  104.  
  105. echo '<div class="fmenu">Файлы: '.$total.' из 10</div>';
  106. if ($total){
  107. while ($fileRes = mysqli_fetch_assoc($fileReq)){
  108. echo $i % 2 ? '<div class="p_t">' : '<div class="p_m">';
  109. echo show_file($fileRes);
  110. echo '<div class="sub"><input type="submit" name="delfile['.$fileRes['id'].']" onclick="return confirm(\'Вы действительно хотите удалить файл?\');" value="Удалить" /></div></div>';
  111. ++$i;
  112. }
  113. }
  114. if ($total < 10){
  115. echo '<div class="msg">';
  116. 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" />';
  117. echo '<br /><input type="submit" name="addfile" value="Прикрепить" /></div>';
  118. }
  119. echo '</form>';