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