Update to PHP 7.
[cl7.git] / php / panel.php
1 <?php # coding:utf-8
2
3 include_once("traitement_pre_affichage.php");
4
5 /**
6 * Représente le panel latéral contenant la liste des inscrits,
7 * la boite de login et d'autres informations.
8 */
9 class Panel
10 {
11 private $participant;
12
13 function Panel($participant)
14 {
15 $this->participant = $participant;
16 }
17
18 function rendre()
19 {
20 # selection de tous les participants
21 $res_SQL = pg_query("SELECT pseudo FROM participants ORDER BY id");
22
23 echo '<div id="nbParticipants"><em>', pg_num_rows($res_SQL), '</em> inscrit', (pg_num_rows($res_SQL) > 1 ? 's' : ''), '</div>';
24
25 # affichage des participants
26 if (pg_num_rows($res_SQL) > 0)
27 echo '<ul id="participants">';
28 while ($participant_pseudo = pg_fetch_object($res_SQL))
29 echo '<li>', traitement_pre_affichage($participant_pseudo->pseudo, 8), '</li>';
30 if (pg_num_rows($res_SQL) > 0)
31 echo '</ul>';
32
33 if($this->participant->existe())
34 {
35 echo'
36 <form method="post" action="index.php?';
37
38 foreach($_GET as $nom => $valeur)
39 echo $nom,'=',$valeur,'&amp;';
40
41 echo'">
42 <p><input type="hidden" name="effacer_cookie" value="1" /></p>
43 <p><input type="submit" value="logout" /></p>
44 </form>';
45 }
46 else
47 {
48 echo'
49 <form method="post" action="index.php?';
50
51 foreach($_GET as $nom => $valeur)
52 echo $nom,'=',$valeur,'&amp;';
53
54 echo'">
55 <p>login / pass</p>
56 <p><input type="hidden" name="log" value="1" /></p>
57 <p><input type="text" name="pseudo" size="10" maxlength="30" /></p>
58 <p><input type="password" name="password" size="10" maxlength="15" /></p>
59 <p><input type="submit" value="oki" class="submitInvisible" /></p>
60 </form>
61 ';
62 }
63 }
64 }
65 ?>