Просмотр файла download/include/edit_about.php

Размер файла: 1.63Kb
  1. <?php
  2.  
  3. include H.'engine/includes/head.php';
  4.  
  5. $sql->query("SELECT * FROM `down_files` WHERE `id` = '$id' AND (`type` = 2 OR `type` = 3) LIMIT 1");
  6. $res_down = $sql->fetch();
  7. if ($sql->num_rows() == 0 || !is_file($res_down['dir'] . '/' . $res_down['name']) || !$admin) {
  8. echo '<a href="index.php">К категориям</a>';
  9. include H.'engine/includes/foot.php';
  10.  
  11. }
  12. if (isset($_POST['submit'])) {
  13. $about = trim($_POST['opis']);
  14. if (!empty($about)) {
  15. $files = fopen('about/' . $id . '.txt', 'w+');
  16. flock($files, LOCK_EX);
  17. fputs($files, $about);
  18. flock($files, LOCK_UN);
  19. fclose($files);
  20. } elseif (is_file('about/' . $id . '.txt')) {
  21. unlink('about/' . $id . '.txt');
  22. }
  23. if (file_exists(H.'engine/files/tmp/download[file='.$id.';page=1].swc'))
  24. unlink(H.'engine/files/tmp/download[file='.$id.';page=1].swc');
  25. exit(header('Location: index.php?act=view&id=' . $id));
  26. }
  27. else {
  28. if (is_file('about/' . $id . '.txt'))
  29. $about = htmlspecialchars(file_get_contents('about/' . $id . '.txt'));
  30. else
  31. $about = null;
  32. echo
  33. '<div class="p_m">' . text::output($res_down['rus_name']) . '</div><div class="p_m">Описание</div>'.
  34. '<div class="post"><form action="index.php?act=edit_about&amp;id=' . $id . '" method="post">'.
  35. '<small>Максимум 500 символов</small><br /><textarea name="opis">' . $about . '</textarea>'.
  36. '<br /><input type="submit" name="submit" value="Отправить"/></form></div>'.
  37. '<div class="p_t"><a href="index.php?act=view&amp;id=' . $id . '">Назад</a></div>';
  38. }