.01
.02
.03
.04
.05
.06
.07
.08
.09
.10
.11
.12
.13
.14
.15
.16
.17
.18
.19
.20
.21
.22
.23
.24
.25
.26
.27
.28
.29
.30
.31
.32
.33
.34
.35
.36
.37
.38
.39
.40
.41
|
|
<?php
/******************************************************************************/
/* */
/* __ ____ */
/* ___ / / ___ / __/__ __ _____________ ___ */
/* / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-< */
/* / .__/_//_/ .__/___/\___/\_,_/_/ \__/\__/___/ */
/* /_/ /_/ */
/* */
/* */
/******************************************************************************/
/* */
/* Titre : Comment limiter la vistesse de download */
/* */
/* URL : http://www.phpsources.org/scripts377-PHP.htm */
/* Auteur : Matt */
/* Date édition : 27 Avril 2008 */
/* Website auteur : http://www.france-relations.com */
/* */
/******************************************************************************/
$file = "somefile.zip"; // Nom du fichier
$speed = 50; // i.e. 50 kb/s temps de telechargement
if(file_exists($file) && is_file($file)) {
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Content-Disposition: filename=$file" . "%20");
flush();
$fd = fopen($file, "r");
while(!feof($fd)) {
echo fread($fd, round($speed*1024)); // $speed kilobytes (Kb)
flush();
sleep(1);
}
fclose ($fd);
}
?>
|