www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 2ba04949b0b321a63956c25b6e2af686afe51d14
parent 838b7426386d2db0f3232e78781bae22a4a3650b
Author: John Charron <rm_rf_windows@yahoo.fr>
Date:   Fri, 25 Feb 2011 13:37:02 +0100

Merge branch 'master' of https://github.com/jsmaniac/2011-m1s2-ter

Diffstat:
Mcode/serveur/php/createGame.php | 52++++++++++++++++++++++++++++++++++++++--------------
Mcode/serveur/php/ressources/simple.css | 8++++----
Mcode/serveur/php/ressources/strings.inc | 4++--
3 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/code/serveur/php/createGame.php b/code/serveur/php/createGame.php @@ -2,21 +2,38 @@ require_once("ressources/strings.inc"); session_start(); +$state = 0; $err = false; $msg = ""; -if(isset($_POST['nbcloudwords'])) - $nbword = $_POST['nbcloudwords']; +if(isset($_POST['nbcloudwords'])) { + $nbwords = $_POST['nbcloudwords']; -for($i = 0; $i < $nbword; $i++) - if(!isset($_POST['word'.$i]) || empty($_POST['word'.$i])) { + if(!is_numeric($nbwords) || $nbwords <= 0) { $err = true; - $msg = $strings['err_creategame_fill_all']; + $msg = $strings['err_creategame_nbwords_value']; } + else + $state = 1; + + if($state == 1) { + for($i = 0; $i < $nbwords; $i++) + if(!isset($_POST['word'.$i]) || empty($_POST['word'.$i])) { + $err = true; + $msg = $strings['err_creategame_fill_all']; + break; + } + } +} +else + $err = true; if($err == false) - $state = 0; -?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + $state = 1; + +?> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <title>PtiClic Android - Création de partie</title> @@ -26,28 +43,35 @@ if($err == false) <body> <?php include("ressources/menu.inc"); ?> <div class="content"> -<<<<<<< HEAD + <h2>Création de parties</h2> <?php if(isset($_POST['nbcloudwords']) && $_POST['nbcloudwords'] > 0) echo '<p>Remplissez le mot central ainsi que les différents mots du nuage pour réaliser un partie personalisée.<br /> Une fois satisfait de votre partie cliquez sur "Enregistrer la partie"'; else echo '<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 /> - Veuillez entrer le nombre de mots composant le nuage dans le formulaire ci-dessous avant de continuer.</p>'; + Veuillez entrer le nombre de mots composant le nuage dans le formulaire ci-dessous avant de continuer.</p><br />'; ?> <form action="createGame.php" method="POST"> - <table class="creategametbl"> <?php - if(!isset($_POST["nbcloudwords"])) { + if($err == true && $msg != "") + echo '<span class="message warning">'.$msg.'</span>'; + else if ($msg != "") + echo '<span class="message success">'.$msg.'</span>'; + + if($state == 0) { + echo '<table class="creategametbl">'; echo '<tr><td><label for="nbcloudwords"> Nombre de mots du nuage : </label></td>'; - echo '<td><input type="text" name="nbcloudwords" /></td></tr>'; + echo '<td id="td2" ><input type="text" name="nbcloudwords" /></td></tr>'; echo '<tr><td id="td2"></td><td><input type="submit" value="suivant" /></td></tr>'; } else { + echo '<table class="creategametbl25">'; + echo '<input type="hidden" name="nbcloudwords" value="'.$nbwords.'" />'; echo '<tr><td colspan="2"><label for="centralword">Mot central : </label><br /><br /></td>'; echo '<td colspan="2" id="td2"><input type="text" name="centralword" /><br /><br /></td>'; - for($i = 0; $i < $_POST['nbcloudwords']; $i++) { + for($i = 0; $i < $nbwords; $i++) { if($i % 2 == 0) { echo '</tr><tr><td><label for="word'.$i.'">Mot '.($i+1).' : </label></td>'; echo '<td id="td2"><input type="text" name="word'.$i.'" /></td>'; @@ -58,7 +82,7 @@ if($err == false) } } - if($_POST['nbcloudwords'] % 2 != 0) + if($nbwords % 2 != 0) echo '<td></td>'; echo '</tr><tr><td colspan="2"></td><td colspan="2" id="td2"><input type="submit" value="Enregistrer la partie" /></td></tr>'; diff --git a/code/serveur/php/ressources/simple.css b/code/serveur/php/ressources/simple.css @@ -57,25 +57,25 @@ margin-left : 4%; } -.logintbl td, .contactbl td, .signuptbl td { +.logintbl td, .contactbl td, .signuptbl td, .creategametbl td { width : 50%; text-align : right; padding-left : 5px; padding-right : 5px; } -.creategametbl td { +.creategametbl25 td { width : 25%; text-align : right; padding-left : 5px; padding-right : 5px; } -.logintbl #td2, .contactbl #td2, .signuptbl #td2, .creategametbl #td2 { +.logintbl #td2, .contactbl #td2, .signuptbl #td2, .creategametbl #td2, .creategametbl25 #td2 { text-align : left; } -.logintbl input[type=submit], .contacttbl input[type=submit], .signuptbl input[type=submit], .creategametbl input[type=submit] { +.logintbl input[type=submit], .contacttbl input[type=submit], .signuptbl input[type=submit], .creategametbl input[type=submit], .creategametbl25 input[type=submit] { display : block; margin-left : 0px; margin-top : 2em; diff --git a/code/serveur/php/ressources/strings.inc b/code/serveur/php/ressources/strings.inc @@ -7,6 +7,7 @@ $strings['ok_contact_msg_sent'] = "Votre message à été envoyé, nous vous rem $strings['err_contact_fill_all'] = "Veuillez remplir tout les champs."; $strings['err_creategame_fill_all'] = "Tous les mots du nage ne sont pas renseignés."; +$strings['err_creategame_nbwords_value'] = "Veuillez entrer une valeur supérieure à zéro."; $strings['err_index_invalid_msg'] = "Paramètre de la requête invalide. Merci de nous signaler le problème."; $strings['err_index_redirect'] = "Erreur de redirection. Merci de nous signaler le problème."; @@ -32,4 +33,4 @@ $strings['err_signup_dbinsert'] = "Une erreur interne est survenue lors de l'ins $strings['err_download_notauth'] = "Pour accéder à la page de téléchargement de l\'application vous devez être authentifié." -?> -\ No newline at end of file +?>