download.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. //未登录
  14. if($user['pk_user_main']<=0){
  15. Common::base_header("Location:".$_lang['host']."passport/login?redirectUrl=/member/$module\n");
  16. }
  17. //引用下载类
  18. require_once ROOT_PATH.'source/include/cls_project_download.php';
  19. $act = Common::sfilter($_REQUEST['act']);
  20. if ($act == 'ready') {
  21. $pid = intval($_REQUEST['pid']);
  22. $re['status'] = 0 ;
  23. $project = $Db->query('SELECT * FROM '.$Base->table('worksmain').' w LEFT JOIN '.$Base->table('pano_config').' p ON w.pk_works_main = p.pk_works_main WHERE w.pk_works_main = '.$pid,'Row');
  24. if (empty($project)) {
  25. $re['msg'] ='未查询到该项目';
  26. }else{
  27. $project = Transaction::decode_str2arr($project);
  28. if (empty($project['sceneGroups'])) {
  29. //查询图片 imagesmain
  30. $scenes = $Db->query("SELECT i.view_uuid AS viewuuid , i.filename AS sceneTitle ,i.thumb_path AS imgPath FROM ".$Base->table('imgsmain')."i LEFT JOIN ".$Base->table('imgs_works')." iw ON i.pk_img_main = iw.pk_img_main WHERE iw.pk_works_main =".$pid);
  31. $project['sceneGroups']['groupName'] = '场景选择';
  32. $project['sceneGroups']['scenes'] = $scenes;
  33. }
  34. chdir(ROOT_PATH);
  35. $p = new ProjectDownload($project,$_lang);
  36. $re['filename'] = $p->buildZip();
  37. $re['status'] = 1;
  38. }
  39. echo $Json->encode($re);
  40. }
  41. else if($act=='download'){
  42. $filename = Common::sfilter($_REQUEST['filename']);
  43. $url = ROOT_PATH.'temp/down/'.$filename;
  44. if (!file_exists($url)) {
  45. die('找不到该文件');
  46. }
  47. /* headers */
  48. header('Cache-control: private');
  49. header("Content-type:application/x-zip-compressed");
  50. header('Content-Length: '.filesize($url));
  51. header('Content-Disposition: filename='.$filename);
  52. /* flush content */
  53. flush();
  54. /* open file */
  55. $fh = @fopen($url, 'r');
  56. while(!feof($fh)){
  57. /* send only current part of the file to browser */
  58. print fread($fh, 10);
  59. /* flush the content to the browser */
  60. flush();
  61. }
  62. /* close file */
  63. @fclose($fh);
  64. unlink($url);
  65. }
  66. ?>