';"/> ';">

Home  >  Article  >  Backend Development  >  Add and delete users in htpasswd online

Add and delete users in htpasswd online

WBOY
WBOYOriginal
2016-07-29 08:34:441135browse

Add or delete users in .htpasswd online
include("./class.Htpasswd.php3");
/* Please modify the path of this .htpasswd file
*/
$htpasswdfile = "/usr2/amitc/ .htpasswd";
// Please do not modify this line
echo '

';
?>

< ;TD>Username:


NAME=doop VALUE="verify" CHECKED> Verify Password

Add new user

Delete user

Change password




Password:
< INPUT TYPE=submit name="operation">


}
else {
echo "
";
echo "You just performed this operation, please check

";
echo "You want to change user $username and password $password = [$doop]
";
$handle = new Htpasswd($htpasswdfile);
switch ($doop) {
case 'add':
print "User
";
$retval = $handle->addUser($username, $password);
if($retval) {
print "User[$username] joined successfully!
" ;
} else {
print "Failed to join user [$username].
";
}
break;
case 'change':
print 'Change password
';
$retval = $handle ->changePass($username, $password);
if($retval) {
print "[$username]'s password was changed successfully.
";
} else {
print "[$username]'s password Modification failed.
";
}
break;
case 'delete':
print 'Delete user
';
$retval = $handle->deleteUser($username);
if($ retval) {
print "[$username] was deleted.
";
} else {
print "An error occurred while deleting [$username].
";
}
break;
case 'verify ':
print 'Code to verify user's password
';
$retval = $handle->verifyUser($username, $password);
if($retval) {
print "[$username] verifies okay with password [$password]
";
} else {
print "Verify Error for [$username] with [$password] (wrong password or user doesn't exist!)
";
}
break;
default:
print 'Do you want to break?
';
}
echo "
";
}
?>
The above has introduced the online addition and deletion of users in htpasswd, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn