- 论坛徽章:
- 2
|
本帖最后由 woshiyiziyu 于 2014-02-12 18:38 编辑
本人小白,想弄个自助修改apache密码的php页面,从网上照抄了一段代码,但是打开的时候是空白,打开其他系统里自带的php页面正常,求各位出手相助。- <?php
- error_reporting(E_ALL);
- include("./class.Htpasswd.php3");
- /*
- */
- $htpasswdfile = "/etc/squid/passwd";
- //
- 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 user<BR>
- <INPUT TYPE=radio NAME=doop VALUE="delete" > delete user <BR>
- <INPUT TYPE=radio NAME=doop VALUE="change" > 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 ",please check <BR><HR>";
- echo " $username $password = [$doop] <BR>";
- $handle = new Htpasswd($htpasswdfile);
- switch ($doop) {
- case 'add':
- print "user<BR>";
- $retval = $handle->addUser($username, $password);
- if($retval) {
- print "user [$username] add success!<BR>";
- } else {
- print "add user [$username] failed.<BR>";
- }
- break;
- case 'change':
- print 'change password<BR>';
- $retval = $handle->changePass($username, $password);
- if($retval) {
- print "[$username] success.<BR>";
- } else {
- print "[$username] failed.<BR>";
- }
- break;
- case 'delete':
- print 'delete user<BR>';
- $retval = $handle->deleteUser($username);
- if($retval) {
- print "[$username] is deleted.<BR>";
- } else {
- print "delete [$username] error.<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 'do you want to break? <BR>';
- }
- echo "</FONT>";
- }
- ?>
复制代码 |
|