Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. --------------------REMOVE THIS----------------------------
  2. 1. kitchen compiles, user is redirected to download.php?id=buildid
  3. 2. ignore_user_abort means script will delete file even if user aborts download
  4. 3. download.php finds md5(buildid).zip
  5. (for security to stop people downloading files except if they have a md5 hash name of the buildid)
  6. 4. file is read in 1024 byte blocks and printed to output
  7. 5. if user aborts download, or we get to the end of file, script deletes the file
  8. --------------------REMOVE THIS----------------------------
  9.  
  10. if(!isset($_GET['id'])){
  11.     echo "build id is not set";
  12.     exit();
  13. }
  14.  
  15. $buildid = md5($_GET['id']);
  16. $buildfile = $buildid.".zip";
  17. $buildsize = filesize($buildfile);
  18.  
  19. ignore_user_abort(true);
  20.  
  21. if ($file = fopen($buildfile, 'rb')) {
  22.     while(!feof($file) and (connection_status()==0)) {
  23.         print(fread($file, 1024));
  24.         flush();
  25.     }
  26. }else{
  27.     echo "build file does not exist";
  28.     exit();
  29. }
  30.  
  31. fclose($file);
  32.  
  33. unlink($buildfile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement