Amélioration de la gestion des encodages.
[auf_paf.git] / admin / index_admin.php
CommitLineData
98ff4c8e 1<?php session_start();\r
2 $admin=$_SESSION["adminAUFPPKH"];\r
3 $UserName=$_SESSION["UserName"];\r
4 $Password=$_SESSION["Password"];\r
5 if(!($admin == "y")){\r
6 include("includes/redirect.php");\r
7 redirect("index.php");\r
8 }\r
9 \r
10 //-----------session expirée-------------------\r
11 if(isset($_SESSION['started'])){\r
12 if((mktime() - $_SESSION['started'] - 60*30) > 0 ){\r
13 unset($_SESSION["loginAUFKH"]);\r
14 unset($_SESSION["adminAUFPPKH"]);\r
15 redirect("index.php");\r
16 }\r
17 }else{\r
18 $_SESSION['started'] = mktime();\r
19 }\r
20?>\r
96ef3f02
CT
21<?php \r
22 header("Content-type: text/html; charset=utf-8");\r
23?>\r
98ff4c8e 24<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
25<html xmlns="http://www.w3.org/1999/xhtml">\r
26<head>\r
96ef3f02 27<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
98ff4c8e 28<title>Gestion de mot de passe -- Administrateur</title>\r
29<script language="javascript1.2" type="text/javascript">\r
30 function delete_message(){\r
31 var flag=true;\r
32 if (!confirm("Est-ce que vous voudriez vraiment supprimer cette information?")) flag =false;\r
33 return flag;\r
34 }\r
35 \r
36 function validate_txt_box_1(Password){\r
37 var flag = true;\r
38 if(Password.txtUserName.value == 0){\r
39 alert("Entrez l'identifiant, s.v.p!");\r
40 Password.txtUserName.focus();\r
41 return false;\r
42 }\r
43 <?php if($_REQUEST["MODI"] == ""){ ?>\r
44 if(Password.txtPassword.value == 0){\r
45 alert("Entrez le mot de passe, s.v.p!");\r
46 Password.txtPassword.focus();\r
47 return false;\r
48 }\r
49 if(Password.txtMail.value == 0){\r
50 alert("Entrez le mail, s.v.p!");\r
51 Password.txtMail.focus();\r
52 return false;\r
53 }\r
54 <?php } ?>\r
55 if(Password.selPerm.value == "Choisissez"){\r
56 alert("Choisissez la permission, s.v.p!");\r
57 Password.selPerm.focus();\r
58 return false;\r
59 }\r
60//--------------------------Modifier------------------------------------\r
61 <?php if($_REQUEST["MODI"] != ""){ ?>\r
62 if(Password.txtOPassword.value == 0){\r
63 alert("Entrez l'ancien mot de passe, s.v.p!");\r
64 Password.txtOPassword.focus();\r
65 return false;\r
66 }\r
67 if(Password.txtNPassword.value == 0){\r
68 alert("Entrez le nouveau mot de passe, s.v.p!");\r
69 Password.txtNPassword.focus();\r
70 return false;\r
71 }\r
72 if(Password.txtMail.value == 0){\r
73 alert("Entrez le mail, s.v.p!");\r
74 Password.txtMail.focus();\r
75 return false;\r
76 }\r
77 <?php } ?>\r
78 }\r
79</script>\r
80</head>\r
81<?php\r
82 include("../includes/connection.php");\r
83 include("../includes/functions.php");\r
84 include("../includes/redirect.php");\r
85 \r
86 $kompler = "{%#bb^csr%#}";\r
87 $ID = $_REQUEST["ID"];\r
88 $MODI = $_REQUEST["MODI"]; //Modif_strqrt\r
89 $DEL = $_REQUEST["DEL"]; //Del_strqrt\r
90 $txtUserName = strtolower(str_replace("'","",$_REQUEST["txtUserName"]));\r
91 $txtOPassword = encrptPwd(strtolower($_REQUEST["txtOPassword"]),$kompler); //echo $txtOPassword;\r
92 $txtNPassword = encrptPwd(strtolower($_REQUEST["txtNPassword"]),$kompler);\r
93 $txtPassword = encrptPwd(strtolower($_REQUEST["txtPassword"]),$kompler);\r
94 $txtMail = $_REQUEST["txtMail"];\r
95 $SEL = $_REQUEST["selPerm"];\r
96 if($_REQUEST["cmdSave"]){\r
97 if($MODI == ""){\r
98 if(check_email($txtMail)){\r
99 $Str = "insert into passwd(login,Passwd,Email,Permission) values('".$txtUserName."','".$txtPassword."','".$txtMail."','".$SEL."')";\r
100 mysql_query($Str) or die("Les informations ne peuvent pas enregistrer!");\r
101 redirect("index_admin.php");\r
102 }else{ $MailErreur = "Pardon, l'addresse mail est incorrect!"; }\r
103 }else{\r
104//---------------Vérifier l'ancien mot de passe----------------------------------------\r
105 $Sql = "Select Passwd from passwd where Passwd='".$txtOPassword."'";\r
106 $Query = mysql_query($Sql);\r
107 $Col = mysql_fetch_row($Query);\r
108 if(($Col[0] == "") && !(check_email($txtMail))){\r
109 $Invalid = "Pardon, l'encien mot de passe est invalid!";\r
110 $MailErreur = "Pardon, l'addresse mail est incorrect!";\r
111 }elseif(($Col[0] == "")){\r
112 $Invalid = "Pardon, l'encien mot de passe est invalid!";\r
113 }elseif(!(check_email($txtMail))){\r
114 $MailErreur = "Pardon, l'addresse mail est incorrect!";\r
115 }else{\r
116 $Upd = "update passwd set login='".$txtUserName."',Passwd='".$txtNPassword."',Email='".$txtMail."',Permission='".$SEL."' where ID=".$ID;\r
117 mysql_query($Upd) or die("Les informations ne peuvent pas modifier!");\r
118 redirect("index_admin.php");\r
119 }\r
120 }\r
121 }\r
122//---------------------Information selectée--------------------------------------------\r
123 if($MODI != ""){\r
124 $Stp = mysql_query("select * from passwd where ID=".$ID);\r
125 if($Stp){\r
126 $Row = mysql_fetch_array($Stp);\r
127 $UName = $Row["login"];\r
128 $Pwd = $Row["Passwd"];\r
129 $Mail = $Row["Email"];\r
130 $Perm = $Row["Permission"];\r
131 }\r
132 $Title = "Modifier Information";\r
133 }else{ $Title = "Ajouter Information"; }\r
134\r
135//---------------------Supprimer information------------------------------------------\r
136 if($DEL != ""){\r
137 $Del = "delete from passwd where ID=".$ID;\r
138 mysql_query($Del) or die("Cet information ne peut pas supprimer!");\r
139 $DEL = "";\r
140 $MODI = "";\r
141 }\r
142?>\r
143<body>\r
144 <center>\r
145<?php\r
146 echo "You have logged in ... ";\r
147 echo "[<a href='../index.php?logout_sqrt'>Logout</a>]";\r
148 echo "<small>&nbsp;&nbsp;&nbsp;&nbsp;<a href='../index_main.php' title='Accueil'>Accueil</a></small>";\r
149?><br><br>\r
150\r
151 <form name="Password" method="post">\r
152 <table width="450" height="193" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;">\r
153 <tr>\r
154 <td align="center" style="padding-bottom:10px;">\r
155 <table width="496" height="193" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse; border-color:#9999CC;">\r
156 <tr bgcolor="#56541f">\r
157 <td height="34" align="center" background="images/tclyit_silver_1.jpg" style="font-family:Arial, Helvetica, sans-serif; color:#996633; background-repeat:repeat-x;"><strong><?php echo $Title; ?></strong></td>\r
158 </tr>\r
159 <tr>\r
160 <td>\r
161 <table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;">\r
162 <tr>\r
163 <td align="left" style="padding-bottom:0; padding-left:10px; padding-right:10px;">\r
164 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Identifiant : </span>\r
165 </td>\r
166 <td style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
167 <input type="text" name="txtUserName" value="<?php if($MODI == ""){ echo $txtUserName; }else{ echo $UName; } ?>" size="40" />\r
168 </td>\r
169 </tr>\r
170 <?php if($MODI == ""){ ?>\r
171 <tr>\r
172 <td align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
173 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Mot de passe : </span>\r
174 </td>\r
175 <td align="left" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
176 <input type="password" name="txtPassword" value="<?php echo $Pwd; ?>" maxlength="8" size="40">\r
177 </td>\r
178 </tr>\r
179 <tr>\r
180 <td align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
181 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Addresse Mail : </span>\r
182 </td>\r
183 <td align="left" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
184 <div align="center" style="z-index:auto; padding-bottom:3px; color:#CC0000;"><?php echo $MailErreur; ?></div>\r
185 <input type="text" name="txtMail" value="<?php if($MODI == ""){ echo $txtMail; }else{ echo $Mail; } ?>" size="40">\r
186 </td>\r
187 </tr>\r
188 <?php }else{ ?>\r
189 <tr>\r
190 <td align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
191 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Ancien Mot de passe : </span>\r
192 </td>\r
193 <td align="left" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
194 <div align="center" style="z-index:auto; padding-bottom:3px; color:#CC0000;"><?php echo $Invalid; ?></div>\r
195 <input type="password" name="txtOPassword" value="" size="40">\r
196 </td>\r
197 </tr>\r
198 <tr>\r
199 <td align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
200 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Nouveau Mot de passe : </span>\r
201 </td>\r
202 <td align="left" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
203 <input type="password" name="txtNPassword" value="" size="40">\r
204 </td>\r
205 </tr>\r
206 <tr>\r
207 <td align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
208 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Addresse Mail : </span>\r
209 </td>\r
210 <td align="left" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
211 <div align="center" style="z-index:auto; padding-bottom:3px; color:#CC0000;"><?php echo $MailErreur; ?></div>\r
212 <input type="text" name="txtMail" value="<?php echo $Mail; ?>" size="40">\r
213 </td>\r
214 </tr>\r
215 <?php } ?>\r
216 <tr bgcolor="#E4D8A3">\r
217 <td align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
218 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Permission : </span>\r
219 </td>\r
220 <td align="left" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
221 <?php if($MODI == ""){ ?>\r
222 <select name="selPerm" style="width:265;">\r
223 <option value="Choisissez">[--Choisissez Permission--]</option>\r
224 <option value="1">Administrateur</option>\r
225 <option value="2">Utilisateur</option>\r
226 </select>\r
227 <?php }else{ ?>\r
228 <select name="selPerm" style="width:265;">\r
229 <?php if($Perm == 1){ ?>\r
230 <option value="1" selected="selected">Administrateur</option>\r
231 <option value="2">Utilisateur</option>\r
232 <option value="Choisissez">[--Choisissez Permission--]</option>\r
233 <?php } ?>\r
234 <?php if($Perm == 2){ ?>\r
235 <option value="2" selected="selected">Utilisateur</option>\r
236 <option value="1">Administrateur</option>\r
237 <option value="Choisissez">[--Choisissez Permission--]</option>\r
238 <?php } ?> \r
239 </select>\r
240 <?php } ?>\r
241 </td>\r
242 </tr>\r
243 <tr>\r
244 <td></td>\r
245 <td align="right" style="padding-right:45px; padding-bottom:5px; padding-top:10px;">\r
246 <input type="submit" name="cmdSave" value="Sauvegarder" onClick="return validate_txt_box_1(Password);" style="border:double; height:27px; border-color:#999966; background-color:#9aa95f; cursor:pointer;">\r
247 </td>\r
248 </tr>\r
249 <tr bgcolor="#EEF1B6">\r
250 <td colspan="2" align="left" style="padding-right:5px; padding-left:5px; padding-bottom:5px; padding-top:10px;">\r
251 <font style="font-size:12px; font-weight:bold; color:#3300FF;"><u>Note</u> : </font>\r
252 <font style="font-size:10px; font-weight:normal; color:#993300;">\r
253 - <i><b>Administrateur</b></i> : Permettre pour ajouter, modifier et supprimer les informations.<br>\r
254 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- <i><b>Utilisateur</b></i> : Permettre pour ajouter et modifier les informations.\r
255 </font>\r
256 </td>\r
257 </tr>\r
258 </table>\r
259 </td>\r
260 </tr>\r
261 </table>\r
262 </td>\r
263 </tr>\r
264 <tr>\r
265 <td align="center" style="padding-top:10px; padding-bottom:20px;">\r
266 <table width="450" height="193" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse; border-color:#9999CC;">\r
267 <tr bgcolor="#56541f">\r
268 <td height="34" align="center" background="images/tclyit_silver_1.jpg" style="font-family:Arial, Helvetica, sans-serif; color:#996633; background-repeat:repeat-x;"><strong>Liste de l'information</strong></td>\r
269 </tr>\r
270 <tr>\r
271 <td align="center" valign="top">\r
272 <table width="700" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse; border-color:#CCCCCC;">\r
273 <tr bgcolor="#CBD898" class="style2">\r
274 <td width="215" align="left" style="padding-bottom:5px;; padding-top:5px; padding-left:10px; padding-right:10px;">\r
275 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Identifiant</span></td>\r
276 <td width="96" align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
277 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Mot de passe</span></td>\r
278 <td width="106" align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
279 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Permission</span></td>\r
280 <td width="" align="left" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
281 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Email</span></td>\r
282 <td width="133" align="center" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
283 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Modifier</span></td>\r
284 <td width="138" align="center" style="padding-bottom:0px; padding-left:10px; padding-right:10px;">\r
285 <span style="font-family:Arial, Helvetica, sans-serif; color:#330000">Supprimer</span></td>\r
286 </tr>\r
287 <?php\r
288 //----------------Montrer l'information------------------------------------------------\r
289 $Sql = "select * from passwd order by login";\r
290 if($Sql){\r
291 $Swl = mysql_query($Sql);\r
292 while($Rows = mysql_fetch_array($Swl)){\r
293 $ID = $Rows["ID"];\r
294 $UserName = $Rows["login"];\r
295 $Password = $Rows["Passwd"];\r
296 $Mails = $Rows["Email"];\r
297 $Perm = $Rows["Permission"];\r
298 if($Perm == 1){\r
299 $Permission = "Administrateur";\r
300 }else{ $Permission = "Utilisateur"; }\r
301 ?>\r
302 <tr bgcolor="#E1E3B0">\r
303 <td style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
304 <?php echo $UserName; ?>\r
305 </td>\r
306 <td title="<?php echo decrptPwd($Password,$kompler); ?>" style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
307 <?php echo $Password; ?>\r
308 </td>\r
309 <td style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
310 <?php echo $Permission; ?>\r
311 </td>\r
312 <td style="padding-top:5px; padding-left:10px; padding-right:10px; padding-bottom:5px;">\r
313 <?php echo $Mails; ?>\r
314 </td>\r
315 <td align="center" style="padding-top:5px; padding-left:5px; padding-right:5px; padding-bottom:5px;">\r
316 <input type="button" name="cmdEdit" value=" Modifier " style="border:double; height:27px; border-color:#999966; background-color:#9aa95f; cursor:pointer; color:#FFFFFF; font-weight:normal;" title='Modifier : <?php echo $UserName; ?>' onClick="javascript:document.location.href='<?php echo"$_PHP_SELF?ID=$ID&MODI=Modif_strqrt"; ?>'" />\r
317 <!--<a href="<?php echo"$_PHP_SELF?ID=$ID&MODI=Modif_strqrt"; ?>" title="Modifier : <?php echo $UserName; ?>"><img src="images/tclyit_m.png" width="122" height="28" border="0"></a>-->\r
318 </td>\r
319 <td align="center" style="padding-top:5px; padding-left:5px; padding-right:5px; padding-bottom:5px;">\r
320 <input type="button" name="cmdDelete" value="Supprimer" style="border:double; height:27px; border-color:#999966; background-color:#9aa95f; cursor:pointer; color:#FFFFFF;" title='Supprimer : <?php echo $UserName; ?>' onClick="javascript: if(window.confirm('Confirmez-vous la suppression de <?php echo "\' ".$UserName." \'"; ?>?')){document.location.href='<?php echo"$_PHP_SELF?ID=$ID&DEL=Del_strqrt"; ?>'}" />\r
321 <!--<a href="<?php echo"$_PHP_SELF?ID=$ID&DEL=Del_strqrt"; ?>" title="Supprimer : <?php echo $UserName; ?>"><img src="images/tclyits_m.png" width="122" height="28" onClick="return delete_message();" border="0"></a>-->\r
322 </td>\r
323 </tr>\r
324 <?php } } ?>\r
325 <tr>\r
326 <td colspan="5"></td>\r
327 <td align="center" style="padding-top:5px; padding-left:5px; padding-right:5px; padding-bottom:5px;">\r
328 <input type="button" name="cmdAjouter" value=" Ajouter " style="border:double; height:27px; border-color:#999966; background-color:#9aa95f; cursor:pointer; color:#FFFFFF;" title="Ajouter nouveau utilisateur" onClick="javascript:document.location.href='<?php echo"index_admin.php"; ?>'" />\r
329 </td>\r
330 </tr>\r
331 </table>\r
332 </td>\r
333 </tr>\r
334 <tr bgcolor="#E2CEAF"><td align="center" style="padding-top:8px; padding-bottom:8px;"><i>Veuillez mettre votre curseur sur le mot de passe vous allez voir le vrai mot de passe!</i></td></tr>\r
335 </table>\r
336 </td>\r
337 </tr>\r
338 </table>\r
339 </form>\r
340 </center>\r
341 \r
342</body>\r
343</html>\r