Linux 系统通过WEB修改svn 帐号密码
增加虚拟目录
vi /etc/httpd/conf/httpd.conf 文件最后添加
Alias /svnadmin "/var/www/html/svnadmin/"
Require valid-user
AuthType Basic
AuthName "SVN user password modify"
AuthUserFile /etc/httpd/svn/htpasswds
我的svn帐号信息存在/etc/httpd/svn/htpasswds ,apache 能够读写此目录
vi /var/www/html/svnadmin/index.php
将以下内容放插入index.php
/*
Alias /svnmodify "/var/www/html/svnadmin/"
Require valid-user
AuthType Basic
AuthName "Subversion Tools"
AuthUserFile /etc/httpd/svn/htpasswds
*/
?>
$username = $_SERVER["PHP_AUTH_USER"];
$authed_pass = $_SERVER["PHP_AUTH_PW"];
$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"] : "");
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";
}
?>
//action=view 显示普通的输入信息
if ($action == "view"){
?>
}
else if($action == "oldpasswrong"){
$msg="The old password you gave is incorrect.";
}
else if($action == "passempty"){
$msg="Please input new password";
}
else if($action == "passnotsame"){
$msg="New passwords do not match.";
}
else{
$passwdfile="/etc/httpd/svn/htpasswds";
$command='"/usr/bin/htpasswd" -b '.$passwdfile." ".$username." ".$newpass;
system($command, $result);
if($result==0){
$msg="User [".$username."]Your new password has been saved,Please re-login.";
}
else{
$msg="User [".$username."]Password change failures,Error".$result.",Please contact [email protected]";
}
}
if (isset($msg)){
?>
}
?>