download.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * Krpano100 下载功能
  4. * ============================================================================
  5. * 技术支持:2015-2099 成都世纪川翔科技有限公司
  6. * 官网地址: http://www.krpano100.com
  7. * ----------------------------------------------------------------------------
  8. * $Author: wanghao 932625974#qq.com $
  9. * $Id: bind.php 28028 2016-06-19Z yuanjiang $
  10. */
  11. define('IN_T',true);
  12. require_once "./source/include/init.php";
  13. $act = Common::sfilter($_REQUEST['act']);
  14. //下载离线项目
  15. if ($act=='project') {
  16. $filename = Common::sfilter($_REQUEST['filename']);
  17. $filename = str_replace('.','',$filename).'.zip';
  18. $url = ROOT_PATH.'temp/down/'.$filename;
  19. if (!file_exists($url)) {
  20. die('找不到该文件');
  21. }
  22. createDowanload($url,$filename);
  23. exit;
  24. }
  25. function createDowanload($url,$filename,$isDelete=false){
  26. /* headers */
  27. //设置该次请求超时时长,1800s
  28. @ini_set("max_execution_time", "1800");
  29. header('Cache-control: private');
  30. header("Content-type:application/x-zip-compressed");
  31. header('Content-Length: '.filesize($url));
  32. header('Content-Disposition:attachment; filename='.$filename);
  33. flush();
  34. $fh = @fopen($url, 'r');
  35. while(!feof($fh)){
  36. print fread($fh, 1024);
  37. flush();
  38. }
  39. @fclose($fh);
  40. if($isDelete)
  41. unlink($url);
  42. }
  43. ?>