<!-- Copyright 2002 (C) Gambit Design Internet Services -->
<!-- This is licensed under the GNU Public License -->
<!-- Author: Derek T Del Conte - derek@gambitdesign.com -->

<?php include_once("../config.inc.php"); ?>

<html>
<head>
	<title><?php echo $isp_name; ?> - Speed Test - Upload</title>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
	<link rel="stylesheet" href="../style.css">
</head>
<body><center>
<?php 
	$kbps = round($_GET['kbps'], 2);
	$ksec = round($kbps / 8, 2);
	$mbps = round($kbps / 1024, 2);
	$msec = round($mbps / 8, 2);

echo $header;

echo '<br><h1>Speed Test - Upload</h1><br>';


echo '<br><br>
Vaše přenosová rychlost je:<br><br>
<font size=+2 color=red>';

if ($mbps > 1)
	{
	printf ("%.2f",$mbps); 	
    echo " Mbit/s<br><br>";
	} else
	{
	printf ("%.0f",$kbps); 	
    echo " kbit/s<br><br>";
    }
?>
</font>
<?php
   if ($msec > 1) {
      echo "což znamená, že sem můžete nahrávat rychlostí " . $msec . " MB/s.";
   } else {
      echo "což znamená, že sem můžete nahrávat rychlostí " . $ksec . " KB/s.";
   }
?>

<br><br>

<table bgcolor=#E6E6E6 cellspacing=5 cellpadding=0 border=0 style="color: #000000;">

<?php

$service_speeds = array();

foreach(array_keys($services) as $service) {
	array_push ($service_speeds, $service);
}

$max_in_array = max ($service_speeds);
$max_in_array = max ($max_in_array, $kbps);

$bar_scale = 400/$max_in_array;

foreach(array_keys($services) as $service) {

	if (($service > $kbps) && $you_out == False) {
		$bar_size = $kbps * $bar_scale;
		$you_bar_height = $bar_height; // + 5;
		echo "<tr>\n";
		echo "<td align=left><b>$kbps kbit/s</b></td>\n";
		echo "<td align=center><b>výsledek</b></td>\n";
		echo "<td align=left><img src=../images/$user_graph_image
			height=$you_bar_height width=$bar_size></td>"; 
		echo "</tr>\n";
		$you_out = True;
	}


	$name = $services[$service]["name"];
	$image = $services[$service]["image"];
	$bar_size = $service * $bar_scale;

	echo "<tr>\n";
	echo "<td align=left>$service kbit/s</td>\n";
	echo "<td align=center>$name</td>\n";
	echo "<td align=left><img src=../images/$image height=$bar_height
		width=$bar_size></td>"; 
	echo "</tr>\n";

}

	if ($you_out == False) {
			$bar_size = $kbps * $bar_scale;
		$you_bar_height = $bar_height ;//+ 5;
		echo "<tr>\n";
		echo "<td align=left><b>$kbps kbit/s</b></td>\n";
		echo "<td align=center><b>výsledek</b></td>\n";
		echo "<td align=left><img src=../images/$user_graph_image
			height=$you_bar_height width=$bar_size></td>"; 
		echo "</tr>\n";
	}

echo '</table>
<br><br>';


echo '<a href="./">Otestovat znovu</a> / ' . $footer_Upload . '<br><br>' . $footer;
?>
</center>
</body>
</html>

<?php

if ($mysql == true) {
	$link = mysql_connect($database["host"], $database["login"],
		$database["password"])
    	or die("Could not connect");
	mysql_select_db($database["database"])
    	or die("Could not select database");

	$ip = $_SERVER['REMOTE_ADDR'];
	$name = gethostbyaddr($ip);
	$query = 'INSERT INTO readings (down, speed, ip, name, browser) VALUES ("0", "'.$kbps.'", "'.$ip.'", "'.$name.'", "'.mysql_escape_string($_SERVER['HTTP_USER_AGENT']).'")';
	$result = mysql_query($query)
    	or die("Query failed");
}

?>
