A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.
1 <!-- 2 /////////////////////////////////////////////////////////////////////////////// 3 / 1.00 / 4 / Administration de l'authentification des accès aux pages Web par HTAccess / 5 /////////////////////////////////////////////////////////////////////////////// 6 7 Copyright (C) 2002 Céline Dengreville 8 9 --> 10 11 <meta http-equiv="Pragma" content="no-cache"> 12 <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" /> 13 <meta http-equiv="expires" content="0"> 14 15 <? 16 // Ajout Bpa Support Langues 17 // I18N support information here 18 if(!isset($language)) $language = "fr_FR"; 19 20 putenv('LANGUAGE='.$language); 21 setlocale("LC_ALL", $language); 22 23 // Set the text domain as 'messages' 24 $domain = 'messages'; 25 bindtextdomain (messages, "./locale"); 26 textdomain($domain); 27 28 29 function getPath() 30 { 31 $rawpath = getcwd(); 32 $path = strtr($rawpath, "\\", "/"); 33 return $path; 34 } 35 36 define ("WEBPATH", getPath()); 37 define ("ADMINFILE", WEBPATH."/user/password_admin"); 38 define ("ZONEFILE", WEBPATH."/../.htaccess"); 39 define ("USERFILE", WEBPATH."/user/password"); 40 define ("ACCESSFILE", WEBPATH."/.htaccess"); 41 define ("VERSION", "1.0"); 42 43 function creerAdminFile(){ 44 45 $f = fopen(ADMINFILE, "w"); 46 fputs($f,"admin:".crypt("admin")."\n"); 47 fclose($f); 48 } 49 50 51 52 function creerAccessFile() { 53 54 $htaccess.= "AuthUserFile ".USERFILE."\n"; 55 $htaccess.= 'AuthName "Htadmin"'."\n"; 56 $htaccess.= "AuthType Basic\n"; 57 $htaccess.="<Limit GET POST PUT>\n"; 58 $htaccess.= "require valid-user\n"; 59 $htaccess.="</Limit>"; 60 $f = fopen(ZONEFILE, "w"); 61 fputs($f, $htaccess); 62 fclose($f); 63 } 64 65 66 67 function verifAccessFile() { 68 69 $Tab = file(ZONEFILE); 70 $modif=1; 71 72 for ($i = 0; $i < count($Tab); $i++) { 73 if (!ereg("^AuthUserFile" ,$Tab[$i],$regs)) { 74 $file[$i]=trim($Tab[$i]); 75 }else{ 76 $part = split(" ",$Tab[$i]); 77 if(trim($part[1])==USERFILE) $modif=0; 78 else $file[$i]="AuthUserFile ".USERFILE; 79 } 80 } 81 if($modif==1){ 82 $f=fopen(ZONEFILE,"w"); 83 for ($i=0; $i<count($file); $i++){ 84 fputs($f,$file[$i]."\n"); 85 } 86 fclose($f); 87 } 88 } 89 90 91 92 function creerAccessAdminFile() { 93 94 $htaccess.= "AuthUserFile ".ADMINFILE."\n"; 95 $htaccess.= "AuthName ".'"'."Zone Protegee".'"'."\n"; 96 $htaccess.= "AuthType Basic\n"; 97 $htaccess.="<Limit GET POST PUT>\n"; 98 $htaccess.= "require valid-user\n"; 99 $htaccess.="</Limit>"; 100 $f = fopen(ACCESSFILE, "w"); 101 fputs($f, $htaccess); 102 fclose($f); 103 } 104 105 106 if (isset($modifier_zone)){ 107 108 if(trim($zone)=="") $erreur = gettext("The protected zone field is empty..."); 109 else{ 110 $Tab = file(ZONEFILE); 111 for ($i = 0; $i < count($Tab); $i++) { 112 if (!ereg("^AuthName" ,$Tab[$i],$regs)) { 113 $file[$i]=trim($Tab[$i]); 114 }else{ 115 $file[$i]="AuthName ".'"'.$zone.'"'; 116 } 117 } 118 119 $f=fopen(ZONEFILE,"w"); 120 for ($i=0; $i<count($file); $i++){ 121 fputs($f,$file[$i]."\n"); 122 } 123 fclose($f); 124 $erreur = gettext("The protected zone name has been succefully modified !"); 125 } 126 } 127 128 if((isset($bouton))&&($bouton=="delete")){ 129 $Tab = file(USERFILE); 130 $j=0; 131 for ($i = 0; $i < count($Tab); $i++) { 132 if($i!=$select){ 133 $users[$j] = trim($Tab[$i]); 134 $j++; 135 } 136 } 137 $f=fopen(USERFILE,"w"); 138 for ($i=0; $i<count($users); $i++){ 139 fputs($f,$users[$i]."\n"); 140 } 141 fclose($f); 142 $select = 0; 143 #$erreur = gettext("L'utilisateur sélectionné a bien été supprimé !"); 144 $erreur = gettext("User succefully deleted !"); 145 } 146 147 if((isset($bouton))&&($bouton=="change")) { 148 149 if(trim($passworded)=="") $erreur = gettext("The password field is empty..."); 150 else if($passworded==$confirmation){ 151 152 $Tab = file(USERFILE); 153 for ($i = 0; $i < count($Tab); $i++) { 154 if($i==$select){ 155 $users[$i][0]=$id; 156 $users[$i][1]=crypt($passworded); 157 } 158 else $users[$i] = split(":",trim($Tab[$i])); 159 } 160 $f=fopen(USERFILE,"w"); 161 for ($i=0; $i<count($users); $i++){ 162 fputs($f,$users[$i][0].":".$users[$i][1]."\n"); 163 } 164 fclose($f); 165 $erreur = gettext("The user account has been modified !"); 166 }else{ 167 $erreur = gettext("Warning, the password didn't match !"); 168 } 169 } 170 171 if(isset($ajouter)) { 172 if(trim($passworded_ajout)=="") $erreur = gettext("The password field is empty..."); 173 else if($passworded_ajout==$confirmation_ajout){ 174 175 $ligne=$id_ajout.":".crypt($passworded_ajout)."\n"; 176 $f=fopen(USERFILE,"a+"); 177 fputs($f,$ligne); 178 fclose($f); 179 $erreur = gettext("The new user has been succefully created !"); 180 181 }else{ 182 $erreur = gettext("Warning, the password didn't match !"); 183 } 184 } 185 186 if(isset($modifier_admin)) { 187 if(trim($pwda)=="") $erreur = gettext("The password field is empty..."); 188 else if($pwda==$confirmationa){ 189 $Tab = file(ADMINFILE); 190 191 $f=fopen(ADMINFILE,"w"); 192 fputs($f,"admin:".crypt($pwda)."\n"); 193 194 fclose($f); 195 $erreur = gettext("The admin password has been modified !"); 196 }else{ 197 $erreur = gettext("Warning, the password didn't match !"); 198 } 199 } 200 201 function load(){ 202 203 global $zone; 204 global $users; 205 global $pwd_admin; 206 207 if(!is_file(ZONEFILE)){ 208 creerAccessFile(); 209 }else{ 210 verifAccessFile(); 211 } 212 213 $Tab = file(ZONEFILE); 214 for ($i = 0; $i < count($Tab); $i++) { 215 if (ereg("^AuthName" ,$Tab[$i],$regs)) { 216 $sentence= split('"',trim($Tab[$i])); 217 $zone = $sentence[1]; 218 } 219 } 220 221 if(!is_file(ACCESSFILE)) { 222 creerAccessAdminFile(); 223 creerAdminFile(); 224 } 225 226 if(is_file(USERFILE)) { 227 $Tab = file(USERFILE); 228 for ($i = 0; $i < count($Tab); $i++) { 229 $users[$i] = split(":",trim($Tab[$i])); 230 } 231 } 232 } 233 ?> 234 235 <html> 236 <head> 237 </head> 238 239 <script> 240 function charge(valeur){ 241 document.location = "index.php?select="+valeur; 242 } 243 244 function chargelang(valeur){ 245 document.location = "index.php?language="+valeur; 246 } 247 248 function verif(valeur,phrase){ 249 document.form3.bouton.value=valeur; 250 if (confirm(phrase)){ 251 document.form3.submit(); 252 } 253 } 254 </script> 255 256 <body> 257 <link rel="stylesheet" href="style.css" type="text/css"> 258 <? load(); ?> 259 <font class="normal"> 260 <h1><? echo gettext("HTADMIN Administration")?> 261 262 <span class="erreur" name="erreur"><? echo $erreur;?> </span> 263 <form action="index.php" method="post" name="form"> 264 <? if (isset($select)){?><input type=hidden name="select" value=<? echo $select ?> ><?}?> 265 <table align="center"> 266 <tr><td colspan=2><h2><? echo gettext("Modification of the protected area") ?></h2> 267 <tr><td><input class="zonetexte" type="text" name="zone" value="<? echo $zone; ?>" size="45" > 268 <td align=right><input type="submit" class="bouton" name="modifier_zone" value=<? echo gettext("change")?>> 269 </table> 270 </form> 271 <form action="index.php" method="post" name="form2"> 272 <? if (isset($select)){?><input type=hidden name="select" value=<? echo $select ?> ><?}?> 273 <table align="center"> 274 <tr><td colspan=2><h2><? echo gettext("Add user")?></h2> 275 <tr><td><? echo gettext("ID :")?><td><input class="zonetexte" type="text" name="id_ajout" > 276 <tr><td><? echo gettext("Password :") ?><td><input class="zonetexte" type="password" name="passworded_ajout" > 277 <tr><td><? echo gettext("Confirm :") ?><td><input class="zonetexte" type="password" name="confirmation_ajout" > 278 <td align="right"><input type="submit" class="bouton" name="ajouter" value=<? echo gettext("add") ?>> 279 </table> 280 </form> 281 <form action="index.php" method="get" name="form3"> 282 <? if (isset($select)){?><input type=hidden name="select" value=<? echo $select ?> ><?}?> 283 <table align="center"> 284 <tr><td colspan=3><h2><? echo gettext("Delete or modify user") ?></h2> 285 <? if (count($users)>0){?> 286 <input type=hidden name="bouton" value="" > 287 <tr><td colspan=3> 288 <select name="user" onChange="charge(this.options[this.selectedIndex].value)"> 289 <? for ($i = 0; $i < count($users); $i++){ ?> 290 <option value=<? echo $i ?> <? if($i==$select){?> selected<?}?> ><? echo $users[$i][0]; ?></option> 291 <? }?> 292 </select> 293 <tr><td><? echo gettext("ID :") ?><td><input class="zonetexte" type="text" name="id" <? if(isset($select)){?>value=<? echo $users[$select][0];?> <?}else {?>value=<? echo $users[0][0];?> <?}?>> 294 <tr><td><? echo gettext("Password :") ?><td><input class="zonetexte" type="password" name="passworded" > 295 <tr><td><? echo gettext("Confirm :")?><td><input class="zonetexte" type="password" name="confirmation"> 296 <tr><td colspan=2 align=right><input type="button" class="bouton" name="supprimer" value=<? echo gettext("delete")?> onclick='verif("delete","<? echo gettext('Do you really want to delete this user ?')?>")'> <input type="button" class="bouton" name="modifier" value=<? echo gettext("change")?> onclick='verif("change","<? echo gettext('Do you really want to modify this user ?')?>")'> 297 <?}else{?> 298 <? echo gettext("No registered user !")?> 299 <?}?> 300 </table> 301 </form> 302 <form action="index.php" method="post" name="form4"> 303 <? if (isset($select)){?><input type=hidden name="select" value=<? echo $select ?> ><?}?> 304 <table align="center"> 305 <tr><td colspan=3><h2><? echo gettext("Change the administrator password")?></h2> 306 <tr><td><? echo gettext("Password :") ?><td><input class="zonetexte" type="password" name="pwda" > 307 <tr><td><? echo gettext("Confirm :") ?><td><input class="zonetexte" type="password" name="confirmationa" > 308 <td align=right><input type="submit" class="bouton" name="modifier_admin" value=<? echo gettext("change")?>> 309 </table></form> 310 <font class="normal" align=center> 311 <? echo gettext("Select language : ") ?> 312 <select name="language" onChange="chargelang(this.options[this.selectedIndex].value)"> 313 <option value="fr_FR" <? if ($language=="fr_FR"){?>selected<?}?>><? echo gettext("French")?></option> 314 <option value="en_EN" <? if ($language=="en_EN"){?>selected<?}?>><? echo gettext("English")?></option> 315 </select> 316 317 <br> Htadmin V<? echo VERSION?> Powered by <a href="http://www.actinux.org/">Actinux</a></font> 318 319 </font> 320 </body> 321 </html>