From 8ff4b00dca6c7dde7d0ff4ae5578272e9aabb268 Mon Sep 17 00:00:00 2001 From: Yoann Date: Wed, 25 May 2011 22:48:32 +0200 Subject: [PATCH] =?UTF-8?q?La=20cr=C3=A9ation=20de=20partie=20prend=20main?= =?UTF-8?q?tenant=20en=20compte=20le=20nombre=20d'autorisation=20de=20cr?= =?UTF-8?q?=C3=A9ation=20de=20parties=20remport=C3=A9es=20par=20les=20joue?= =?UTF-8?q?urs.=20Le=20compteur=20est=20bien=20mis=20=C3=A0=20jours=20lors?= =?UTF-8?q?que=20la=20personne=20cr=C3=A9e=20un=20partie=20de=20sorte=20qu?= =?UTF-8?q?'une=20fois=20qu'il=20est=20=C3=A9puis=C3=A9=20tout=20ses=20cr?= =?UTF-8?q?=C3=A9dits=20il=20ne=20puisse=20plus=20en=20cr=C3=A9er.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/serveur/php/createGame.php | 287 ++++++++++++------------ code/serveur/php/ressources/backend.inc | 13 +- code/serveur/php/signup.php | 2 +- 3 files changed, 160 insertions(+), 142 deletions(-) diff --git a/code/serveur/php/createGame.php b/code/serveur/php/createGame.php index 2d0982d..fdb2ac0 100644 --- a/code/serveur/php/createGame.php +++ b/code/serveur/php/createGame.php @@ -6,7 +6,8 @@ session_start(); if(!isset($_SESSION['userId'])) header("location:login.php?return=createGame&showmsg=oth_login_createGame_nauth"); - + +$cgCount = getNbGameCreationRemained($_SESSION['userId']); ?> @@ -15,151 +16,161 @@ if(!isset($_SESSION['userId'])) PtiClic - Création de partie - - - + + #relations { + margin-bottom : 20px; + margin-top : 10px; + } + + #relations label { + margin-left : 40px; + border-bottom : 1px solid grey; + border-left : 1px solid grey; + -moz-border-radius : 100%; + padding-left : 10px; + padding-right : 10px; + } + + #button { + margin-top : 30px; + margin-left : 50px; + margin-bottom : 40px; + } + + #button input { + margin-left : 10px; + margin-right : 40px; + padding : 4px; + padding-left : 8px; + padding-right : 8px; + font-weight : bold; + } + + -
-

Création de parties

-

Cette page vous permet de créer des parties personalisées en indiquant les mots qui seront affiché pour un mot central.

-

- - - -
- - - -
-
- - - - -
-
- + + +
- - - -
- -
-
+
+ + Vous ne disposez pas assez de points pour pouvoir créer des partes.'; + }?> diff --git a/code/serveur/php/ressources/backend.inc b/code/serveur/php/ressources/backend.inc index bc42557..05382cc 100644 --- a/code/serveur/php/ressources/backend.inc +++ b/code/serveur/php/ressources/backend.inc @@ -34,6 +34,7 @@ require_once("ressources/db.inc"); * getJAimePgid($user, $pgid); * setJAimePgid($user, $pgid, $value); * addGameCreationBonus($user, $nb); +* function deleteOneGameCreation($user); * getNbGameCreationRemained($user); */ @@ -300,6 +301,7 @@ function decodeAndInsertGame($user,$game) { echo JSON_encode(false); } else { insertCreatedGame($centerEid,$cloud,$r1,$r2,10,$user); + deleteOneGameCreation($user); echo JSON_encode(true); } } @@ -752,15 +754,20 @@ function setJAimePgid($user, $pgid, $value) { function addGameCreationBonus($user, $nb) { if($nb > 0) { - getDB()->exec('UPDATE user SET cgCount = cgCount + '.$ng.' WHERE user='.$user); + getDB()->exec('UPDATE user SET cgCount = cgCount + '.$ng.' WHERE login=\''.$user.'\''); return true; } return false; } -function getNbGameCreationRemained() { - return getDB()->querySingle('SELECT cgCount FROM user WHERE user='.$user); +function deleteOneGameCreation($user) { + if(getNbGameCreationRemained($user) > 0) + getDB()->exec('UPDATE user SET cgCount=cgCount-1 WHERE login=\''.$user.'\''); +} + +function getNbGameCreationRemained($user) { + return getDB()->querySingle('SELECT cgCount FROM user WHERE login=\''.$user.'\''); } ?> diff --git a/code/serveur/php/signup.php b/code/serveur/php/signup.php index af6d3fb..ceb2cf9 100644 --- a/code/serveur/php/signup.php +++ b/code/serveur/php/signup.php @@ -79,7 +79,7 @@ if(isset($_POST['signuppswd2'])){ if(count($msg) == 0 && $newpage == false) { - $ok = ($db->query("INSERT INTO user(mail, login, hash_passwd, score, ugroup, sgCount) VALUES ('" . SQLite3::escapeString($signupemail) + $ok = ($db->query("INSERT INTO user(mail, login, hash_passwd, score, ugroup, cgCount) VALUES ('" . SQLite3::escapeString($signupemail) . "', '" . SQLite3::escapeString($signupid) . "', '" . SQLite3::escapeString(md5($signuppswd1)) . "', 0, 1, 0);"));