欢迎光临 Rick 's BLOG
日志首页  | C# .Net编程  | 原创作品  | 生活点滴  | C\C++相关  | 多媒体相关※ERMP  | VB相关  | 其它运维与编程  |  留言簿
SELinux权限导致的Phabricator无法通过http访问git仓库 NGINX配置ssl证书
未知  记录VisualSVNServer配置在线密码修改功能
[ 发布日期:9年前 (2018-02-02) ]   [ 来自:rick@云栖社区 ] [分类:其它运维与编程]
VisualSVN Server使用的是64位版
查看对应的apache版本号是 2.2.32.
这个版本需要使用php5.5以下的,且需要使用64位的php。


下载php 5.4 的64位版本。
php的下载地址:
官网地址:http://windows.php.net/download/
http://windows.php.net/downloads/pecl/releases/

官网从5.5开始才提供了64位的bin包下载。
所以我们需要下载源代码自己编译或者找第三方编译的64位bin包

https://phpdev.toolsforresearch.com/php-5.4.36-nts-Win32-VC9-x86.zip
https://phpdev.toolsforresearch.com/php-5.4.36-Win32-VC9-x86.zip
https://phpdev.toolsforresearch.com/php-5.4.36-nts-Win32-VC9-x64.zip
https://phpdev.toolsforresearch.com/php-5.4.36-Win32-VC9-x64.zip
https://phpdev.toolsforresearch.com/php-5.3.29-nts-Win32-VC9-x86.zip
https://phpdev.toolsforresearch.com/php-5.3.29-Win32-VC9-x86.zip
https://phpdev.toolsforresearch.com/php-5.3.29-nts-Win32-VC9-x64.zip
https://phpdev.toolsforresearch.com/php-5.3.29-Win32-VC9-x64.zip

这里我们下载 php-5.4.36-Win32-VC9-x64.zip


配置Visual SVN Server支持php
1. 将下载的php解压缩到VisualSVNServer的目录中
C:\Program Files\VisualSVN Server\php

2.修改配置文件
C:\Program Files\VisualSVN Server\conf\httpd-custom.conf
[复制到剪贴板]

LoadModule php5_module
"php/php5apache2_2.dll"
<IfModule php5_module>
AddType application/x-httpd-php .php
DirectoryIndex index
.html index.php
</IfModule>
# 配置 php.ini 的路径
PHPIniDir "php"
?>


3.建立php脚本
我们这里主要是利用了apach自己的htpasswd.exe工具来进行密码的变更操作

可以下载一个apache的完整包提取该工具放到如下路径:
C:\Program Files\VisualSVN Server\bin\htpasswd.exe

新建一个 php 文件放到 C:\Program Files\VisualSVN Server\htdocs\pw\index.php



[复制到剪贴板]

<?php
$passwdfile
="C:/Repositories/htpasswd";
$htpasswdPath = "C:/Program Files/VisualSVN Server/bin/htpasswd.exe";

$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";
}
?>
<html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=GBK">
<
title>Subversion 在线自助密码修改</title>
</
head>
<
body>

<?php
//action=view 显示普通的输入信息
if ($action == "view") {
?>
<script language = "javaScript">
function
loginIn(myform) {
var
newpass=myform.newpass.value;
var
repeatpass=myform.repeatpass.value;

if (
newpass=="") {
alert("请输入密码!");
return
false;
}

if (
repeatpass=="") {
alert("请重复输入密码!");
return
false;
}

if (
newpass!=repeatpass) {
alert("两次输入密码不一致,请重新输入!");
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 密码修改</th>
</
tr>
<
tr>
<
td>用 户 名:</td>
<
td align="left"> <?php echo $username?></td>
</
tr>
<
tr>
<
td>原 密 码:</td>
<
td><input type=password size=12 name=oldpass></td>
</
tr>
<
tr>
<
td>用户密码:</td>
<
td><input type=password size=12 name=newpass></td>
</
tr>
<
tr>
<
td>确认密码:</td>
<
td><input type=password size=12 name=repeatpass></td>
</
tr>
<
tr>
<
td colspan=2>
<
input onclick="return loginIn(this.form)" class="button" type=submit value="修 改">
<
input name="reset" type=reset class="button" value="取 消">
<
a href="/"><input name="return" type=button class="button" value="返 回"></a>
</
td>
</
tr>
</
table>
</
form>
<?php
} else if ($action == "oldpasswrong") {
$msg="原密码错误!";
} else if (
$action == "passempty") {
$msg="请输入新密码!";
} else if (
$action == "passnotsame") {
$msg="两次输入密码不一致,请重新输入!";
} else {

$command='"'. $htpasswdPath. '" -b '.$passwdfile." ".$username." ".$newpass;
system($command, $result);
if (
$result==0) {
$msg_succ="用户[".$username."]密码修改成功,请用新密码登陆.";
} else {
$msg="用户[".$username."]密码修改失败,返回值为".$result.",请和管理员联系!";
}
}

if (isset(
$msg_succ)) {
?>
<script language="javaScript">
<!--
alert("<?php echo $msg_succ?>");
window.location.href="/"
//-->
</script>
<?php
} else if (isset($msg)) {
?>
<script language="javaScript">
<!--
alert("<?php echo $msg?>");
window.location.href="<?php echo $_SERVER["PHP_SELF"]?>"
//-->
</script>
<?php
}
?>
</body>
</
html>
?>


修改C:\Program Files\VisualSVN Server\WebUI\index.html
增加里面修改的链接
[复制到剪贴板]

<a href="/pw/">自助修改密码</a>
?>

如果文章对您有帮助,给个赞赏吧!
引用通告地址 (0):
复制引用地址https://www.rickw.cn/trackback/254
复制引用地址https://www.rickw.cn/trackback/254/GBK
[ 分类:其它运维与编程  | 查看:4155 ]

暂时没有评论,快来发表一个评论吧。
发表评论
作者:   用户:[访客] 
评论:

表  情
禁止表情 | 禁止UBB | 禁止图片 | 识别链接
对不起,你没有权限上传附件!
验证:
 
PoweredBy R-Blog V1.00 © 2004-2026 WWW.RICKW.CN, Processed in second(s) , 5 queries    京ICP备17058477号-5