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

Размер файла: 2.83Kb
  1. <?php
  2.  
  3. $dir_clean = opendir('time_files/created_zip');
  4. while ($file = readdir($dir_clean)) {
  5. if ($file != 'index.php' && $file != '.htaccess' && $file != '.' && $file != '..') {
  6. $time_file = filemtime('time_files/created_zip/' . $file);
  7. if ($time_file < ($time - 300))
  8. unlink('time_files/created_zip/' . $file);
  9. }
  10. }
  11. closedir($dir_clean);
  12. $req_down = mysql_query("SELECT * FROM `down_files` WHERE `id` = '$id' AND (`type` = 2 OR `type` = 3) LIMIT 1");
  13. $res_down = mysql_fetch_assoc($req_down);
  14.  
  15. if (mysql_num_rows($req_down) == 0 || !is_file($res_down['dir'] . '/' . $res_down['name']) || format($res_down['name']) != 'txt' || ($res_down['type'] == 3 && !$admin)) {
  16. include H.'engine/includes/head.php'; echo display_error('Файл не найден<br /><a href="index.php">К категориям</a>');
  17. include H.'engine/includes/foot.php';
  18. }
  19.  
  20. if (isset($_GET['more'])) {
  21. $more = abs(intval($_GET['more']));
  22. $req_more = mysql_query("SELECT * FROM `down_more` WHERE `id` = '$more' LIMIT 1");
  23. $res_more = mysql_fetch_assoc($req_more);
  24. if (!mysql_num_rows($req_more) || !is_file($res_down['dir'] . '/' . $res_more['name']) || format($res_more['name']) != 'txt') {
  25. include H.'engine/includes/head.php'; echo display_error('Файл не найден<br /><a href="index.php">К категориям</a>');
  26. include H.'engine/includes/foot.php';
  27. exit;
  28. }
  29. $down_file = $res_down['dir'] . '/' . $res_more['name'];
  30. $title_pages = $res_more['rus_name'];
  31. $txt_file = $res_more['name'];
  32. }
  33. else {
  34. $down_file = $res_down['dir'] . '/' . $res_down['name'];
  35. $title_pages = $res_down['rus_name'];
  36. $txt_file = $res_down['name'];
  37. }
  38.  
  39. if (!isset($_SESSION['down_' . $id])) {
  40. mysql_query("UPDATE `down_files` SET `field`=`field`+1 WHERE `id`='$id'");
  41. $_SESSION['down_' . $id] = 1;
  42. }
  43. $file = 'time_files/created_zip/' . $txt_file . '.zip';
  44. if (!file_exists($file)) {
  45. require_once H.'sys/inc/zip.php';
  46. $zip = new PclZip($file);
  47. function w($event, &$header)
  48. {
  49. $header['stored_filename'] = basename($header['filename']);
  50. return 1;
  51. }
  52. $zip->create($down_file, PCLZIP_CB_PRE_ADD, 'w');
  53. chmod($file, 0644);
  54. }
  55.  
  56. include H.'engine/includes/head.php';
  57.  
  58. echo '<div class="p_m"><b>' . output_text($title_pages) . '</b></div>';
  59. echo '<div class="menu"><a href="' . output_text($file) . '">Скачать в ZIP</a></div>';
  60. echo '<div class="menu"><input type="text" value="http://'.$_SERVER['HTTP_HOST'].'/' . $dir_load . '/' . output_text($file) . '"/><b></b></div>';
  61. echo '<div class="menu">Файл будет доступен для скачивания в течение 5 минут</div>';
  62. echo '<div class="p_t"><a href="index.php?act=view&amp;id=' . $id . '">К файлу</a></div>';
  63.  
  64. ?>