Browse Source

1、修复更新绑定主机和端口信息的bug2、完善在线更换svnserve端口和主机名的逻辑

docker-svn
witersen 3 years ago
parent
commit
ed88c081c6
  1. 277
      01.web/src/views/advance/index.vue
  2. 4
      02.php/api.php
  3. 30
      02.php/app/controller/common.class.php
  4. 6
      02.php/app/controller/logs.class.php
  5. 24
      02.php/app/controller/personal.class.php
  6. 91
      02.php/app/controller/subversion.class.php
  7. 46
      02.php/app/controller/svngroup.class.php
  8. 172
      02.php/app/controller/svnrep.class.php
  9. 40
      02.php/app/controller/svnuser.class.php
  10. 4
      02.php/app/controller/update.class.php
  11. 6
      02.php/app/core/controller.class.php
  12. 12
      02.php/extension/SVNAdmin/src/class/SVNInfo.class.php
  13. 37
      02.php/server/svnadmind.php
  14. 8
      02.php/templete/json/listen.json
  15. 3
      02.php/templete/svnserve/svnserve

277
01.web/src/views/advance/index.vue

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
<Col span="12">
<span>{{ formSvn.version }}</span>
</Col>
<Col span="1"> </Col>
<Col span="6">
<Button
type="error"
@ -43,6 +44,7 @@ @@ -43,6 +44,7 @@
>未知</span
>
</Col>
<Col span="1"> </Col>
<Col span="6">
<Button
:loading="loadingSvnserveStart"
@ -64,25 +66,45 @@ @@ -64,25 +66,45 @@
<FormItem label="svnserve绑定端口">
<Row>
<Col span="12">
<span>{{ formSvn.bindPort }}</span>
<InputNumber
:min="1"
v-model="tempBindPort"
@on-change="ChangeEditPort"
></InputNumber>
</Col>
<Col span="1"> </Col>
<Col span="6">
<Button type="warning" @click="ModalEditPort">修改</Button>
<Button
type="warning"
@click="EditPort"
:disabled="disabledEditPort"
:loading="loadingEditPort"
>修改</Button
>
</Col>
</Row>
</FormItem>
<FormItem label="svnserve绑定主机名">
<Row>
<Col span="12">
<span>{{ formSvn.bindHost }}</span>
<Input
v-model="tempBindHost"
@on-change="ChangeEditHost"
placeholder="默认地址:0.0.0.0"
/>
</Col>
<Col span="1"> </Col>
<Col span="6">
<Tooltip
:transfer="true"
max-width="350"
content="请注意,如果您的机器为公网服务器且非弹性IP,则可能会绑定失败。原因与云服务器厂商分配公网IP给服务器的方式有关。如果绑定失败,建议配置使用管理系统主机名代替检出地址。"
>
<Button type="warning" @click="ModalEditHost"
<Button
type="warning"
@click="EditHost"
:disabled="disabledEditHost"
:loading="loadingEditHost"
>修改</Button
>
</Tooltip>
@ -92,10 +114,19 @@ @@ -92,10 +114,19 @@
<FormItem label="管理系统主机名">
<Row>
<Col span="12">
<span>{{ formSvn.manageHost }}</span>
<Input
v-model="tempManageHost"
@on-change="ChangeEditManageHost"
placeholder="默认地址:127.0.0.1"
/>
</Col>
<Col span="1"> </Col>
<Col span="6">
<Button type="warning" @click="ModalEditManageHost"
<Button
type="warning"
@click="EditManageHost"
:disabled="disabledEditManageHost"
:loading="loadingEditManageHost"
>修改</Button
>
</Col>
@ -108,25 +139,13 @@ @@ -108,25 +139,13 @@
v-model="formSvn.enable"
@on-change="EditEnable"
>
<Radio :label="formSvn.bindHost"></Radio>
<Radio :label="formSvn.manageHost"></Radio>
<Radio label="bindHost">svnserve绑定主机名</Radio>
<Radio label="manageHost">管理系统主机名</Radio>
</RadioGroup>
</Col>
<Col span="6"> </Col>
</Row>
</FormItem>
<FormItem label="svnserve运行日志">
<Row>
<Col span="12">
<span>{{ formSvn.svnserveLog }}</span>
</Col>
<Col span="6">
<Button type="success" @click="ViewSvnserveLog"
>查看</Button
>
</Col>
</Row>
</FormItem>
</Form>
</Card>
</TabPane>
@ -330,6 +349,23 @@ @@ -330,6 +349,23 @@
export default {
data() {
return {
/**
* 临变量
*/
//svnserve
tempBindPort: 0,
//svnserve
tempBindHost: "",
//
tempManageHost: "",
/**
* 控制修改状态
*/
disabledEditPort: true,
disabledEditHost: true,
disabledEditManageHost: true,
/**
* tab
*/
@ -338,8 +374,16 @@ export default { @@ -338,8 +374,16 @@ export default {
/**
* 加载
*/
//svnserve
loadingSvnserveStart: false,
//svnserve
loadingSvnserveStop: false,
//
loadingEditHost: false,
//
loadingEditPort: false,
//
loadingEditManageHost: false,
/**
* subversion信息
@ -399,7 +443,7 @@ export default { @@ -399,7 +443,7 @@ export default {
this.currentAdvanceTab = name;
},
/**
* 获取版本信息
* 获取subversion的详细信息
*/
GetDetail() {
var that = this;
@ -410,6 +454,14 @@ export default { @@ -410,6 +454,14 @@ export default {
var result = response.data;
if (result.status == 1) {
that.formSvn = result.data;
//
that.tempBindPort = result.data.bindPort;
that.tempBindHost = result.data.bindHost;
that.tempManageHost = result.data.manageHost;
//
that.disabledEditPort = true;
that.disabledEditHost = true;
that.disabledEditManageHost = true;
} else {
that.$Message.error(result.message);
}
@ -419,6 +471,36 @@ export default { @@ -419,6 +471,36 @@ export default {
that.$Message.error("出错了 请联系管理员!");
});
},
/**
* 修改端口的值 触发重新计算按钮的禁用状态
*/
ChangeEditPort(value) {
if (this.tempBindPort == this.formSvn.bindPort) {
this.disabledEditPort = true;
} else {
this.disabledEditPort = false;
}
},
/**
* 修改地址的值 触发重新计算按钮的禁用状态
*/
ChangeEditHost(event) {
if (this.tempBindHost == this.formSvn.bindHost) {
this.disabledEditHost = true;
} else {
this.disabledEditHost = false;
}
},
/**
* 修改管理系统主机名的值 触发重新计算按钮的禁用状态
*/
ChangeEditManageHost(event) {
if (this.tempManageHost == this.formSvn.manageHost) {
this.disabledEditManageHost = true;
} else {
this.disabledEditManageHost = false;
}
},
/**
* 获取配置文件信息
*/
@ -513,51 +595,132 @@ export default { @@ -513,51 +595,132 @@ export default {
/**
* 修改svnserve的绑定端口
*/
ModalEditPort() {},
EditPort() {},
EditPort() {
var that = this;
that.$Modal.confirm({
title: "更换svnserve服务绑定端口",
content:
"确定要更换svnserve服务绑定端口吗?此操作会使svnserve服务停止并重新启动!",
onOk: () => {
that.loadingEditPort = true;
var data = {
bindPort: that.tempBindPort,
};
that.$axios
.post("/api.php?c=subversion&a=EditPort&t=web", data)
.then(function (response) {
that.loadingEditPort = false;
var result = response.data;
if (result.status == 1) {
that.$Message.success(result.message);
that.GetDetail();
} else {
that.GetDetail();
that.$Message.error(result.message);
}
})
.catch(function (error) {
that.loadingEditPort = false;
console.log(error);
that.$Message.error("出错了 请联系管理员!");
});
},
});
},
/**
* 修改svnserve的绑定主机
*/
ModalEditHost() {},
EditHost() {},
/**
* 修改管理系统主机名
*/
ModalEditManageHost() {},
EditManageHost() {},
/**
* 修改检出地址
*/
EditEnable(value) {},
/**
* 查看svnserve运行日志
*/
ViewSvnserveLog() {},
/**
* 添加仓库
*/
ModalAddRep() {
this.modalAddRep = true;
EditHost() {
var that = this;
that.$Modal.confirm({
title: "更换svnserve服务绑定主机",
content:
"确定要更换svnserve服务绑定主机吗?此操作会使svnserve服务停止并重新启动!",
onOk: () => {
that.loadingEditHost = true;
var data = {
bindHost: that.tempBindHost,
};
that.$axios
.post("/api.php?c=subversion&a=EditHost&t=web", data)
.then(function (response) {
that.loadingEditHost = false;
var result = response.data;
if (result.status == 1) {
that.$Message.success(result.message);
that.GetDetail();
} else {
that.GetDetail();
that.$Message.error(result.message);
}
})
.catch(function (error) {
that.loadingEditHost = false;
console.log(error);
that.$Message.error("出错了 请联系管理员!");
});
},
});
},
AddRep() {},
/**
* 编辑仓库名称
* 修改管理系统主机名
*/
ModalEditRepName(index, repName) {
this.modalEditRepName = true;
EditManageHost() {
var that = this;
that.$Modal.confirm({
title: "更换管理系统主机名",
content:
"确定要更换管理系统主机名吗?此操作不会影响svnserve服务的状态!",
onOk: () => {
that.loadingEditManageHost = true;
var data = {
manageHost: that.tempManageHost,
};
that.$axios
.post("/api.php?c=subversion&a=EditManageHost&t=web", data)
.then(function (response) {
that.loadingEditManageHost = false;
var result = response.data;
if (result.status == 1) {
that.$Message.success(result.message);
that.GetDetail();
} else {
that.GetDetail();
that.$Message.error(result.message);
}
})
.catch(function (error) {
that.loadingEditManageHost = false;
console.log(error);
that.$Message.error("出错了 请联系管理员!");
});
},
});
},
EditRepName() {},
/**
* 删除仓库
*
* 修改检出地址
*/
DelRep(index, repName) {
this.$Modal.confirm({
title: "删除SVN用户-xxxxx用户",
content: "确定要删除该用户吗?<br/>该操作不可逆!",
onOk: () => {},
});
EditEnable(value) {
var that = this;
var data = {
enable: value,
};
that.$axios
.post("/api.php?c=subversion&a=EditEnable&t=web", data)
.then(function (response) {
var result = response.data;
if (result.status == 1) {
that.$Message.success(result.message);
that.GetDetail();
} else {
that.GetDetail();
that.$Message.error(result.message);
}
})
.catch(function (error) {
console.log(error);
that.$Message.error("出错了 请联系管理员!");
});
},
},
};

4
02.php/api.php

@ -46,8 +46,8 @@ $type = isset($_GET['t']) ? $_GET['t'] : ''; @@ -46,8 +46,8 @@ $type = isset($_GET['t']) ? $_GET['t'] : '';
* 请求参数即Request Payload
* Content-Type: application/json
*/
$requestPayload = file_get_contents("php://input");
$requestPayload = !empty($requestPayload) ? json_decode($requestPayload, true) : [];
$payload = file_get_contents("php://input");
$payload = !empty($payload) ? json_decode($payload, true) : [];
/**
* 获取文件信息

30
02.php/app/controller/common.class.php

@ -40,8 +40,8 @@ class common extends controller @@ -40,8 +40,8 @@ class common extends controller
$codeResult = $this->database->get('verification_code', [
'end_time'
], [
'uuid' => $this->requestPayload['uuid'],
'code' => $this->requestPayload['code'],
'uuid' => $this->payload['uuid'],
'code' => $this->payload['code'],
]);
if ($codeResult == null) {
FunMessageExit(200, 0, '验证码错误', $codeResult);
@ -50,26 +50,26 @@ class common extends controller @@ -50,26 +50,26 @@ class common extends controller
FunMessageExit(200, 0, '验证码过期');
}
FunCheckForm($this->requestPayload, [
FunCheckForm($this->payload, [
'user_name' => ['type' => 'string', 'notNull' => true],
'user_pass' => ['type' => 'string', 'notNull' => true],
'user_role' => ['type' => 'string', 'notNull' => true],
]);
if ($this->requestPayload['user_role'] == 1) {
if ($this->payload['user_role'] == 1) {
$result = $this->database->get('admin_users', [
'admin_user_id',
'admin_user_name',
'admin_user_phone',
'admin_user_email'
], [
'admin_user_name' => $this->requestPayload['user_name'],
'admin_user_password' => $this->requestPayload['user_pass']
'admin_user_name' => $this->payload['user_name'],
'admin_user_password' => $this->payload['user_pass']
]);
if ($result == null) {
FunMessageExit(200, 0, '账号密码错误');
}
} else if ($this->requestPayload['user_role'] == 2) {
} else if ($this->payload['user_role'] == 2) {
//进行用户数据同步
$this->Svnuser->SyncUserToDb();
@ -79,8 +79,8 @@ class common extends controller @@ -79,8 +79,8 @@ class common extends controller
'svn_user_pass',
'svn_user_status'
], [
'svn_user_name' => $this->requestPayload['user_name'],
'svn_user_pass' => $this->requestPayload['user_pass']
'svn_user_name' => $this->payload['user_name'],
'svn_user_pass' => $this->payload['user_pass']
]);
if ($result == null) {
FunMessageExit(200, 0, '登陆失败');
@ -93,16 +93,16 @@ class common extends controller @@ -93,16 +93,16 @@ class common extends controller
$this->Logs->InsertLog(
'用户登录',
'登陆成功 '
. '账号:' . $this->requestPayload['user_name'] . ' '
. '账号:' . $this->payload['user_name'] . ' '
. 'IP地址:' . $_SERVER["REMOTE_ADDR"],
$this->requestPayload['user_name']
$this->payload['user_name']
);
FunMessageExit(200, 1, '登陆成功', [
'token' => FunCreateToken($this->requestPayload['user_role'], $this->requestPayload['user_name']),
'user_name' => $this->requestPayload['user_name'],
'user_role_name' => $this->requestPayload['user_role'] == 1 ? '管理人员' : 'SVN用户',
'user_role_id' => $this->requestPayload['user_role']
'token' => FunCreateToken($this->payload['user_role'], $this->payload['user_name']),
'user_name' => $this->payload['user_name'],
'user_role_name' => $this->payload['user_role'] == 1 ? '管理人员' : 'SVN用户',
'user_role_id' => $this->payload['user_role']
]);
}

6
02.php/app/controller/logs.class.php

@ -26,9 +26,9 @@ class logs extends controller @@ -26,9 +26,9 @@ class logs extends controller
*/
function GetLogList()
{
$pageSize = $this->requestPayload['pageSize'];
$currentPage = $this->requestPayload['currentPage'];
$searchKeyword = trim($this->requestPayload['searchKeyword']);
$pageSize = $this->payload['pageSize'];
$currentPage = $this->payload['currentPage'];
$searchKeyword = trim($this->payload['searchKeyword']);
//分页
$begin = $pageSize * ($currentPage - 1);

24
02.php/app/controller/personal.class.php

@ -26,25 +26,25 @@ class personal extends controller @@ -26,25 +26,25 @@ class personal extends controller
*/
function EditAdminUserName()
{
if ($this->requestPayload['userName'] != $this->requestPayload['confirm']) {
if ($this->payload['userName'] != $this->payload['confirm']) {
FunMessageExit(200, 0, '输入不一致');
}
if (trim($this->requestPayload['userName']) == '') {
if (trim($this->payload['userName']) == '') {
FunMessageExit(200, 0, '用户名不合法');
}
$info = $this->database->get('admin_users', [
'admin_user_name'
], [
'admin_user_name' => $this->requestPayload['userName']
'admin_user_name' => $this->payload['userName']
]);
if ($info != null) {
FunMessageExit(200, 0, '与已有用户冲突');
}
$this->database->update('admin_users', [
'admin_user_name' => $this->requestPayload['userName']
'admin_user_name' => $this->payload['userName']
], [
'admin_user_name' => $this->globalUserName
]);
@ -57,16 +57,16 @@ class personal extends controller @@ -57,16 +57,16 @@ class personal extends controller
*/
function EditAdminUserPass()
{
if ($this->requestPayload['password'] != $this->requestPayload['confirm']) {
if ($this->payload['password'] != $this->payload['confirm']) {
FunMessageExit(200, 0, '输入不一致');
}
if (trim($this->requestPayload['password']) == '') {
if (trim($this->payload['password']) == '') {
FunMessageExit(200, 0, '密码不合法');
}
$this->database->update('admin_users', [
'admin_user_pass' => $this->requestPayload['password']
'admin_user_pass' => $this->payload['password']
], [
'admin_user_name' => $this->globalUserName
]);
@ -79,7 +79,7 @@ class personal extends controller @@ -79,7 +79,7 @@ class personal extends controller
*/
function EditSvnUserPass()
{
if ($this->requestPayload['newPassword'] != $this->requestPayload['confirm']) {
if ($this->payload['newPassword'] != $this->payload['confirm']) {
FunMessageExit(200, 0, '输入不一致');
}
@ -92,16 +92,16 @@ class personal extends controller @@ -92,16 +92,16 @@ class personal extends controller
FunMessageExit(200, 0, '用户不存在');
}
if (trim($this->requestPayload['newPassword']) == '') {
if (trim($this->payload['newPassword']) == '') {
FunMessageExit(200, 0, '密码不合法');
}
if ($result != $this->requestPayload['oldPassword']) {
if ($result != $this->payload['oldPassword']) {
FunMessageExit(200, 0, '旧密码输入错误');
}
//修改SVN指定用户的密码
$result = $this->SVNAdminUser->UpdSvnUserPass($this->globalPasswdContent, $this->globalUserName, $this->requestPayload['newPassword']);
$result = $this->SVNAdminUser->UpdSvnUserPass($this->globalPasswdContent, $this->globalUserName, $this->payload['newPassword']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
}
@ -112,7 +112,7 @@ class personal extends controller @@ -112,7 +112,7 @@ class personal extends controller
FunShellExec('echo \'' . $result . '\' > ' . SVN_PASSWD_FILE);
$this->database->update('svn_users', [
'svn_user_pass' => $this->requestPayload['newPassword']
'svn_user_pass' => $this->payload['newPassword']
], [
'svn_user_name' => $this->globalUserName
]);

91
02.php/app/controller/subversion.class.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-04-24 23:37:05
* @LastEditors: witersen
* @LastEditTime: 2022-05-01 02:25:57
* @LastEditTime: 2022-05-02 00:55:54
* @Description: QQ:1801168257
*/
@ -46,7 +46,7 @@ class subversion extends controller @@ -46,7 +46,7 @@ class subversion extends controller
{
$result = $this->SVNAdminInfo->GetSubversionListen(SVNSERVE_ENV_FILE, LISTEN_FILE);
$checkoutHost = $result[$result['enable']];
if ($result['bindPort'] != '3690') {
if ($result['bindPort'] != 3690) {
$checkoutHost .= ':' . $result['bindPort'];
}
FunMessageExit(200, 1, '成功', [
@ -100,10 +100,10 @@ class subversion extends controller @@ -100,10 +100,10 @@ class subversion extends controller
FunMessageExit(200, 1, '成功', [
'version' => $version,
'installed' => $installed,
'bindPort' => $bindInfo['bindPort'],
'bindPort' => (int)$bindInfo['bindPort'],
'bindHost' => $bindInfo['bindHost'],
'manageHost' => $bindInfo['manageHost'],
'enable' => $bindInfo[$bindInfo['enable']],
'enable' => $bindInfo['enable'],
'svnserveLog' => SVNSERVE_LOG_FILE
]);
}
@ -145,13 +145,32 @@ class subversion extends controller @@ -145,13 +145,32 @@ class subversion extends controller
*/
function EditPort()
{
//获取现在的端口于与要修改的端口对比检查是否相同
//port不能为空
//获取现在的端口与要修改的端口对比检查是否相同
$result = $this->SVNAdminInfo->GetSubversionListen(SVNSERVE_ENV_FILE, LISTEN_FILE);
if ($this->payload['bindPort'] == $result['bindPort']) {
FunMessageExit(200, 0, '无需更换,端口相同');
}
//停止svnserve
FunShellExec("systemctl stop svnserve");
FunShellExec('systemctl stop svnserve');
//重新构建配置文件内容
$config = sprintf("OPTIONS=\"-r '%s' --config-file '%s' --log-file '%s' --listen-port %s --listen-host %s\"", SVN_REPOSITORY_PATH, SVN_CONF_FILE, SVNSERVE_LOG_FILE, $this->payload['bindPort'], $result['bindHost']);
//更换端口
//写入配置文件
FunShellExec('echo \'' . $config . '\' > ' . SVNSERVE_ENV_FILE);
//启动svnserve
$result = FunShellExec('systemctl start svnserve');
if ($result['resultCode'] != 0) {
FunMessageExit(200, 0, '启动异常' . $result['error']);
} else {
FunMessageExit();
}
}
/**
@ -159,6 +178,33 @@ class subversion extends controller @@ -159,6 +178,33 @@ class subversion extends controller
*/
function EditHost()
{
//host不能为空
//不能带前缀如http或者https
//获取现在的绑定主机与要修改的主机对比检查是否相同
$result = $this->SVNAdminInfo->GetSubversionListen(SVNSERVE_ENV_FILE, LISTEN_FILE);
if ($this->payload['bindHost'] == $result['bindHost']) {
FunMessageExit(200, 0, '无需更换,地址相同');
}
//停止svnserve
FunShellExec('systemctl stop svnserve');
//重新构建配置文件内容
$config = sprintf("OPTIONS=\"-r '%s' --config-file '%s' --log-file '%s' --listen-port %s --listen-host %s\"", SVN_REPOSITORY_PATH, SVN_CONF_FILE, SVNSERVE_LOG_FILE, $result['bindPort'], $this->payload['bindHost']);
//写入配置文件
FunShellExec('echo \'' . $config . '\' > ' . SVNSERVE_ENV_FILE);
//启动svnserve
$result = FunShellExec('systemctl start svnserve');
if ($result['resultCode'] != 0) {
FunMessageExit(200, 0, '启动异常' . $result['error']);
} else {
FunMessageExit();
}
}
/**
@ -166,6 +212,24 @@ class subversion extends controller @@ -166,6 +212,24 @@ class subversion extends controller
*/
function EditManageHost()
{
//不能为空
//不能带前缀如http或者https
$result = $this->SVNAdminInfo->GetSubversionListen(SVNSERVE_ENV_FILE, LISTEN_FILE);
if ($this->payload['manageHost'] == $result['manageHost']) {
FunMessageExit(200, 0, '无需更换,地址相同');
}
//更新内容
FunShellExec('echo \'' . json_encode([
'bindPort' => $result['bindPort'],
'bindHost' => $result['bindHost'],
'manageHost' => $this->payload['manageHost'],
'enable' => $result['enable']
]) . '\' > ' . LISTEN_FILE);
FunMessageExit();
}
/**
@ -173,6 +237,19 @@ class subversion extends controller @@ -173,6 +237,19 @@ class subversion extends controller
*/
function EditEnable()
{
$result = $this->SVNAdminInfo->GetSubversionListen(SVNSERVE_ENV_FILE, LISTEN_FILE);
//enable的值可为 manageHost、bindHost
//更新内容
FunShellExec('echo \'' . json_encode([
'bindPort' => $result['bindPort'],
'bindHost' => $result['bindHost'],
'manageHost' => $result['manageHost'],
'enable' => $this->payload['enable']
]) . '\' > ' . LISTEN_FILE);
FunMessageExit();
}
/**

46
02.php/app/controller/svngroup.class.php

@ -103,9 +103,9 @@ class svngroup extends controller @@ -103,9 +103,9 @@ class svngroup extends controller
//同步
$this->SyncGroupToDb();
$pageSize = $this->requestPayload['pageSize'];
$currentPage = $this->requestPayload['currentPage'];
$searchKeyword = trim($this->requestPayload['searchKeyword']);
$pageSize = $this->payload['pageSize'];
$currentPage = $this->payload['currentPage'];
$searchKeyword = trim($this->payload['searchKeyword']);
//分页
$begin = $pageSize * ($currentPage - 1);
@ -125,7 +125,7 @@ class svngroup extends controller @@ -125,7 +125,7 @@ class svngroup extends controller
],
'LIMIT' => [$begin, $pageSize],
'ORDER' => [
$this->requestPayload['sortName'] => strtoupper($this->requestPayload['sortType'])
$this->payload['sortName'] => strtoupper($this->payload['sortType'])
]
]);
@ -152,9 +152,9 @@ class svngroup extends controller @@ -152,9 +152,9 @@ class svngroup extends controller
function EditGroupNote()
{
$this->database->update('svn_groups', [
'svn_group_note' => $this->requestPayload['svn_group_note']
'svn_group_note' => $this->payload['svn_group_note']
], [
'svn_group_name' => $this->requestPayload['svn_group_name']
'svn_group_name' => $this->payload['svn_group_name']
]);
FunMessageExit();
@ -166,10 +166,10 @@ class svngroup extends controller @@ -166,10 +166,10 @@ class svngroup extends controller
function CreateGroup()
{
//检查分组名是否合法
FunCheckRepGroup($this->requestPayload['svn_group_name']);
FunCheckRepGroup($this->payload['svn_group_name']);
//检查用户是否已存在
$result = $this->SVNAdminGroup->AddSvnGroup($this->globalAuthzContent, $this->requestPayload['svn_group_name']);
$result = $this->SVNAdminGroup->AddSvnGroup($this->globalAuthzContent, $this->payload['svn_group_name']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
}
@ -182,7 +182,7 @@ class svngroup extends controller @@ -182,7 +182,7 @@ class svngroup extends controller
//写入数据库
$this->database->insert('svn_groups', [
'svn_group_name' => $this->requestPayload['svn_group_name'],
'svn_group_name' => $this->payload['svn_group_name'],
'include_user_count' => 0,
'include_group_count' => 0,
'svn_group_note' => ''
@ -197,7 +197,7 @@ class svngroup extends controller @@ -197,7 +197,7 @@ class svngroup extends controller
function DelGroup()
{
//从authz文件删除
$result = $this->SVNAdminGroup->DelSvnGroup($this->globalAuthzContent, $this->requestPayload['svn_group_name']);
$result = $this->SVNAdminGroup->DelSvnGroup($this->globalAuthzContent, $this->payload['svn_group_name']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
@ -210,7 +210,7 @@ class svngroup extends controller @@ -210,7 +210,7 @@ class svngroup extends controller
//从数据库删除
$this->database->delete('svn_groups', [
'svn_group_name' => $this->requestPayload['svn_group_name']
'svn_group_name' => $this->payload['svn_group_name']
]);
FunMessageExit();
@ -222,21 +222,21 @@ class svngroup extends controller @@ -222,21 +222,21 @@ class svngroup extends controller
function EditGroupName()
{
//新分组名称是否合法
FunCheckRepGroup($this->requestPayload['groupNameNew']);
FunCheckRepGroup($this->payload['groupNameNew']);
$svnGroupList = $this->SVNAdminGroup->GetSvnGroupList($this->globalAuthzContent);
//旧分组是否存在
if (!in_array($this->requestPayload['groupNameOld'], $svnGroupList)) {
if (!in_array($this->payload['groupNameOld'], $svnGroupList)) {
FunMessageExit(200, 0, '当前分组不存在');
}
//新分组名称是否冲突
if (in_array($this->requestPayload['groupNameNew'], $svnGroupList)) {
if (in_array($this->payload['groupNameNew'], $svnGroupList)) {
FunMessageExit(200, 0, '要修改的分组名称已经存在');
}
$result = $this->SVNAdminGroup->UpdSvnGroup($this->globalAuthzContent, $this->requestPayload['groupNameOld'], $this->requestPayload['groupNameNew']);
$result = $this->SVNAdminGroup->UpdSvnGroup($this->globalAuthzContent, $this->payload['groupNameOld'], $this->payload['groupNameNew']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
}
@ -251,9 +251,9 @@ class svngroup extends controller @@ -251,9 +251,9 @@ class svngroup extends controller
*/
function GetGroupMember()
{
$memberUserList = $this->SVNAdminGroup->GetSvnUserListByGroup($this->globalAuthzContent, $this->requestPayload['svn_group_name']);
$memberUserList = $this->SVNAdminGroup->GetSvnUserListByGroup($this->globalAuthzContent, $this->payload['svn_group_name']);
$memberGroupList = $this->SVNAdminGroup->GetSvnGroupListByGroup($this->globalAuthzContent, $this->requestPayload['svn_group_name']);
$memberGroupList = $this->SVNAdminGroup->GetSvnGroupListByGroup($this->globalAuthzContent, $this->payload['svn_group_name']);
$allGroupList = $this->SVNAdminGroup->GetSvnGroupList($this->globalAuthzContent);
@ -315,7 +315,7 @@ class svngroup extends controller @@ -315,7 +315,7 @@ class svngroup extends controller
*/
function GroupAddUser()
{
$result = $this->SVNAdminGroup->AddSvnGroupUser($this->globalAuthzContent, $this->requestPayload['svn_group_name'], $this->requestPayload['svn_user_name']);
$result = $this->SVNAdminGroup->AddSvnGroupUser($this->globalAuthzContent, $this->payload['svn_group_name'], $this->payload['svn_user_name']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
}
@ -336,7 +336,7 @@ class svngroup extends controller @@ -336,7 +336,7 @@ class svngroup extends controller
*/
function GroupRemoveUser()
{
$result = $this->SVNAdminGroup->DelSvnGroupUser($this->globalAuthzContent, $this->requestPayload['svn_group_name'], $this->requestPayload['svn_user_name']);
$result = $this->SVNAdminGroup->DelSvnGroupUser($this->globalAuthzContent, $this->payload['svn_group_name'], $this->payload['svn_user_name']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
}
@ -357,7 +357,7 @@ class svngroup extends controller @@ -357,7 +357,7 @@ class svngroup extends controller
*/
function GroupAddGroup()
{
$result = $this->SVNAdminGroup->AddSvnGroupGroup($this->globalAuthzContent, $this->requestPayload['svn_group_name'], $this->requestPayload['svn_group_name_add']);
$result = $this->SVNAdminGroup->AddSvnGroupGroup($this->globalAuthzContent, $this->payload['svn_group_name'], $this->payload['svn_group_name_add']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
}
@ -373,9 +373,9 @@ class svngroup extends controller @@ -373,9 +373,9 @@ class svngroup extends controller
//检查是否存在分组循环嵌套问题
//获取分组所在的所有分组
$groupGroupList = $this->GetSvnGroupAllGroupList($this->requestPayload['svn_group_name']);
$groupGroupList = $this->GetSvnGroupAllGroupList($this->payload['svn_group_name']);
if (in_array($this->requestPayload['svn_group_name_add'], $groupGroupList)) {
if (in_array($this->payload['svn_group_name_add'], $groupGroupList)) {
FunMessageExit(200, 0, '存在分组循环嵌套的情况');
}
@ -389,7 +389,7 @@ class svngroup extends controller @@ -389,7 +389,7 @@ class svngroup extends controller
*/
function GroupRemoveGroup()
{
$result = $this->SVNAdminGroup->DelSvnGroupGroup($this->globalAuthzContent, $this->requestPayload['svn_group_name'], $this->requestPayload['svn_group_name_del']);
$result = $this->SVNAdminGroup->DelSvnGroupGroup($this->globalAuthzContent, $this->payload['svn_group_name'], $this->payload['svn_group_name_del']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[groups]标识)');
}

172
02.php/app/controller/svnrep.class.php

@ -32,41 +32,41 @@ class svnrep extends controller @@ -32,41 +32,41 @@ class svnrep extends controller
function CreateRep()
{
//检查表单
FunCheckForm($this->requestPayload, [
FunCheckForm($this->payload, [
'rep_name' => ['type' => 'string', 'notNull' => true],
'rep_note' => ['type' => 'string', 'notNull' => false],
'rep_type' => ['type' => 'string', 'notNull' => true],
]);
//检查仓库名是否合法
FunCheckRepName($this->requestPayload['rep_name']);
FunCheckRepName($this->payload['rep_name']);
//检查仓库是否存在
$this->SVNAdminRep->CheckRepExist($this->requestPayload['rep_name']);
$this->SVNAdminRep->CheckRepExist($this->payload['rep_name']);
//创建空仓库
//解决创建中文仓库乱码问题
FunShellExec('export LC_CTYPE=en_US.UTF-8 && svnadmin create ' . SVN_REPOSITORY_PATH . $this->requestPayload['rep_name']);
FunShellExec('export LC_CTYPE=en_US.UTF-8 && svnadmin create ' . SVN_REPOSITORY_PATH . $this->payload['rep_name']);
if ($this->requestPayload['rep_type'] == '2') {
if ($this->payload['rep_type'] == '2') {
//以指定的目录结构初始化仓库
$this->SVNAdminRep->InitRepStruct(TEMPLETE_INIT_STRUTCT, SVN_REPOSITORY_PATH . $this->requestPayload['rep_name']);
$this->SVNAdminRep->InitRepStruct(TEMPLETE_INIT_STRUTCT, SVN_REPOSITORY_PATH . $this->payload['rep_name']);
}
//检查是否创建成功
$this->SVNAdminRep->CheckRepCreate($this->requestPayload['rep_name']);
$this->SVNAdminRep->CheckRepCreate($this->payload['rep_name']);
//向authz写入仓库信息
$status = $this->SVNAdminRep->SetRepAuthz($this->globalAuthzContent, $this->requestPayload['rep_name'], '/');
$status = $this->SVNAdminRep->SetRepAuthz($this->globalAuthzContent, $this->payload['rep_name'], '/');
if ($status != '1') {
FunShellExec('echo \'' . $status . '\' > ' . SVN_AUTHZ_FILE);
}
//写入数据库
$this->database->insert('svn_reps', [
'rep_name' => $this->requestPayload['rep_name'],
'rep_name' => $this->payload['rep_name'],
'rep_size' => 0,
'rep_note' => $this->requestPayload['rep_note'],
'rep_note' => $this->payload['rep_note'],
'rep_rev' => 0,
'rep_uuid' => 0
]);
@ -293,9 +293,9 @@ class svnrep extends controller @@ -293,9 +293,9 @@ class svnrep extends controller
*/
$this->SyncRepAndDb();
$pageSize = $this->requestPayload['pageSize'];
$currentPage = $this->requestPayload['currentPage'];
$searchKeyword = trim($this->requestPayload['searchKeyword']);
$pageSize = $this->payload['pageSize'];
$currentPage = $this->payload['currentPage'];
$searchKeyword = trim($this->payload['searchKeyword']);
//分页
$begin = $pageSize * ($currentPage - 1);
@ -316,7 +316,7 @@ class svnrep extends controller @@ -316,7 +316,7 @@ class svnrep extends controller
],
'LIMIT' => [$begin, $pageSize],
'ORDER' => [
$this->requestPayload['sortName'] => strtoupper($this->requestPayload['sortType'])
$this->payload['sortName'] => strtoupper($this->payload['sortType'])
]
]);
@ -379,9 +379,9 @@ class svnrep extends controller @@ -379,9 +379,9 @@ class svnrep extends controller
*/
$this->SyncUserRepAndDb();
$pageSize = $this->requestPayload['pageSize'];
$currentPage = $this->requestPayload['currentPage'];
$searchKeyword = trim($this->requestPayload['searchKeyword']);
$pageSize = $this->payload['pageSize'];
$currentPage = $this->payload['currentPage'];
$searchKeyword = trim($this->payload['searchKeyword']);
//分页
$begin = $pageSize * ($currentPage - 1);
@ -399,7 +399,7 @@ class svnrep extends controller @@ -399,7 +399,7 @@ class svnrep extends controller
],
'LIMIT' => [$begin, $pageSize],
'ORDER' => [
'rep_name' => strtoupper($this->requestPayload['sortType'])
'rep_name' => strtoupper($this->payload['sortType'])
],
'svn_user_name' => $this->globalUserName
]);
@ -427,9 +427,9 @@ class svnrep extends controller @@ -427,9 +427,9 @@ class svnrep extends controller
function EditRepNote()
{
$this->database->update('svn_reps', [
'rep_note' => $this->requestPayload['rep_note']
'rep_note' => $this->payload['rep_note']
], [
'rep_name' => $this->requestPayload['rep_name']
'rep_name' => $this->payload['rep_name']
]);
FunMessageExit(200, 1, '已保存');
@ -440,9 +440,9 @@ class svnrep extends controller @@ -440,9 +440,9 @@ class svnrep extends controller
*/
function GetUserRepCon()
{
$path = $this->requestPayload['path'];
$path = $this->payload['path'];
$repName = $this->requestPayload['rep_name'];
$repName = $this->payload['rep_name'];
/**
* 获取svn检出地址
@ -637,10 +637,10 @@ class svnrep extends controller @@ -637,10 +637,10 @@ class svnrep extends controller
* 管理员为 /
* SVN用户为管理员设定的路径值
*/
$path = $this->requestPayload['path'];
$path = $this->payload['path'];
//获取全路径的一层目录树
$cmdSvnlookTree = sprintf("svnlook tree '%s' --full-paths --non-recursive '%s'", SVN_REPOSITORY_PATH . $this->requestPayload['rep_name'], $path);
$cmdSvnlookTree = sprintf("svnlook tree '%s' --full-paths --non-recursive '%s'", SVN_REPOSITORY_PATH . $this->payload['rep_name'], $path);
$result = FunShellExec($cmdSvnlookTree);
$result = $result['result'];
$resultArray = explode("\n", trim($result));
@ -650,16 +650,16 @@ class svnrep extends controller @@ -650,16 +650,16 @@ class svnrep extends controller
$data = [];
foreach ($resultArray as $key => $value) {
//获取文件或者文件夹最年轻的版本号
$lastRev = $this->SVNAdminRep->GetRepFileRev($this->requestPayload['rep_name'], $value);
$lastRev = $this->SVNAdminRep->GetRepFileRev($this->payload['rep_name'], $value);
//获取文件或者文件夹最年轻的版本的作者
$lastRevAuthor = $this->SVNAdminRep->GetRepFileAuthor($this->requestPayload['rep_name'], $lastRev);
$lastRevAuthor = $this->SVNAdminRep->GetRepFileAuthor($this->payload['rep_name'], $lastRev);
//同上 日期
$lastRevDate = $this->SVNAdminRep->GetRepFileDate($this->requestPayload['rep_name'], $lastRev);
$lastRevDate = $this->SVNAdminRep->GetRepFileDate($this->payload['rep_name'], $lastRev);
//同上 日志
$lastRevLog = $this->SVNAdminRep->GetRepFileLog($this->requestPayload['rep_name'], $lastRev);
$lastRevLog = $this->SVNAdminRep->GetRepFileLog($this->payload['rep_name'], $lastRev);
$pathArray = explode('/', $value);
$pathArray = array_values(array_filter($pathArray, 'FunArrayValueFilter'));
@ -679,7 +679,7 @@ class svnrep extends controller @@ -679,7 +679,7 @@ class svnrep extends controller
array_push($data, [
'resourceType' => 1,
'resourceName' => $pathArray[$pathArrayCount - 1],
'fileSize' => $this->SVNAdminRep->GetRepRevFileSize($this->requestPayload['rep_name'], $value),
'fileSize' => $this->SVNAdminRep->GetRepRevFileSize($this->payload['rep_name'], $value),
'revAuthor' => $lastRevAuthor,
'revNum' => 'r' . $lastRev,
'revTime' => $lastRevDate,
@ -695,7 +695,7 @@ class svnrep extends controller @@ -695,7 +695,7 @@ class svnrep extends controller
//处理面包屑
if ($path == '/') {
$breadPathArray = ['/'];
$breadNameArray = [$this->requestPayload['rep_name']];
$breadNameArray = [$this->payload['rep_name']];
} else {
$pathArray = explode('/', $path);
//将全路径处理为带有/的数组
@ -709,7 +709,7 @@ class svnrep extends controller @@ -709,7 +709,7 @@ class svnrep extends controller
}
//处理为递增的路径数组
$breadPathArray = ['/'];
$breadNameArray = [$this->requestPayload['rep_name']];
$breadNameArray = [$this->payload['rep_name']];
$tempPath = '/';
for ($i = 1; $i < count($tempArray); $i += 2) {
$tempPath .= $tempArray[$i] . $tempArray[$i + 1];
@ -734,10 +734,10 @@ class svnrep extends controller @@ -734,10 +734,10 @@ class svnrep extends controller
*/
function GetRepTree()
{
$path = $this->requestPayload['path'];
$path = $this->payload['path'];
//获取全路径的一层目录树
$cmdSvnlookTree = sprintf("svnlook tree '%s' --full-paths --non-recursive '%s'", SVN_REPOSITORY_PATH . $this->requestPayload['rep_name'], $path);
$cmdSvnlookTree = sprintf("svnlook tree '%s' --full-paths --non-recursive '%s'", SVN_REPOSITORY_PATH . $this->payload['rep_name'], $path);
$result = FunShellExec($cmdSvnlookTree);
$result = $result['result'];
$resultArray = explode("\n", trim($result));
@ -776,7 +776,7 @@ class svnrep extends controller @@ -776,7 +776,7 @@ class svnrep extends controller
'expand' => true,
'loading' => false,
'resourceType' => 2,
'title' => $this->requestPayload['rep_name'] . '/',
'title' => $this->payload['rep_name'] . '/',
'fullPath' => '/',
'children' => $data
]
@ -791,10 +791,10 @@ class svnrep extends controller @@ -791,10 +791,10 @@ class svnrep extends controller
*/
function GetRepPathUserPri()
{
$result = $this->SVNAdminRep->GetRepUserListWithPri($this->globalAuthzContent, $this->requestPayload['rep_name'], $this->requestPayload['path']);
$result = $this->SVNAdminRep->GetRepUserListWithPri($this->globalAuthzContent, $this->payload['rep_name'], $this->payload['path']);
if ($result == '0') {
//没有该路径的记录
if ($this->requestPayload['path'] == '/') {
if ($this->payload['path'] == '/') {
//不正常 没有写入仓库记录
FunMessageExit(200, 0, '该仓库没有被写入配置文件!请刷新仓库列表以同步');
} else {
@ -817,10 +817,10 @@ class svnrep extends controller @@ -817,10 +817,10 @@ class svnrep extends controller
*/
function GetRepPathGroupPri()
{
$result = $this->SVNAdminRep->GetRepGroupListWithPri($this->globalAuthzContent, $this->requestPayload['rep_name'], $this->requestPayload['path']);
$result = $this->SVNAdminRep->GetRepGroupListWithPri($this->globalAuthzContent, $this->payload['rep_name'], $this->payload['path']);
if ($result == '0') {
//没有该路径的记录
if ($this->requestPayload['path'] == '/') {
if ($this->payload['path'] == '/') {
//不正常 没有写入仓库记录
FunMessageExit(200, 0, '该仓库没有被写入配置文件!请刷新仓库列表以同步');
} else {
@ -843,10 +843,10 @@ class svnrep extends controller @@ -843,10 +843,10 @@ class svnrep extends controller
*/
function AddRepPathUserPri()
{
$repName = $this->requestPayload['rep_name'];
$path = $this->requestPayload['path'];
$pri = $this->requestPayload['pri'];
$user = $this->requestPayload['user'];
$repName = $this->payload['rep_name'];
$path = $this->payload['path'];
$pri = $this->payload['pri'];
$user = $this->payload['user'];
/**
* 这里要进行重复添加用户的判断操作
@ -896,9 +896,9 @@ class svnrep extends controller @@ -896,9 +896,9 @@ class svnrep extends controller
*/
function DelRepPathUserPri()
{
$repName = $this->requestPayload['rep_name'];
$path = $this->requestPayload['path'];
$user = $this->requestPayload['user'];
$repName = $this->payload['rep_name'];
$path = $this->payload['path'];
$user = $this->payload['user'];
$result = $this->SVNAdminRep->DelRepUserPri($this->globalAuthzContent, $user, $repName, $path);
@ -920,10 +920,10 @@ class svnrep extends controller @@ -920,10 +920,10 @@ class svnrep extends controller
*/
function EditRepPathUserPri()
{
$repName = $this->requestPayload['rep_name'];
$path = $this->requestPayload['path'];
$pri = $this->requestPayload['pri'];
$user = $this->requestPayload['user'];
$repName = $this->payload['rep_name'];
$path = $this->payload['path'];
$pri = $this->payload['pri'];
$user = $this->payload['user'];
/**
* 处理权限
@ -948,10 +948,10 @@ class svnrep extends controller @@ -948,10 +948,10 @@ class svnrep extends controller
*/
function AddRepPathGroupPri()
{
$repName = $this->requestPayload['rep_name'];
$path = $this->requestPayload['path'];
$pri = $this->requestPayload['pri'];
$group = $this->requestPayload['group'];
$repName = $this->payload['rep_name'];
$path = $this->payload['path'];
$pri = $this->payload['pri'];
$group = $this->payload['group'];
/**
* 这里要进行重复添加分组的判断操作
@ -1001,9 +1001,9 @@ class svnrep extends controller @@ -1001,9 +1001,9 @@ class svnrep extends controller
*/
function DelRepPathGroupPri()
{
$repName = $this->requestPayload['rep_name'];
$path = $this->requestPayload['path'];
$group = $this->requestPayload['group'];
$repName = $this->payload['rep_name'];
$path = $this->payload['path'];
$group = $this->payload['group'];
$result = $this->SVNAdminRep->DelRepGroupPri($this->globalAuthzContent, $group, $repName, $path);
@ -1025,10 +1025,10 @@ class svnrep extends controller @@ -1025,10 +1025,10 @@ class svnrep extends controller
*/
function EditRepPathGroupPri()
{
$repName = $this->requestPayload['rep_name'];
$path = $this->requestPayload['path'];
$pri = $this->requestPayload['pri'];
$group = $this->requestPayload['group'];
$repName = $this->payload['rep_name'];
$path = $this->payload['path'];
$pri = $this->payload['pri'];
$group = $this->payload['group'];
/**
* 处理权限
@ -1056,29 +1056,29 @@ class svnrep extends controller @@ -1056,29 +1056,29 @@ class svnrep extends controller
function EditRepName()
{
//检查新仓库名是否合法
FunCheckRepName($this->requestPayload['new_rep_name']);
FunCheckRepName($this->payload['new_rep_name']);
//检查原仓库是否不存在
$this->SVNAdminRep->CheckRepCreate($this->requestPayload['old_rep_name'], '要修改的仓库不存在');
$this->SVNAdminRep->CheckRepCreate($this->payload['old_rep_name'], '要修改的仓库不存在');
//检查新仓库名是否存在
$this->SVNAdminRep->CheckRepExist($this->requestPayload['new_rep_name'], '已经存在同名仓库');
$this->SVNAdminRep->CheckRepExist($this->payload['new_rep_name'], '已经存在同名仓库');
//从仓库目录修改仓库名称
FunShellExec('mv ' . SVN_REPOSITORY_PATH . $this->requestPayload['old_rep_name'] . ' ' . SVN_REPOSITORY_PATH . $this->requestPayload['new_rep_name']);
FunShellExec('mv ' . SVN_REPOSITORY_PATH . $this->payload['old_rep_name'] . ' ' . SVN_REPOSITORY_PATH . $this->payload['new_rep_name']);
//检查修改过的仓库名称是否存在
$this->SVNAdminRep->CheckRepCreate($this->requestPayload['new_rep_name'], '修改仓库名称失败');
$this->SVNAdminRep->CheckRepCreate($this->payload['new_rep_name'], '修改仓库名称失败');
//从数据库修改仓库名称
$this->database->update('svn_reps', [
'rep_name' => $this->requestPayload['new_rep_name']
'rep_name' => $this->payload['new_rep_name']
], [
'rep_name' => $this->requestPayload['old_rep_name']
'rep_name' => $this->payload['old_rep_name']
]);
//从配置文件修改仓库名称
$this->SVNAdminRep->UpdRepAuthz($this->globalAuthzContent, $this->requestPayload['old_rep_name'], $this->requestPayload['new_rep_name']);
$this->SVNAdminRep->UpdRepAuthz($this->globalAuthzContent, $this->payload['old_rep_name'], $this->payload['new_rep_name']);
FunMessageExit();
}
@ -1089,19 +1089,19 @@ class svnrep extends controller @@ -1089,19 +1089,19 @@ class svnrep extends controller
function DelRep()
{
//从配置文件删除指定仓库的所有路径
$result = $this->SVNAdminRep->DelRepAuthz($this->globalAuthzContent, $this->requestPayload['rep_name']);
$result = $this->SVNAdminRep->DelRepAuthz($this->globalAuthzContent, $this->payload['rep_name']);
if ($result != '1') {
FunShellExec('echo \'' . $result . '\' > ' . SVN_AUTHZ_FILE);
}
//从数据库中删除
$this->database->delete('svn_reps', [
'rep_name' => $this->requestPayload['rep_name']
'rep_name' => $this->payload['rep_name']
]);
//从仓库目录删除仓库文件夹
FunShellExec('cd ' . SVN_REPOSITORY_PATH . ' && rm -rf ./' . $this->requestPayload['rep_name']);
$this->SVNAdminRep->CheckRepDelete($this->requestPayload['rep_name']);
FunShellExec('cd ' . SVN_REPOSITORY_PATH . ' && rm -rf ./' . $this->payload['rep_name']);
$this->SVNAdminRep->CheckRepDelete($this->payload['rep_name']);
//返回
FunMessageExit();
@ -1112,7 +1112,7 @@ class svnrep extends controller @@ -1112,7 +1112,7 @@ class svnrep extends controller
*/
function GetRepDetail()
{
$result = $this->SVNAdminRep->GetRepDetail($this->requestPayload['rep_name']);
$result = $this->SVNAdminRep->GetRepDetail($this->payload['rep_name']);
$resultArray = explode("\n", $result);
$newArray = [];
@ -1145,7 +1145,7 @@ class svnrep extends controller @@ -1145,7 +1145,7 @@ class svnrep extends controller
*/
function RepDump()
{
$this->SVNAdminRep->RepDump($this->requestPayload['rep_name'], $this->requestPayload['rep_name'] . '_' . date('YmdHis') . '_' . FunGetRandStr() . '.dump');
$this->SVNAdminRep->RepDump($this->payload['rep_name'], $this->payload['rep_name'] . '_' . date('YmdHis') . '_' . FunGetRandStr() . '.dump');
FunMessageExit();
}
@ -1155,7 +1155,7 @@ class svnrep extends controller @@ -1155,7 +1155,7 @@ class svnrep extends controller
*/
function DelRepBackup()
{
$this->SVNAdminRep->DelRepBackup($this->requestPayload['fileName']);
$this->SVNAdminRep->DelRepBackup($this->payload['fileName']);
FunMessageExit();
}
@ -1173,9 +1173,9 @@ class svnrep extends controller @@ -1173,9 +1173,9 @@ class svnrep extends controller
*/
function DownloadRepBackup1()
{
$filePath = SVN_BACHUP_PATH . $this->requestPayload['fileName'];
$filePath = SVN_BACHUP_PATH . $this->payload['fileName'];
$fileName = $this->requestPayload['fileName'];
$fileName = $this->payload['fileName'];
//以只读和二进制模式打开文件
$fp = @fopen($filePath, 'rb');
@ -1234,7 +1234,7 @@ class svnrep extends controller @@ -1234,7 +1234,7 @@ class svnrep extends controller
*/
function DownloadRepBackup2()
{
$filePath = SVN_BACHUP_PATH . $this->requestPayload['fileName'];
$filePath = SVN_BACHUP_PATH . $this->payload['fileName'];
//文件类型
$mimeType = 'application/octet-stream';
@ -1286,15 +1286,15 @@ class svnrep extends controller @@ -1286,15 +1286,15 @@ class svnrep extends controller
function ImportRep()
{
//检查备份文件是否存在
if (!file_exists(SVN_BACHUP_PATH . $this->requestPayload['fileName'])) {
if (!file_exists(SVN_BACHUP_PATH . $this->payload['fileName'])) {
FunMessageExit(200, 0, '备份文件不存在');
}
//检查操作的仓库是否存在
$this->SVNAdminRep->CheckRepCreate($this->requestPayload['rep_name'], '仓库不存在');
$this->SVNAdminRep->CheckRepCreate($this->payload['rep_name'], '仓库不存在');
//使用svndump
$result = $this->SVNAdminRep->RepLoad($this->requestPayload['rep_name'], $this->requestPayload['fileName']);
$result = $this->SVNAdminRep->RepLoad($this->payload['rep_name'], $this->payload['fileName']);
if ($result['error'] == '') {
FunMessageExit();
@ -1309,10 +1309,10 @@ class svnrep extends controller @@ -1309,10 +1309,10 @@ class svnrep extends controller
function GetRepHooks()
{
//检查仓库是否存在
$this->SVNAdminRep->CheckRepCreate($this->requestPayload['rep_name'], '仓库不存在');
$this->SVNAdminRep->CheckRepCreate($this->payload['rep_name'], '仓库不存在');
clearstatcache();
if (!is_dir(SVN_REPOSITORY_PATH . $this->requestPayload['rep_name'] . '/' . 'hooks')) {
if (!is_dir(SVN_REPOSITORY_PATH . $this->payload['rep_name'] . '/' . 'hooks')) {
FunMessageExit(200, 0, '仓库不存在或文件损坏');
}
@ -1376,12 +1376,12 @@ class svnrep extends controller @@ -1376,12 +1376,12 @@ class svnrep extends controller
'post-revprop-change'
];
$file_arr = scandir(SVN_REPOSITORY_PATH . $this->requestPayload['rep_name'] . '/' . 'hooks');
$file_arr = scandir(SVN_REPOSITORY_PATH . $this->payload['rep_name'] . '/' . 'hooks');
foreach ($file_arr as $file_item) {
if ($file_item != '.' && $file_item != '..') {
if (in_array($file_item, $hooks_file_list)) {
$temp = FunShellExec(sprintf("cat '%s'", SVN_REPOSITORY_PATH . $this->requestPayload['rep_name'] . '/' . 'hooks' . '/' . $file_item));
$temp = FunShellExec(sprintf("cat '%s'", SVN_REPOSITORY_PATH . $this->payload['rep_name'] . '/' . 'hooks' . '/' . $file_item));
$hooks_type_list[$file_item]['shell'] = $temp['result'];
$hooks_type_list[$file_item]['shell'] = trim($hooks_type_list[$file_item]['shell']);
}
@ -1396,7 +1396,7 @@ class svnrep extends controller @@ -1396,7 +1396,7 @@ class svnrep extends controller
*/
function EditRepHook()
{
$cmd = sprintf("echo '%s' > '%s'", trim($this->requestPayload['content']), SVN_REPOSITORY_PATH . $this->requestPayload['rep_name'] . '/hooks/' . $this->requestPayload['type']);
$cmd = sprintf("echo '%s' > '%s'", trim($this->payload['content']), SVN_REPOSITORY_PATH . $this->payload['rep_name'] . '/hooks/' . $this->payload['type']);
FunShellExec($cmd);

40
02.php/app/controller/svnuser.class.php

@ -97,9 +97,9 @@ class svnuser extends controller @@ -97,9 +97,9 @@ class svnuser extends controller
//将SVN用户数据同步到数据库
$this->SyncUserToDb();
$pageSize = $this->requestPayload['pageSize'];
$currentPage = $this->requestPayload['currentPage'];
$searchKeyword = trim($this->requestPayload['searchKeyword']);
$pageSize = $this->payload['pageSize'];
$currentPage = $this->payload['currentPage'];
$searchKeyword = trim($this->payload['searchKeyword']);
//分页
$begin = $pageSize * ($currentPage - 1);
@ -120,7 +120,7 @@ class svnuser extends controller @@ -120,7 +120,7 @@ class svnuser extends controller
],
'LIMIT' => [$begin, $pageSize],
'ORDER' => [
$this->requestPayload['sortName'] => strtoupper($this->requestPayload['sortType'])
$this->payload['sortName'] => strtoupper($this->payload['sortType'])
]
]);
@ -151,7 +151,7 @@ class svnuser extends controller @@ -151,7 +151,7 @@ class svnuser extends controller
*/
function EnableUser()
{
$result = $this->SVNAdminUser->EnabledUser($this->globalPasswdContent, $this->requestPayload['svn_user_name']);
$result = $this->SVNAdminUser->EnabledUser($this->globalPasswdContent, $this->payload['svn_user_name']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
}
@ -169,7 +169,7 @@ class svnuser extends controller @@ -169,7 +169,7 @@ class svnuser extends controller
*/
function DisableUser()
{
$result = $this->SVNAdminUser->DisabledUser($this->globalPasswdContent, $this->requestPayload['svn_user_name']);
$result = $this->SVNAdminUser->DisabledUser($this->globalPasswdContent, $this->payload['svn_user_name']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
}
@ -188,9 +188,9 @@ class svnuser extends controller @@ -188,9 +188,9 @@ class svnuser extends controller
function EditUserNote()
{
$this->database->update('svn_users', [
'svn_user_note' => $this->requestPayload['svn_user_note']
'svn_user_note' => $this->payload['svn_user_note']
], [
'svn_user_name' => $this->requestPayload['svn_user_name']
'svn_user_name' => $this->payload['svn_user_name']
]);
FunMessageExit();
@ -202,10 +202,10 @@ class svnuser extends controller @@ -202,10 +202,10 @@ class svnuser extends controller
function CreateUser()
{
//检查用户名是否合法
FunCheckRepUser($this->requestPayload['svn_user_name']);
FunCheckRepUser($this->payload['svn_user_name']);
//检查用户是否已存在
$result = $this->SVNAdminUser->AddSvnUser($this->globalPasswdContent, $this->requestPayload['svn_user_name'], $this->requestPayload['svn_user_pass']);
$result = $this->SVNAdminUser->AddSvnUser($this->globalPasswdContent, $this->payload['svn_user_name'], $this->payload['svn_user_pass']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
}
@ -214,7 +214,7 @@ class svnuser extends controller @@ -214,7 +214,7 @@ class svnuser extends controller
}
//检查密码是否不为空
if (trim($this->requestPayload['svn_user_pass']) == '') {
if (trim($this->payload['svn_user_pass']) == '') {
FunMessageExit(200, 0, '密码不能为空');
}
@ -223,8 +223,8 @@ class svnuser extends controller @@ -223,8 +223,8 @@ class svnuser extends controller
//写入数据库
$this->database->insert('svn_users', [
'svn_user_name' => $this->requestPayload['svn_user_name'],
'svn_user_pass' => $this->requestPayload['svn_user_pass'],
'svn_user_name' => $this->payload['svn_user_name'],
'svn_user_pass' => $this->payload['svn_user_pass'],
'svn_user_status' => 1,
'svn_user_note' => ''
]);
@ -238,7 +238,7 @@ class svnuser extends controller @@ -238,7 +238,7 @@ class svnuser extends controller
function EditUserPass()
{
//检查用户是否已存在
$result = $this->SVNAdminUser->UpdSvnUserPass($this->globalPasswdContent, $this->requestPayload['svn_user_name'], $this->requestPayload['svn_user_pass'], !$this->requestPayload['svn_user_status']);
$result = $this->SVNAdminUser->UpdSvnUserPass($this->globalPasswdContent, $this->payload['svn_user_name'], $this->payload['svn_user_pass'], !$this->payload['svn_user_status']);
if ($result == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
}
@ -247,7 +247,7 @@ class svnuser extends controller @@ -247,7 +247,7 @@ class svnuser extends controller
}
//检查密码是否不为空
if (trim($this->requestPayload['svn_user_pass']) == '') {
if (trim($this->payload['svn_user_pass']) == '') {
FunMessageExit(200, 0, '密码不能为空');
}
@ -256,9 +256,9 @@ class svnuser extends controller @@ -256,9 +256,9 @@ class svnuser extends controller
//写入数据库
$this->database->update('svn_users', [
'svn_user_pass' => $this->requestPayload['svn_user_pass'],
'svn_user_pass' => $this->payload['svn_user_pass'],
], [
'svn_user_name' => $this->requestPayload['svn_user_name']
'svn_user_name' => $this->payload['svn_user_name']
]);
FunMessageExit();
@ -270,7 +270,7 @@ class svnuser extends controller @@ -270,7 +270,7 @@ class svnuser extends controller
function DelUser()
{
//从passwd文件中全局删除
$resultPasswd = $this->SVNAdminUser->DelSvnUserPasswd($this->globalPasswdContent, $this->requestPayload['svn_user_name'], !$this->requestPayload['svn_user_status']);
$resultPasswd = $this->SVNAdminUser->DelSvnUserPasswd($this->globalPasswdContent, $this->payload['svn_user_name'], !$this->payload['svn_user_status']);
if ($resultPasswd == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
@ -280,7 +280,7 @@ class svnuser extends controller @@ -280,7 +280,7 @@ class svnuser extends controller
}
//从authz文件中删除
$resultAuthz = $this->SVNAdminUser->DelUserAuthz($this->globalAuthzContent, $this->requestPayload['svn_user_name']);
$resultAuthz = $this->SVNAdminUser->DelUserAuthz($this->globalAuthzContent, $this->payload['svn_user_name']);
if ($resultAuthz == '0') {
FunMessageExit(200, 0, '文件格式错误(不存在[users]标识)');
@ -288,7 +288,7 @@ class svnuser extends controller @@ -288,7 +288,7 @@ class svnuser extends controller
//从数据删除
$this->database->delete('svn_users', [
'svn_user_name' => $this->requestPayload['svn_user_name']
'svn_user_name' => $this->payload['svn_user_name']
]);
FunShellExec('echo \'' . $resultAuthz . '\' > ' . SVN_AUTHZ_FILE);

4
02.php/app/controller/update.class.php

@ -42,7 +42,7 @@ class update extends controller @@ -42,7 +42,7 @@ class update extends controller
/**
* 检测新版本
*/
function CheckUpdate($requestPayload)
function CheckUpdate($payload)
{
foreach (unserialize(UPDATE_SERVER) as $key => $value) {
$versionInfo = FunCurlRequest($value);
@ -81,7 +81,7 @@ class update extends controller @@ -81,7 +81,7 @@ class update extends controller
/**
* 确认更新
*/
function StartUpdate($requestPayload)
function StartUpdate($payload)
{
}
}

6
02.php/app/core/controller.class.php

@ -75,7 +75,7 @@ class controller @@ -75,7 +75,7 @@ class controller
public $globalAuthzContent;
public $globalPasswdContent;
public $requestPayload;
public $payload;
public $database;
@ -109,8 +109,8 @@ class controller @@ -109,8 +109,8 @@ class controller
/**
* 请求载体
*/
global $requestPayload;
$this->requestPayload = $requestPayload;
global $payload;
$this->payload = $payload;
/**
* 数据库连接

12
02.php/extension/SVNAdmin/src/class/SVNInfo.class.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-04-27 17:58:13
* @LastEditors: witersen
* @LastEditTime: 2022-04-30 19:28:20
* @LastEditTime: 2022-05-02 00:23:14
* @Description: QQ:1801168257
* @copyright: https://github.com/witersen/
*/
@ -33,7 +33,7 @@ class Info extends Core @@ -33,7 +33,7 @@ class Info extends Core
$bindPort = '';
$bindHost = '';
$svnserveContent = FunShellExec('cat ' . $SVNSERVE_ENV_FILE);
$svnserveContent = FunShellExec(sprintf("cat '%s'", $SVNSERVE_ENV_FILE));
$svnserveContent = $svnserveContent['result'];
//匹配端口
@ -46,13 +46,13 @@ class Info extends Core @@ -46,13 +46,13 @@ class Info extends Core
$bindHost = trim($hostMatchs[1]);
}
$listenContent = FunShellExec('cat ' . $LISTEN_FILE);
$listenContent = FunShellExec(sprintf("cat '%s'", $LISTEN_FILE));
$listenContent = $listenContent['result'];
if (!FunCheckJson($listenContent)) {
//文件格式错误则初始化
FunShellExec('echo \'' . json_encode([
'bindPort' => $bindPort == '' ? '3690' : $bindPort,
'bindPort' => $bindPort == '' ? 3690 : $bindPort,
'bindHost' => $bindHost == '' ? '0.0.0.0' : $bindHost,
'manageHost' => '127.0.0.1',
'enable' => $bindHost == '' ? 'manageHost' : 'bindHost'
@ -61,7 +61,7 @@ class Info extends Core @@ -61,7 +61,7 @@ class Info extends Core
//更新内容
$listenArray = json_decode($listenContent, true);
if ($listenArray['bindPort'] != $bindPort) {
$listenArray['bindPort'] = $bindPort == '' ? '3690' : $bindHost;
$listenArray['bindPort'] = $bindPort == '' ? 3690 : $bindPort;
}
if ($listenArray['bindHost'] != $bindHost) {
$listenArray['bindHost'] = $bindHost == '' ? '0.0.0.0' : $bindHost;
@ -74,7 +74,7 @@ class Info extends Core @@ -74,7 +74,7 @@ class Info extends Core
]) . '\' > ' . $LISTEN_FILE);
}
$listenContent = FunShellExec('cat ' . $LISTEN_FILE);
$listenContent = FunShellExec(sprintf("cat '%s'", $LISTEN_FILE));
$listenContent = $listenContent['result'];
$listenArray = json_decode($listenContent, true);

37
02.php/server/svnadmind.php

@ -3,10 +3,17 @@ @@ -3,10 +3,17 @@
* @Author: witersen
* @Date: 2022-04-24 23:37:06
* @LastEditors: witersen
* @LastEditTime: 2022-04-30 20:18:24
* @LastEditTime: 2022-05-01 21:03:26
* @Description: QQ:1801168257
*/
/**
* 将工作模式限制在cli模式
*/
if (!preg_match('/cli/i', php_sapi_name())) {
exit('require php-cli mode');
}
ini_set('display_errors', '1');
error_reporting(E_ALL);
@ -253,20 +260,23 @@ class Daemon @@ -253,20 +260,23 @@ class Daemon
public function Run($argv)
{
$this->CheckSysType();
$this->CheckPhpVersion();
$this->CheckDisabledFunction();
if (isset($argv[1])) {
$this->workMode = $argv[1];
if (!in_array($this->workMode, $this->scripts)) {
exit('用法:php svnadmin.php [start | stop | console]' . PHP_EOL);
}
if ($this->workMode == 'start') {
$this->StartDaemon();
} else if ($this->workMode == 'stop') {
if ($this->workMode == 'stop') {
$this->StopDaemon();
} else if ($this->workMode == 'console') {
$this->StartConsole();
} else {
$this->CheckSysType();
$this->CheckPhpVersion();
$this->CheckDisabledFunction();
if ($this->workMode == 'start') {
$this->StartDaemon();
} else if ($this->workMode == 'console') {
$this->StartConsole();
}
}
} else {
exit('用法:php svnadmin.php [start | stop | console]' . PHP_EOL);
@ -274,10 +284,5 @@ class Daemon @@ -274,10 +284,5 @@ class Daemon
}
}
/**
* 将工作模式限制在cli模式
*/
if (preg_match('/cli/i', php_sapi_name())) {
$deamon = new Daemon();
$deamon->Run($argv);
}
$deamon = new Daemon();
$deamon->Run($argv);

8
02.php/templete/json/listen.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"bindPort": "",
"bindHost": "",
"manageHost": "",
"enable": ""
"bindPort": 3690,
"bindHost": "0.0.0.0",
"manageHost": "127.0.0.1",
"enable": "manageHost"
}

3
02.php/templete/svnserve/svnserve

@ -1 +1,2 @@ @@ -1 +1,2 @@
OPTIONS="-r /home/svnadmin/rep --config-file /home/svnadmin/svnserve.conf --log-file /home/svnadmin/logs/svnserve/svnserve.log"
//OPTIONS="-r /home/svnadmin/rep --config-file /home/svnadmin/svnserve.conf --log-file /home/svnadmin/logs/svnserve/svnserve.log"
OPTIONS="-r '%s' --config-file '%s' --log-file '%s' --listen-port 3690 --listen-host 0.0.0.0"
Loading…
Cancel
Save