Guest User

Untitled

a guest
Nov 24th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6. if (file_exists($username)) {
  7. echo "Name already taken.";
  8. } else {
  9. mkdir($username, 0755);
  10. }
  11. fopen("/$username/.htaccess", "r+");
  12. $htaccesscontent = "AuthUserFile /.htpasswd\nAuthType Basic\nrequire user $username";
  13. file_put_contents("/$username/.htaccess", "$htaccesscontent");
  14. fclose("/$username/.htaccess");
  15. $hashed = crypt($password);
  16. fopen("/$username/.htpasswd", "r");
  17. $htpasswdcontent = "$username:$hashed";
  18. file_put_contents("/$username/.htpasswd", "$htpasswdcontent");
  19. fclose("/$username/.htpasswd");
  20. echo "Please <a href='/$username'>click here</a> to login.";
  21. }
  22. ?>
Add Comment
Please, Sign In to add comment