Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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