forked from leblanc-simon/OpenSondage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfos_sondage.php
272 lines (227 loc) · 10.1 KB
/
infos_sondage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<?php
//==========================================================================
//
//Université de Strasbourg - Direction Informatique
//Auteur : Guilhem BORGHESI
//Création : Février 2008
//
//borghesi@unistra.fr
//
//Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
//respectant les principes de diffusion des logiciels libres. Vous pouvez
//utiliser, modifier et/ou redistribuer ce programme sous les conditions
//de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
//sur le site "http://www.cecill.info".
//
//Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
//pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
//termes. Vous pouvez trouver une copie de la licence dans le fichier LICENCE.
//
//==========================================================================
//
//Université de Strasbourg - Direction Informatique
//Author : Guilhem BORGHESI
//Creation : Feb 2008
//
//borghesi@unistra.fr
//
//This software is governed by the CeCILL-B license under French law and
//abiding by the rules of distribution of free software. You can use,
//modify and/ or redistribute the software under the terms of the CeCILL-B
//license as circulated by CEA, CNRS and INRIA at the following URL
//"http://www.cecill.info".
//
//The fact that you are presently reading this means that you have had
//knowledge of the CeCILL-B license and that you accept its terms. You can
//find a copy of this license in the file LICENSE.
//
//==========================================================================
session_start();
include_once('fonctions.php');
if (file_exists('bandeaux_local.php')) {
include_once('bandeaux_local.php');
} else {
include_once('bandeaux.php');
}
// On teste toutes les variables pour supprimer l'ensemble des warnings PHP
// On transforme en entites html les données afin éviter les failles XSS
$post_var = array('choix_sondage', 'poursuivre', 'titre', 'nom', 'adresse', 'commentaires', 'studsplus', 'mailsonde', 'creation_sondage_date', 'creation_sondage_date_x', 'creation_sondage_autre', 'creation_sondage_autre_x',);
foreach ($post_var as $var) {
if (isset($_POST[$var]) === true) {
$$var = htmlentities($_POST[$var], ENT_QUOTES, 'UTF-8');
} else {
$$var = null;
}
}
// On initialise egalement la session car sinon bonjour les warning :-)
$session_var = array('choix_sondage', 'titre', 'nom', 'adresse', 'commentaires', 'mailsonde', 'studsplus', );
foreach ($session_var as $var) {
if (issetAndNoEmpty($var, $_SESSION) === false) {
$_SESSION[$var] = null;
}
}
// On initialise également les autres variables
$erreur_adresse = false;
$erreur_injection_titre = false;
$erreur_injection_nom = false;
$erreur_injection_commentaires = false;
$cocheplus = '';
$cochemail = '';
#tests
if (issetAndNoEmpty("poursuivre")){
$_SESSION["choix_sondage"] = $choix_sondage;
$_SESSION["titre"] = $titre;
$_SESSION["nom"] = $nom;
$_SESSION["adresse"] = $adresse;
$_SESSION["commentaires"] = $commentaires;
unset($_SESSION["studsplus"]);
if ($studsplus !== null) {
$_SESSION["studsplus"] = '+';
} else {
$_SESSION["studsplus"] = '';
}
unset($_SESSION["mailsonde"]);
if ($mailsonde !== null) {
$_SESSION["mailsonde"] = true;
} else {
$_SESSION["mailsonde"] = false;
}
if(validateEmail($adresse) === false) {
$erreur_adresse = true;
}
if (preg_match(';<|>|";',$titre)) {
$erreur_injection_titre = true;
}
if (preg_match(';<|>|";',$nom)) {
$erreur_injection_nom = true;
}
if (preg_match(';<|>|";',$commentaires)) {
$erreur_injection_commentaires = true;
}
// Si pas d'erreur dans l'adresse alors on change de page vers date ou autre
if ($titre && $nom && $adresse && !$erreur_adresse && ! $erreur_injection_titre && ! $erreur_injection_commentaires && ! $erreur_injection_nom) {
/*
# pyg@framasoft.net : inutile.
if ($creation_sondage_date !== null || $creation_sondage_date_x !== null) {
header("Location:choix_date.php");
exit();
}
if ($creation_sondage_autre !== null || $creation_sondage_autre_x !== null) {
header("Location:choix_autre.php");
exit();
}
if ( $creation_sondage_autre_x !== null) {
header("Location:choix_autre.php");
exit();
}
*/
if ( $poursuivre == "creation_sondage_date" ) {
header("Location:choix_date.php");
exit();
}
if ( $poursuivre == "creation_sondage_autre" ) {
header("Location:choix_autre.php");
exit();
}
}
}
//affichage de la page
print_header(true);
echo '<body>'."\n";
framanav();
//affichage des bandeaux de tete
logo();
bandeau_tete();
echo '<div class="bandeautitre">'. _("Poll creation (1 on 2)") .'</div>'."\n";
sous_bandeau();
// premier sondage ? test l'existence des schémas SQL avant d'aller plus loin
if(!check_table_sondage()) {
echo '<p style="color:#FF0000; text-align:center">'.
_("STUdS is not properly installed, please check the 'INSTALL' to setup the database before continuing") .
"</p>"."\n";
bandeau_pied();
echo '</body>'."\n";
echo '</html>'."\n";
die();
}
//debut du formulaire
echo '<form name="formulaire" id="formulaire" action="infos_sondage.php" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
echo '<div class=corps>'."\n";
echo '<br>'. _("You are in the poll creation section. <br> Required fields cannot be left blank") .'<br><br>'."\n";
//Affichage des différents champs textes a remplir
echo '<table>'."\n";
echo '<tr><td>'. _("Poll title *: ") .'</td><td><input type="text" name="titre" size="40" maxlength="80" value="'.stripslashes($_SESSION["titre"]).'"></td>'."\n";
if (!$_SESSION["titre"] && issetAndNoEmpty("poursuivre") ) {
print "<td><font color=\"#FF0000\">" . _("Enter a title") . "</font></td>"."\n";
} elseif ($erreur_injection_titre) {
print "<td><font color=\"#FF0000\">" . _("Characters < > and \" are not permitted") . "</font></td><br>"."\n";
}
echo '</tr>'."\n";
echo '<tr><td>'. _("Comments: ") .'</td><td><textarea name="commentaires" rows="7" cols="40">'.stripslashes($_SESSION["commentaires"]).'</textarea></td>'."\n";
if ($erreur_injection_commentaires) {
print "<td><font color=\"#FF0000\">" . _("Characters < > and \" are not permitted") . "</font></td><br>"."\n";
}
echo '</tr>'."\n";
echo '<tr><td>'. _("Your name*: ") .'</td><td>';
if (USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) {
echo '<input type="hidden" name="nom" size="40" maxlength="40" value="'.$_SESSION["nom"].'">'.stripslashes($_SESSION["nom"]).'</td>'."\n";
} else {
echo '<input type="text" name="nom" size="40" maxlength="40" value="'.stripslashes($_SESSION["nom"]).'"></td>'."\n";
}
if (!$_SESSION["nom"] && issetAndNoEmpty("poursuivre")) {
print "<td><font color=\"#FF0000\">" . _("Enter a name") . "</font></td>"."\n";
} elseif ($erreur_injection_nom) {
print "<td><font color=\"#FF0000\">" . _("Characters < > and \" are not permitted") . "</font></td><br>"."\n";
}
echo '</tr>'."\n";
echo '<tr><td>'. _("Your e-mail address *: ") .'</td><td>';
if (USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) {
echo '<input type="hidden" name="adresse" size="40" maxlength="64" value="'.$_SESSION["adresse"].'">'.$_SESSION["adresse"].'</td>'."\n";
} else {
echo '<input type="text" name="adresse" size="40" maxlength="64" value="'.$_SESSION["adresse"].'"></td>'."\n";
}
if (!$_SESSION["adresse"] && issetAndNoEmpty("poursuivre")) {
print "<td><font color=\"#FF0000\">" . _("Enter an email address") . " </font></td>"."\n";
} elseif ($erreur_adresse && issetAndNoEmpty("poursuivre")) {
print "<td><font color=\"#FF0000\">" . _("The address is not correct! (You should enter a valid email address in order to receive the link to your poll)") . "</font></td>"."\n";
}
echo '</tr>'."\n";
echo '</table>'."\n";
//focus javascript sur le premier champ
echo '<script type="text/javascript">'."\n";
echo 'document.formulaire.titre.focus();'."\n";
echo '</script>'."\n";
#echo '<br>'. _("The fields marked with * are required!") .'<br><br>'."\n";
#affichage du cochage par défaut
if (!$_SESSION["studsplus"] && !issetAndNoEmpty('creation_sondage_date') && !issetAndNoEmpty('creation_sondage_autre') && !issetAndNoEmpty('creation_sondage_date_x') && !issetAndNoEmpty('creation_sondage_autre_x')) {
$_SESSION["studsplus"]="+";
}
if ($_SESSION["studsplus"]=="+") {
$cocheplus="checked";
}
echo '<input type=checkbox name=studsplus '.$cocheplus.' id="studsplus"><label for="studsplus">'. _(" Voters can modify their vote themselves.") .'</label><br>'."\n";
if ($_SESSION["mailsonde"]) {
$cochemail="checked";
}
echo '<input type=checkbox name=mailsonde '.$cochemail.' id="mailsonde"><label for="mailsonde">'. _(" To receive an email for each new vote.") .'</label><br>'."\n";
//affichage des boutons pour choisir sondage date ou autre
if ($_GET['choix_sondage'] == 'date') {
$choix = "creation_sondage_date";
} elseif ($_GET['choix_sondage'] == 'autre') {
$choix = "creation_sondage_autre";
}
echo '<input type="hidden" name="choix_sondage" value="'. $choix_sondage .'"/>';
echo '<br><button name="poursuivre" value="'. $choix .'" type="submit" class="button green poursuivre"><strong>'. _('Next') . '</strong> </button>';
echo '<div style="clear:both"></div>';
#echo '<br><table id="choix_sondage">'."\n";
#echo '<tr><td><input type="image" name="creation_sondage_date" value="Trouver une date" src="images/calendar-32.png" id="creation_sondage_date"><label for="creation_sondage_date" style="cursor:pointer">'. _("Schedule an event") .'</label></td></tr>'."\n";
#echo '<tr><td><input type="image" name="creation_sondage_autre" value="'. _('Make a poll') . '" src="images/chart-32.png" id="creation_sondage_autre"><label for="creation_sondage_autre" style="cursor:pointer" onclick="document.formulaire.creation_sondage_autre.click()">'. _("Make a choice") .'</label></td></tr>'."\n";
#echo '<tr><td><button name="creation_sondage_autre_x" value="creation_sondage_autre_x" type="submit" /><img src="images/chart-32.png" alt="Next page" /><strong>'. _('Make a poll') . '</strong> </button></td></tr>'."\n";
#echo '</table>'."\n";
#echo '<br><br><br>'."\n";
echo '</div>'."\n";
echo '</form>'."\n";
//bandeau de pied
bandeau_pied();
echo '</body>'."\n";
echo '</html>'."\n";