svn结合apache后用户修改密码的解决方案
2011-09-28 17:03
274 查看
svn结合apache后,修改密码就得在server端,由管理员修改密码,很不方便也不安全。
现在做已了一个web界面实现用户svn密码的修改。
我用php,做了两个页面,一个是信息收集,一个是调用系统命令
前置条件:apche已集成了svn,php
1.apache添加svntools访问目录
在/etc/ini.d/http.conf
Alias /svntools "/opt/svntools/"
<Directory "/opt/svntools">
AuthType Basic
AuthName "Subversion Tools"
AuthUserFile /opt/svn/passwd
Require valid-user
</Directory>
2.在/opt/svntols目录下创建php页面
2.1 index.php页面
<html>
<head>
<title>Change your svn passwd</title>
</head>
<script type="text/javaScript">
function check(){
if(document.form.oldpwd.value.length == 0){
alert("please input your old password!");
document.form.oldpwd.focus();
return false;
}
if(document.form.oldpwd.value != document.form.pwd.value){
alert("your old pssword is not right! please input your password!");
document.form.oldpwd.focus();
return false;
}
if(document.form.newpwd.value.length == 0){
alert("please input your new password!");
document.form.newpwd.focus();
return false;
}
if(document.form.rnewpwd.value.length == 0){
alert("please repeat input your new password!");
document.form.rnewpwd.focus();
return false;
}
if(document.form.newpwd.value != document.form.rnewpwd.value){
alert("your tow password is not the same! please reset !");
document.fomr.newpwd.focus();
return false;
}
return true;
}
</script>
<body>
<h1 align="center">Change your svn password</h1>
<?php
$username = $_SERVER["PHP_AUTH_USER"];
$authed_pass = $_SERVER["PHP_AUTH_PW"];
?>
<form action="result.php" name="form" method="post">
<table width="300" cellpadding="3" cellspacing="8" align="center">
<tr><th colspan=2> Subversion Change password</th></tr>
<tr>
<td>username:</td>
<td>
<input type="text" name="a" value='<?php echo $username;?>' disabled="true"/>
<input type="hidden" name="hide" value='<?php echo $username;?>'/>
</td>
</tr>
<tr><td>oldpassword:</td>
<td>
<input type="password" name="oldpwd"/>
<input type="hidden" name="pwd" value='<?php echo $authed_pass;?>'/>
</td>
</tr>
<tr><td>newpassword:</td><td><input type="password" name="newpwd"/></td></tr>
<tr><td>repeatnewpassword:</td><td><input type="password" name="rnewpwd"/></td></tr>
<tr><td><input type="submit" value="sure" onclick="return check()"/></td><td><input type="reset" value="reset"</td></tr>
</table>
</form>
</body>
</html>
2.2 result.php页面
<html>
<head>
</head>
<body>
<h1 algin="center">RESULT</h3>
<?php
$user = $_POST["hide"];
$pwd = $_POST["newpwd"];
$command = "htpasswd -b /opt/svn/passwd $user $pwd";
exec($command,$res,$rc);
if($rc == 0){
echo "success";
echo "<br/>";
echo "please remember your username and password.";
echo "<br/>";
echo "username: $user ";
echo "<br/>";
echo "passwd: $pwd";
echo "<br/>";
}else{
echo "fails ";
}
?>
</body>
</html>
参考了以下这篇网文
http://tech.16c.cn/svnpz/20080202/58.html
现在做已了一个web界面实现用户svn密码的修改。
我用php,做了两个页面,一个是信息收集,一个是调用系统命令
前置条件:apche已集成了svn,php
1.apache添加svntools访问目录
在/etc/ini.d/http.conf
Alias /svntools "/opt/svntools/"
<Directory "/opt/svntools">
AuthType Basic
AuthName "Subversion Tools"
AuthUserFile /opt/svn/passwd
Require valid-user
</Directory>
2.在/opt/svntols目录下创建php页面
2.1 index.php页面
<html>
<head>
<title>Change your svn passwd</title>
</head>
<script type="text/javaScript">
function check(){
if(document.form.oldpwd.value.length == 0){
alert("please input your old password!");
document.form.oldpwd.focus();
return false;
}
if(document.form.oldpwd.value != document.form.pwd.value){
alert("your old pssword is not right! please input your password!");
document.form.oldpwd.focus();
return false;
}
if(document.form.newpwd.value.length == 0){
alert("please input your new password!");
document.form.newpwd.focus();
return false;
}
if(document.form.rnewpwd.value.length == 0){
alert("please repeat input your new password!");
document.form.rnewpwd.focus();
return false;
}
if(document.form.newpwd.value != document.form.rnewpwd.value){
alert("your tow password is not the same! please reset !");
document.fomr.newpwd.focus();
return false;
}
return true;
}
</script>
<body>
<h1 align="center">Change your svn password</h1>
<?php
$username = $_SERVER["PHP_AUTH_USER"];
$authed_pass = $_SERVER["PHP_AUTH_PW"];
?>
<form action="result.php" name="form" method="post">
<table width="300" cellpadding="3" cellspacing="8" align="center">
<tr><th colspan=2> Subversion Change password</th></tr>
<tr>
<td>username:</td>
<td>
<input type="text" name="a" value='<?php echo $username;?>' disabled="true"/>
<input type="hidden" name="hide" value='<?php echo $username;?>'/>
</td>
</tr>
<tr><td>oldpassword:</td>
<td>
<input type="password" name="oldpwd"/>
<input type="hidden" name="pwd" value='<?php echo $authed_pass;?>'/>
</td>
</tr>
<tr><td>newpassword:</td><td><input type="password" name="newpwd"/></td></tr>
<tr><td>repeatnewpassword:</td><td><input type="password" name="rnewpwd"/></td></tr>
<tr><td><input type="submit" value="sure" onclick="return check()"/></td><td><input type="reset" value="reset"</td></tr>
</table>
</form>
</body>
</html>
2.2 result.php页面
<html>
<head>
</head>
<body>
<h1 algin="center">RESULT</h3>
<?php
$user = $_POST["hide"];
$pwd = $_POST["newpwd"];
$command = "htpasswd -b /opt/svn/passwd $user $pwd";
exec($command,$res,$rc);
if($rc == 0){
echo "success";
echo "<br/>";
echo "please remember your username and password.";
echo "<br/>";
echo "username: $user ";
echo "<br/>";
echo "passwd: $pwd";
echo "<br/>";
}else{
echo "fails ";
}
?>
</body>
</html>
参考了以下这篇网文
http://tech.16c.cn/svnpz/20080202/58.html
相关文章推荐
- Apache+SVN-让用户自行修改SVN密码
- 服务端linux +svn+apache 实现客户端svn用户自主修改密码
- Linux下 Apache+SVN 让用户自行修改SVN密码
- 通过web修改svn用户密码
- 为VisualSVN Server增加在线修改用户密码的功能
- linux svn+apache 配置客户自助修改密码
- VisualSVN Server 修改用户密码
- apache+php自助修改svn密码
- svn 添加用户,修改密码,删除用户
- Eclipse中修改SVN的用户名密码的解决方案
- 搭建samba、apache、changepassword,用户手动修改samba用户密码
- 为VisualSVN Server增加在线修改用户密码的功能
- SVN服务器搭建和使用以及冲突解决、用户密码修改
- 【解决方案】Windows域用户不登录域如何自行修改密码
- svn用户添加、密码修改、删除
- 为VisualSVN Server增加在线修改用户密码的功能
- 使 svn 用户可以修改自己的密码
- 为VisualSVN Server增加在线修改用户密码的功能
- Subversion客户端远程修改用户密码配置Apache22Passwd
- SVN如何修改用户密码