MOD #137 création de classes et suppression de variables globales
[cl7.git] / php / panel.php
diff --git a/php/panel.php b/php/panel.php
new file mode 100644 (file)
index 0000000..21c2fa4
--- /dev/null
@@ -0,0 +1,71 @@
+<?php # coding:utf-8
+\r
+include_once("traitement_pre_affichage.php");\r
+\r
+/**\r
+  * Représente le panel latéral contenant la liste des inscrits,\r
+  * la boite de login et d'autres informations.\r
+  */\r
+class Panel\r
+{\r
+   private $participant;\r
+\r
+   function Panel($participant)\r
+   {\r
+      $this->participant;\r
+   }\r
+\r
+   function rendre()\r
+   {
+      # selection de tous les participants
+      $res_SQL = mysql_query("SELECT pseudo FROM participants ORDER BY id");
+
+      echo '<div id="nbParticipants"><em>', mysql_num_rows($res_SQL), '</em> inscrit', (mysql_num_rows($res_SQL) > 1 ? 's' : ''), '</div>';
+
+      # affichage des participants
+      if (mysql_num_rows($res_SQL) > 0)
+         echo '<ul id="participants">';
+      for ($i=0; $i<mysql_num_rows($res_SQL); $i++)
+      {
+         mysql_data_seek($res_SQL, $i);
+         $le_participant_pseudo = mysql_fetch_object($res_SQL);
+         echo '<li>', traitement_pre_affichage($le_participant_pseudo->pseudo, 8), '</li>';
+      }
+      if (mysql_num_rows($res_SQL) > 0)
+         echo '</ul>';
+
+      if($this->participant->valide)
+      {
+         echo'
+         <form method="post" action="index.php?';
+         
+         foreach($HTTP_GET_VARS as $nom => $valeur)
+         echo $nom,'=',$valeur,'&amp;';
+         
+         echo'">
+          <p><input type="hidden" name="effacer_cookie" value="1" /></p>
+          <p><input type="submit" value="logout" /></p>
+         </form>';
+      }
+      else
+      {
+         if (isset($log)) echo '<em>[erreur de loggation]</em>';
+         
+         echo'
+         <form method="post" action="index.php?';
+         
+         foreach($HTTP_GET_VARS as $nom => $valeur)
+         echo $nom,'=',$valeur,'&amp;';
+         
+         echo'">
+         <p>login / pass</p>
+         <p><input type="hidden" name="log" value="1" /></p>
+         <p><input type="text" name="pseudo" size="10" maxlength="30" /></p>
+         <p><input type="password" name="password" size="10" maxlength="10" /></p>
+         <p><input type="submit" value="oki" class="submitInvisible" /></p>
+         </form>
+         ';
+      }\r
+   }\r
+}
+?>