<?php

if (isset($_REQUEST['downloadtest'])) {
	// downloadtest

		$mDataLength = (int)$_REQUEST['downloadtest'];

		if ($mDataLength == 0) {
			$mDataLength = 102400;
		}

    header('Content-Type: application/binary');
    header('Cache-Control: no-cache');
		header('Content-Disposition: attachment; filename="testdata.dat"');

    flush();
    
    echo "ok\n";
    echo str_pad('', $mDataLength, '0') ;
    flush();

} else {

	if (isset($_REQUEST['uploadtest'])) {

   	// uploadtest

    $mData = $_REQUEST['uploadtest'];
    flush();

    echo "ok\n";
    echo strlen($mData)-1;
    flush();

	} else {

	  echo "notest\n";
		flush();

	}

}

?>