//$_POST=$_GET;
if(isset($_POST["hash"])){
function jsonRemoveUnicodeSequences($struct) {
return preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode($struct));
}
function echoUTF($struct) {
return preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", $struct);
}
function anti_injection_login($sql, $formUse = true)
{
$sql = preg_replace("/(from|select|insert|delete|where|drop table|show tables|,|'|#|\*|--|\\\\)/i","",$sql);
$sql = trim($sql);
$sql = strip_tags($sql);
if(!$formUse || !get_magic_quotes_gpc())
$sql = addslashes($sql);
return $sql;
}
function my_query_first($query){
mysql_query('SET NAMES "utf8";');
$result = mysql_query($query) or die('Erreur SQL !
'.$query.'
'.mysql_error());
if(mysql_num_rows($result)==0) return 0;
$row = mysql_fetch_row($result);
return $row[0];
}
$unityHash = anti_injection_login($_POST["hash"]);
$phpHash = "ascidie12:"; // same code in here as in your Unity game
if ($unityHash == $phpHash){
// CONNECTIONS =========================================================
$host = "localhost"; //put your host here
$user = "root"; //in general is root
$password = "root"; //use your password here
$dbname = "virtualembryo"; //your database
$link=mysql_connect($host, $user, $password) or die("Cant connect into database");
mysql_select_db($dbname)or die("Cant connect into database");
if(isset($_POST["upload"])){ //Query on the Upload
$upload=intval($_POST["upload"]);
if($upload==0){//New data time Insertion ....
$file=$_FILES['UPLOAD_'.$_POST["id_upload"].'-'.$_POST["t"].'_txt'];
$query = 'INSERT INTO upload_time (id_upload,t,field) VALUES ('.$_POST["id_upload"].','.$_POST["t"].',"'.file_get_contents($file['tmp_name']).'")';
$result = mysql_query($query);
if (!$result) echoUTF($query);
}
if($upload==1){//New Upload
$now=new DateTime();
$query = 'INSERT INTO upload (id_people, filename,date, type) VALUES ('.$_POST["id_people"].',"'.$_POST["filename"].'","'.$now->format('Y-m-d h:s:i').'",'.$_POST["type"].')';
$result = mysql_query($query);
if (!$result) echoUTF('Error : ' . mysql_error());
else echo mysql_insert_id();
}
if($upload==2){// Update numberof Cells and minV and maxV
$SQL = 'UPDATE upload SET nbCell="'.$_POST["nbCell"].'" ,minV="'.$_POST["minV"].'" ,maxV="'.$_POST["maxV"].'" WHERE id='.$_POST["id_upload"];
$result = mysql_query($SQL);
if (!$result) echoUTF('Error : ' . mysql_error());
}
if($upload==3){//Get Upload LIST
$query = 'SELECT id,filename,date,type,nbCell,minV,maxV from upload WHERE id_people='.$_POST["id_people"];
$result = mysql_query($query);
if (!$result) echoUTF('Error : ' . mysql_error());
else {
$rows = array();
while($r = mysql_fetch_row($result)) {
$rows[] = $r;
}
print jsonRemoveUnicodeSequences($rows);
}
}
if($upload==4){// Delete dataset
$SQL = 'DELETE FROM upload WHERE id='.$_POST["id_upload"];
$result = mysql_query($SQL);
if (!$result) echoUTF('Error : ' . mysql_error());
$query = 'DELETE FROM upload_time WHERE id_upload='.$_POST["id_upload"];
$result = mysql_query($query);
if (!$result) echoUTF('Error : ' . $query);
}
if($upload==5){//Get Upload Dataset time step + step
$query = 'SELECT field from upload_time WHERE id_upload='.$_POST["id_upload"].' AND t='.$_POST["t"];
$result = mysql_query($query);
if (!$result) echoUTF('Error : ' . mysql_error());
else {
$row = mysql_fetch_row($result);
echo ($row[0]);
}
}
}
}
}
?>