From 7e415f0586afe35a45d7fc6c34bfe32f55381096 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Fri, 11 Sep 2009 12:00:03 +0200 Subject: [PATCH] =?utf8?q?MOD=20#137=20cr=C3=A9ation=20de=20classes=20et?= =?utf8?q?=20suppression=20de=20variables=20globales=20/!\=20Pas=20test?= =?utf8?q?=C3=A9,=20ya=20surement=20plus=20rien=20qui=20fonctionne=20~=5F~?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- index.php | 23 +- php/config.php | 1 - php/connexion.php | 116 +++---- php/controller.php | 290 +++++++++--------- php/menu_droit.php | 58 ---- php/pages/inscription.php | 30 +- php/pages/jeux_joues.php | 16 +- php/{ => pages}/pizzas.php | 32 +- php/panel.php | 71 +++++ ...{class_participant.php => participant.php} | 17 +- 10 files changed, 345 insertions(+), 309 deletions(-) delete mode 100644 php/menu_droit.php rename php/{ => pages}/pizzas.php (74%) create mode 100644 php/panel.php rename php/{class_participant.php => participant.php} (80%) diff --git a/index.php b/index.php index f7136c5..e0b42df 100644 --- a/index.php +++ b/index.php @@ -3,17 +3,24 @@ $page = $_GET['page']; if (!isset($page)) $page = "accueil"; #la page par défaut - /* Pour déterminer si en LAN !? $IP_SERVEUR = '192.168.1.1'; $MASK_RESEAU = '255.255.255.0'; if($titre[1] && (ip2long($REMOTE_ADDR) & ip2long($MASK_RESEAU)) != (ip2long($IP_SERVEUR) & ip2long($MASK_RESEAU))) */ -include_once("php/class_participant.php"); +include_once("php/participant.php"); include_once("php/connexion.php"); include_once("php/config.php"); include_once("php/controller.php"); +include_once("php/panel.php"); + +# Différents objets, sont accessibles directements par les pages (voir dossier '/php/pages/'). +$config = new Config(); +$connexion = new Connexion(); +$participant = $connexion->participant; +$controller = new Controller($participant); +$panel = new Panel($participant); $MENU = array( 'accueil' => 'Accueil', @@ -35,10 +42,10 @@ echo ''; - '; - + if ($controller->message_utilisateur) echo ''; + # Des constantes stockées en BD accessible par le javascript. echo ''; echo ''; @@ -91,7 +98,7 @@ echo ''; '; - include("php/menu_droit.php"); + $panel->rendre(); echo ''; } @@ -104,7 +111,7 @@ echo ''; include("php/pages/jeux_joues.php"); break; case 'inscription' : - if (Participant::nombre_participant_max_atteint() && !$le_participant->valide) + if (Participant::nombre_participant_max_atteint() && !$participant->valide) echo 'Nous sommes désolés, il n\'y a plus de places libres'; else include("php/pages/inscription.php"); @@ -128,7 +135,7 @@ echo ''; include("php/pages/photos.php"); break; case 'pizzas': - include("php/pizzas.php"); + include("php/pages/pizzas.php"); break; default : echo 'erreur, page introuvable'; diff --git a/php/config.php b/php/config.php index 4bcecc3..5730ac0 100644 --- a/php/config.php +++ b/php/config.php @@ -16,5 +16,4 @@ class Config private $config; } -$config = new Config(); ?> diff --git a/php/connexion.php b/php/connexion.php index 1c78bb0..e35e7fa 100644 --- a/php/connexion.php +++ b/php/connexion.php @@ -1,64 +1,72 @@ -' - ); - fclose($f); - echo "Le fichier a été créé, veuillez le compléter et recommencer."; - exit(); -} +include_once("participant.php"); -include_once("config_bd.php"); -include_once("class_participant.php"); - -$lien_mysql = mysql_connect($SQL_HOTE, $SQL_LOGIN, $SQL_PASS); -if (!$lien_mysql || !mysql_select_db($NOM_BASE)) +/* + * Connexion à la base de données et création du participant courant. + */ +class Connexion { - echo "Connexion à la base de données impossible. Voir le fichier 'php/config_bd.php'"; - exit(); -} + public $participant; + + funtion Connexion() + { + if (!file_exists("php/config_bd.php")) { + echo "Le fichier 'php/config_bd.php' n'existe pas, création en cours...\n"; + if (!is_writable(".")) + { + echo "Le dossier 'php' n'est pas accessible en écriture, veuillez changer les droits et recommencer."; + exit(); + } + $f = fopen("php/config_bd.php", "w"); + fwrite($f, '' + ); + fclose($f); + echo "Le fichier a été créé, veuillez le compléter et recommencer."; + exit(); + } + + include_once("config_bd.php"); + + $lien_mysql = mysql_connect($SQL_HOTE, $SQL_LOGIN, $SQL_PASS); + if (!$lien_mysql || !mysql_select_db($NOM_BASE)) + { + echo "Connexion à la base de données impossible. Voir le fichier 'php/config_bd.php'"; + exit(); + } -mysql_set_charset("UTF8"); -mysql_query('SET AUTOCOMMIT=0'); + mysql_set_charset("UTF8"); + mysql_query('SET AUTOCOMMIT=0'); -if (isset($_POST['effacer_cookie'])) # le membre se délogue -{ - setcookie("COOKIE_INFO_PATICIPANT", "", time() - 100); # 'efface' le cookie membre - unset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]); - unset($log); -} + if (isset($_POST['effacer_cookie'])) # le membre se délogue + { + setcookie("COOKIE_INFO_PATICIPANT", "", time() - 100); # 'efface' le cookie membre + unset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]); + unset($log); + } -if (isset($_POST['log'])) # le membre se logue -{ - $le_participant = new Participant($_POST['pseudo'], $_POST['password']); - if ($le_participant->valide) - { - setcookie ("COOKIE_INFO_PATICIPANT", $le_participant->info->id, time() + 31104000); + if (isset($_POST['log'])) # le membre se logue + { + $this->participant = new Participant($_POST['pseudo'], $_POST['password']); + if ($this->participant->valide) + { + setcookie ("COOKIE_INFO_PATICIPANT", $this->participant->info->id, time() + 31104000); + } + } + else if (isset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"])) # le cookie existe deja chez le participant + { + $this->participant = new Participant($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]); + } + else + { + $this->participant = new Participant(); + } } } -else if (isset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"])) # le cookie existe deja chez le participant -{ - $le_participant = new Participant($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]); -} -else -{ - $le_participant = new Participant(); -} ?> \ No newline at end of file diff --git a/php/controller.php b/php/controller.php index bec8917..5d83bab 100644 --- a/php/controller.php +++ b/php/controller.php @@ -1,163 +1,169 @@ -valide && strtolower($le_participant->info->pseudo) === strtolower($_POST['pseudo'])) // le pseudo n'a pas changé - return FALSE; - - $loginDejaPris = mysql_fetch_array(mysql_query("SELECT count(*) FROM participants WHERE pseudo = '".addslashes($_POST['pseudo'])."'")); - if ($loginDejaPris[0] > 0) + function Controller($participant) { - $message_utilisateur = "Le pseudo '".$_POST["pseudo"]."' est déjà pris"; - return TRUE; - } - return FALSE; -} + $this->participant = $participant; + + # inscription d'un nouveau participant + if (isset($_POST['inscription']) && !Participant::nombre_participant_max_atteint()) + { + if ($config->get("inscription_terminees")) + return; -/** - * Renvoie TRUE si les données d'une inscription sont valides (POST). - */ -function donnees_inscription_valides() -{ - return - $_POST['pseudo'] != "" && - $_POST['pass1'] != "" && - $_POST['pass1'] == $_POST['pass2'] && - strlen($_POST['pass1']) >= 3 && - $_POST['nom'] != "" && - $_POST['prenom'] != "" && - $_POST['e_mail'] != ""; -} + traiter_donnees_inscription(); + if (!login_deja_pris() && # vérification des données + donnees_inscription_valides() && + $_POST['accord'] == "on" + ) + { + mysql_query("BEGIN TRANSACTION"); + mysql_query(" + INSERT INTO participants + (pseudo, password, clan_nom, clan_tag, nom, prenom, age, e_mail, remarques) + VALUES ( + '".addslashes($_POST['pseudo'])."', + '".addslashes($_POST['pass1'])."', + '".addslashes($_POST['clan_nom'])."', + '".addslashes($_POST['clan_tag'])."', + '".addslashes($_POST['nom'])."', + '".addslashes($_POST['prenom'])."', + '".addslashes($_POST['age'])."', + '".addslashes($_POST['e_mail'])."', + '".addslashes($_POST['remarques'])."' + )" + ); + $id = mysql_insert_id(); + set_periodes($id); + mysql_query("COMMIT"); + + $this->participant = new participant($_POST['pseudo'], $_POST['pass1']); + setcookie("COOKIE_INFO_PATICIPANT", $this->participant->info->id, time() + 31104000); + $page = "bienvenue"; + } + } + # un participant modifie ses infos + else if(isset($_POST['modification_participant']) && $this->participant->valide) + { + if ($config->get("inscription_terminees")) + return; -/** - * Met à jour les periodes du participant dont l'id est donnée - * en fonction de $_POST["periodes"] - * Attention, cette fonction doit être appelée dans une transaction. - */ -function set_periodes($id) -{ - $periodes = $_POST['periodes']; - if (!$periodes) - $periodes = array(); + traiter_donnees_inscription(); + if (!login_deja_pris() && donnees_inscription_valides()) + { + mysql_query("BEGIN TRANSACTION"); + mysql_query("UPDATE participants SET pseudo = '".addslashes($_POST['pseudo'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET password = '".addslashes($_POST['pass1'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET clan_nom = '".addslashes($_POST['clan_nom'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET clan_tag = '".addslashes($_POST['clan_tag'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET nom = '".addslashes($_POST['nom'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET prenom = '".addslashes($_POST['prenom'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET age = '".addslashes($_POST['age'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET e_mail = '".addslashes($_POST['e_mail'])."' WHERE id = " . $this->participant->info->id); + mysql_query("UPDATE participants SET remarques = '".addslashes($_POST['remarques'])."' WHERE id = " . $this->participant->info->id); + set_periodes($this->participant->info->id); + mysql_query("COMMIT"); + //header("Location: /inscrits.html"); + $this->message_utilisateur = "Les modifications ont été enregistrées"; + $page = "inscrits"; // TODO : moche car la page ne va plus correspondre à l'url + } + } + # vote pour des jeux (autorisé même lorsque les inscriptions sont terminées) + else if (isset($_POST['set_jeux_joues']) && $this->participant->valide) + { + $votes = $_POST['votes']; + if (!$votes) + $votes = array(); + + mysql_query("BEGIN TRANSACTION"); + + # l'utilisateur peut proposer le nom d'un jeu qui ne se trouve pas dans la liste + $jeu = trim($_POST['jeu']); + if ($jeu !== '') + { + mysql_query("INSERT INTO jeux (nom) VALUES ('".addslashes($jeu)."')"); + $id = mysql_insert_id(); + if ($id != 0) # si le jeu se trouve déjà dans la liste alors $id == 0 + array_unshift($votes, $id); + } + + # suppression des anciens votes (remplacement par les nouveaux) + mysql_query("DELETE FROM jeux_choisis WHERE participant_id = " . $this->participant->info->id); + + # traite les trois premiers votes + for ($i = 0; $i < count($votes) && $i < $config->get('nb_votes_jeux'); $i++) + { + mysql_query("INSERT INTO jeux_choisis (participant_id, jeu_id) VALUES (".$this->participant->info->id.", ".(int)$votes[$i].")"); + } + + mysql_query("COMMIT"); + } + } - mysql_query("DELETE FROM participations WHERE participant_id = " . (int)$id); - for ($i = 0; $i < count($periodes); $i++) + /** + * Traiter les données de l'inscription (trim par exemple). + */ + private function traiter_donnees_inscription() { - mysql_query(" - INSERT INTO participations (participant_id, periode_id) - VALUES (".$id.", ".(int)$periodes[$i].") - "); + $_POST['pseudo'] = trim($_POST['pseudo']); } -} - -# inscription d'un nouveau participant -if (isset($_POST['inscription']) && !Participant::nombre_participant_max_atteint()) -{ - if ($config->get("inscription_terminees")) - return; - traiter_donnees_inscription(); - if (!login_deja_pris() && # vérification des données - donnees_inscription_valides() && - $_POST['accord'] == "on" - ) + private function login_deja_pris() { - mysql_query("BEGIN TRANSACTION"); - mysql_query(" - INSERT INTO participants - (pseudo, password, clan_nom, clan_tag, nom, prenom, age, e_mail, remarques) - VALUES ( - '".addslashes($_POST['pseudo'])."', - '".addslashes($_POST['pass1'])."', - '".addslashes($_POST['clan_nom'])."', - '".addslashes($_POST['clan_tag'])."', - '".addslashes($_POST['nom'])."', - '".addslashes($_POST['prenom'])."', - '".addslashes($_POST['age'])."', - '".addslashes($_POST['e_mail'])."', - '".addslashes($_POST['remarques'])."' - )" - ); - $id = mysql_insert_id(); - set_periodes($id); - mysql_query("COMMIT"); - - $le_participant = new participant($_POST['pseudo'], $_POST['pass1']); - setcookie("COOKIE_INFO_PATICIPANT", $le_participant->info->id, time() + 31104000); - $page = "bienvenue"; + if ($this->participant->valide && strtolower($this->participant->info->pseudo) === strtolower($_POST['pseudo'])) // le pseudo n'a pas changé + return FALSE; + + $loginDejaPris = mysql_fetch_array(mysql_query("SELECT count(*) FROM participants WHERE pseudo = '".addslashes($_POST['pseudo'])."'")); + if ($loginDejaPris[0] > 0) + { + $this->message_utilisateur = "Le pseudo '".$_POST["pseudo"]."' est déjà pris"; + return TRUE; + } + return FALSE; } -} -# un participant modifie ses infos -else if(isset($_POST['modification_participant']) && $le_participant->valide) -{ - if ($config->get("inscription_terminees")) - return; - traiter_donnees_inscription(); - if (!login_deja_pris() && donnees_inscription_valides()) - { - mysql_query("BEGIN TRANSACTION"); - mysql_query("UPDATE participants SET pseudo = '".addslashes($_POST['pseudo'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET password = '".addslashes($_POST['pass1'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET clan_nom = '".addslashes($_POST['clan_nom'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET clan_tag = '".addslashes($_POST['clan_tag'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET nom = '".addslashes($_POST['nom'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET prenom = '".addslashes($_POST['prenom'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET age = '".addslashes($_POST['age'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET e_mail = '".addslashes($_POST['e_mail'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET remarques = '".addslashes($_POST['remarques'])."' WHERE id = " . $le_participant->info->id); - set_periodes($le_participant->info->id); - mysql_query("COMMIT"); - //header("Location: /inscrits.html"); - $message_utilisateur = "Les modifications ont été enregistrées"; - $page = "inscrits"; // TODO : moche car la page ne va plus correspondre à l'url - } -} -# vote pour des jeux (autorisé même lorsque les inscriptions sont terminées) -else if (isset($_POST['set_jeux_joues']) && $le_participant->valide) -{ - $votes = $_POST['votes']; - if (!$votes) - $votes = array(); - - mysql_query("BEGIN TRANSACTION"); - - # l'utilisateur peut proposer le nom d'un jeu qui ne se trouve pas dans la liste - $jeu = trim($_POST['jeu']); - if ($jeu !== '') + /** + * Renvoie TRUE si les données d'une inscription sont valides (POST). + */ + private function donnees_inscription_valides() { - mysql_query("INSERT INTO jeux (nom) VALUES ('".addslashes($jeu)."')"); - $id = mysql_insert_id(); - if ($id != 0) # si le jeu se trouve déjà dans la liste alors $id == 0 - array_unshift($votes, $id); + return + $_POST['pseudo'] != "" && + $_POST['pass1'] != "" && + $_POST['pass1'] == $_POST['pass2'] && + strlen($_POST['pass1']) >= 3 && + $_POST['nom'] != "" && + $_POST['prenom'] != "" && + $_POST['e_mail'] != ""; } - - # suppression des anciens votes (remplacement par les nouveaux) - mysql_query("DELETE FROM jeux_choisis WHERE participant_id = " . $le_participant->info->id); - # traite les trois premiers votes - for ($i = 0; $i < count($votes) && $i < $config->get('nb_votes_jeux'); $i++) + /** + * Met à jour les periodes du participant dont l'id est donnée + * en fonction de $_POST["periodes"] + * Attention, cette fonction doit être appelée dans une transaction. + */ + private function set_periodes($id) { - mysql_query("INSERT INTO jeux_choisis (participant_id, jeu_id) VALUES (".$le_participant->info->id.", ".(int)$votes[$i].")"); + $periodes = $_POST['periodes']; + if (!$periodes) + $periodes = array(); + + mysql_query("DELETE FROM participations WHERE participant_id = " . (int)$id); + for ($i = 0; $i < count($periodes); $i++) + { + mysql_query(" + INSERT INTO participations (participant_id, periode_id) + VALUES (".$id.", ".(int)$periodes[$i].") + "); + } } - - mysql_query("COMMIT"); } + ?> diff --git a/php/menu_droit.php b/php/menu_droit.php deleted file mode 100644 index 32800c9..0000000 --- a/php/menu_droit.php +++ /dev/null @@ -1,58 +0,0 @@ -', mysql_num_rows($res_SQL), ' inscrit', (mysql_num_rows($res_SQL) > 1 ? 's' : ''), ''; - -# affichage des participants -if (mysql_num_rows($res_SQL) > 0) - echo ''; -?> - - -valide) -{ - echo' -
-

-

-
'; -} -else -{ - if (isset($log)) echo '[erreur de loggation]'; - - echo' -
-

login / pass

-

-

-

-

-
- '; -} -?> diff --git a/php/pages/inscription.php b/php/pages/inscription.php index dc415f0..cfdd1e7 100644 --- a/php/pages/inscription.php +++ b/php/pages/inscription.php @@ -6,7 +6,7 @@ if ($config->get("inscription_terminees")) return; } -if ($le_participant->valide) +if ($participant->valide) echo '

Modification de mes infos

'; else echo'

Les personnes inscrites s\'engagent à être présentes à la LAN et à payer la somme convenue.

Elles peuvent se désinscrirent en cas d\'empèchements majeurs.

'; @@ -14,7 +14,7 @@ else
valide) + if($participant->valide) echo '

'; else echo '

'; @@ -29,7 +29,7 @@ else pseudo (login) - " /> + " /> @@ -37,8 +37,8 @@ else password (pour pouvoir par la suite modifier mes infos) - " /> - re: " /> + " /> + re: " /> @@ -46,7 +46,7 @@ else clan name - " /> + " /> + @@ -72,7 +72,7 @@ else nom - + @@ -80,7 +80,7 @@ else prénom - + @@ -88,7 +88,7 @@ else age - + @@ -96,7 +96,7 @@ else email (non-public) - + @@ -109,12 +109,12 @@ else SELECT periodes.id, periodes.nom, participations.participant_id FROM periodes LEFT JOIN participations ON periodes.id = participations.periode_id - AND participations.participant_id = ".($le_participant->valide ? $le_participant->info->id : "0")." + AND participations.participant_id = ".($participant->valide ? $participant->info->id : "0")." ORDER BY periodes.id "); while($periode = mysql_fetch_object($res)) { - echo '

valide && (!$_POST['periodes'] || in_array($periode->id, $_POST['periodes']))) || $periode->participant_id ? 'checked="checked"' : '').' id="periode'.$periode->id.'" type="checkbox" />

'; + echo '

valide && (!$_POST['periodes'] || in_array($periode->id, $_POST['periodes']))) || $periode->participant_id ? 'checked="checked"' : '').' id="periode'.$periode->id.'" type="checkbox" />

'; } ?> @@ -132,11 +132,11 @@ else remarques - + valide) + if (!$participant->valide) echo' diff --git a/php/pages/jeux_joues.php b/php/pages/jeux_joues.php index 135f57d..6bf932d 100644 --- a/php/pages/jeux_joues.php +++ b/php/pages/jeux_joues.php @@ -2,7 +2,7 @@ include_once("php/traitement_pre_affichage.php"); -if (!$le_participant->valide) +if (!$participant->valide) { echo '

Remarque : Il faut être inscrit pour pouvoir voter.

'; } @@ -12,7 +12,7 @@ echo '

- ', ($le_participant->valide ? '' : ''), ''; + ', ($participant->valide ? '' : ''), ''; $jeux_query = mysql_query(" SELECT jeux.id, jeux.nom, jeux_choisis.participant_id, COUNT(*) + IF(participant_id is not null, 1, 0) - 1 AS nb_vote @@ -24,18 +24,18 @@ $jeux_query = mysql_query(" while ($jeu = mysql_fetch_object($jeux_query)) { # est-ce que le participant courant à voté pour ce jeu ? - if ($le_participant->valide) + if ($participant->valide) { $a_vote = mysql_fetch_row(mysql_query(" SELECT COUNT(*) FROM jeux_choisis - WHERE participant_id = ".$le_participant->info->id." AND jeu_id = ".$jeu->id + WHERE participant_id = ".$participant->info->id." AND jeu_id = ".$jeu->id )); $a_vote = $a_vote[0]; } else $a_vote = FALSE; echo '', - $le_participant->valide ? '' : '', + $participant->valide ? '' : '', '', ''; } @@ -43,7 +43,7 @@ while ($jeu = mysql_fetch_object($jeux_query)) echo '
VotesJeux
VotesJeux
' . $jeu->nb_vote . '' . traitement_pre_affichage($jeu->nom) . '
'; -if ($le_participant->valide) +if ($participant->valide) echo '

Autre :

'; @@ -51,7 +51,7 @@ if ($le_participant->valide) echo '
'; # affichage du nombre de vote restant -if ($le_participant->valide) - echo '

Nombre de votes restant : ' . $le_participant->nb_vote_restant() . '

'; +if ($participant->valide) + echo '

Nombre de votes restant : ' . $participant->nb_vote_restant() . '

'; ?> \ No newline at end of file diff --git a/php/pizzas.php b/php/pages/pizzas.php similarity index 74% rename from php/pizzas.php rename to php/pages/pizzas.php index ce43dd2..be856bd 100644 --- a/php/pizzas.php +++ b/php/pages/pizzas.php @@ -5,26 +5,26 @@ function selection_pizzas() { global $config; - global $le_participant; + global $participant; $requ = mysql_query("select * from pizzas order by nom"); echo '

commande de pizza

'; if ($config->get('pizza_peut_commander')) { - if ($le_participant->info->pizza != null) + if ($participant->info->pizza != null) echo '
Vous avez deja commandé une pizza ! mais vous pouvez encore changez votre choix:'; echo '
'; echo ''; echo ''; - echo ''; + echo ''; while($pizza = mysql_fetch_object($requ)) - echo ''; + echo ''; echo '
NomCompositionPrix
info->pizza==null?'checked':''), '>', ($le_participant->info->pizza==null?'':''), 'Aucune', ($le_participant->info->pizza==null?'':''), '
info->pizza==null?'checked':''), '>', ($participant->info->pizza==null?'':''), 'Aucune', ($participant->info->pizza==null?'':''), '
info->pizza==$pizza->id?'class="pizzaChoisie"':''),'>info->pizza==$pizza->id?'checked':''), '>
info->pizza==$pizza->id?'class="pizzaChoisie"':''),'>info->pizza==$pizza->id?'checked':''), '>

'; } else - if ($le_participant->info->pizza != null) - echo '

votre pizza ', pizza($le_participant->info->pizza), ' va bientot arriver'; + if ($participant->info->pizza != null) + echo '

votre pizza ', pizza($participant->info->pizza), ' va bientot arriver'; else echo "

la commande de pizza est terminée, veuillez attendre la prochaine vague

"; } @@ -78,7 +78,7 @@ function pizza ($id) // Affiche qui prends koi function kiakoi() { - global $le_participant; + global $participant; $requ = mysql_query("select * from participants order by nom"); @@ -91,7 +91,7 @@ function kiakoi() if ($participant->pizza != null) { $pizza = mysql_fetch_object(mysql_query("select * from pizzas where id = " . $participant->pizza)); - echo '', $participant->pseudo ,'', $pizza->nom, '', $pizza->prix, '.-', ($le_participant->info->admin?'':''), ($participant->pizza_paye?'payé':'non payé !'), ($le_participant->info->admin?'':'') ,''; + echo '', $participant->pseudo ,'', $pizza->nom, '', $pizza->prix, '.-', ($participant->info->admin?'':''), ($participant->pizza_paye?'payé':'non payé !'), ($participant->info->admin?'':'') ,''; } else echo '', $participant->pseudo ,'--', '-'; @@ -102,16 +102,16 @@ function kiakoi() function liens() { - global $le_participant; + global $participant; $res = ''; if (!isset($_GET['stats'])) $res .= '
voir les stats globaux'; - // if ($le_participant->info->admin && !isset($kiakoi)) + // if ($participant->info->admin && !isset($kiakoi)) // $res .= '
qui prend quoi'; - if ($le_participant->info->admin) + if ($participant->info->admin) $res .= '

remise a zero de toutes les commandes'; return $res; @@ -122,16 +122,16 @@ function liens() echo '
'; -if ($le_participant->valide) // le participant est loggé +if ($participant->valide) // le participant est loggé { // Si demande d'effacer les commande et que le gars est admin, le fait - if(isset($_GET['reset']) && $le_participant->info->admin) + if(isset($_GET['reset']) && $participant->info->admin) { mysql_query("update participants set pizza = null, pizza_paye = 0"); - $le_participant->info->pizza = -1; //mettre a jour le participants courant pour la beaute de l'affichage + $participant->info->pizza = -1; //mettre a jour le participants courant pour la beaute de l'affichage } - if(isset($_GET['paye']) && $le_participant->info->admin) + if(isset($_GET['paye']) && $participant->info->admin) { /////// methode d'inversion // $gars = mysql_fetch_object(mysql_query("select * from participants where id = " . $paye)); @@ -158,7 +158,7 @@ if ($le_participant->valide) // le participant est loggé echo 'Aucune pizza commandée !'; // la pizza est '-1' donc pas de pizza commandée $pizza_id = "NULL"; } - mysql_query("update participants set pizza = " . $pizza_id . " where id = " . $le_participant->info->id); + mysql_query("update participants set pizza = " . $pizza_id . " where id = " . $participant->info->id); } else selection_pizzas(); diff --git a/php/panel.php b/php/panel.php new file mode 100644 index 0000000..21c2fa4 --- /dev/null +++ b/php/panel.php @@ -0,0 +1,71 @@ +participant; + } + + function rendre() + { + # selection de tous les participants + $res_SQL = mysql_query("SELECT pseudo FROM participants ORDER BY id"); + + echo '
', mysql_num_rows($res_SQL), ' inscrit', (mysql_num_rows($res_SQL) > 1 ? 's' : ''), '
'; + + # affichage des participants + if (mysql_num_rows($res_SQL) > 0) + echo ''; + + if($this->participant->valide) + { + echo' +
+

+

+
'; + } + else + { + if (isset($log)) echo '[erreur de loggation]'; + + echo' +
+

login / pass

+

+

+

+

+
+ '; + } + } +} +?> diff --git a/php/class_participant.php b/php/participant.php similarity index 80% rename from php/class_participant.php rename to php/participant.php index ea27ffa..f7f1acf 100644 --- a/php/class_participant.php +++ b/php/participant.php @@ -1,21 +1,24 @@ - ce n'est pas un participant valide + # Aucunes valeurs transmise => ce n'est pas un participant valide. if ($v1 == NULL && $v2 == NULL) { $this->valide = 0; -- 2.43.0