03-08-2014, 10:24 AM
kreasikan lagi biar cakep
PHP Code:
<?php
if(isset($_GET['kbps']))
{
?>
<?php
$kbps = round($_GET['kbps'], 2);
$ksec = round($kbps / 8, 2);
$mbps = round($kbps / 1024, 2);
$msec = round($mbps / 8, 2);
?>
<center>
<br><br>
Your Current Bandwidth is:<br><br>
<?php
if ($mbps > 1)
{
printf ("%.2f",$mbps);
echo " Mbps<br><br>";
}
else
{
printf ("%.2f",$kbps);
echo "kbps<br><br>";
}
echo "That Means You Can Download At " . $ksec . " KB/sec. FROM THIS SITE.";
?>
<br><br>
<a href="speed.php">Perform a New Test</a>
</center>
<?php
}
else
{
?>
<?php
$default_kbyte_test_size = 512;
?>
<html>
<head>
<title>Bandwidth Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META HTTP-EQUIV="Expires" CONTENT="Fri, Jun 12 1981 08:20:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<br><br><br><br><br><br>
Testing Your Current Bandwidth...
<script language="JavaScript">
<!--
time = new Date();
starttime = time.getTime();
// -->
</script>
<?php
// $data_file Should Be A Junk Binary File I Tested It With a 3 MB file.
//Use Any Binary File And Just Rename It
//I Just Used A ZIpped Backup File Of Mine
$data_file = "A_Sample_binary_file.zip";
$fd = fopen ($data_file, "rb+");
$test_kbytes = $default_kbyte_test_size;
$contents = fread ($fd, $test_kbytes * 1024);
echo "<!-- $contents -->";
fclose ($fd);
?>
<script language="JavaScript">
<!--
time = new Date();
endtime = time.getTime();
if (endtime == starttime)
{downloadtime = 0
}
else
{downloadtime = (endtime - starttime)/1000;
}
kbytes_of_data = <?php echo $test_kbytes; ?>;
linespeed = kbytes_of_data/downloadtime;
kbps = (Math.round((linespeed*8)*10*1.024))/10;
nexturl = 'speed.php?kbps='+ kbps;
//alert(kbytes_of_data);
document.location.href=nexturl;
// -->
</script>
<center>
</body>
</html>
<?php
}
?>