8 |
jpm |
1 |
<?php
|
|
|
2 |
if ($_REQUEST["action"] == "logout") {
|
|
|
3 |
echo 'ici';
|
|
|
4 |
$this->LogoutUser();
|
|
|
5 |
$this->SetMessage("Vous êtes maintenant déconnecté !");
|
|
|
6 |
$this->Redirect($this->href());
|
|
|
7 |
} else if ($user = $this->GetUser()) {
|
|
|
8 |
|
|
|
9 |
// is user trying to update?
|
|
|
10 |
if ($_REQUEST["action"] == "update")
|
|
|
11 |
{
|
|
|
12 |
$this->Query("update ".$this->config["table_prefix"]."users set ".
|
|
|
13 |
"email = '".mysql_escape_string($_POST["email"])."', ".
|
|
|
14 |
"doubleclickedit = '".mysql_escape_string($_POST["doubleclickedit"])."', ".
|
|
|
15 |
"show_comments = '".mysql_escape_string($_POST["show_comments"])."', ".
|
|
|
16 |
"revisioncount = '".mysql_escape_string($_POST["revisioncount"])."', ".
|
|
|
17 |
"changescount = '".mysql_escape_string($_POST["changescount"])."', ".
|
|
|
18 |
"motto = '".mysql_escape_string($_POST["motto"])."' ".
|
|
|
19 |
"where name = '".$user["name"]."' limit 1");
|
|
|
20 |
|
|
|
21 |
$this->SetUser($this->LoadUser($user["name"]));
|
|
|
22 |
|
|
|
23 |
// forward
|
|
|
24 |
$this->SetMessage("Paramètres sauvegardés !");
|
|
|
25 |
$this->Redirect($this->href());
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
if ($_REQUEST["action"] == "changepass")
|
|
|
29 |
{
|
|
|
30 |
// check password
|
|
|
31 |
$password = $_POST["password"];
|
|
|
32 |
if (preg_match("/ /", $password)) $error = "Les espaces ne sont pas permis dans les mots de passe.";
|
|
|
33 |
else if (strlen($password) < 5) $error = "Password too short.";
|
|
|
34 |
else if ($user["password"] != md5($_POST["oldpass"])) $error = "Mauvais mot de passe.";
|
|
|
35 |
else
|
|
|
36 |
{
|
|
|
37 |
$this->Query("update ".$this->config["table_prefix"]."users set "."password = md5('".mysql_escape_string($password)."') "."where name = '".$user["name"]."'");
|
|
|
38 |
$this->SetMessage("Mot de passe changé !");
|
|
|
39 |
$user["password"]=md5($password);
|
|
|
40 |
$this->SetUser($user);
|
|
|
41 |
$this->Redirect($this->href());
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
// user is logged in; display config form
|
|
|
45 |
print($this->FormOpen());
|
|
|
46 |
?>
|
|
|
47 |
<input type="hidden" name="action" value="update" />
|
|
|
48 |
<table>
|
|
|
49 |
<tr>
|
|
|
50 |
<td align="right"></td>
|
|
|
51 |
<td>Hello, <?php echo $this->Link($user["name"]) ?>!</td>
|
|
|
52 |
</tr>
|
|
|
53 |
<tr>
|
|
|
54 |
<td align="right">Votre adresse e-mail :</td>
|
|
|
55 |
<td><input name="email" value="<?php echo htmlentities($user["email"]) ?>" size="40" /></td>
|
|
|
56 |
</tr>
|
|
|
57 |
<tr>
|
|
|
58 |
<td align="right">Edition en Doublecliquant :</td>
|
|
|
59 |
<td><input type="hidden" name="doubleclickedit" value="N" /><input type="checkbox" name="doubleclickedit" value="Y" <?php echo $user["doubleclickedit"] == "Y" ? "checked=\"checked\"" : "" ?> /></td>
|
|
|
60 |
</tr>
|
|
|
61 |
<tr>
|
|
|
62 |
<td align="right">Montrer les commentaires par default :</td>
|
|
|
63 |
<td><input type="hidden" name="show_comments" value="N" /><input type="checkbox" name="show_comments" value="Y" <?php echo $user["show_comments"] == "Y" ? "checked\"checked\"" : "" ?> /></td>
|
|
|
64 |
</tr>
|
|
|
65 |
<tr>
|
|
|
66 |
<td align="right">Nombre maximum de derniers commentaires :</td>
|
|
|
67 |
<td><input name="changescount" value="<?php echo htmlentities($user["changescount"]) ?>" size="40" /></td>
|
|
|
68 |
</tr>
|
|
|
69 |
<tr>
|
|
|
70 |
<td align="right">Nombre maximum de versions :</td>
|
|
|
71 |
<td><input name="revisioncount" value="<?php echo htmlentities($user["revisioncount"]) ?>" size="40" /></td>
|
|
|
72 |
</tr>
|
|
|
73 |
<tr>
|
|
|
74 |
<td align="right">Votre devise :</td>
|
|
|
75 |
<td><input name="motto" value="<?php echo htmlentities($user["motto"]) ?>" size="40" /></td>
|
|
|
76 |
</tr>
|
|
|
77 |
<tr>
|
|
|
78 |
<td></td>
|
|
|
79 |
<td><input type="submit" value="Mise à jour" /> <input type="button" value="Déconnection" onClick="document.location='<?php echo $this->href("", "", "action=logout"); ?>'" /></td>
|
|
|
80 |
</tr>
|
|
|
81 |
|
|
|
82 |
<?php
|
|
|
83 |
print($this->FormClose());
|
|
|
84 |
|
|
|
85 |
print($this->FormOpen());
|
|
|
86 |
?>
|
|
|
87 |
<input type="hidden" name="action" value="changepass" />
|
|
|
88 |
|
|
|
89 |
<tr>
|
|
|
90 |
<td> </td>
|
|
|
91 |
<td> </td>
|
|
|
92 |
</tr>
|
|
|
93 |
<tr>
|
|
|
94 |
<td align="right"></td>
|
|
|
95 |
<td><?php echo $this->Format("Changement de mot de passe"); ?></td>
|
|
|
96 |
</tr>
|
|
|
97 |
<?php
|
|
|
98 |
if ($error)
|
|
|
99 |
{
|
|
|
100 |
print("<tr><td></td><td><div class=\"error\">".$this->Format($error)."</div></td></tr>\n");
|
|
|
101 |
}
|
|
|
102 |
?>
|
|
|
103 |
<tr>
|
|
|
104 |
<td align="right">Votre ancien mot de passe :</td>
|
|
|
105 |
<td><input type="password" name="oldpass" size="40" /></td>
|
|
|
106 |
</tr>
|
|
|
107 |
<tr>
|
|
|
108 |
<td align="right">Nouveau mot de passe :</td>
|
|
|
109 |
<td><input type="password" name="password" size="40" /></td>
|
|
|
110 |
</tr>
|
|
|
111 |
<tr>
|
|
|
112 |
<td></td>
|
|
|
113 |
<td><input type="submit" value="Changer" size="40" /></td>
|
|
|
114 |
</tr>
|
|
|
115 |
</table>
|
|
|
116 |
<?php
|
|
|
117 |
print($this->FormClose());
|
|
|
118 |
|
|
|
119 |
} else {
|
|
|
120 |
// user is not logged in
|
|
|
121 |
|
|
|
122 |
// is user trying to log in or register?
|
|
|
123 |
if ($_REQUEST["action"] == "login")
|
|
|
124 |
{
|
|
|
125 |
// if user name already exists, check password
|
|
|
126 |
if ($existingUser = $this->LoadUser($_POST["name"]))
|
|
|
127 |
{
|
|
|
128 |
// check password
|
|
|
129 |
if ($existingUser["password"] == md5($_POST["password"]))
|
|
|
130 |
{
|
|
|
131 |
$this->SetUser($existingUser, $_POST["remember"]);
|
|
|
132 |
$this->Redirect($this->href());
|
|
|
133 |
}
|
|
|
134 |
else
|
|
|
135 |
{
|
|
|
136 |
$error = "Mauvais mot de passe !";
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
// otherwise, create new account
|
|
|
140 |
else
|
|
|
141 |
{
|
|
|
142 |
$name = trim($_POST["name"]);
|
|
|
143 |
$email = trim($_POST["email"]);
|
|
|
144 |
$password = $_POST["password"];
|
|
|
145 |
$confpassword = $_POST["confpassword"];
|
|
|
146 |
|
|
|
147 |
// check if name is WikkiName style
|
|
|
148 |
if (!$this->IsWikiName($name)) $error = "Votre nom d'utilisateur dois être formaté en NomWiki.";
|
|
|
149 |
else if (!$email) $error = "Vous devez spécifier une adresse e-mail.";
|
|
|
150 |
else if (!preg_match("/^.+?\@.+?\..+$/", $email)) $error = "Ceci ne ressemble pas à une adresse e-mail.";
|
|
|
151 |
else if ($confpassword != $password) $error = "Les mots de passe n'étaient pas identiques";
|
|
|
152 |
else if (preg_match("/ /", $password)) $error = "Les espaces ne sont pas permis dans un mot de passe.";
|
|
|
153 |
else if (strlen($password) < 5) $error = "Mot de passe trop court. Un mot de passe doit contenir au minimum 5 caractères alphanumériques.";
|
|
|
154 |
else
|
|
|
155 |
{
|
|
|
156 |
$this->Query("insert into ".$this->config["table_prefix"]."users set ".
|
|
|
157 |
"signuptime = now(), ".
|
|
|
158 |
"name = '".mysql_escape_string($name)."', ".
|
|
|
159 |
"email = '".mysql_escape_string($email)."', ".
|
|
|
160 |
"password = md5('".mysql_escape_string($_POST["password"])."')");
|
|
|
161 |
|
|
|
162 |
// log in
|
|
|
163 |
$this->SetUser($this->LoadUser($name));
|
|
|
164 |
|
|
|
165 |
// forward
|
|
|
166 |
$this->Redirect($this->href());
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
print($this->FormOpen());
|
|
|
172 |
?>
|
|
|
173 |
<input type="hidden" name="action" value="login" />
|
|
|
174 |
<table>
|
|
|
175 |
<tr>
|
|
|
176 |
<td align="right"></td>
|
|
|
177 |
<td><?php echo $this->Format("Si vous êtes déjà enregistré, identifiez-vous ici"); ?></td>
|
|
|
178 |
</tr>
|
|
|
179 |
<?php
|
|
|
180 |
if ($error)
|
|
|
181 |
{
|
|
|
182 |
print("<tr><td></td><td><div class=\"error\">".$this->Format($error)."</div></td></tr>\n");
|
|
|
183 |
}
|
|
|
184 |
?>
|
|
|
185 |
<tr>
|
|
|
186 |
<td align="right">Votre NomWiki :</td>
|
|
|
187 |
<td><input name="name" size="40" value="<?php echo $name ?>" /></td>
|
|
|
188 |
</tr>
|
|
|
189 |
<tr>
|
|
|
190 |
<td align="right">Mot de passe (5 caractères minimum) :</td>
|
|
|
191 |
<td><input type="password" name="password" size="40" />
|
|
|
192 |
<input type="hidden" name="remember" value="0" /><input type="checkbox" name="remember" value="1" /> <?php echo $this->Format("Se souvenir de moi.") ?> </td>
|
|
|
193 |
</tr>
|
|
|
194 |
<tr>
|
|
|
195 |
<td></td>
|
|
|
196 |
<td><input type="submit" value="Identification" size="40" /></td>
|
|
|
197 |
</tr>
|
|
|
198 |
</table>
|
|
|
199 |
<?php
|
|
|
200 |
print($this->FormClose());
|
|
|
201 |
}
|
|
|
202 |
?>
|
|
|
203 |
|