#创建脚本目录
mkdir -p /var/www/svn/svntools
#创建apache配置文件
touch /etc/httpd/conf.d/alias.conf
#输入以下内容:
Alias /svntools "/var/www/svn/svntools"
Require valid-user
AuthType Basic
AuthName "svn tools"
AuthUserFile "/var/www/svn/project/conf/passwd"
#重启apache服务
service httpd restart
#创建修改密码的php脚本
$username = $_SERVER["PHP_AUTH_USER"]; //经过 AuthType Basic 认证的用户名
$authed_pass = $_SERVER["PHP_AUTH_PW"]; //经过 AuthType Basic 认证的密码
$input_oldpass = (isset($_REQUEST["oldpass"]) ? $_REQUEST["oldpass"] : ""); //从界面上输入的原密码
$newpass = (isset($_REQUEST["newpass"]) ? $_REQUEST["newpass"] : ""); //界面上输入的新密码
$repeatpass = (isset($_REQUEST["repeatpass"]) ? $_REQUEST["repeatpass"] : ""); //界面上输入的重复密码
$action = (isset($_REQUEST["action"]) ? $_REQUEST["action"] : ""); //以hide方式提交到服务器的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";
}
?>
Subversion 在线自助密码修改//action=view 显示普通的输入信息
if ($action == "view"){
?>
Subversion 密码修改 | |
---|---|
用户名: | =$username?> |
原密码: | |
用户密码: | |
确认密码: | |
}
else if($action == "oldpasswrong"){
$msg="原密码错误!";
}
else if($action == "passempty"){
$msg="请输入新密码!";
}
else if($action == "passnotsame"){
$msg="两次输入密码不一致,请重新输入!";
}
else{
$passwdfile="/var/www/svn/project/conf/passwd";
$command='"htpasswd" -b '.$passwdfile." ".$username." ".$newpass;
system($command, $result);
if($result==0){
$msg="用户[".$username."]密码修改成功,请用新密码登陆.";
}
else{
$msg="用户[".$username."]密码修改失败,返回值为".$result.",请和管理员联系!";
}
}
if (isset($msg)){
?>
}
?>