download.php 1002 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. include '../auth.php';
  3. ?>
  4. <?php
  5. //Download Handler for Auto Renaming System
  6. if (isset($_GET['download']) && $_GET['download'] != ""){
  7. if (file_exists( $_GET['download']) == false){
  8. die("ERROR. File doesn't exists.");
  9. }
  10. $target = $_GET['download'];
  11. $ext = pathinfo($target, PATHINFO_EXTENSION);
  12. $filedata = explode('/',$target);
  13. $fullFileName = array_pop($filedata);
  14. $filename = str_replace(".mp4","",$fullFileName);
  15. if (strpos($filename,"inith")!== false){
  16. $decodedName = hex2bin(str_replace("inith",'',$filename));
  17. }else{
  18. $decodedName = $filename;
  19. }
  20. header("Content-Type: video/mp4");
  21. header("Content-Length: " . filesize($target));
  22. header('Content-Disposition: attachment; filename="'.$decodedName . "." . $ext.'"');
  23. //readfile($target);
  24. $handle = fopen($target, 'rb');
  25. $buffer = '';
  26. while (!feof($handle)) {
  27. $buffer = fread($handle, 4096);
  28. echo $buffer;
  29. ob_flush();
  30. flush();
  31. }
  32. fclose($handle);
  33. exit;
  34. }
  35. ?>