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