downloadautoreport.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /****************************
  3. * File : downloadautoreport.php
  4. * Author : Cygnusa
  5. * @2019
  6. ****************************/
  7. //SECURITY
  8. if ( ! defined('APPLICATION_PATH')) exit('No direct script access allowed');
  9. //CLASS DEFINE
  10. class downloadautoreport
  11. {
  12. //FUNCTION LISTS
  13. function __construct($parent)
  14. {
  15. $this->funcDownload($parent);
  16. }
  17. //FUNCTIONS
  18. private function funcDownload($parent)
  19. {
  20. globalfunc::checkMethodType($parent,array('GET'));
  21. globalfunc::checkParamCount($parent,1);
  22. $decode_url= base64_decode(escape_str($parent->params[0]));
  23. //CONNECT S3
  24. $s3=awsfileserver::connectS3();
  25. try{
  26. //$s3_sign_url=awsfileserver::getS3Url($s3,$obj);
  27. $s3_sign_url=awsfileserver::getS3FileUrl($s3,S3_BUCKET,$decode_url);
  28. $obj=new stdClass();
  29. $obj->key_name=$decode_url;
  30. $info=awsfileserver::checkexist($s3,S3_BUCKET,$obj);
  31. if($info)
  32. {
  33. $arr=@explode('?',$s3_sign_url);
  34. $filerr=@explode('/',$arr[0]);
  35. $download_file=end($filerr);
  36. header('Content-Type: application/octet-stream');
  37. header("Access-Control-Allow-Origin: *");
  38. header('Content-Disposition: filename='.$download_file);
  39. @readfile($s3_sign_url);
  40. }else
  41. {
  42. echo 'FILE NOT FOUND';exit;
  43. }
  44. }catch(Exception $e)
  45. {
  46. echo 'FILE NOT FOUND';exit;
  47. }
  48. }
  49. }
  50. ?>