PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Artur Graniszewski   QoS Bandwidth Throttle in PHP   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: QoS Bandwidth Throttle in PHP
Limit the speed of files served for download
Author: By
Last change: Improved code documentation
Date: 13 years ago
Size: 737 bytes
 

Contents

Class file image Download
<?php

require("./throttler.php");

// create new config
$config = new ThrottleConfig();
// enable burst rate for 30 seconds
$config->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);

header("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
"A";
}