Ajout de l'identifiant de l'utilisateur lorsqu'il crée une partie.
This commit is contained in:
parent
cc5b862248
commit
823050840e
|
@ -27,7 +27,7 @@ create table relation(rid integer primary key autoincrement, start, end, type, w
|
|||
create table type_node(name, num);
|
||||
create table type_relation(name, num, extended_name, info);
|
||||
create table user(login primary key, mail, hash_passwd, score, ugroup);
|
||||
create table game(gid integer primary key autoincrement, eid_central_word, relation_1, relation_2, difficulty);
|
||||
create table game(gid integer primary key autoincrement, eid_central_word, relation_1, relation_2, difficulty, author);
|
||||
create table game_cloud(gid, num, difficulty, eid_word, totalWeight, probaR1, probaR2, probaR0, probaTrash);
|
||||
create table played_game(pgid integer primary key autoincrement, gid, login, timestamp);
|
||||
create table played_game_cloud(pgid, gid, type, num, relation, weight, score);
|
||||
|
|
|
@ -340,7 +340,7 @@ function insertCreatedGame($centerEid, $cloud, $r1, $r2, $totalDifficulty,$userN
|
|||
// Insère dans la base une partie avec le mot central $centerEid, le nuage $cloud et les relations $r1 et $r2
|
||||
$db->exec("begin transaction;");
|
||||
$db->exec("INSERT INTO game(gid, eid_central_word, relation_1, relation_2, difficulty, author)
|
||||
VALUES (null, $centerEid, $r1, $r2, $totalDifficulty, $userName);");
|
||||
VALUES (null, $centerEid, $r1, $r2, $totalDifficulty, '$userName');");
|
||||
$gid = $db->lastInsertRowID();
|
||||
|
||||
$t = time();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
require_once("ressources/backend.inc");
|
||||
require_once("ressources/db.inc");
|
||||
|
@ -30,14 +31,21 @@ function logError($errNum, $msg, $other="")
|
|||
*/
|
||||
function main()
|
||||
{
|
||||
if(!isset($_GET['action']) || !isset($_GET['user']) || !isset($_GET['passwd'])) {
|
||||
if(!isset($_GET['action']))
|
||||
throw new Exception("La requête est incomplète", 2);
|
||||
else if(!isset($_SESSION['userId']) && (!isset($_GET['user']) || !isset($_GET['passwd'])))
|
||||
throw new Exception("La requête est incomplète", 2);
|
||||
else if(isset($_SESSION['userId'])) {
|
||||
$user = $_SESSION['userId'];
|
||||
$loginIsOk = true;
|
||||
}
|
||||
else {
|
||||
$user = SQLite3::escapeString($_GET['user']);
|
||||
$loginIsOk = checkLogin($user, $_GET['passwd']);
|
||||
}
|
||||
|
||||
// Login
|
||||
$action = $_GET['action'];
|
||||
$user = SQLite3::escapeString($_GET['user']);
|
||||
$loginIsOk = checkLogin($user, $_GET['passwd']);
|
||||
|
||||
if ($action != 3 && (!$loginIsOk)) {
|
||||
throw new Exception("Utilisateur non enregistré ou mauvais mot de passe", 3);
|
||||
}
|
||||
|
@ -84,7 +92,7 @@ function main()
|
|||
if (!isset($_GET['game']))
|
||||
errRequestIncomplete();
|
||||
|
||||
decodeAndInsertGame($_GET['game']);
|
||||
decodeAndInsertGame($user,$_GET['game']);
|
||||
|
||||
} else {
|
||||
throw new Exception("Commande inconnue", 2);
|
||||
|
|
Loading…
Reference in New Issue
Block a user