Line 17... |
Line 17... |
17 |
// | |
|
17 |
// | |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
22 |
// CVS : $Id: inscription.class.php,v 1.15 2006-12-01 13:23:16 florian Exp $
|
22 |
// CVS : $Id: inscription.class.php,v 1.16 2007-03-22 15:58:35 alexandre_tb Exp $
|
23 |
/**
|
23 |
/**
|
24 |
* Inscription
|
24 |
* Inscription
|
25 |
*
|
25 |
*
|
26 |
* Un module d'inscription, en général ce code est spécifique à
|
26 |
* Un module d'inscription, en général ce code est spécifique à
|
27 |
* un site web
|
27 |
* un site web
|
Line 29... |
Line 29... |
29 |
*@package inscription
|
29 |
*@package inscription
|
30 |
//Auteur original :
|
30 |
//Auteur original :
|
31 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
31 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
32 |
//Autres auteurs :
|
32 |
//Autres auteurs :
|
33 |
*@copyright Tela-Botanica 2000-2004
|
33 |
*@copyright Tela-Botanica 2000-2004
|
34 |
*@version $Revision: 1.15 $ $Date: 2006-12-01 13:23:16 $
|
34 |
*@version $Revision: 1.16 $ $Date: 2007-03-22 15:58:35 $
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
35 |
// +------------------------------------------------------------------------------------------------------+
|
36 |
*/
|
36 |
*/
|
Line 37... |
Line 37... |
37 |
|
37 |
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
Line 144... |
Line 144... |
144 |
* @access public
|
144 |
* @access public
|
145 |
*/
|
145 |
*/
|
146 |
function construitFormulaire($url)
|
146 |
function construitFormulaire($url)
|
147 |
{
|
147 |
{
|
148 |
$squelette =& $this->defaultRenderer();
|
148 |
$squelette =& $this->defaultRenderer();
|
149 |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
|
149 |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table class="inscription_table">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
|
150 |
$squelette->setElementTemplate( '<tr>'."\n".
|
150 |
$squelette->setElementTemplate( '<tr>'."\n".
|
151 |
'<td style="font-size:12px;width:140px;text-align:right;">'."\n".'{label}'.
|
151 |
'<td class="inscription_cellule_gauche">'."\n".'{label}'.
|
152 |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n".
|
152 |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n".
|
153 |
' :</td>'."\n".
|
153 |
' :</td>'."\n".
|
154 |
'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
|
154 |
'<td class="inscription_cellule_droite"> '."\n".'{element}'."\n".
|
155 |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
155 |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
156 |
'</td>'."\n".
|
156 |
'</td>'."\n".
|
157 |
'</tr>'."\n");
|
157 |
'</tr>'."\n");
|
158 |
$squelette->setElementTemplate( '<tr><td colspan="2" style="font-size:12px;text-align:left;">{label}{element}</td></tr>'."\n", 'lettre');
|
158 |
$squelette->setElementTemplate( '<tr><td colspan="2" style="font-size:12px;text-align:left;">{label}{element}</td></tr>'."\n", 'lettre');
|
159 |
$squelette->setElementTemplate( '<tr><td colspan="2" style="font-size:12px;text-align:left;">{label}{element}</td></tr>'."\n", 'visible');
|
159 |
$squelette->setElementTemplate( '<tr><td colspan="2" style="font-size:12px;text-align:left;">{label}{element}</td></tr>'."\n", 'visible');
|
Line 166... |
Line 166... |
166 |
|
166 |
|
167 |
$debut = '<h2>'.INS_AJOUT_MEMBRE.'</h2>'."\n";
|
167 |
$debut = '<h2>'.INS_AJOUT_MEMBRE.'</h2>'."\n";
|
168 |
$this->addElement('html', $debut);
|
168 |
$this->addElement('html', $debut);
|
169 |
$this->addElement('text', 'email', INS_EMAIL) ;
|
169 |
$this->addElement('text', 'email', INS_EMAIL) ;
|
170 |
$this->addRule('email', INS_EMAIL_REQUIS, 'required','', 'client') ;
|
170 |
$this->addRule('email', INS_EMAIL_REQUIS, 'required','', 'client') ;
|
- |
|
171 |
$this->addRule('email', INS_MAIL_INCORRECT, 'email', '', 'client') ;
|
- |
|
172 |
|
- |
|
173 |
// Le mot de passe
|
171 |
$this->addRule('email', INS_MAIL_INCORRECT, 'email', '', 'client') ;
|
174 |
$this->addElement('html', '<tr><td colspan="2"><span class="commentaire">'.INS_LAIUS_MOT_DE_PASSE.'</span></td></tr>');
|
172 |
$this->addElement('password', 'mot_de_passe', INS_MOT_DE_PASSE, array('size' => '10')) ;
|
175 |
$this->addElement('password', 'mot_de_passe', INS_MOT_DE_PASSE, array('size' => '10', 'onkeyup' => 'test_robustesse()')) ;
|
173 |
$this->addElement('password', 'mot_de_passe_repete', INS_REPETE_MOT_DE_PASSE, array('size' => '10')) ;
|
176 |
$this->addElement('password', 'mot_de_passe_repete', INS_REPETE_MOT_DE_PASSE, array('size' => '10')) ;
|
174 |
$this->addRule('mot_de_passe', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
|
177 |
$this->addRule('mot_de_passe', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
|
175 |
$this->addRule('mot_de_passe_repete', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
|
178 |
$this->addRule('mot_de_passe_repete', INS_MOT_DE_PASSE_REQUIS, 'required', '', 'client') ;
|
- |
|
179 |
$this->addRule(array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
|
- |
|
180 |
|
- |
|
181 |
// Un template special pour la ligne de mot de passe
|
- |
|
182 |
// avec le niveau de securite
|
- |
|
183 |
$squelette->setElementTemplate('<tr>'."\n".
|
- |
|
184 |
'<td class="inscription_cellule_gauche">'."\n".'{label}'.
|
- |
|
185 |
'<!-- BEGIN required --><span class="symbole_obligatoire"> *</span><!-- END required -->'."\n".
|
- |
|
186 |
' :</td>'."\n".
|
- |
|
187 |
'<td class="inscription_cellule_droite"> '."\n".'{element}'."\n".
|
- |
|
188 |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
|
- |
|
189 |
' '.INS_LAIUS_ROBUSTESSE.' <span id="histo_robustesse" style="font-weight:bold;"></span>'.
|
- |
|
190 |
'</td>'."\n".
|
- |
|
191 |
'</tr>'."\n", 'mot_de_passe');
|
- |
|
192 |
// Le javascript pour gérer la sécurité
|
- |
|
193 |
GEN_stockerCodeScript('
|
- |
|
194 |
function test_robustesse() {
|
- |
|
195 |
msg="";
|
- |
|
196 |
cchi=1;cmaj=1;cmin=1;cdiv=1;cspe=1
|
- |
|
197 |
pw = document.formulaire_inscription.mot_de_passe.value;
|
- |
|
198 |
if (document.getElementById) {
|
- |
|
199 |
robustesse = document.getElementById(\'histo_robustesse\');
|
- |
|
200 |
} else if (document.all) {
|
- |
|
201 |
robustesse = document.all[\'histo_robustesse\'];
|
- |
|
202 |
} else {
|
- |
|
203 |
robustesse = document.layers[\'histo_robustesse\'];
|
- |
|
204 |
}
|
- |
|
205 |
|
- |
|
206 |
pw = pw.replace(/(^\s+)|(\s+$)/g,\'\');
|
- |
|
207 |
lpw = pw.length;
|
- |
|
208 |
for (i = 0; i < lpw; i++) {
|
- |
|
209 |
ac=pw.charCodeAt(i);
|
- |
|
210 |
if(ac<128){
|
- |
|
211 |
// Code ascii de 48 a 57 : les chiffres
|
- |
|
212 |
if(ac>47 && ac<58){cchi+=1}
|
- |
|
213 |
// de 65 a 90 lettres majuscules
|
- |
|
214 |
else if(ac>64 && ac<91){cmaj+=1}
|
- |
|
215 |
// 97 a 122 lettres minuscules
|
- |
|
216 |
else if(ac>96 && ac<123){cmin+=1}
|
- |
|
217 |
else cdiv+=1
|
- |
|
218 |
} // les caracteres speciaux > 122
|
- |
|
219 |
else {cspe+=1}
|
- |
|
220 |
}
|
- |
|
221 |
// Formule de calcul de la robustesse
|
- |
|
222 |
cx = cchi * cmaj * cmin * cdiv * cspe;
|
- |
|
223 |
cx= Math.round(Math.log(cx*cx));
|
- |
|
224 |
|
- |
|
225 |
if (lpw < 4) {
|
- |
|
226 |
robustesse.style.color = "#FF0000";
|
- |
|
227 |
msg = "Trop court" ;
|
- |
|
228 |
} else {
|
- |
|
229 |
switch (cx) {
|
- |
|
230 |
case 3: msg = "Faible";
|
- |
|
231 |
robustesse.style.color = "#AA00AA";
|
- |
|
232 |
break;
|
- |
|
233 |
case 4:
|
- |
|
234 |
case 5: msg = "moyen";
|
- |
|
235 |
robustesse.style.color = "#5500CC";
|
- |
|
236 |
break;
|
- |
|
237 |
default : msg = "élevé";
|
- |
|
238 |
robustesse.style.color = "#0000FF";
|
- |
|
239 |
}
|
- |
|
240 |
}
|
- |
|
241 |
robustesse.innerHTML = msg;
|
- |
|
242 |
}
|
176 |
$this->addRule(array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
|
243 |
');
|
177 |
$this->addElement('text', 'nom', INS_NOM) ;
|
244 |
$this->addElement('text', 'nom', INS_NOM) ;
|
178 |
$this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
|
245 |
$this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
|
179 |
$this->addElement('text', 'prenom', INS_PRENOM) ;
|
246 |
$this->addElement('text', 'prenom', INS_PRENOM) ;
|
180 |
$this->addRule('prenom', INS_PRENOM_REQUIS, 'required', '', 'client') ;
|
247 |
$this->addRule('prenom', INS_PRENOM_REQUIS, 'required', '', 'client') ;
|