1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * ajout.php is a part of PhpWebGallery * |
---|
4 | * ------------------- * |
---|
5 | * last update : Tuesday, July 16, 2002 * |
---|
6 | * email : pierrick@z0rglub.com * |
---|
7 | * * |
---|
8 | ***************************************************************************/ |
---|
9 | |
---|
10 | /*************************************************************************** |
---|
11 | * * |
---|
12 | * This program is free software; you can redistribute it and/or modify * |
---|
13 | * it under the terms of the GNU General Public License as published by * |
---|
14 | * the Free Software Foundation; * |
---|
15 | * * |
---|
16 | ***************************************************************************/ |
---|
17 | |
---|
18 | include_once( './include/isadmin.inc.php' ); |
---|
19 | |
---|
20 | $error = array(); |
---|
21 | $absent = false; |
---|
22 | |
---|
23 | $query = 'select'; |
---|
24 | $query.= ' pseudo,status,mail_address'; |
---|
25 | $query.= ' from '.$prefixeTable.'users'; |
---|
26 | $query.= ' where id = '.$_GET['user_id']; |
---|
27 | $query.= ';'; |
---|
28 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
29 | |
---|
30 | $pseudo = $row['pseudo']; |
---|
31 | $status = $row['status']; |
---|
32 | $mail_address = $row['mail_address']; |
---|
33 | |
---|
34 | if ( $pseudo == 'visiteur' || |
---|
35 | ( $pseudo == $conf['webmaster'] |
---|
36 | && $user['pseudo'] != $conf['webmaster'] ) ) |
---|
37 | { |
---|
38 | echo "<div class=\"erreur\">".$lang['user_err_modify']."</div>"; |
---|
39 | $absent = true; |
---|
40 | } |
---|
41 | if ( $_GET['mode'] == 'modif' ) |
---|
42 | { |
---|
43 | if ( $pseudo == '' ) |
---|
44 | { |
---|
45 | echo"<div class=\"info\">".$lang['user_err_unknown']."</div>"; |
---|
46 | $absent = true; |
---|
47 | } |
---|
48 | } |
---|
49 | if ( !$absent ) |
---|
50 | { |
---|
51 | if ( $_GET['valider'] == 1 ) |
---|
52 | { |
---|
53 | if ( $_GET['mode'] != 'modif' ) |
---|
54 | { |
---|
55 | $error = register_user( $_POST['pseudo'], $_POST['password'], |
---|
56 | $_POST['password'], $_POST['mail_address'], |
---|
57 | $_POST['status'] ); |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | $use_new_password = false; |
---|
62 | if ( $_POST['use_new_pwd'] == 1) |
---|
63 | { |
---|
64 | $use_new_password = true; |
---|
65 | } |
---|
66 | $error = update_user( $_GET['user_id'], $_POST['mail_address'], |
---|
67 | $_POST['status'], $use_new_password, |
---|
68 | $_POST['password'] ); |
---|
69 | } |
---|
70 | } |
---|
71 | if ( sizeof( $error ) > 0 ) |
---|
72 | { |
---|
73 | echo "<div class=\"erreur\">".$lang['adduser_err_message'].sizeof( $error )." :"; |
---|
74 | echo "<ul>"; |
---|
75 | for ( $i = 0; $i < sizeof( $error ); $i++ ) |
---|
76 | { |
---|
77 | echo "<li>".$error[$i]."</li>"; |
---|
78 | } |
---|
79 | echo "</ul>"; |
---|
80 | echo "</div>"; |
---|
81 | } |
---|
82 | if ( sizeof( $error ) == 0 && $_GET['valider'] == 1 ) |
---|
83 | { |
---|
84 | echo"<div class=\"info\">".$lang['adduser_info_message']."\"$pseudo\" "; |
---|
85 | if ( $_POST['use_new_pwd'] == 1 ) |
---|
86 | { |
---|
87 | echo $lang['adduser_info_password_updated']." "; |
---|
88 | } |
---|
89 | echo"[ <a href=\"".add_session_id_to_url( "./admin.php?page=liste_users" )."\">".$lang['adduser_info_back']."</a> ]</div>"; |
---|
90 | } |
---|
91 | if ( $_GET['valider'] != 1 || $_GET['mode'] != "modif" || sizeof( $error ) > 0 ) |
---|
92 | { |
---|
93 | if ( $_GET['mode'] != "modif" && sizeof( $error ) == 0 ) |
---|
94 | { |
---|
95 | unset( $pseudo, $password, $status, $mail_address ); |
---|
96 | } |
---|
97 | if ( !isset( $_POST['use_new_pwd'] ) || $_POST['use_new_pwd'] != 1 ) |
---|
98 | { |
---|
99 | unset( $password ); |
---|
100 | } |
---|
101 | $action = "./admin.php?page=ajout&valider=1"; |
---|
102 | if ( $_GET['mode'] == "modif" ) |
---|
103 | { |
---|
104 | $action.= "&mode=modif&user_id=".$_GET['user_id']; |
---|
105 | } |
---|
106 | echo"<form method=\"post\" action=\"".add_session_id_to_url( $action )."\"> |
---|
107 | <table style=\"width:100%;\"> |
---|
108 | <tr align=\"center\" valign=\"middle\"> |
---|
109 | <td> |
---|
110 | <table style=\"margin-left:auto;margin-right:auto;\"> |
---|
111 | <tr> |
---|
112 | <th colspan=\"2\">".$lang['adduser_fill_form']."</th> |
---|
113 | </tr> |
---|
114 | <tr> |
---|
115 | <td colspan=\"2\"><div style=\"margin-bottom:0px;\"> </div></td> |
---|
116 | </tr> |
---|
117 | <tr> |
---|
118 | <td>".$lang['adduser_login']."</td> |
---|
119 | <td>"; |
---|
120 | if ( $_GET['mode'] == "modif" ) |
---|
121 | { |
---|
122 | echo"<span style=\"color:red;\">$pseudo [".$lang['adduser_unmodify']."]</span>"; |
---|
123 | echo"<input type=\"hidden\" name=\"pseudo\" value=\"$pseudo\"/>"; |
---|
124 | } |
---|
125 | else |
---|
126 | { |
---|
127 | echo"<input type=\"text\" name=\"pseudo\" value=\"$pseudo\"/>"; |
---|
128 | } |
---|
129 | echo" |
---|
130 | </td> |
---|
131 | </tr>"; |
---|
132 | echo" |
---|
133 | <tr> |
---|
134 | <td>"; |
---|
135 | if ( $_GET['mode'] == "modif" ) |
---|
136 | { |
---|
137 | echo $lang['new']." ".$lang['password']."<input type=\"checkbox\" name=\"use_new_pwd\" value=\"1\""; |
---|
138 | if ( isset( $_POST['use_new_pwd'] ) && $_POST['use_new_pwd'] == 1 ) |
---|
139 | { |
---|
140 | echo " checked=\"checked\""; |
---|
141 | } |
---|
142 | echo " />"; |
---|
143 | } |
---|
144 | else |
---|
145 | { |
---|
146 | echo $lang['password']; |
---|
147 | } |
---|
148 | echo"</td> |
---|
149 | <td>"; |
---|
150 | echo"<input type=\"text\" name=\"password\" value=\"$password\"/></td> |
---|
151 | </tr>"; |
---|
152 | echo" |
---|
153 | <tr> |
---|
154 | <td>".$lang['reg_mail_address']."</td>"; |
---|
155 | echo " |
---|
156 | <td><input type=\"text\" name=\"mail_address\" value=\"$mail_address\"/></td> |
---|
157 | </tr>"; |
---|
158 | echo" |
---|
159 | <tr> |
---|
160 | <td>".$lang['adduser_status']."</td> |
---|
161 | <td>"; |
---|
162 | if ( $pseudo == $conf['webmaster'] ) |
---|
163 | { |
---|
164 | echo "<span style=\"color:red;\">$status [".$lang['adduser_unmodify']."]</span> |
---|
165 | <input type=\"hidden\" name=\"status\" value=\"$status\"/>"; |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | echo" |
---|
170 | <select name=\"status\">"; |
---|
171 | // on récupère toutes les status possibles dans la base |
---|
172 | // par l'intermédiaire de la fonction get_enums |
---|
173 | $option = get_enums( $prefixeTable."users", "status" ); |
---|
174 | for ( $i = 0; $i < sizeof( $option ); $i++ ) |
---|
175 | { |
---|
176 | if ( isset( $status ) ) |
---|
177 | { |
---|
178 | echo" |
---|
179 | <option value=\"$option[$i]\""; |
---|
180 | if ( $option[$i] == $status ) |
---|
181 | { |
---|
182 | echo" selected=\"selected\""; |
---|
183 | } |
---|
184 | echo">"; |
---|
185 | switch ( $option[$i] ) |
---|
186 | { |
---|
187 | case "admin" : |
---|
188 | { |
---|
189 | echo $lang['adduser_status_admin']; |
---|
190 | break; |
---|
191 | } |
---|
192 | case "membre" : |
---|
193 | { |
---|
194 | echo $lang['adduser_status_member']; |
---|
195 | break; |
---|
196 | } |
---|
197 | case "visiteur" : |
---|
198 | { |
---|
199 | echo $lang['adduser_status_guest']; |
---|
200 | break; |
---|
201 | } |
---|
202 | } |
---|
203 | echo"</option>"; |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | echo" |
---|
208 | <option value=\"$option[$i]\""; |
---|
209 | if ( $option[$i] == "visiteur" ) |
---|
210 | { |
---|
211 | echo" selected=\"selected\""; |
---|
212 | } |
---|
213 | echo">"; |
---|
214 | switch ( $option[$i] ) |
---|
215 | { |
---|
216 | case "admin" : |
---|
217 | { |
---|
218 | echo $lang['adduser_status_admin']; |
---|
219 | break; |
---|
220 | } |
---|
221 | case "membre" : |
---|
222 | { |
---|
223 | echo $lang['adduser_status_member']; |
---|
224 | break; |
---|
225 | } |
---|
226 | case "visiteur" : |
---|
227 | { |
---|
228 | echo $lang['adduser_status_guest']; |
---|
229 | break; |
---|
230 | } |
---|
231 | } |
---|
232 | echo"</option>"; |
---|
233 | } |
---|
234 | } |
---|
235 | echo" |
---|
236 | </select>"; |
---|
237 | } |
---|
238 | echo" |
---|
239 | </td> |
---|
240 | </tr> |
---|
241 | <tr> |
---|
242 | <td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".$lang['submit']."\"/></td> |
---|
243 | </tr> |
---|
244 | </table> |
---|
245 | </td> |
---|
246 | </tr> |
---|
247 | </table> |
---|
248 | </form>"; |
---|
249 | if ( $_GET['mode'] == "modif" ) |
---|
250 | { |
---|
251 | echo "<div style=\"text-align:center;margin-bottom:10px;\">[ <a href=\"".add_session_id_to_url( "./admin.php?page=liste_users" )."\">".$lang['adduser_info_back']."</a> ]</div>"; |
---|
252 | } |
---|
253 | } |
---|
254 | } |
---|
255 | ?> |
---|