Skip to content

Instantly share code, notes, and snippets.

@Ruzzz
Last active October 12, 2015 21:18
Show Gist options
  • Save Ruzzz/4088915 to your computer and use it in GitHub Desktop.
Save Ruzzz/4088915 to your computer and use it in GitHub Desktop.
Php | Test | Speed limit
<?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