The source of htpasswd_maker.php (click to demo the file) viewed 7243 times.

If I wrote this code, then it is licensed under the GPL. If someone else wrote it, then please ask them if you want to use the code.


<?php
////////////////////////////////////////////////////////
// .htpasswd Maker  v1.0 - sebflipper Copyright 2004  //
//            http://www.sebflipper.com/               //
//                                                    //
// This script will generate an encrypted password    //
//       for .htpasswd and .htaccess files            //
////////////////////////////////////////////////////////
?>

<HTML>
<HEAD>
<TITLE>.htpasswd Maker</TITLE>
<style type="text/css">
<!--
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: x-small;
}

table {
    font-size: x-small;
}
-->
</style>
</HEAD>
<BODY>

<?

if ( isset($_POST[user]) && isset($_POST[password1]))
{
 if( 
$_POST[password1] == $_POST[password2] )
  {

    
/*$pfad = $DOCUMENT_ROOT . dirname($PHP_SELF) . "/.htpasswd";
    $safe= dirname ($PHPSELF);



    $htaccess_text = "AuthType Basic\n".
    "AuthName \"\"\n".
    "AuthUserFile $pfad\n".
    "require valid-user\n";*/
    
    
$user $_POST[user];
    
$password1 $_POST[password1];

    for (
$i 0$i count ($user); $i++)
    {
     
$htpasswd_text .= "$user[$i]:".crypt($password1[$i],CRYPT_STD_DES)."";
    }


       echo 
"First make a file called .htaccess put this in it:<br><br>

       AuthName \"Password Protected Directory\"<br>
       AuthType Basic<br>
       AuthUserFile /your/server/path/.htpasswd<br>
       require valid-user<br><br>

       Then make a file called .htpasswd. Below is the text you need to enter into your .htpasswd file, then upload both the file to the directory you want to protect!"
;
       echo 
"<p><hr></p>";
       echo 
nl2br($htpasswd_text);
       echo 
"<p><hr></p>";
  }
  else
  {

      echo 
"<p><hr></p>";
      echo 
"<b>Passwords do not match</b>";
      echo 
"<p><hr></p>";

  }
}

?>
<script language="javascript">
<!--
function ValidateForm() {

for (i = 0; i < document.forms[0].elements.length; i++) {
       if (document.forms[0].elements[i].value == "") {
     switch (document.forms[0].elements[i].type) {
       case "text":
         alert('Please complete all fields before submitting');
         document.all.submit.style.visibility='visible';
         return false;
         break;

       case "textarea":
         alert('Please complete all fields before submitting');
         document.all.submit.style.visibility='visible';
         return false;
         break;

       case "file":
         alert('Please complete all fields before submitting');
         document.all.submit.style.visibility='visible';
         return false;
         break;
     }
       }
     }
    return true;
    }
//-->
</script>
<FORM METHOD="POST" ACTION="<? echo $PHP_SELF?>" onSubmit='return ValidateForm()'>
<table>
<tr><td>Username:</td><td><INPUT TYPE="TEXT" NAME="user[]"></td></tr>
<tr><td>Password:</td><td><INPUT TYPE="PASSWORD" NAME="password1[]"></td></tr>
<tr><td>Password again:</td><td><INPUT TYPE="PASSWORD" NAME="password2[]"></td></tr>
<tr><td><center><INPUT type=submit name="submit" VALUE="Encrypt" onclick="document.all.submit.style.visibility='hidden'">
</FORM>
</center></td></tr>
</table>
<p>Note: We do NOT store your usernames and passwords.</p>
<p>.htpasswd Maker v1.2 designed by <a href="http://www.sebflipper.com/" target="_blank">Seb Flipper</a></p>
</BODY>
</HTML>



If you want to have a look at the source code, chose a file from this list:

ip.txt
(Demo Script)
userdetails.php
(Demo Script)
perl_smtp_email.php
(Demo Script)
server_mon.php
(Demo Script)
floor_time.php
(Demo Script)
url_verify.php
(Demo Script)
birthday.php
(Demo Script)
md5_password.php
(Demo Script)
email.php
(Demo Script)
char_limit.php
(Demo Script)
time.php
(Demo Script)
htpasswd_maker.php
(Demo Script)
title_case.php
(Demo Script)
password.php
(Demo Script)
phpself.php
(Demo Script)
smarty.php
(Demo Script)
phpinfo.php
(Demo Script)
ip_monitor.php
(Demo Script)
html.php
(Demo Script)
pad_test.php
(Demo Script)
mysql_backup.php
(Demo Script)
cookies.php
(Demo Script)
unix_time.php
(Demo Script)
convert_link.php
(Demo Script)

To colour code your own PHP paste it here: