Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit']))
- {
- $username = $_POST['username'];
- $password = $_POST['password'];
- if (file_exists($username)) {
- echo "Name already taken.";
- } else {
- mkdir($username, 0755);
- }
- fopen("/$username/.htaccess", "r+");
- $htaccesscontent = "AuthUserFile /.htpasswd\nAuthType Basic\nrequire user $username";
- file_put_contents("/$username/.htaccess", "$htaccesscontent");
- fclose("/$username/.htaccess");
- $hashed = crypt($password);
- fopen("/$username/.htpasswd", "r");
- $htpasswdcontent = "$username:$hashed";
- file_put_contents("/$username/.htpasswd", "$htpasswdcontent");
- fclose("/$username/.htpasswd");
- echo "Please <a href='/$username'>click here</a> to login.";
- }
- ?>
Add Comment
Please, Sign In to add comment