mkdir -p /var/www/svn/svntools
#创建apache配置文件
touch /etc/httpd/conf.d/alias.conf
#输入下面内容:
Alias /svntools "/var/www/svn/svntools"
<Directory "/var/www/svn/svntools">
Require valid-user
AuthType Basic
AuthName "svn tools"
AuthUserFile "/var/www/svn/project/conf/passwd"
</Directory>
#重新启动apache服务
service httpd restart
#创建改动password的php脚本
<?
$username = $_SERVER["PHP_AUTH_USER"]; //经过 AuthType Basic 认证的用户名
$authed_pass = $_SERVER["PHP_AUTH_PW"]; //经过 AuthType Basic 认证的password
$input_oldpass = (isset($_REQUEST["oldpass"]) ? $_REQUEST["oldpass"] : ""); //从界面上输入的原password
$newpass = (isset($_REQUEST["newpass"]) ? $_REQUEST["newpass"] : ""); //界面上输入的新password
$repeatpass = (isset($_REQUEST["repeatpass"]) ? $_REQUEST["repeatpass"] : ""); //界面上输入的反复password
$action = (isset($_REQUEST["action"]) ? $_REQUEST["action"] : ""); //以hide方式提交到server的action
if($action!="modify"){
$action = "view";
}
else if($authed_pass!=$input_oldpass){
$action = "oldpasswrong";
}
else if(empty($newpass)){
$action = "passempty";
}
else if($newpass!=$repeatpass){
$action = "passnotsame";
}
else{
$action = "modify";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Subversion 在线自助password改动</title>
</head>
<body>
<?
//action=view 显示普通的输入信息 if ($action == "view"){ ?> <script language = "javaScript"> <!-- function loginIn(myform) { var newpass=myform.newpass.value; var repeatpass=myform.repeatpass.value; if(newpass==""){ alert("请输入password!
"); return false; } if(repeatpass==""){ alert("请反复输入password!
"); return false; } if(newpass!=repeatpass){ alert("两次输入password不一致,请又一次输入!"); return false; } return true; } //--> </script> <style type="text/css"> <!-- table { border: 1px solid #CCCCCC; background-color: #f9f9f9; text-align: center; vertical-align: middle; font-size: 9pt; line-height: 15px; } th { font-weight: bold; line-height: 20px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-bottom-style: solid; color: #333333; background-color: f6f6f6; } input{ height: 18px; } .button { height: 20px; } --> </style> <br><br><br> <form method="post"> <input type="hidden" name="action" value="modify"/> <table width="220" cellpadding="3" cellspacing="8" align="center"> <tr> <th colspan=2>Subversion password改动</th> </tr> <tr> <td>用户名:</td> <td align="left"> <?
=$username?
></td> </tr> <tr> <td>原password:</td> <td><input type=password size=12 name=oldpass></td> </tr> <tr> <td>用户password:</td> <td><input type=password size=12 name=newpass></td> </tr> <tr> <td>确认password:</td> <td><input type=password size=12 name=repeatpass></td> </tr> <tr> <td colspan=2> <input οnclick="return loginIn(this.form)" class="button" type=submit value="修 改"> <input name="reset" type=reset class="button" value="取 消"> </td> </tr> </table> </form> <? } else if($action == "oldpasswrong"){ $msg="原password错误!"; } else if($action == "passempty"){ $msg="请输入新password。"; } else if($action == "passnotsame"){ $msg="两次输入password不一致。请又一次输入。"; } else{ $passwdfile="/var/www/svn/project/conf/passwd"; $command='"htpasswd" -b '.$passwdfile." ".$username." ".$newpass; system($command, $result); if($result==0){ $msg="用户[".$username."]password改动成功。请用新password登陆."; } else{ $msg="用户[".$username."]password改动失败。返回值为".$result.",请和管理员联系!
"; } } if (isset($msg)){ ?
> <script language="javaScript"> <!-- alert("<?=$msg?>"); window.location.href="<?=$_SERVER["PHP_SELF"]?>" //--> </script> <? } ?> </body> </html>