<?php /* Table Game */ require_once("../mysql_connect.inc.php"); $authentication_key=$_POST['authentication_key']; if ($authentication_key !== "azertyuiop") { header("Clé d'authentification non reconnue", true, 401); exit(); } $parameters=json_decode($_POST['parameters'], true); if ( !is_array($parameters) || !is_numeric($parameters['longpollingduration']) ){ header("Erreur paramètres", true, 400); exit(); } $longpollingduration=$parameters['longpollingduration']; $nbusersthreshold=$parameters['nbusersthreshold']; $questiontimeframe=$parameters['questiontimeframe']; $nbquestions=$parameters['nbquestions']; if ( $parameters['flushusertable'] === "true" ) { $req="TRUNCATE TABLE User;"; mysql_query($req); //TODO check result } $req="INSERT INTO Game VALUES (NULL, $longpollingduration, $nbusersthreshold, $questiontimeframe, $nbquestions)"; $res=mysql_query($req); echo mysql_error(); if ( $res===true && mysql_affected_rows() === 1 ) { header("OK : CREATED", true, 201); } else { header("erreur", true, 400); } ?>