Create speedtest.php

This commit is contained in:
tianyu 2015-08-03 20:58:37 +08:00
parent cdfbb5c63e
commit 01ba20bca9
1 changed files with 27 additions and 0 deletions

27
speedtest/speedtest.php Normal file
View File

@ -0,0 +1,27 @@
<?php
# I recommend you use HTTPS and Basic access authentication to protect this file
$method = $_SERVER['REQUEST_METHOD'];
switch ($method) {
case 'POST':
$name = $_POST['client'];
$time = $_POST['time'];
$extra = $_POST['extra'];
# echo $extra;
// write extra to file.
$filename = $name;
echo $filename;
$fp = fopen($filename.".txt","a");
if( $fp == false ){
echo "Open file error";
}else{
fwrite($fp,$extra);
fclose($fp);
shell_exec("./speedtest.py . ".escapeshellarg($filename)." ".escapeshellarg($time)." >>/tmp/speedtest.txt 2>&1 &");
}
break;
case 'GET':
echo '<head><meta http-equiv="refresh" content="0; url=home.htm" /></head>';
break;
}
?>