Home >Backend Development >PHP Tutorial >Add or delete users in .htpasswd online_PHP tutorial

Add or delete users in .htpasswd online_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:02:11996browse

Add or delete users in .htpasswd online

include("./class.Htpasswd.php3");

/* Please modify the path of this .htpasswd file
*/
$htpasswdfile = "/usr2/amitc/.htpasswd";


// Do not modify this line
echo '

';
?>
;INPUT TYPE=text name="username">

="verify" CHECKED> Verify Password

Add new user

Delete user

Change password


< ;TD>

>
if(!isset($operation)) {
}
else {
echo " echo "You have just performed this operation, please check

";
echo "You want to perform = [$doop] < on user $username and password $password ;BR>";
$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.< ;BR>";
} else {
print "[$username]'s password change failed.
";
}
break;

case 'delete' :
print 'Delete user
';
$retval = $handle->deleteUser($username);
if($retval) {
print "[$username] was Delete.
";
} 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 't exist!)
";
}

break;

default:
print 'Do you want to break?
';
}
echo "
";
}
?>



http://www.bkjia.com/PHPjc/316627.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/316627.html

TechArticleAdd or delete users online in .htpasswd?php include(./class.Htpasswd.php3); /* Please Modify this .htpasswd file path*/ $htpasswdfile = /usr2/amitc/.htpasswd; // Do not modify this line echo 'FOR...
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