在线增减.htpasswd内的用户
程序员文章站
2022-05-25 20:25:38
在线增减.htpasswd内的用户
在线增减.htpasswd内的用户
<?php
include("./class.htpasswd.php3");
/* 请修改此.htpasswd文件路径
*/
$htpasswdfile = "/usr2/amitc/.htpasswd";
// 此行请勿修改
echo '<form action="'.$php_self . '" method=post>';
?>
<table border><tr>
<td>username: </td>
<td><input type=text name="username"></td>
</tr><tr>
<td>password: </td>
<td><input type=text name="password"></td>
</tr><tr>
<td>
<input type=radio name=doop value="verify" checked> verify password <br>
<input type=radio name=doop value="add" > 加入新用户<br>
<input type=radio name=doop value="delete" > 删除用户 <br>
<input type=radio name=doop value="change" > 更改密码 <br>
</td>
<td>
<input type=submit name="operation">
</td></tr>
</tr>
</table>
</form>
<?php
if(!isset($operation)) {
}
else {
echo "<font color=red> <hr>";
echo "您刚进行了此项操作,请核查 <br><hr>";
echo "您要对用户 $username 及密码 $password 进行 = [$doop] <br>";
$handle = new htpasswd($htpasswdfile);
switch ($doop) {
case 'add':
print "用户<br>";
$retval = $handle->adduser($username, $password);
if($retval) {
print "用户 [$username] 加入成功!<br>";
} else {
print "加入用户 [$username] 失败.<br>";
}
break;
case 'change':
print '修改密码<br>';
$retval = $handle->changepass($username, $password);
if($retval) {
print "[$username] 的密码修改成功.<br>";
} else {
print "[$username] 的密码修改失败.<br>";
}
break;
case 'delete':
print '删除用户<br>';
$retval = $handle->deleteuser($username);
if($retval) {
print "[$username] 被删除.<br>";
} else {
print "删除 [$username]时发生错误.<br>";
}
break;
case 'verify':
print 'code to verify user's password<br>';
$retval = $handle->verifyuser($username, $password);
if($retval) {
print "[$username] verifies okay with password [$password]<br>";
} else {
print "verify error for [$username] with [$password] (wrong password or user doesn't exist!) <br>";
}
break;
default:
print '您要中断? <br>';
}
echo "</font>";
}
?>
<?php
include("./class.htpasswd.php3");
/* 请修改此.htpasswd文件路径
*/
$htpasswdfile = "/usr2/amitc/.htpasswd";
// 此行请勿修改
echo '<form action="'.$php_self . '" method=post>';
?>
<table border><tr>
<td>username: </td>
<td><input type=text name="username"></td>
</tr><tr>
<td>password: </td>
<td><input type=text name="password"></td>
</tr><tr>
<td>
<input type=radio name=doop value="verify" checked> verify password <br>
<input type=radio name=doop value="add" > 加入新用户<br>
<input type=radio name=doop value="delete" > 删除用户 <br>
<input type=radio name=doop value="change" > 更改密码 <br>
</td>
<td>
<input type=submit name="operation">
</td></tr>
</tr>
</table>
</form>
<?php
if(!isset($operation)) {
}
else {
echo "<font color=red> <hr>";
echo "您刚进行了此项操作,请核查 <br><hr>";
echo "您要对用户 $username 及密码 $password 进行 = [$doop] <br>";
$handle = new htpasswd($htpasswdfile);
switch ($doop) {
case 'add':
print "用户<br>";
$retval = $handle->adduser($username, $password);
if($retval) {
print "用户 [$username] 加入成功!<br>";
} else {
print "加入用户 [$username] 失败.<br>";
}
break;
case 'change':
print '修改密码<br>';
$retval = $handle->changepass($username, $password);
if($retval) {
print "[$username] 的密码修改成功.<br>";
} else {
print "[$username] 的密码修改失败.<br>";
}
break;
case 'delete':
print '删除用户<br>';
$retval = $handle->deleteuser($username);
if($retval) {
print "[$username] 被删除.<br>";
} else {
print "删除 [$username]时发生错误.<br>";
}
break;
case 'verify':
print 'code to verify user's password<br>';
$retval = $handle->verifyuser($username, $password);
if($retval) {
print "[$username] verifies okay with password [$password]<br>";
} else {
print "verify error for [$username] with [$password] (wrong password or user doesn't exist!) <br>";
}
break;
default:
print '您要中断? <br>';
}
echo "</font>";
}
?>
上一篇: CentOS6.5 升级 Python 2.7 版本详细介绍
下一篇: Linux下用C获取当前时间