Skip to content

Instantly share code, notes, and snippets.

@skorotkiewicz
Created December 8, 2016 15:16
Show Gist options
  • Save skorotkiewicz/319cafc9df5f13de9d95cb0b1b3001ed to your computer and use it in GitHub Desktop.
Save skorotkiewicz/319cafc9df5f13de9d95cb0b1b3001ed to your computer and use it in GitHub Desktop.
.htpasswd generator webpage in php
Use this form to generate your encrypted htaccess password.
<form method="post" action="">
<p><input type="text" name="login" placeholder="Login" /></p>
<p><input type="text" name="password" placeholder="Password" /></p>
<p><input type="submit" value="Get" /></p>
</form>
<?PHP
// demo: http://tmp.itunix.eu/aLog.php
$login = $_POST['login'];
$password = $_POST['password'];
if ($password) {
echo '<p>/var/www/.htpasswd</p>';
echo '<code style="padding: 20px; background-color: #dedede;">';
$encryptPassword = crypt($password, base64_encode($password));
echo $login . ':' . $encryptPassword;
echo '</code>';
?>
<p>
<br />
<strong>.htaccess file</strong>
<br />
AuthName "Please give your password" <br />
AuthType Basic <br />
AuthUserFile /var/www/.htpasswd <br />
Require valid-user <br />
</p>
<?PHP
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment