Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $file = '.htpasswds';
- $login = $_SERVER['REMOTE_USER'];
- $pass = $_POST['pass'];
- $pass2 = $_POST['pass2'];
- $passlen = strlen($pass);
- if($passlen < 6){
- print "Password Not Long Enough.";
- exit();
- }
- if($pass != $pass2){
- print "Passwords do not match.";
- exit();
- }
- $hash = crypt($pass, base64_encode($pass));
- $current = file_get_contents($file);
- //find and remove old entry
- $array = explode("\n",$current);
- foreach($array as $arr) {
- if(!(preg_match("/^$login/s",$arr))) {
- $output[] = $arr;
- }
- }
- $current = implode("\n",$output);
- $current .= "\n$login:$hash";
- file_put_contents($file, $current);
- print "Success"
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement