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