commit 29244a1875ba7ec84958fe2cbe16225f9ba02a44
parent 630c04215fc835e2d132c060fe724a4a4e4e8595
Author: Bertrand BRUN <bertrand0brun@gmail.com>
Date: Thu, 17 Mar 2011 11:57:43 +0100
Merge branch 'master' of https://github.com/jsmaniac/2011-m1s2-ter
Diffstat:
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/code/serveur/README.sh b/code/serveur/README.sh
@@ -20,8 +20,7 @@ echo "==============================="
echo
echo "Étape 4/5 : Insertion dans la bdd"
echo "================================="
-[ -e php/db ] && mv php/db php/db.old
-pv sql | sqlite3 php/db
+pv sql | sqlite3 php/db.new
echo
@@ -33,5 +32,8 @@ sudo chgrp -R www-data php > /tmp/log-chmod-pticlic || sudo chgrp -R www php > /
echo "ATTENTION : Les deux méthodes de chgrp ont échoué !"
exit 1
}
-chmod 664 php/db
+chmod 664 php/db.new
chmod 775 php
+
+[ -e php/db ] && mv php/db php/db.old
+mv php/db.new php/db
+\ No newline at end of file
diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php
@@ -24,7 +24,7 @@ require_once("db.php");
* normalizeProbas($row);
* setGame($user, $pgid, $gid, $answers);
* get_game_relations();
-* setGameGetScore($pgid, $gid, $answers);
+* setGameGetScore($user, $pgid, $gid, $answers);
* insertNode($node);
* getNodeEid($node);
*/
@@ -164,6 +164,7 @@ function cgChooseRelations()
*/
function cgBuildCloud($centerEid, $cloudSize, $sources, $sumWeights)
{
+ $db = getDB();
// On boucle tant qu'il n'y a pas eu au moins 2 sources épuisées
$cloud = array();
$nbFailed = 0;
@@ -213,6 +214,8 @@ function cgBuildCloud($centerEid, $cloudSize, $sources, $sumWeights)
$rejected = false;
// Ne pas mettre le mot central dans le nuage.
if ($res['eid'] == $centerEid) { continue; }
+ $nodeName = $db->querySingle("select name from node where eid=".$res['eid'].";");
+ if (substr($nodeName, 0, 2) == "::") { continue; }
foreach ($cloud as $c) {
if ($c['eid'] == $res['eid']) {
$nbFailed++;
@@ -578,7 +581,7 @@ function setGame($user, $pgid, $gid, $answers)
$db->exec("commit;");
$scores['total'] = $gameScore;
$scores['nb'] = $nbScores;
- $scores['alreadyPlayed'] = 0;
+ $scores['alreadyPlayed'] = 'false';
return $scores;
}
@@ -603,7 +606,7 @@ function getGameScores($user, $pgid, $gid) {
}
$scores['total'] = $gameScore;
$scores['nb'] = $nbScores;
- $scores['alreadyPlayed'] = 1;
+ $scores['alreadyPlayed'] = 'true';
return $scores;
}
@@ -624,7 +627,7 @@ function get_game_relations()
return $relations;
}
-function setGameGetScore($pgid, $gid, $answers) {
+function setGameGetScore($user, $pgid, $gid, $answers) {
$scores = setGame($user, intval($pgid), intval($gid), $answers);
// On renvoie une nouvelle partie pour garder le client toujours bien alimenté.
echo '{"scoreTotal":'.$scores['total'];
diff --git a/code/serveur/php/server.php b/code/serveur/php/server.php
@@ -70,7 +70,7 @@ function main()
}
// TODO : il faudrait filtrer les paramètres qui correspondent à une réponse
// au lieu d'envoyer $_GET en entier, mais on ne connaît pas leur nom à l'avance.
- setGameGetScore($_GET['pgid'], $_GET['gid'], $_GET);
+ setGameGetScore($user, $_GET['pgid'], $_GET['gid'], $_GET);
} else {
throw new Exception("Commande inconnue", 2);
}