(The company has a need to prevent people from constantly downloading and seeing it on others' websites) the following translation is from Google, which can be used to limit the speed of file download. It intercepts the output of PHP scripts and provides a buffer for the browser. It is called the number of bytes each time. Class from the last measurement time PHP output buffer rinse, and keep for a period of time,
(The company has a need to prevent people from constantly downloading and seeing it on others' websites) the following translation is from Google, which can be used to limit the speed of file download. It intercepts the output of PHP scripts and provides a buffer for the browser. It is called the number of bytes each time. Class from the last measurement time PHP output buffer rinse, and keep for a period of time,
(The company has a need to prevent people from constantly downloading and seeing it on others' websites)
Translated by Google
This class can be used to limit the speed of object download.
It intercepts the output of PHP scripts and provides a buffer for the browser. It is called the number of bytes each time.
Class from the last measurement time PHP output buffer rinse, and maintain for a period of time if the average download speed for PHP exceeds the given limit.
---------------------------------------------------------------------------
There are three different bandwidth shaping mechanisms to ensure adequate service quality:
1) The burstable transmission rate will be switched off X bytes and then sent to the user (this helps to quickly send small images and limit the download speed and huge file size)
2) The burstable transmission rate will be disabled for a period of time. In seconds, it will return to the standard throttling speed.
3) The burst transmission rate will not be activated, and the download speed limit will be constant (in this case, throughout the download process $ configuration> burstLimit must be equal to the configuration-> rateLimit) PHP
Source code and demo:Source code source demonstration Source
BurstTimeout = 30; // set burst transfer rate to 50000 bytes/second $ config-> burstLimit = 50000; // set standard transfer rate to 15.000 bytes/second (after initial 30 seconds of burst rate) $ config-> rateLimit = 15000; // enable module (this is a default value) $ config-> enabled = true; // start throttling $ x = new Throttle ($ config); // A http://www.codepearl.comheader ("Content-type: application/force-download "); header ("Content-Disposition: attachment; filename = \" test.txt \ ""); header ("Content-Length: 60000000"); // generate 60.000.000 bytes file. for ($ I = 0; $ I <60000000; $ I ++) {echo "";}
BurstSize = 500000; // set burst transfer rate to 50000 bytes/second $ config-> burstLimit = 50000; // set standard transfer rate to 15.000 bytes/second (after initial 30 seconds of burst rate) $ config-> rateLimit = 15000; // enable module (this is a default value) $ config-> enabled = true; // start throttling $ x = new Throttle ($ config); // A http://www.codepearl.comheader ("Content-type: application/force-download "); header ("Content-Disposition: attachment; filename = \" test.txt \ ""); header ("Content-Length: 60000000"); // generate 60.000.000 bytes file. for ($ I = 0; $ I <60000000; $ I ++) {echo "";}