<!-- This is licensed under the GNU Public License -->
<!-- Author: Ashus -->
<?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">
		<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>
<?php 
echo $header;

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

function storefile($var, $maxfilesize) {
	if (($_FILES[$var]['size'] <= $maxfilesize) &&
			(is_uploaded_file($_FILES[$var]['tmp_name'])))
				{
				if (unlink ($_FILES[$var]['tmp_name']))
					{
					return true;
					}
				}
	return false;
	}

if(isset($_FILES['fname'])) {
	$filename = md5(uniqid(time()));
	if (storefile('fname', 5242880)) {
		$uploadtime = (round(microtime(true)*1000)-$_POST['send_time']+$_POST['client_time']-$_POST['server_time'])/1000;
		$kbytes_of_data = $_FILES['fname']['size']/1024;
		$linespeed = $kbytes_of_data / $uploadtime;
		$kbps = (round(($linespeed*8)*10*1.024))/10;
		echo '<script language="JavaScript">
			nextpage = \'results.php?kbps=' . $kbps . '&uploadtime=' . $uploadtime . '&KB=' . $kbytes_of_data . '\';
			document.location.href=nextpage;
			// -->
			</script>';
	} else {
		echo('Chyba při uploadu (souhlasí velikost souboru?)...');
	}
} else {

echo '<form name="uploadspdtst" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'" method="POST" onSubmit="return StartCounter();">';
echo "<script language=\"JavaScript\">
<!--
	function RightNow() {
		time = new Date();
		return time.getTime();
		}
	function StartCounter() {
		now_time = RightNow();
		var send_time = document.getElementById('send_time');
		send_time.value = now_time;
		return true;
		}
	client_time = RightNow();
	document.write('<input type=\"hidden\" name=\"client_time\" value=\"'+client_time+'\">');
// -->
</script>";
echo '<input type="hidden" name="server_time" value="'.(round(microtime(true)*1000)).'" />
	<input type="hidden" name="send_time" value="">
	<input type="hidden" name="MAX_FILE_SIZE" value="5242880" />
    Vyberte nekomprimovatelný soubor (max. 5 MB):<br><br>
	<input name="fname" type="file" /><br><br>
    <input class="button" type="submit" value="OK" />
</form>
<br><br>
Pokud právě nemáte žádný vhodný soubor, můžete použít <b>testovací</b>:<br><small>
(pravým tlačítkem a uložit jako)</small>
<br>';

$i=0;
foreach ($avail_images as $one)
	{
	if ($one > 5120) Break;
	$i++;
	echo '<a href="../'.$images_path_1.$i.'.png">test_'.$i.'.png ('.$one.' kB)</a><br>';
	}
echo '<a href="../test_5mb.bin">test_5mb.bin (5120 kB)</a><br><br>';

echo $footer . '<br><br>' . $footer_Upload;
}

?>
</center>
</body>
</html>
