8 |
jpm |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// is user trying to log in or register?
|
|
|
4 |
if ($_REQUEST["action"] == "ajout") {
|
|
|
5 |
$name = trim($_POST["name"]);
|
|
|
6 |
$email = trim($_POST["email"]);
|
|
|
7 |
$password = $_POST["password"];
|
|
|
8 |
$confpassword = $_POST["confpassword"];
|
|
|
9 |
|
|
|
10 |
// check if name is WikkiName style
|
|
|
11 |
if (! $this->IsWikiName($name) ) $error = "Votre nom d'utilisateur dois être formaté en NomWiki.";
|
|
|
12 |
else if (!$email) $error = "Vous devez spécifier une adresse e-mail.";
|
|
|
13 |
else if (!preg_match("/^.+?\@.+?\..+$/", $email)) $error = "Ceci ne ressemble pas à une adresse e-mail.";
|
|
|
14 |
else if ($confpassword != $password) $error = "Les mots de passe n'étaient pas identiques";
|
|
|
15 |
else if (preg_match("/ /", $password)) $error = "Les espaces ne sont pas permis dans un mot de passe.";
|
|
|
16 |
else if (strlen($password) < 5) $error = "Mot de passe trop court. Un mot de passe doit contenir au minimum 5 caractères alphanumériques.";
|
|
|
17 |
else {
|
|
|
18 |
$reussite = "L'administrateur a bien été ajouté !";
|
|
|
19 |
$this->Query( "insert into ".$this->config["table_prefix"]."users set ".
|
|
|
20 |
"signuptime = now(), ".
|
|
|
21 |
"name = '".mysql_escape_string($name)."', ".
|
|
|
22 |
"email = '".mysql_escape_string($email)."', ".
|
|
|
23 |
"password = md5('".mysql_escape_string($_POST["password"])."')");
|
|
|
24 |
// log in
|
|
|
25 |
//$this->SetUser($this->LoadUser($name));
|
|
|
26 |
// forward
|
|
|
27 |
//$this->Redirect($this->href());
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
print($this->FormOpen());
|
|
|
32 |
?>
|
|
|
33 |
<input type="hidden" name="action" value="ajout" />
|
|
|
34 |
<table>
|
|
|
35 |
<tr>
|
|
|
36 |
<td align="left" colspan="2"><?php echo $this->Format("Pour ajouter un administrateur renseigner les champs ci-dessous:"); ?></td>
|
|
|
37 |
</tr>
|
|
|
38 |
<?php
|
|
|
39 |
if ($error) {
|
|
|
40 |
print('<tr><td></td><td><div class="error">'.$this->Format($error)."</div></td></tr>\n");
|
|
|
41 |
}
|
|
|
42 |
if ($reussite) {
|
|
|
43 |
echo('<tr><td></td><td><div class="reussite">'.$this->Format($reussite)."</div></td></tr>\n");
|
|
|
44 |
}
|
|
|
45 |
?>
|
|
|
46 |
<tr>
|
|
|
47 |
<td align="right">Votre NomWiki :</td>
|
|
|
48 |
<td><input name="name" size="40" value="<?php echo $name ?>" /></td>
|
|
|
49 |
</tr>
|
|
|
50 |
<tr>
|
|
|
51 |
<td align="right">Mot de passe (5 caractères minimum) :</td>
|
|
|
52 |
<td><input type="password" name="password" size="40" /></td>
|
|
|
53 |
</tr>
|
|
|
54 |
<tr>
|
|
|
55 |
<td align="right">Confirmation du mot de passe :</td>
|
|
|
56 |
<td><input type="password" name="confpassword" size="40" /></td>
|
|
|
57 |
</tr>
|
|
|
58 |
<tr>
|
|
|
59 |
<td align="right">Adresse e-mail :</td>
|
|
|
60 |
<td><input name="email" size="40" value="<?php echo $email ?>" /></td>
|
|
|
61 |
</tr>
|
|
|
62 |
<tr>
|
|
|
63 |
<td></td>
|
|
|
64 |
<td><input type="submit" value="Nouveau compte" size="40" /></td>
|
|
|
65 |
</tr>
|
|
|
66 |
</table>
|
|
|
67 |
<?php
|
|
|
68 |
print($this->FormClose());
|
|
|
69 |
?>
|
|
|
70 |
|