La création de partie prend maintenant en compte le nombre d'autorisation de création de parties remportées par les joueurs.
Le compteur est bien mis à jours lorsque la personne crée un partie de sorte qu'une fois qu'il est épuisé tout ses crédits il ne puisse plus en créer.
This commit is contained in:
parent
04b86bf7ee
commit
8ff4b00dca
|
@ -6,7 +6,8 @@ session_start();
|
||||||
|
|
||||||
if(!isset($_SESSION['userId']))
|
if(!isset($_SESSION['userId']))
|
||||||
header("location:login.php?return=createGame&showmsg=oth_login_createGame_nauth");
|
header("location:login.php?return=createGame&showmsg=oth_login_createGame_nauth");
|
||||||
|
|
||||||
|
$cgCount = getNbGameCreationRemained($_SESSION['userId']);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
@ -15,151 +16,161 @@ if(!isset($_SESSION['userId']))
|
||||||
<title>PtiClic - Création de partie</title>
|
<title>PtiClic - Création de partie</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<link rel="stylesheet" href="ressources/simple.css" />
|
<link rel="stylesheet" href="ressources/simple.css" />
|
||||||
<script type="text/javascript" src="ressources/jquery-1.5.1.min.js" /></script>
|
|
||||||
<script type="text/javascript" src="ressources/createGame.js" /></script>
|
<?php if($cgCount > 0) {?>
|
||||||
<style type="text/css">
|
<script type="text/javascript" src="ressources/jquery-1.5.1.min.js" /></script>
|
||||||
#wordLines input{
|
<script type="text/javascript" src="ressources/createGame.js" /></script>
|
||||||
border : 2px solid grey;
|
<?php } ?>
|
||||||
}
|
|
||||||
.status {
|
<style type="text/css">
|
||||||
visibility: hidden;
|
#wordLines input{
|
||||||
}
|
border : 2px solid grey;
|
||||||
.valid .status, #center.valid .status {
|
}
|
||||||
color: #20FF20;
|
.status {
|
||||||
visibility: visible;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
.invalid .status, #center.invalid .status, #center .status {
|
.valid .status, #center.valid .status {
|
||||||
color: #FF2020;
|
color: #20FF20;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
.invalid .status, #center.invalid .status, #center .status {
|
||||||
.wordLinesTable {
|
color: #FF2020;
|
||||||
min-height : 20px;
|
visibility: visible;
|
||||||
min-width : 20px;
|
}
|
||||||
border-collapse : collapse;
|
|
||||||
border-spacing : 0px;
|
.wordLinesTable {
|
||||||
margin-left : 30px;
|
min-height : 20px;
|
||||||
}
|
min-width : 20px;
|
||||||
|
border-collapse : collapse;
|
||||||
.wordLinesTable td {
|
border-spacing : 0px;
|
||||||
padding : 6px;
|
margin-left : 30px;
|
||||||
padding-left : 10px;
|
}
|
||||||
}
|
|
||||||
|
.wordLinesTable td {
|
||||||
.wordLinesTable .lightLine {
|
padding : 6px;
|
||||||
background-color : #F0F0D0;
|
padding-left : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wordLinesTable td:first-child {
|
.wordLinesTable .lightLine {
|
||||||
text-align : right;
|
background-color : #F0F0D0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wordLinesTable td:first-child {
|
||||||
|
text-align : right;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#center {
|
#center {
|
||||||
margin-left : 100px;
|
margin-left : 100px;
|
||||||
margin-top : 20px;
|
margin-top : 20px;
|
||||||
margin-bottom : 30px;
|
margin-bottom : 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#center label {
|
#center label {
|
||||||
border-bottom : 1px solid grey;
|
border-bottom : 1px solid grey;
|
||||||
border-left : 1px solid grey;
|
border-left : 1px solid grey;
|
||||||
-moz-border-radius : 100%;
|
-moz-border-radius : 100%;
|
||||||
padding-left : 10px;
|
padding-left : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#relations {
|
#relations {
|
||||||
margin-bottom : 20px;
|
margin-bottom : 20px;
|
||||||
margin-top : 10px;
|
margin-top : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#relations label {
|
#relations label {
|
||||||
margin-left : 40px;
|
margin-left : 40px;
|
||||||
border-bottom : 1px solid grey;
|
border-bottom : 1px solid grey;
|
||||||
border-left : 1px solid grey;
|
border-left : 1px solid grey;
|
||||||
-moz-border-radius : 100%;
|
-moz-border-radius : 100%;
|
||||||
padding-left : 10px;
|
padding-left : 10px;
|
||||||
padding-right : 10px;
|
padding-right : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#button {
|
#button {
|
||||||
margin-top : 30px;
|
margin-top : 30px;
|
||||||
margin-left : 50px;
|
margin-left : 50px;
|
||||||
margin-bottom : 40px;
|
margin-bottom : 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#button input {
|
#button input {
|
||||||
margin-left : 10px;
|
margin-left : 10px;
|
||||||
margin-right : 40px;
|
margin-right : 40px;
|
||||||
padding : 4px;
|
padding : 4px;
|
||||||
padding-left : 8px;
|
padding-left : 8px;
|
||||||
padding-right : 8px;
|
padding-right : 8px;
|
||||||
font-weight : bold;
|
font-weight : bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include("ressources/menu.inc"); ?>
|
<?php include("ressources/menu.inc"); ?>
|
||||||
<form class="content creategame">
|
<h2>Création de parties</h2>
|
||||||
<h2>Création de parties</h2>
|
<?php if($cgCount > 0) { ?>
|
||||||
<p>Cette page vous permet de créer des parties personalisées en indiquant les mots qui seront affiché pour un mot central.<br /><br />
|
<h3>Vous pouvez créer encore <?php echo $cgCount;?> partie(s).</h3>
|
||||||
<div id="errorDiv" class="message warning" style="display:none;"></div>
|
<form class="content creategame">
|
||||||
<div id="successDiv" class="message success" style="display:none;"></div>
|
<p>Cette page vous permet de créer des parties personalisées en indiquant les mots qui seront affiché pour un mot central.<br /><br />
|
||||||
<a id="newCreationLink" style="display:none;" href="createGame.php">Créer une autre partie</a>
|
<div id="errorDiv" class="message warning" style="display:none;"></div>
|
||||||
|
<div id="successDiv" class="message success" style="display:none;"></div>
|
||||||
<div id="center">
|
<a id="newCreationLink" style="display:none;" href="createGame.php">Créer une autre partie</a>
|
||||||
<label for="centralWord"> Le mot central : </label>
|
|
||||||
<input type="text" id="centralWord" name="centralWord" />
|
<div id="center">
|
||||||
<span class="status">●</span>
|
<label for="centralWord"> Le mot central : </label>
|
||||||
</div>
|
<input type="text" id="centralWord" name="centralWord" />
|
||||||
<div id="relations">
|
<span class="status">●</span>
|
||||||
<label for="relation1">Relation 1</label>
|
</div>
|
||||||
<select name="relation1" id="relation1">
|
<div id="relations">
|
||||||
</select>
|
<label for="relation1">Relation 1</label>
|
||||||
<label for="relation2">Relation 2</label>
|
<select name="relation1" id="relation1">
|
||||||
<select name="relation2" id="relation2">
|
</select>
|
||||||
</select>
|
<label for="relation2">Relation 2</label>
|
||||||
</div>
|
<select name="relation2" id="relation2">
|
||||||
<div id="wordLines">
|
</select>
|
||||||
<div id="templates" style="display:none">
|
</div>
|
||||||
<table>
|
<div id="wordLines">
|
||||||
<thead> </thead>
|
<div id="templates" style="display:none">
|
||||||
<tbody>
|
<table>
|
||||||
<tr class="wordLine">
|
<thead> </thead>
|
||||||
<td>
|
<tbody>
|
||||||
<label for="word-"></label>
|
<tr class="wordLine">
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<label for="word-"></label>
|
||||||
<input value="" class="word" type="text" id="word-"/>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<input value="" class="word" type="text" id="word-"/>
|
||||||
<span class="status">●</span>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<span class="status">●</span>
|
||||||
<input type="checkbox" id="r1-"/><label class="r1 relationLabel" for="r1-">Blabla</label>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<input type="checkbox" id="r1-"/><label class="r1 relationLabel" for="r1-">Blabla</label>
|
||||||
<input type="checkbox" id="r2-"/><label class="r2 relationLabel" for="r2-">Blabla</label>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<input type="checkbox" id="r2-"/><label class="r2 relationLabel" for="r2-">Blabla</label>
|
||||||
<input type="checkbox" id="r3-"/><label class="r3 relationLabel" for="r3-">Blabla</label>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<input type="checkbox" id="r3-"/><label class="r3 relationLabel" for="r3-">Blabla</label>
|
||||||
<input type="checkbox" id="r4-"/><label class="r4 relationLabel" for="r4-">Blabla</label>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
</tr>
|
<input type="checkbox" id="r4-"/><label class="r4 relationLabel" for="r4-">Blabla</label>
|
||||||
</tbody>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="wordLinesTable">
|
||||||
|
<tr><td></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="button"></div>
|
||||||
<table class="wordLinesTable">
|
</form>
|
||||||
<tr><td></td></tr>
|
<?php }
|
||||||
</table>
|
else {
|
||||||
</div>
|
echo '<span class="message warning">Vous ne disposez pas assez de points pour pouvoir créer des partes.</span>';
|
||||||
<div id="button"></div>
|
}?>
|
||||||
</form>
|
|
||||||
<?php include("ressources/footer.inc"); ?>
|
<?php include("ressources/footer.inc"); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -34,6 +34,7 @@ require_once("ressources/db.inc");
|
||||||
* getJAimePgid($user, $pgid);
|
* getJAimePgid($user, $pgid);
|
||||||
* setJAimePgid($user, $pgid, $value);
|
* setJAimePgid($user, $pgid, $value);
|
||||||
* addGameCreationBonus($user, $nb);
|
* addGameCreationBonus($user, $nb);
|
||||||
|
* function deleteOneGameCreation($user);
|
||||||
* getNbGameCreationRemained($user);
|
* getNbGameCreationRemained($user);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -300,6 +301,7 @@ function decodeAndInsertGame($user,$game) {
|
||||||
echo JSON_encode(false);
|
echo JSON_encode(false);
|
||||||
} else {
|
} else {
|
||||||
insertCreatedGame($centerEid,$cloud,$r1,$r2,10,$user);
|
insertCreatedGame($centerEid,$cloud,$r1,$r2,10,$user);
|
||||||
|
deleteOneGameCreation($user);
|
||||||
echo JSON_encode(true);
|
echo JSON_encode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,15 +754,20 @@ function setJAimePgid($user, $pgid, $value) {
|
||||||
|
|
||||||
function addGameCreationBonus($user, $nb) {
|
function addGameCreationBonus($user, $nb) {
|
||||||
if($nb > 0) {
|
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 true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNbGameCreationRemained() {
|
function deleteOneGameCreation($user) {
|
||||||
return getDB()->querySingle('SELECT cgCount FROM user WHERE user='.$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.'\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -79,7 +79,7 @@ if(isset($_POST['signuppswd2'])){
|
||||||
|
|
||||||
if(count($msg) == 0 && $newpage == false)
|
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($signupid)
|
||||||
. "', '" . SQLite3::escapeString(md5($signuppswd1))
|
. "', '" . SQLite3::escapeString(md5($signuppswd1))
|
||||||
. "', 0, 1, 0);"));
|
. "', 0, 1, 0);"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user