summaryrefslogtreecommitdiff
path: root/app/v1_php/api/game
diff options
context:
space:
mode:
Diffstat (limited to 'app/v1_php/api/game')
-rw-r--r--app/v1_php/api/game/index.php44
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";
+}
+?>