ubuntu svn apache2 SVN权限的问题困扰了我多长时间

Apache+svn+openldap+phpldapadmin方案操作日志 - acooly - ITeye技术网站
博客分类:
1.方案说明
apache作为前端访问入口和功能整合
svn的认证使用apache代理openLDAP完成
svn的权限和授权受限于svn本身的机制,目前任然使用其原生配置文件方式。
openLDAP提供用户身份认证数据提供和用户统一管理
2.环境及软件
2.1.操作系统准备
操作系统:centos-6.3 64位
因为在部署整个环境中经常需要安装一些系统的组件,所以,这里先配置好yum的仓库,便于后面安装设置。
yum仓库设置
1.centos-6.3安装包FTP准备
在网络内任务服务器上,解压操作系统的ISO文件(如:/pub/centos/6.3),并把对应的包文件夹暴露为FTP服务(访问地址如:ftp://192.168.30.33/pub/centos/6.3/x86_64/)
2.设置操作系统的yum仓库
# cd /etc/yum.repos.d/
# 如果文件不存在则创建文件:centos6.3_x86_64.repo
# touch centos6.3_x86_64.repo
# 使用VI编辑设置仓库
# vi centos6.3_x86_64.repo
[centos6.3]
name=centos6.3
baseurl=ftp://192.168.30.33/pub/centos/6.3/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
以上配置中,gpgcheck=0表示访问不需要验证;enabled=1表示本仓库可用。
3.安装必须的组件
# yum install openssl
# yum install gcc
如果后续在各软件安装过程中,出现错误提示需要依赖某组件或找不到某组件,请使用yum search 和 yum install 进行安装。
2.2.软件准备
软件所有内网共享地址:\\192.168.30.202\public_resources\topic\apache_svn_openldap_phpldapadmin
httpd-2.2.21.tar.gz
(下载地址://httpd/httpd-2.2.23.tar.gz )
subversion-1.7.9.tar.bz2
db-5.3.15.tar.gz(bdb)
openldap-2.4.35.tgz
phpldapadmin-1.2.3.zip
sqlite-amalgamation-3071602.zip
# mkdir /data/packages
# cd /data/packages
拷贝或下载一下文件到/data/packages目录,待用。
3.安装openLDAP
LDAP采用openLDAP,因为其依赖DBD,所以我们先安装BDB。
# cd /data/packages
# tar -zxvf db-5.2.15.tar.gz
# db-5.3.15/build_unix
# ../dist/configure
# make install
如果出现错误:configure: error: C compiler cannot create executables
解决办法:yum install glibc-devel
安装完成后,安装目录在:/usr/local/BerkeleyDB.5.3
# 设置系统级动态链接
# cd /etc/ld.so.conf.d
# touch bdb.conf
# echo /usr/local/BerkeleyDB.5.3/lib & bdb.conf
# ldconfig
安装openLDAP
# cd /data/packages
tar -xzvf openldap-2.4.35.tgz
cd openldap-2.4.35
./configure --prefix=/usr/local/openldap CPPFLAGS="-I/usr/local/BerkeleyDB.5.3/include" LDFLAGS="-L/usr/local/BerkeleyDB.5.3/lib"
make depend
make install
安装完成后目录在:/usr/local/openldap/
配置openLDAP
# 新建LDAP数据存储目录
# mkdir /data/openldap/data
openLDAP一般只需要配置:/usr/local/openldap/etc/openldap/slapd.conf 文件,主要是设置根,认证,名称等基础信息。如下:
# vi /usr/local/openldap/etc/openldap/slapd.conf
# 默认的schema只有core,增加两个常用的schema,用于建立用户信息。
/usr/local/openldap/etc/openldap/schema/core.schema
/usr/local/openldap/etc/openldap/schema/cosine.schema
/usr/local/openldap/etc/openldap/schema/inetorgperson.schema
#######################################################################
# BDB database definitions
#######################################################################
# 使用bdb作为存储
# 顶层节点DN配置
"dc=feinno,dc=com"
# 管理员DN
"cn=Manager,dc=feinno,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoid.
See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# 密码,这里设置的是123456,请根据其情况设置
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
# 存储路径
/data/openldap/data
# Indices to maintain
# 索引配置
objectClass
以上内容是需要修改和配置的,其他参数主要是权限配置,可以暂不配置。完成配置后,请保持退出。
# 配置环境变量,用户后续的LDAP操作
# vi /etc/profile
在文件结尾加入:
export PATH=$PATH:/usr/local/openldap/bin
# soruce /etc/profile
启动openLDAP
# /usr/local/openldap/libexec/slapd
# 停止openLDAP
# killall slapd
验证和使用openLDAP
1.命令行方式使用ldif文件建立根组织DN
# mkdir /data/openldap/ldif
# cd /data/openldap/ldif
dn:dc=feinno,dc=com
objectclass:top
objectclass:dcObject
objectclass:organization
# 命令方式创建根DN entity:"dc=feinno,dc=com",使用rootdn的账户和密码(前面slapd.conf文件中配置)
# ldapadd -x -D "cn=Manager,dc=feinno,dc=com" -W -.ldif
Enter LDAP Password:
adding new entry "dc=feinno,dc=com"
# 查询已经创建的entity
# ldapsearch -x -b 'dc=feinno,dc=com' '(objectclass=*)'
2.使用桌面客户端工具
推荐使用桌面工具:
LDAPAdmin 下载地址:
Apache LDAP studio
下载地址:
这里使用LDAPAdmin 做操作演示。
我们Demo的LDAP结构如下:
建立连接:
创建组织结构单元:
建立部门节点:
建立用户:
3.使用B/S的phpLDAPAdmin
请参见后面第7节
4.安装Apache
apache是整个SVN和LDAP的前端,这里打开其动态加载功能(DSO)
# yum install openldap-devel zlib-devel expat-devel
# cd /data/packages
# tar -xzvf httpd-2.2.23.tar.gz
# cd httpd-2.2.23
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-dav=share --enable-dav-fs --with-ldap --enable-ldap --enable-authnz-ldap
# make install
安装完成后,目录在:/usr/local/apache2
# 设置环境变量,方面后面操作
# vi /etc/profile
在文件结尾加入:
export PATH=$PATH:/usr/local/apache2/bin
# soruce /etc/profile
主配置文件:/usr/local/apache2/conf/httpd.conf
1、修改ServerName,防止DNS查找失败错误
# If your host doesn't have a registered DNS name, enter its IP address here.
ServerName localhost:80
2、打开server-status配置,支持apache 状态检查。
请确保主配置文件中存在配置行:
LoadModule status_module modules/mod_status.so
在主配置文件结尾加入:
ExtendedStatus On
&Location /server-status&
SetHandler server-status
Order allow,deny
Allow from all
&/Location&
系统服务和自启动
# apache 服务和自启动
Apache加入到系统服务里面:
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
在文件头部加入如下内容:
# Comments to support chkconfig on RedHat Linux
# chkconfig:
# description:http server
# chkconfig --add httpd
# chkconfig --level 35 httpd on
等级0表示:表示关机
等级1表示:单用户模式
等级2表示:无网络连接的多用户命令行模式
等级3表示:有网络连接的多用户命令行模式
等级4表示:不可用
等级5表示:带图形界面的多用户模式
等级6表示:重新启动
# apachectl start
# 打开浏览器访问:http://ip
如果现实:It work! 表示安装成功。
# 关闭apache,等待配置
# apachectl stop
# subversion1.7.9的编译依赖 SQLITE的算法
# cd /data/packages
# tar -xjvf subversion-1.7.9.tar.bz2
# cd subversion-1.7.9
# mkdir sqlite-amalgamation
# unzip sqlite-amalgamation-3071602.zip
# cp sqlite-amalgamation-3071602/sqlite3.c subversion-1.7.9/sqlite-amalgamation/
# cd subversion-1.7.9
# ./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2
# make install
安装成功后,安装目录在:/usr/local/subversion
# 设置环境变量
# vi /etc/profile
在文件结尾加入:
export PATH=/usr/local/subversion/bin:$PATH
# soruce /etc/profile
创建和配置仓库
# 创建SVN仓库目录
# mkdir /data/svn/repositories
# cd /data/svn/repositories
# 创建测试工程
# svnadmin create project1
# svnadmin create project2
# svnadmin create project3
# svnadmin create project4
# svnadmin create project5
# 创建authz.conf文件,作为工程权限控制的配置文件。(配置语法请参考:)
# vi authz.conf
admin=zhangpu
[project1:/]
libingyang=r
完成以上后,待用,后续使用apache整合。
6.配置apache+svn+ldap
# 采用HOST方式配置,打开主配置文件httpd.conf文件中对host配置的引用注释。
# vi /usr/local/apache2/conf
Include conf/extra/httpd-vhosts.conf
# 配置vhost
# cd /usr/local/apache2/conf/extra
# vi httpd-vhosts.conf
NameVirtualHost *:80
LoadModule dav_svn_module
modules/mod_dav_svn.so
LoadModule authz_svn_module
modules/mod_authz_svn.so
&VirtualHost *:80&
ServerAdmin
ServerName
ErrorLog logs/-error_log
CustomLog logs/-access_log common
&Location /svn&
SVNListParentPath on
SVNParentPath /data/svn/repositories/
AuthzSVNAccessFile /data/svn/repositories/authz.conf
# 在ldap找不到账号的情况下可以使用其它的认证方式(如,密码文件)
AuthzLDAPAuthoritative off
# openLDAP的管理账户
AuthLDAPBindDN "cn=Manager,dc=feinno,dc=com"
AuthLDAPBindPassword 123456
AuthBasicProvider ldap
# 认证数据来源:"ou=rd,dc=cq,dc=feinno,dc=com" 下所有子entity的uid作为认证用户名
AuthLDAPURL "ldap://localhost:389/ou=rd,dc=cq,dc=feinno,dc=com?uid?sub?(objectClass=*)"
# http 基本认证
AuthType Basic
AuthName "feinno Subversion repository"
Require valid-user
# 设置目录权限,实现列表所有工程目录
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
&/Location&
&/VirtualHost&
完成配置后,保存退出。
# 启动验证# service httpd start使用浏览器访问:http://ip/svn/输入你在LDAP中设置的账户名(UID)和passwd
7.安装php和phpldapadmin
安装配置PHP
# yum install libxml2
# yum install libxml2-devel -y
# cd /data/packages
# tar -xzvf php-5.3.22.tar.gz
# cd php-5.3.22
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php5 --with-ldap --with-gettext
# make install
安装完成后的目录在:/usr/local/php5
# 拷贝默认的配置文件
# cp /data/packages/php-5.3.22/php.ini-development /usr/local/lib/php.ini
# 如果在配置的时候出现如下问题一般是因为64位操作系统造成的原因,请如下操作解决。
configure: error: Cannot find ldap libraries in /usr/lib
# cp -frp /usr/lib64/libldap* /usr/lib/
# 停止apache配置支持php
# service httpd stop
# vi /usr/local/apache2/conf/httpd.conf
LoadModule php5_module
modules/libphp5.so
# 在文件中找到&IfModule dir_module&节点,在后面增加目录默认页面:index.php
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
&IfModule dir_module&
DirectoryIndex index.html index.php
&/IfModule&
# 在文件结尾增加对php文件的支持
&FilesMatch \.php$&
SetHandler application/x-httpd-php
&/FilesMatch&
&FilesMatch "\.ph(p[2-6]?|tml)$"&
SetHandler application/x-httpd-php
&/FilesMatch&
&FilesMatch "\.phps$"&
SetHandler application/x-httpd-php-source
&/FilesMatch&
安装phpldapadmin
下载1.2.3版本,直接解压到apache的相关目录。修改config/config.php文件配置LDAP相关参数。
# cd /data/packages/phpldapadmin-1.2.3.zip /usr/local/apache2/htdocs/
# cd /usr/local/apache2/htdocs/
# unzip phpldapadmin-1.2.3.zip
# mv phpldapadmin-1.2.3 phpldapadmin
# cd /usr/local/apache2/htdocs/phpldapadmin/config
# 修改phpldapadmin参数
# cp config.php.example config.php
# vi config.php
# ldap服务器地址
$servers-&setValue('server','host','127.0.0.1');
# ldap服务端口
$servers-&setValue('server','port',389);
# ldap根实体dn
$servers-&setValue('server','base',array('dc=feinno,dc=com'));
# ldap管理用户名
$servers-&setValue('login','bind_id','cn=Manager,dc=feinno,dc=com');
# ldap管理用户密码
$servers-&setValue('login','bind_pass','123456');
保存退出。
从新启动apache,验证phpldapadmin
# service httpd start
访问:http://ip/phpldapdmin
使用ldap的管理账户登录。
浏览: 240735 次
来自: 重庆
楼主还维护这个博文么?请教一下MemCachedClient
我按照的步骤安装好了,测试也是可以的,但是web应用服务 ...
非常好的文章,楼主的钻研精神值得学习。
修改hdfs-core.xml配置文件,关闭权限验证。是修改
能顺利跑起来,谢谢博主分享使用PHP进行Apache+SVN的权限管理 - Tyler Chen - ITeye技术网站
博客分类:
1、解释SVN权限[web/secure/parse_auth_passwd.php]
* read_authz(): read authz file.
* read_passwd(): read passwd file.
* write_authz(): write authz file to a temp file.
* edit_group($group_name="",$group_users=""): edit a group and the users.
* remove_group($group_name=""): remove a group.
* get_groups(): return the groups of authz file.
* get_group_users($group_name = ""): return the group users.
* edit_repository($repo_name=""): edit(add) a repository.
* remove_repository($repo_name=""): remove a repository.
* editAuth_repository($repo_name="", $auth_rw=array()): edit authorization of the repository, $auth can be group or user.
* removeAuth_repository($repo_name="", $auth=""): remove authorization of the repository, $auth can be group or user.
* get_repositories(): return the repositories of the authz file.
* get_repository_group_user($repository_name = ""): get the groups and users of the repository.
* create_repository($repository_name = ''): create a repostory.
* edit_user($user_name="", $password=""): edit or add the user with the password.
* remove_user($user_name=""): remove the user.
* copy_authz(): copy authz file to a temp file.
* copy_passwd(): copy passwd file to a temp file.
* get_users(): get the users of authz file.
* active_authz(): active the authz configuration that you have changed.
* active_passwd(): active the passwd configuration that you have changed.
* restore_authz(): restore last authz file.
* restore_passwd(): restore last passwd file.
* copy_file($source="", $dest=""): private method to copy a file.
if(PATH_SEPARATOR == ':'){
$backup_dir = "/opt/hdb/svnroot/conf/backup";/* Linux */
$authz = "/opt/hdb/svnroot/conf/authz";/* Linux */
$authz_temp = "/opt/hdb/svnroot/conf/.authz";/* Linux */
$passwd = "/opt/hdb/svnroot/conf/passwd";/* Linux */
$passwd_temp = "/opt/hdb/svnroot/conf/.passwd";/* Linux */
$htpasswd = "/usr/bin/htpasswd"; /* Linux */
$svn_repository_dir = '/opt/hdb/svnroot'; /* Linux */
$svn_admin = '/usr/bin/svnadmin';
$backup_dir = "D:\\ProgramFiles\\portable\\xampp\\htdocs\\web\backup";/* Windows */
$authz = "D:\\ProgramFiles\\portable\\xampp\\htdocs\\web\\authz";/* Windows */
$authz_temp = "D:\\ProgramFiles\\portable\\xampp\\htdocs\\web\\authz_temp";/* Windows */
$passwd = "D:\\ProgramFiles\\portable\\xampp\\htdocs\\web\\passwd";/* Windows */
$passwd_temp = "D:\\ProgramFiles\\portable\\xampp\\htdocs\\web\\passwd_temp";/* Windows */
$htpasswd = "D:\\ProgramFiles\\portable\\xampp\\apache\\bin\\htpasswd.exe"; /* Windows */
$svn_repository_dir = 'D:\\ProgramFiles\\portable\\xampp\\htdocs\\svnroot'; /* Windows */
$svn_admin = 'E:\\Server\\svn\\svn-win32-1.6.6\\bin\\svnadmin.exe';
$authzArr = array("[groups]" =& array());
$passwdArr = array();
} catch (Exception $e) {
if($debug){
echo '&H1&Caught exception: ',
$e-&getMessage(), "&\H1&";
/* =========================== read authz file =========================== */
function read_authz() {
global $authzA
global $authz_
$fd = @fopen($authz_temp, "r");
if ($fd == false) {
echo "&H1&fail to open file $authz_temp!&\H1&";
rewind($fd); /* unnessecary but I'm paranoid */
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
if ($debug) {
echo "Buffer = [$buffer]&BR&";
/* all data is comprised of a name, an optional seperator, and a datum */
/* oh wow!.. trim()!!! I could hug somebody! */
$buffer = trim($buffer);
if( strlen ($buffer) & 1 ||
$buffer[0] == "#"){
{/* process [] section*/
if($buffer[0] == "["){
$section = $
if(!array_key_exists($section,$authzArr)){
$authzArr[$section] = array();
if ($debug) {
echo "currSection = [$section]&BR&";
{/* process [groups] section*/
if($section == "[groups]"){
$pieces = explode("=", $buffer);
$count = count($pieces);
if($count == 0){
}else if($count == 1){
$authzArr["[groups]"][trim($pieces[0])]=array();
$authzArr["[groups]"][trim($pieces[0])]=explode(",", trim($pieces[1]));
{// process repository section
$pieces = explode("=", $buffer);
$count = count($pieces);
if($count == 0){
}else if($count == 1){
$authzArr[$section][trim($pieces[0])]=array();
$authzArr[$section][trim($pieces[0])]=trim($pieces[1]);
if($debug){// print
echo "&BR/&========== print authz ============&BR/&";
foreach ($authzArr as $k =& $v) {
echo "&BR/&KEY=$k, value=";
foreach ($v as $kk =& $vv) {
echo "&BR/&KEY=$kk, value=";
print_r($vv);
echo "&BR/&";
echo "&BR/&";
echo "&BR/&========== print authz end ============&BR/&";
fclose($fd);
function read_passwd() {
global $passwd_
global $passwdA
$fd = @fopen($passwd_temp, "r");
if ($fd == false) {
echo "&H1&fail to open file $passwd_temp!&\H1&";
rewind($fd); /* unnessecary but I'm paranoid */
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
if ($debug) {
echo "Buffer = [$buffer]&BR&";
/* all data is comprised of a name, an optional seperator, and a datum */
/* oh wow!.. trim()!!! I could hug somebody! */
$buffer = trim($buffer);
if( strlen ($buffer) & 1 || $buffer[0] == "#"){
{/* process user:password*/
if(strpos($buffer,':') & 0){
$pos = strpos($buffer,':');
$passwdArr[trim(substr($buffer,0,$pos))] = trim(substr($buffer,$pos+1));
if($debug){// print
echo "&BR/&========== print passwd ============&BR/&";
foreach ($passwdArr as $k =& $v) {
echo "&BR/&KEY=$k, value=$v&BR/&";
echo "&BR/&========== print passwd end ============&BR/&";
fclose($fd);
function write_authz(){
global $authzA
global $authz_
echo "=============";
$fd_temp = @fopen($authz_temp, 'w');
rewind($fd_temp);
foreach ($authzArr as $k =& $v) {
fputs($fd_temp,"\n".$k."\n");
foreach ($v as $kk =& $vv) {
if(is_array($vv)){
fputs($fd_temp,$kk." = ".join(',',$vv)."\n");
fputs($fd_temp,$kk." = ".$vv."\n");
fclose($fd_temp);
/* =========================== read authz file end =========================== */
/* =========================== GROUP =========================== */
function edit_group($group_name="",$group_users=""){
global $authzA
$group_name = trim($group_name);
if( strlen($group_name) & 1 ){
return "group name is required: $group_name!";
$group_users = trim($group_users);
$pieces = strlen($group_users)&0 ? explode(",", $group_users) : array();
foreach( $pieces as $k =& $v ){
if(strlen($v)&1){
if( !preg_match("/^[a-zA-Z][a-zA-Z0-9_]*$/", $v) ){
return "group user name is illegal(/^[a-zA-Z][a-zA-Z0-9_]*$/): $v!";
$authzArr["[groups]"][$group_name] = $
write_authz();
function remove_group($group_name=""){
global $authzA
$group_name = trim($group_name);
if( strlen($group_name) & 1 ){
return "group name is required: $group_name!";
if( !array_key_exists($group_name, $authzArr["[groups]"]) ){
unset( $authzArr["[groups]"][$group_name] );
write_authz();
function get_groups(){
global $authzA
$groupArr = array();
foreach ($authzArr["[groups]"] as $k =& $v) {
$groupArr[$k] = $k;
ksort($groupArr);
if( $debug ){
echo "Group: ".join(",",$groupArr)."\n";
return $groupA
function get_group_users($group_name = ""){
global $authzA
$group_name = trim($group_name);
if( strlen($group_name) & 1 ){
return array();
$groupUserArr = array();
foreach ($authzArr["[groups]"] as $k =& $v) {
if( $k != $group_name ){
foreach ($v as $kk =& $vv) {
$vv = trim($vv);
if( strlen($vv) & 0 ){
$groupUserArr[$vv] = $
ksort($groupUserArr);
if( $debug ){
echo "Group [$group_name] users: ".join(",",$groupUserArr)."\n";
return $groupUserA
/* =========================== GROUP END =========================== */
/* =========================== Repository =========================== */
function edit_repository($repo_name=""){
global $authzA
$repo_name = trim($repo_name);
if( strlen($repo_name) & 1 ){
return "repository name is required: $repo_name!";
if( array_key_exists($repo_name, $authzArr) ){
if( !preg_match("/^\\[[a-zA-Z0-9_:\/]*\\]$/", $repo_name) ){
return "repository name is illegal(/^\\[[a-zA-Z0-9_:\/]*\\]$/): $repo_name!";
$authzArr[$repo_name]=array();
write_authz();
function remove_repository($repo_name=""){
global $authzA
$repo_name = trim($repo_name);
if( strlen($repo_name) & 1 ){
return "repository name is required: $repo_name!";
if( !array_key_exists($repo_name, $authzArr) ){
unset( $authzArr[$repo_name] );
write_authz();
function editAuth_repository($repo_name="", $auth_rw=array()){
global $authzA
$repo_name = trim($repo_name);
if( strlen($repo_name) & 1 ){
return "repository name is required: $repo_name!";
if( !array_key_exists($repo_name, $authzArr) ){
return "repository name not found: $repo_name!";
$authzArr[$repo_name] = array();
foreach($auth_rw as $k =& $v){
$auth = trim($k);
$rw = trim($v);
if( strlen($auth) & 1 ){
return "group name or user name is required: $auth!";
$rw = (strpos($rw, "r") & -1 ? "r" : "").(strpos($rw, "w") & -1 ? "w" : "");
if( strlen($rw) & 1 ){
$rw = " ";
if( $auth[0] == "@" && !array_key_exists(substr($auth,1), $authzArr["[groups]"]) ){
return "group name not found: $auth!";
$authzArr[$repo_name][$auth] = $
write_authz();
function removeAuth_repository($repo_name="", $auth=""){
global $authzA
$repo_name = trim($repo_name);
if( strlen($repo_name) & 1 ){
return "repository name is required: $repo_name!";
$auth = trim($auth);
if( strlen($auth) & 1 ){
return "group name or user name is required: $auth!";
if( !array_key_exists($repo_name, $authzArr) ){
return "repository name not found: $repo_name!";
if( !array_key_exists($auth, $authzArr[$repo_name]) ){
unset( $authzArr[$repo_name][$auth] );
write_authz();
function get_repositories(){
global $authzA
$repositoryArr = array();
foreach ($authzArr as $k =& $v) {
if($k == "[groups]"){
$repositoryArr[$k] = $k;
ksort($repositoryArr);
if( $debug ){
echo "Repository: ".join(",",$repositoryArr)."\n";
return $repositoryA
function get_repository_group_user($repository_name = ""){
global $authzA
$repository_name = trim($repository_name);
if( strlen($repository_name) & 1 ){
return array("group" =& array(), "user" =& array(), "*" =& array());
$repositoryGroupUserArr = array("group" =& array(), "user" =& array(), "*" =& array());
foreach ($authzArr as $k =& $v) {
if($k == "[groups]" || $k != $repository_name ){
foreach ($v as $kk =& $vv) {
$kk = trim($kk);
$vv = strtolower(trim($vv));
$vv = strlen($vv) & 1 ? ' ' : $
if( $kk[0] == "@" ){
$repositoryGroupUserArr["group"][$kk] = $
} else if( $kk == "*" ){
$repositoryGroupUserArr["*"][$kk] = $
$repositoryGroupUserArr["user"][$kk] = $
if( $debug ){
echo "Repository $repository_name: ";
print_r($repositoryGroupUserArr);
return $repositoryGroupUserA
function create_repository($repository_name = ''){
global $svn_repository_
global $svn_
$repository_name = trim($repository_name);
if( strlen($repository_name) & 1 ){
return "repository name is required!";
if( !preg_match("/^[a-zA-Z][a-zA-Z0-9_]*$/", $repository_name) ){
return "repository name is illegal (/^[a-zA-Z][a-zA-Z0-9_]*$/): $repository_name!";
$handle = opendir($svn_repository_dir);
$count = 0;
if($handle) {
while(false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if( $file == $repository_name ){
return "repository name is existing: $repository_name!";
$filename = $svn_repository_dir.DIRECTORY_SEPARATOR.$
if( is_dir($filename) ){
$count = $count + 1;
closedir($handle);
if( $count & 19 ){
return "Can't make any more svn repository, repository number is over 20: $repository_name!";
if( !mkdir($svn_repository_dir.DIRECTORY_SEPARATOR.$repository_name) ){
return "Can't make repository dir: $repository_name!";
$out = '';
$retval = 1;
exec($svn_admin.' create '.$svn_repository_dir.DIRECTORY_SEPARATOR.$repository_name, $out, $retval);
if( $retval == 0 ){
return edit_repository("[$repository_name:/]");;
return "exec svn_admin error: $repository_name : $out !";
/* =========================== Repository end =========================== */
/* =========================== User =========================== */
function edit_user($user_name="", $password=""){
global $passwd_
$user_name = trim($user_name);
if( strlen($user_name) & 1 ){
return "user name is required: $user_name!";
if( !preg_match("/^[a-zA-Z][a-zA-Z0-9_]*$/", $user_name) ){
return "user name is illegal(/^[a-zA-Z][a-zA-Z0-9_]*$/): $user_name!";
$password = trim($password);
if( strlen($password) & 6 ){
return "password is required (length & 5): $password!";
if( strpos($password, " ") &-1 ){
return "password can't contain the blank character!";
$out = "";
$retval = 1;
exec($htpasswd." -bm ".$passwd_temp." ".$user_name." ".$password, $out, $retval);
if( $retval == 0 ){
return "exec htpasswd error: $out, $user_name, $password!";
function remove_user($user_name=""){
global $authzA
global $passwd_
$user_name = trim($user_name);
if( strlen($user_name) & 1 ){
return "user name is required: $user_name!";
$out = "";
$retval = 1;
exec($htpasswd." -D ".$passwd_temp." ".$user_name, $out, $retval);
if( $retval == 1 ){
return "exec htpasswd error: $out";
foreach ($authzArr as $k =& $v) {
foreach ($v as $kk =& $vv) {
if($k == '[groups]'){
foreach ($vv as $kkk =& $vvv) {
if( $vvv == $user_name){
unset($authzArr[$k][$kk][$kkk]);
} else if( $kk == $user_name ){
unset($authzArr[$k][$kk]);
write_authz();
function get_users(){
global $authzA
global $passwdA
$userArr = array();
foreach ($authzArr as $k =& $v) {
foreach ($v as $kk =& $vv) {
if($k == "[groups]"){
if( !is_array($vv) ){
foreach ($vv as $kkk =& $vvv) {
$vvv = trim($vvv);
if( strlen($vvv) & 0 ){
$userArr[$vvv] = $
} else if($kk[0] != "@" ){
$kk = trim($kk);
if( strlen($kk) & 0 ){
$userArr[$kk] = $
foreach ($passwdArr as $k =& $v) {
if( !array_key_exists($k, $userArr) ){
$userArr[$k] = $k;
if( array_key_exists("*", $userArr) ){
unset($userArr["*"]);
ksort($userArr);
if( $debug ){
echo "User: ".join(",",$userArr)."\n";
return $userA
/* =========================== User end =========================== */
function copy_authz(){
global $authz_
copy_file($authz,$authz_temp);
function copy_passwd(){
global $passwd_
copy_file($passwd,$passwd_temp);
function active_authz(){
global $authz_
global $backup_
copy_file($authz,$backup_dir.DIRECTORY_SEPARATOR.'authz'.time());
copy_file($authz_temp, $authz);
function active_passwd(){
global $passwd_
global $backup_
copy_file($passwd,$backup_dir.DIRECTORY_SEPARATOR.'passwd'.time());
copy_file($passwd_temp, $passwd);
function restore_authz(){
global $backup_
$last_file = '';
$handle = opendir($backup_dir);
if($handle) {
while(false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && strpos($file,'authz')&-1) {
$filename = $backup_dir.DIRECTORY_SEPARATOR.$
if(is_file($filename)&&(strlen($last_file)==0 || filectime($last_file)&filectime($filename))) {
$last_file = $
closedir($handle);
if(strlen($last_file)&0){
copy_file($last_file,$authz);
function restore_passwd(){
global $backup_
$last_file = '';
$handle = opendir($backup_dir);
if($handle) {
while(false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && strpos($file,'passwd')&-1) {
$filename = $backup_dir.DIRECTORY_SEPARATOR.$
if(is_file($filename)&&(strlen($last_file)==0 || filectime($last_file)&filectime($filename))) {
$last_file = $
closedir($handle);
if(strlen($last_file)&0){
copy_file($last_file,$passwd);
function copy_file($source="", $dest=""){
$source = trim($source);
if( strlen($source) & 1 ){
$dest = trim($dest);
if( strlen($dest) & 1 ){
$fd_temp =
$fd = @fopen($source, "r");
rewind($fd);
$fd_temp = @fopen($dest, 'w');
rewind($fd_temp);
while (!feof($fd)) {
$buffer = fgets($fd, 4096);
if ($debug) {
echo "Buffer = [$buffer]&BR&";
fputs($fd_temp, $buffer);
} catch(Exception $e) {
echo 'Caught exception: ',
$e-&getMessage(), "\n";
try{fclose($fd_temp);}catch(Exception $ee){}
try{fclose($fd);}catch(Exception $ee){}
try{fclose($fd_temp);}catch(Exception $ee){}
try{fclose($fd);}catch(Exception $ee){}
2、生成管理页面[web/secure/edit_auth_passwd.php]
session_start();
require('parse_auth_passwd.php');
header("Expires: Mon, 26 Jul :00 GMT");
// Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");// always modified
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Pragma: no-cache");
// HTTP/1.0
$view_group = "";
$view_repository = "";
$remove_group = "";
$remove_repository = "";
$remove_user = "";
$add_group = "";
$add_repository = "";
$create_repository = "";
$add_user = "";
$edit_group_user = "";
$edit_repository_group_user = "";
$active_authz_passwd = "";
$active_start = "";
$rollback_authz = "";
$rollback_passwd = "";
$hide_add = "";
if(!isset($_SESSION["last_view"])){
$_SESSION["last_view"] = "";
if(!isset($_SESSION["hide_add"])){
$_SESSION["hide_add"] = "0";
if( isset($_SESSION["COPY_FILE"]) ){
$_SESSION["COPY_FILE"] = time();
read_authz();
read_passwd();
if(isset($_GET['view_group'])){
$view_group = trim($_GET['view_group']);
$_SESSION["last_view"]='view_group='.rawurlencode($view_group);
if(isset($_GET['view_repository'])){
$view_repository = trim($_GET['view_repository']);
$_SESSION["last_view"]='view_repository='.rawurlencode($view_repository);
if(isset($_GET['remove_group'])){
$remove_group = trim($_GET['remove_group']);
remove_group($remove_group);
redirect();
}else if(isset($_GET['remove_repository'])){
$remove_repository = trim($_GET['remove_repository']);
remove_repository($remove_repository);
redirect();
}else if(isset($_GET['remove_user'])){
$remove_user = trim($_GET['remove_user']);
remove_user($remove_user);
redirect();
}else if(isset($_GET['active_authz_passwd'])){
$active_authz_passwd = trim($_GET['active_authz_passwd']);
active_authz();
active_passwd();
copy_authz();
copy_passwd();
redirect();
}else if(isset($_GET['rollback_authz'])){
$rollback_authz = trim($_GET['rollback_authz']);
restore_authz();
copy_authz();
copy_passwd();
redirect();
}else if(isset($_GET['rollback_passwd'])){
$rollback_passwd = trim($_GET['rollback_passwd']);
restore_passwd();
copy_authz();
copy_passwd();
redirect();
}else if(isset($_GET['active_start'])){
$active_start = trim($_GET['active_start']);
$_SESSION["COPY_FILE"] = time();
copy_authz();
copy_passwd();
redirect();
}else if(isset($_POST['add_group'])){
$add_group = trim($_POST['add_group']);
$group_name = trim($_POST['group_name']);
error(edit_group($group_name));
redirect();
}else if(isset($_POST['add_repository'])){
$add_repository = trim($_POST['add_repository']);
$repository_name = trim($_POST['repository_name']);
error(edit_repository($repository_name));
redirect();
}else if(isset($_POST['create_repository'])){
$create_repository = trim($_POST['create_repository']);
$repository_name = trim($_POST['repository_name']);
error(create_repository($repository_name));
redirect();
}else if(isset($_POST['add_user'])){
$add_user = trim($_POST['add_user']);
$user_name = trim($_POST['user_name']);
$user_password = trim($_POST['user_password']);
$user_password_confirm = trim($_POST['user_password_confirm']);
if($user_password != $user_password_confirm){
error("User password has different input: $user_password and $user_password_confirm!");
error(edit_user($user_name,$user_password));
redirect();
}else if(isset($_POST['edit_group_user'])){
$edit_group_user = trim($_POST['edit_group_user']);
$group_name = $view_group = trim($_POST['group_name']);
$users = get_users();
$group_users = array();
foreach($users as $k){
if(isset($_POST[$k])){
$group_users[]=$k;
error(edit_group($group_name,join(',',$group_users)));
redirect();
}else if(isset($_POST['edit_repository_group_user'])){
$edit_repository_group_user = trim($_POST['edit_repository_group_user']);
$repository_name = $view_repository = trim($_POST['repository_name']);
$repository_groups_users = array();
$groups = get_groups();
foreach($groups as $k){
if(isset($_POST['@'.$k.'=r'])){
$rw=$rw.'r';
if(isset($_POST['@'.$k.'=w'])){
$rw=$rw.'w';
if(isset($_POST['@'.$k.'=n'])){
if(strlen($rw)&0){
$repository_groups_users['@'.$k]=$
$users = get_users();
foreach($users as $k){
if(isset($_POST[$k.'=r'])){
$rw=$rw.'r';
if(isset($_POST[$k.'=w'])){
$rw=$rw.'w';
if(isset($_POST[$k.'=n'])){
if(strlen($rw)&0){
$repository_groups_users[$k]=$
if(isset($_POST['*=r'])){
$rw=$rw.'r';
if(isset($_POST['*=w'])){
$rw=$rw.'w';
if(strlen($rw)&1 && isset($_POST['*=n'])){
if(strlen($rw)&0){
$repository_groups_users['*']=$
error(editAuth_repository($repository_name,$repository_groups_users));
redirect();
}else if(isset($_GET['hide_add'])){
$_SESSION["hide_add"] = $hide_add = trim($_GET['hide_add']);
redirect();
function redirect(){
global $view_
global $view_
if(isset($_SESSION["last_view"])&&strlen($_SESSION["last_view"])&0){
header('Location: '.request_uri().'?'.$_SESSION["last_view"]);
header('Location: '.request_uri());
function request_uri(){
if (isset($_SERVER['PHP_SELF'])){
$uri = $_SERVER['PHP_SELF'];
function error($error_msg = ""){
if(strlen($error_msg)&0){
if(!array_key_exists("error_msg",$_SESSION)){
$_SESSION["error_msg"]=array();
$_SESSION["error_msg"][]=$error_
$msg=isset($_SESSION["error_msg"])?join(',',$_SESSION["error_msg"]):"";
$_SESSION["error_msg"]=array();
&!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 3//EN"&
&TITLE&SVN Authorization Management&/TITLE&
&STYLE TYPE="text/css"&
font-family: helvetica, sans-
color: #FFFFFF;
A.logolink
color: #FFFFFF;
font-size: .8
color: #FFFFFF;
color: #999999;
font-size: .8
font-weight:
color: #660000;
font-size: .8
TD.checkbox
DIV.scroll{
height: 150
overflow-y:
overflow-x:
padding-right: 18px\9;
padding: 0
width: 960
DIV.floatl{
DIV.floatr{
DIV.with48p{
width: 48%;
DIV.clear{
height: 18px\9;
&BODY BGCOLOR="#660000"&
&?php if(!isset($_SESSION["COPY_FILE"])){ ?&
&DIV CLASS="body"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD ALIGN=center CLASS="logo"& &B&SVN AUTHORIZATION CONFIGURATION TOOL&/B& &/TD&&/TR&
&TR BGCOLOR="#CC0000"& &TD ALIGN=center CLASS="logo"& &A CLASS="logo" HREF="edit_auth_passwd.php?active_start=1"&Start Configure&/A& &/TD&&/TR&
&DIV CLASS="body"&&!-- BODY DIV START --&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD ALIGN=center CLASS="logo"& &B&SVN AUTHORIZATION CONFIGURATION TOOL&/B& &/TD&&/TR&
&!-- =================================== ERROR MESSAGES =================================== --&
&?php $msg=error(); if(strlen($msg)&0){ ?&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD ALIGN=left CLASS="logo"& &B&ERROR MESSAGE: &/B&&?php echo $ ?& &/TD&&/TR&
&?php } ?&
&!-- =================================== ERROR MESSAGES END =================================== --&
&!-- =================================== SVN AUTHORIZATION CONFIGURATION PANEL =================================== --&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"&
&TD CLASS="logo"& &B&SVN AUTHORIZATION&/B& CONFIGURATION PANEL &/TD&
&TD CLASS="logo"&&/TD&
&TD CLASS="logo" ALIGN=right&
&A CLASS="logo" HREF="edit_auth_passwd.php?active_authz_passwd=1" onclick="return confirm('Write the changes to auth and passwd file?');"&Active Profile&/A& |
&A CLASS="logo" HREF="edit_auth_passwd.php?active_start=1" onclick="return confirm('Give up the current changes?');"&Reset Configuration&/A& |
&A CLASS="logo" HREF="edit_auth_passwd.php?rollback_authz=1" onclick="return confirm('Rollback the last auth file?');"&Rollback Authz&/A& |
&A CLASS="logo" HREF="edit_auth_passwd.php?rollback_passwd=1" onclick="return confirm('Rollback the last passwd file?');"&Rollback Passwd&/A&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"&
&TD CLASS="logo"& &B&SVN ADD&/B& INFOMATION PANEL &/TD&
&TD ALIGN=right CLASS="logo"&
&?php if(isset($_SESSION["hide_add"])&&$_SESSION["hide_add"]=="0"){ ?&
&A CLASS="logo" HREF="edit_auth_passwd.php?hide_add=1"&Hide Add Panel&/A&
&?php } else{ ?&
&A CLASS="logo" HREF="edit_auth_passwd.php?hide_add=0"&Show Add Panel&/A&
&?php } ?&
&?php if(isset($_SESSION["hide_add"])&&$_SESSION["hide_add"]!="1"){ ?&
&!-- === SUMIT GROUP === --&
&DIV CLASS="floatl with48p"&
&FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION="edit_auth_passwd.php"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" colspan="2"& &B&ADD GROUP&/B& &/TD&&/TR&
&TD ALIGN=left CLASS="logo"& Group Name: &/TD&
&TD ALIGN=right CLASS="logo"& &INPUT TYPE="text" SIZE="32" MAXLENGTH="64" NAME="group_name"& &/TD&
&TR BGCOLOR="#CC0000"& &TD ALIGN=right CLASS="logo" colspan="2"& &INPUT TYPE="submit" NAME="add_group" value="ADD GROUP"& &/TD&&/TR&
&!-- === SUMIT GROUP END === --&
&!-- === SUMIT REPOSITORY NAME === --&
CLASS="floatr with48p"&
&FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION="edit_auth_passwd.php"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" colspan="2"& &B&ADD REPOSITORY&/B& &/TD&&/TR&
&TD ALIGN=left CLASS="logo"& Repository Name: &/TD&
&TD ALIGN=right CLASS="logo"& &INPUT TYPE="text" SIZE="32" MAXLENGTH="128" NAME="repository_name"& &/TD&
&TR BGCOLOR="#CC0000"& &TD ALIGN=right CLASS="logo" colspan="2"& &INPUT TYPE="submit" NAME="create_repository" value="CREATE REPOSITORY" onclick="return confirm('Do you want to create repository?');"/&
&INPUT TYPE="submit" NAME="add_repository" value="ADD REPOSITORY"/& &/TD&&/TR&
&!-- === SUMIT REPOSITORY NAME END === --&
&DIV CLASS="clear"&&/DIV&
&!-- === SUMIT USER NAME === --&
&FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION="edit_auth_passwd.php"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" colspan="6"& &B&ADD USER&/B& &/TD&&/TR&
&TD ALIGN=left CLASS="logo"& User Name: &/TD&
&TD ALIGN=right CLASS="logo"& &INPUT TYPE="text" SIZE="24" MAXLENGTH="64" NAME="user_name"& &/TD&
&TD ALIGN=left CLASS="logo"& User Password: &/TD&
&TD ALIGN=right CLASS="logo"& &INPUT TYPE="password" SIZE="24" MAXLENGTH="64" NAME="user_password"& &/TD&
&TD ALIGN=left CLASS="logo"& Password Confirm: &/TD&
&TD ALIGN=right CLASS="logo"& &INPUT TYPE="password" SIZE="24" MAXLENGTH="64" NAME="user_password_confirm"& &/TD&
&TR BGCOLOR="#CC0000"& &TD ALIGN=right CLASS="logo" colspan="6"& &INPUT TYPE="submit" NAME="add_user" value="ADD USER"& &/TD&&/TR&
&!-- === SUMIT USER NAME END === --&
&DIV CLASS="clear"&&/DIV&
&?php } ?&
&!-- =================================== SVN AUTHORIZATION CONFIGURATION PANEL END =================================== --&
&!-- =================================== SVN AUTHORIZATION INFOMATION PANEL =================================== --&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo"& &B&SVN AUTHORIZATION&/B& INFOMATION PANEL &/TD&&/TR&
&DIV CLASS="floatl" STYLE="width: 29%;"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" COLSPAN="3"& &B&GROUP LIST&/B& &/TD&&/TR&
&DIV CLASS="scroll" STYLE="background-color:#666666;"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
$groups = get_groups(); foreach($groups as $k){ $t = htmlentities($k); ?&
&TR BGCOLOR="#666666"&
&TD ALIGN=right CLASS="logo"& &?php echo $t; ?& &/TD&
&TD ALIGN=right CLASS="logo op"& &A HREF="edit_auth_passwd.php?remove_group=&?php echo rawurlencode($k); ?&" CLASS="tabon" onclick="return confirm('Remove Group &?php echo $t; ?&?');"&DELETE&/a& &/TD&
&TD ALIGN=right CLASS="logo"& &A HREF="edit_auth_passwd.php?view_group=&?php echo rawurlencode($k); ?&" CLASS="tabon"&VIEW&/a& &/TD&
&?php } ?&
&DIV CLASS="floatl" style="width: 44%; left: 10 right: 10"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" COLSPAN="3"& &B&REPOSITORY LIST&/B& &/TD&&/TR&
&DIV CLASS="scroll" STYLE="background-color:#666666;"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
$repositories = get_repositories(); foreach($repositories as $k){ $t = htmlentities($k); ?&
&TR BGCOLOR="#666666"&
&TD ALIGN=right CLASS="logo"& &?php echo $t; ?& &/TD&
&TD ALIGN=right CLASS="logo op"& &A HREF="edit_auth_passwd.php?remove_repository=&?php echo rawurlencode($k); ?&" CLASS="tabon" onclick="return confirm('Remove Repository &?php echo $t; ?&?');"&DELETE&/a& &/TD&
&TD ALIGN=right CLASS="logo"& &A HREF="edit_auth_passwd.php?view_repository=&?php echo rawurlencode($k); ?&" CLASS="tabon"&VIEW&/a& &/TD&
&?php } ?&
&DIV CLASS="floatl" STYLE="width: 25%; left: 20"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" COLSPAN="2"& &B&USER LIST&/B& &/TD&&/TR&
&DIV CLASS="scroll" STYLE="background-color:#666666;"&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
$users = get_users(); foreach($users as $k){ $t = htmlentities($k); ?&
&TR BGCOLOR="#666666"&
&TD ALIGN=right CLASS="logo"& &?php echo $t; ?& &/TD&
&TD ALIGN=right CLASS="logo op"& &A HREF="edit_auth_passwd.php?remove_user=&?php echo rawurlencode($k); ?&" CLASS="tabon" onclick="return confirm('Remove User &?php echo $t; ?&?');"&DELETE&/a& &/TD&
&?php } ?&
&DIV CLASS="clear"&&/DIV&
&!-- =================================== SVN AUTHORIZATION INFOMATION PANEL END =================================== --&
&!-- =================================== SVN GROUP [] CONFIGURATION PANEL =================================== --&
&?php if(strlen($view_group)&0){ ?&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo"& &B&SVN GROUP &?php echo $view_ ?&&/B& CONFIGURATION PANEL (R:read W:write N:none)&/TD&&/TR&
&FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION="edit_auth_passwd.php"&
&INPUT TYPE=hidden NAME="group_name" VALUE="&?php echo htmlentities($view_group);?&"/&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" COLSPAN="&?php echo $column=6;?&"& &B&GROUP USER LIST&/B& &/TD&&/TR&
&TR BGCOLOR="#666666"&
&?php for($i=0;$i&$$i++){ /*start for*/?&
&TD CLASS="logo" VALIGN="top" &?php if($i+1!=$column){?&STYLE="border-right:white 1"&?php } ?&&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&?php $count=0; $users = get_users(); $groupUsers = get_group_users($view_group); foreach($users as $k){if($count++%$column!=$i){} $t = htmlentities($k); $ake=array_key_exists($k,$groupUsers);/*start foreach1*/ ?&
&TR BGCOLOR="&?php echo $ake?'#AA1122':'#666666';?&"&
&TD ALIGN=left CLASS="logo checkbox"& &INPUT TYPE="checkbox" NAME="&?php echo $t; ?&" value="1" &?php if($ake){ ?&checked="checked" &?php } ?& /& &/TD&
&TD ALIGN=right CLASS="logo"& &?php echo $t; ?& &/TD&
&?php }/*end foreach1*/ ?&
&?php } /*end for*/?&
&TR BGCOLOR="#CC0000"& &TD ALIGN=right CLASS="logo" COLSPAN="&?php echo $?&"& &INPUT TYPE="SUBMIT" NAME="edit_group_user" value="Edit Group User"/& &/TD&&/TR&
&?php } ?&
&!-- =================================== SVN GROUP [] CONFIGURATION PANEL END =================================== --&
&!-- =================================== SVN REPOSITORY [] CONFIGURATION PANEL =================================== --&
&?php if(strlen($view_repository)&0){ $groups = get_groups(); $users = get_users(); $repoGroupUsers = get_repository_group_user($view_repository); ?&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo"& &B&SVN REPOSITORY &?php echo $view_ ?&&/B& CONFIGURATION PANEL (R:read W:write N:none)&/TD&&/TR&
&FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION="edit_auth_passwd.php"&
&INPUT TYPE=hidden NAME="repository_name" VALUE="&?php echo htmlentities($view_repository);?&"/&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" COLSPAN="&?php echo $column=3;?&"& &B&REPOSITORY GROUP LIST&/B& &/TD&&/TR&
&TR BGCOLOR="#666666"&
&?php for($i=0;$i&$$i++){ /*start for*/?&
&TD CLASS="logo" VALIGN="top" &?php if($i+1!=$column){?&STYLE="border-right:white 1"&?php } ?&&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&?php $count=0; foreach($groups as $k){if($count++%$column!=$i){} $t = htmlentities($k); $ake=array_key_exists("@".$k,$repoGroupUsers["group"]);/*start foreach1*/ ?&
&TR BGCOLOR="&?php echo $ake?'#AA1122':'#666666';?&"&
&TD ALIGN=left CLASS="logo"&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities('@'.$t.'=r'); ?&" value="r" &?php if($ake && strpos($repoGroupUsers["group"]["@".$k],"r")&-1){ ?&checked="checked"&?php } ?&/&R&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities('@'.$t.'=w'); ?&" value="w" &?php if($ake && strpos($repoGroupUsers["group"]["@".$k],"w")&-1){ ?&checked="checked"&?php } ?&/&W&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities('@'.$t.'=n'); ?&" value="n" &?php if($ake && $repoGroupUsers["group"]["@".$k]==' '){ ?&checked="checked"&?php } ?&/&N&
&TD ALIGN=right CLASS="logo"& &?php echo '@'.$t; ?& &/TD&
&?php }/*end foreach1*/ ?&
&?php } /*end for*/?&
&TR BGCOLOR="#CC0000"& &TD ALIGN=right CLASS="logo" COLSPAN="&?php echo $?&"& &INPUT TYPE="SUBMIT" NAME="edit_repository_group_user" value="Edit Repostitory Group & User"/& &/TD&&/TR&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&TR BGCOLOR="#CC0000"& &TD CLASS="logo" COLSPAN="&?php echo $column=3;?&"& &B&REPOSITORY USER LIST&/B& &/TD&&/TR&
&TR BGCOLOR="#666666"&
&?php for($i=0;$i&$$i++){ /*start for*/?&
&TD CLASS="logo" VALIGN="top" &?php if($i+1!=$column){?&STYLE="border-right:white 1"&?php } ?&&
&TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"&
&?php $count=0; foreach($users as $k){if($count++%$column!=$i){} $t = htmlentities($k); $ake=array_key_exists($k,$repoGroupUsers["user"]);/*start foreach1*/ ?&
&?php if($count==$i+1){$ake1=0;if($count==1){$ake1=array_key_exists('*',$repoGroupUsers['*']);}/*start if3*/ ?&
&TR BGCOLOR="&?php echo $ake1?'#AA1122':'#666666';?&"&
&TD ALIGN=left CLASS="logo"&
&?php if($count==1){ ?&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities('*=r'); ?&" value="r" &?php if($ake1 && strpos($repoGroupUsers['*']['*'],"r")&-1){ ?&checked="checked"&?php } ?&/&R&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities('*=w'); ?&" value="w" &?php if($ake1 && strpos($repoGroupUsers['*']['*'],"w")&-1){ ?&checked="checked"&?php } ?&/&W&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities('*=n'); ?&" value="n" &?php if($ake1 && $repoGroupUsers['*']['*']==' '){ ?&checked="checked"&?php } ?&/&N&
&?php } ?&
&TD ALIGN=right CLASS="logo"& &?php echo $count==1?'*':'&'; ?& &/TD&
&?php }/*end if3*/ ?&
&TR BGCOLOR="&?php echo $ake?'#AA1122':'#666666';?&"&
&TD ALIGN=left CLASS="logo"&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities($t.'=r'); ?&" value="r" &?php if($ake && strpos($repoGroupUsers["user"][$k],"r")&-1){ ?&checked="checked"&?php } ?&/&R&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities($t.'=w'); ?&" value="w" &?php if($ake && strpos($repoGroupUsers["user"][$k],"w")&-1){ ?&checked="checked"&?php } ?&/&W&
&INPUT TYPE="checkbox" NAME="&?php echo htmlentities($t.'=n'); ?&" value="n" &?php if($ake && $repoGroupUsers["user"][$k]==' '){ ?&checked="checked"&?php } ?&/&N&
&TD ALIGN=right CLASS="logo"& &?php echo $t; ?& &/TD&
&?php }/*end foreach1*/ ?&
&?php } /*end for*/?&
&TR BGCOLOR="#CC0000"& &TD ALIGN=right CLASS="logo" COLSPAN="&?php echo $?&"& &INPUT TYPE="SUBMIT" NAME="edit_repository_group_user" value="Edit Repostitory Group & User"/& &/TD&&/TR&
&DIV CLASS="clear"&&/DIV&
&?php } ?&
&!-- =================================== SVN REPOSITORY [] CONFIGURATION PANEL END =================================== --&
&/DIV&&!-- BODY DIV END --&
3、生成secure的Index页面[web/secure/index.php]
header('Location: edit_auth_passwd.php');
4、生成Index页面[web/index.php]
header('Location: secure/edit_auth_passwd.php');
5、Apache的httpd/conf.d/svn_tools.conf的配置
Alias /svntools/ "/opt/hdb/svnroot/httpd/web/"
&Directory /opt/hdb/svnroot/httpd/web/&
AllowOverride all
Options Indexes Includes FollowSymLinks
Order deny,allow
Allow from all
&/Directory&
&Directory /opt/hdb/svnroot/httpd/web/secure/&
AllowOverride all
Order deny,allow
Allow from all
AuthUserFile /opt/hdb/svnroot/conf/passwd
#AuthGroupFile /dev/null
AuthName "access to the svn tools web GUI"
AuthType Basic
&Limit GET&
require user chenzhao
&/Directory&
6、注意权限问题
chown -R apache.apache svnroot/conf
chown -R apache.apache svnroot/httpd/web
下载次数: 29
(515.7 KB)
下载次数: 16
浏览: 83168 次
来自: 广州
没什么大的用处,没有说到实质性的东西~
royzs 写道cd /usr/src/redhat/SPEC ...
cd /usr/src/redhat/SPECS
xsgkaka 写道楼上 我也遇到这个问题,我将宋体ttc改为 ...

我要回帖

更多关于 apache svn 的文章

 

随机推荐