Posted this on another forum a while ago, so i figure why not here as well:
For you advanced users this might turn out to be useful. For example a good application of this would be if you host your site at college, and the tech deparment gets pissed if your using a lot of bandwidth. So you can mirror to your girlfriends computer, and use her bandwidth and so forth.
Its really inexpensive, and useful. I used it when I had a file server in Berkerly.
<?
$server = "127.0.0.1"; // Your server.
$maxband = "500000"; // Maximum Bandwidth before rollover in bytes.
$mirror = "mirror.yoursite.com"; // The mirror server.
$handle = fopen ("http://$server/server-status?auto", "r");
while (!feof($handle)) {
$buffer=fread($handle,4096);
}
fclose($handle);
list($th,$tb,$cpu,$uptime,$rs,$bs,$br,$busy,$idle,$scoreboard)= split ("
", $buffer);
$bs = ereg_replace(".*BytesPerSec: ", "", $bs);
if ($bs > $maxband) {
$location = "http://$mirror/$file";
} else {
$location = "http://$server/$file";
}
echo "<p>$server limit is $maxband bytes. Current bandwidth is $bs.</p>";
echo "<p>Sending you to <b>$location</b>.</p>";
?>