Add or subtract on line. User _php base within HTPASSWD

Source: Internet
Author: User
Add or subtract on line. Users within HTPASSWD

<?php
Include ("./class. Htpasswd.php3 ");

/* Please modify this. htpasswd file path
*/
$htpasswdfile = "/USR2/AMITC/.HTPASSWD";


Please do not modify this row
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" > Add new User <BR>
<input type=radio name=doop value= "Delete" > Delete user <BR>
<input type=radio name=doop value= "Change" > Password <BR>
</TD>
<TD>
<input type=submit name= "Operation" >
</TD></TR>
</TR>
</TABLE>
</FORM>
<?php
if (!isset ($operation)) {
}
else {
echo "<font color=red> <HR>";
echo "You have just done this, please check <BR><HR>";
echo "You want the user $username and password $password = [$doop] <BR>";
$handle = new htpasswd ($htpasswdfile);

Switch ($doop) {
Case ' Add ':
Print "User <BR>";
$retval = $handle->adduser ($username, $password);
if ($retval) {
print "User [$username] join success!<br>";
} else {
print "Join user [$username] failed .<br>";
}
Break

Case ' Change ':
print ' Modify password <BR> ';
$retval = $handle->changepass ($username, $password);
if ($retval) {
Print "[$username] Password modification succeeded .<br>";
} else {
Print "[$username] Password modification failed .<br>";
}
Break

Case ' Delete ':
print ' Delete user <BR> ';
$retval = $handle->deleteuser ($username);
if ($retval) {
Print "[$username] is deleted .<br>";
} else {
Error .<br> when print "deletes [$username]";
}
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 ' You want to break? <BR> ';
}
echo "</FONT>";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.