在线增减.htpasswd内的用户_PHP教程
程序员文章站
2022-05-09 14:02:26
...
在线增减.htpasswd内的用户
include("./class.Htpasswd.php3");
/* 请修改此.htpasswd文件路径
*/
$htpasswdfile = "/usr2/amitc/.htpasswd";
// 此行请勿修改
echo '
if(!isset($operation)) {
}
else {
echo "
";
echo "您刚进行了此项操作,请核查
";
echo "您要对用户 $username 及密码 $password 进行 = [$doop]
";
$handle = new Htpasswd($htpasswdfile);
switch ($doop) {
case 'add':
print "用户
";
$retval = $handle->addUser($username, $password);
if($retval) {
print "用户 [$username] 加入成功!
";
} else {
print "加入用户 [$username] 失败.
";
}
break;
case 'change':
print '修改密码
';
$retval = $handle->changePass($username, $password);
if($retval) {
print "[$username] 的密码修改成功.
";
} else {
print "[$username] 的密码修改失败.
";
}
break;
case 'delete':
print '删除用户
';
$retval = $handle->deleteUser($username);
if($retval) {
print "[$username] 被删除.
";
} else {
print "删除 [$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 '您要中断?
';
}
echo "";
}
?>
include("./class.Htpasswd.php3");
/* 请修改此.htpasswd文件路径
*/
$htpasswdfile = "/usr2/amitc/.htpasswd";
// 此行请勿修改
echo '
if(!isset($operation)) {
}
else {
echo "
";
echo "您刚进行了此项操作,请核查
";
echo "您要对用户 $username 及密码 $password 进行 = [$doop]
";
$handle = new Htpasswd($htpasswdfile);
switch ($doop) {
case 'add':
print "用户
";
$retval = $handle->addUser($username, $password);
if($retval) {
print "用户 [$username] 加入成功!
";
} else {
print "加入用户 [$username] 失败.
";
}
break;
case 'change':
print '修改密码
';
$retval = $handle->changePass($username, $password);
if($retval) {
print "[$username] 的密码修改成功.
";
} else {
print "[$username] 的密码修改失败.
";
}
break;
case 'delete':
print '删除用户
';
$retval = $handle->deleteUser($username);
if($retval) {
print "[$username] 被删除.
";
} else {
print "删除 [$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 '您要中断?
';
}
echo "";
}
?>