diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2011-01-22 10:52:39 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2011-01-22 10:52:39 +0000 |
commit | b54487ae821da5e7574bf2135b90d0669b30b181 (patch) | |
tree | 80aa6229d2a0fbb3e03454043158d1746cc193d2 /app/v1_php/api/game | |
parent | 190b6eff45149c373786669ca4455e52692ab2c4 (diff) | |
download | 2011-usi-b54487ae821da5e7574bf2135b90d0669b30b181.tar.gz 2011-usi-b54487ae821da5e7574bf2135b90d0669b30b181.tar.bz2 2011-usi-b54487ae821da5e7574bf2135b90d0669b30b181.zip |
Ajout du code fait par ludo dans le métro pour commencer à vraiment intégrer les specs
git-svn-id: file:///var/svn/2011-usi/trunk@6 db941bf7-0cb3-4dda-9634-87faf64f93a7
Diffstat (limited to 'app/v1_php/api/game')
-rw-r--r-- | app/v1_php/api/game/index.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/v1_php/api/game/index.php b/app/v1_php/api/game/index.php new file mode 100644 index 0000000..a8658ac --- /dev/null +++ b/app/v1_php/api/game/index.php @@ -0,0 +1,44 @@ +<?php + +/* +Table Game +Unique key : +*/ + +require_once("../mysql_connect.inc.php"); + +$authentication_key=$_POST['authentication_key']; + +if ($authentication_key !== "azertyuiop") { + // header 401, "Clé d'authentification non reconnue" + echo "401, Clé d'authentification non reconnue\n"; +} + +$parameters=json_decode($_POST['parameters']); +if ( !is_array($parameters) || !is_numeric($parameters['longpollingduration']) ){ + // header 400, "Erreur" + echo "header 400, Erreur paramètres\n"; +} + +$longpollingduration=$parameters['longpollingduration']; +$nbusersthreshold=$parameters['nbusersthreshold']; +$questiontimeframe=$parameters['questiontimeframe']; +$nbquestions=$parameters['nbquestions']; + +if ( $parameters['flushusertable'] === "true" ) { + $req="TRUNCATE TABLE User;" + $res=mysql_query($req); + //TODO check result +} + +$req="INSERT INTO Game (NULL, $longpollingduration, $nbusersthreshold, $questiontimeframe, $nbquestions)"; +$res=mysql_query($req); + +if ( mysql_num_rows() === 1 ) { + //TODO header 201, "OK : CREATED" + echo "header 201, OK : CREATED\n"; +} else { + // header 400, "Erreur" + echo "header 400, Erreur insertion SQL\n"; +} +?> |