Last active
October 12, 2015 21:18
-
-
Save Ruzzz/4088915 to your computer and use it in GitHub Desktop.
Php | Test | Speed limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = $_GET['file']; | |
$downloadRate = isset($_GET['speed']) ? intval($_GET['speed']) : 500; | |
if (file_exists($filename) && is_file($filename)) | |
{ | |
header('Cache-control: private'); | |
header('Content-Type: application/x-shockwave-flash'); // Set MIME | |
header('Content-Length: '.filesize($filename)); | |
header('Content-Disposition: filename='.$filename); | |
flush(); | |
$file = fopen($filename, "r"); | |
while (!feof($file)) | |
{ | |
print fread($file, round($downloadRate * 1024)); | |
flush(); | |
sleep(1); | |
} | |
fclose($file); | |
} | |
else | |
die('Error: The file '.$filename.' does not exist!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment