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

Размер файла: 2.31Kb
  1. <?php
  2. # Script by seg0ro http://mobilarts.ru
  3. # Not for sale!!!
  4.  
  5. # fixed
  6.  
  7. $set['title'] .= ' | Скачать тему';
  8.  
  9. if (!$topic){
  10. include H . 'engine/includes/head.php';
  11. echo Core::msg_show('Отсутствует идентификатор темы!<br /><a href="index.php">Форум</a>');
  12. include H . 'engine/includes/foot.php';
  13. }
  14.  
  15. if (!$user_id){
  16. include H . 'engine/includes/head.php';
  17. echo Core::msg_show('Только для авторизованных!<br /><a href="index.php?topic='.$topic.'&amp;page=end">Назад</a>');
  18. include H . 'engine/includes/foot.php';
  19. }
  20.  
  21. $sql->query("SELECT * FROM `forum_posts` WHERE `refid` = '$topic' ORDER BY `time` ASC ");
  22.  
  23. $name = 'Тема: '.text::output($topicRes['name']).PHP_EOL .'Скачано с сайта '.$_SERVER['HTTP_HOST'];
  24.  
  25. $text = array();
  26. if(isset($_POST['loadtxt'])){
  27. while ($res = $sql->fetch()){
  28. $text[] = $res['user']." (".date("d.m.Y/H:i", $res['time']).")\r\n".$res['text']."";
  29. }
  30. array_unshift($text, $name);
  31. $tmp = implode("\r\n\r\n",$text);
  32. header ('Content-Encoding: none');
  33. header ('Content-type: text/plain');
  34. header ('Content-Disposition: attachment; filename="topic__'.$topic.'.txt"');
  35. header ('Last-Modified: ' . date("D, d M Y H:i:s T"));
  36. echo $tmp;
  37. exit;
  38. }elseif(isset($_POST['loadgzip'])){
  39. while ($res = $sql->fetch()){
  40. $text[] = $res['user']." (".date("d.m.Y/H:i", $res['time']).")\r\n".$res['text']."";
  41. }
  42. array_unshift($text, $name);
  43. $tmp = implode("\r\n\r\n",$text);
  44. header ('Content-Encoding: none');
  45. header ('Content-type: multipart/alternative');
  46. header ('Content-Disposition: attachment; filename="topic_'.$topic.'.txt.gz"');
  47. header ('Last-Modified: ' . date("D, d M Y H:i:s T"));
  48. echo gzencode($tmp);
  49. exit;
  50. }else{
  51. include H . 'engine/includes/head.php';
  52.  
  53. echo '<div class="fmenu"><a href="index.php">Форум</a> / <a href="index.php?topic='.$topic.'&amp;page=1">'.text::output($topicRes['name']).'</a> / Загрузить тему</div>';
  54. echo '<form action="index.php?act=loadtopic&amp;topic='.$topic.'&amp;page=end" method="post"><div class="msg"><input type="submit" name="loadtxt" value="Загрузить .txt" />'.
  55. /*' <input type="submit" name="loadgzip" value="Загрузить .gzip" />'.*/
  56. '</div></form>';
  57. }