Browse Source

对文件上传的大小限制作出具体处理和说明

docker-svn
witersen 3 years ago
parent
commit
b72c28e335
  1. 43
      01.web/src/views/repositoryInfo/index.vue
  2. 3
      02.php/api.php
  3. 11
      02.php/app/controller/Svnrep.php
  4. 31
      02.php/app/service/Svnrep.php
  5. 46
      02.php/config/database.php
  6. 16
      02.php/server/install.php

43
01.web/src/views/repositoryInfo/index.vue

@ -450,8 +450,14 @@ @@ -450,8 +450,14 @@
<span>从本地上传</span>
</Radio>
<Alert type="warning" show-icon
>1大文件建议通过FTP等方式上传<br />2注意重复文件会自动覆盖</Alert
>
>1大文件建议通过FTP等方式上传<br />
2PHP上传限制参数如下<br/><br/>
file_uploads{{uploadLimit.file_uploads==true?'开启':'关闭'}}<br/>
upload_max_filesize{{uploadLimit.upload_max_filesize}}<br/>
post_max_size{{uploadLimit.post_max_size}}<br/><br/>
3还要注意web服务器的限制<br/><br/>
如Nginx需考虑 client_max_body_size 等参数
</Alert>
<Radio label="2">
<span>从服务器选择</span>
</Radio>
@ -740,6 +746,12 @@ export default { @@ -740,6 +746,12 @@ export default {
/**
* 表单
*/
//
uploadLimit: {
file_uploads: true,
upload_max_filesize: 0,
post_max_size: 0,
},
//SVN
formRepAdd: {
rep_name: "",
@ -1081,7 +1093,6 @@ export default { @@ -1081,7 +1093,6 @@ export default {
// console.log(writer);
// console.log('test-end');
// writableStream.abort();
// // also possible to call abosrt on the writer you got from `getWriter()`
// writer.abort();
@ -2233,6 +2244,8 @@ export default { @@ -2233,6 +2244,8 @@ export default {
this.modalRepAdvance = true;
//
this.GetRepDetail();
//
this.GetUploadSize();
},
/**
* 获取仓库的属性内容key-vlaue的形式
@ -2283,10 +2296,32 @@ export default { @@ -2283,10 +2296,32 @@ export default {
*/
ChangeRadioUploadType(value) {
this.formUploadBackup.selectType = value;
if (value == "2") {
if (value == "1") {
//php
this.GetUploadSize();
} else if (value == "2") {
this.GetBackupList();
}
},
//
GetUploadSize() {
var that = this;
var data = {};
that.$axios
.post("/api.php?c=Svnrep&a=GetUploadLimit&t=web", data)
.then(function (response) {
var result = response.data;
if (result.status == 1) {
that.uploadLimit = result.data;
} else {
that.$Message.error(result.message);
}
})
.catch(function (error) {
console.log(error);
that.$Message.error("出错了 请联系管理员!");
});
},
//
BeforeUpload() {
this.loadingUploadBackup = true;

3
02.php/api.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-04-24 23:37:06
* @LastEditors: witersen
* @LastEditTime: 2022-05-08 21:43:14
* @LastEditTime: 2022-05-09 17:35:57
* @Description: QQ:1801168257
*/
@ -94,7 +94,6 @@ foreach ($disable_functions as $disable) { @@ -94,7 +94,6 @@ foreach ($disable_functions as $disable) {
}
}
//检测守护进程状态
$state = FunDetectState();
if ($state == 0) {

11
02.php/app/controller/Svnrep.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-04-24 23:37:05
* @LastEditors: witersen
* @LastEditTime: 2022-05-07 14:29:39
* @LastEditTime: 2022-05-09 18:54:31
* @Description: QQ:1801168257
*/
@ -226,6 +226,15 @@ class Svnrep extends Base @@ -226,6 +226,15 @@ class Svnrep extends Base
$this->ServiceSvnrep->DownloadRepBackup();
}
/**
* 获取上传限制
*/
public function GetUploadLimit()
{
$result = $this->ServiceSvnrep->GetUploadLimit();
json2($result);
}
/**
* 上传文件到备份文件夹
*/

31
02.php/app/service/Svnrep.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-04-24 23:37:05
* @LastEditors: witersen
* @LastEditTime: 2022-05-09 17:08:00
* @LastEditTime: 2022-05-09 18:57:10
* @Description: QQ:1801168257
*/
@ -1278,11 +1278,40 @@ class Svnrep extends Base @@ -1278,11 +1278,40 @@ class Svnrep extends Base
$transfer->send();
}
/**
* 获取上传限制
*/
public function GetUploadLimit()
{
$file_uploads = ini_get('file_uploads');
if ($file_uploads == 0 || $file_uploads == false || strtolower($file_uploads) == 'off') {
$file_uploads = false;
} else {
$file_uploads = true;
}
// $webServer = strtolower($_SERVER['SERVER_SOFTWARE']);
// if (strpos($webServer, 'nginx')) {
// $client_max_body_size = '';
// }
return message(200, 1, '成功', [
'file_uploads' => $file_uploads,
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
]);
}
/**
* 上传文件到备份文件夹
*/
public function UploadBackup()
{
$file_uploads = ini_get('file_uploads');
if ($file_uploads == 0 || $file_uploads == false || strtolower($file_uploads) == 'off') {
return message(200, 0, '文件上传功能关闭');
}
if (array_key_exists('file', $_FILES)) {
//扩展名
$fileType = substr(strrchr($_FILES['file']['name'], '.'), 1);

46
02.php/config/database.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-05-07 00:38:48
* @LastEditors: witersen
* @LastEditTime: 2022-05-07 14:48:43
* @LastEditTime: 2022-05-09 17:50:37
* @Description: QQ:1801168257
*/
@ -11,24 +11,24 @@ @@ -11,24 +11,24 @@
* for MySQL
* config from Medoo 1.7.10
*/
return [
'database_type' => 'mysql',
'server' => 'sas2.witersen.com',
'database_name' => 'svnadmin',
'username' => 'svnadmin',
'password' => 'svnadmin',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'port' => 3306,
'prefix' => '',
'logging' => false,
'option' => [
PDO::ATTR_CASE => PDO::CASE_NATURAL
],
'command' => [
'SET SQL_MODE=ANSI_QUOTES'
]
];
// return [
// 'database_type' => 'mysql',
// 'server' => 'localhost',
// 'database_name' => 'svnadmin',
// 'username' => 'svnadmin',
// 'password' => 'svnadmin',
// 'charset' => 'utf8mb4',
// 'collation' => 'utf8mb4_general_ci',
// 'port' => 3306,
// 'prefix' => '',
// 'logging' => false,
// 'option' => [
// PDO::ATTR_CASE => PDO::CASE_NATURAL
// ],
// 'command' => [
// 'SET SQL_MODE=ANSI_QUOTES'
// ]
// ];
/**
* for SQLite
@ -37,7 +37,7 @@ return [ @@ -37,7 +37,7 @@ return [
* %s 为占位符 无需修改
*/
// return [
// 'database_type' => 'sqlite',
// 'database_file' => '%ssvnadmin.db'
// ];
return [
'database_type' => 'sqlite',
'database_file' => '%ssvnadmin.db'
];

16
02.php/server/install.php

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* @Author: witersen
* @Date: 2022-05-08 13:31:07
* @LastEditors: witersen
* @LastEditTime: 2022-05-09 16:28:17
* @LastEditTime: 2022-05-09 17:39:28
* @Description: QQ:1801168257
*/
@ -264,7 +264,7 @@ CON; @@ -264,7 +264,7 @@ CON;
file_put_contents(BASE_PATH . '/../config/bin.php', $binCon);
/**
* 相关文件配置
* 3、相关文件配置
*/
$templete_path = BASE_PATH . '/../templete/';
@ -317,7 +317,17 @@ CON; @@ -317,7 +317,17 @@ CON;
echo '===============================================' . PHP_EOL;
/**
* 将svnserve注册为系统服务
* 4、配置SQLite数据库文件
*/
echo '配置并启用SQLite数据库' . PHP_EOL;
copy($templete_path . '/database/sqlite/svnadmin.db', $this->config_svn['home_path'] . 'svnadmin.db');
echo '===============================================' . PHP_EOL;
//配置SQLite数据库文件的父目录权限配置为777 解决无法写入且不报错的问题
shell_exec('chmod 777 ' . $this->config_svn['home_path']);
/**
* 5、将svnserve注册为系统服务
*/
echo '清理之前注册的svnserve服务' . PHP_EOL;

Loading…
Cancel
Save