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 @@
<span>从本地上传</span> <span>从本地上传</span>
</Radio> </Radio>
<Alert type="warning" show-icon <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"> <Radio label="2">
<span>从服务器选择</span> <span>从服务器选择</span>
</Radio> </Radio>
@ -740,6 +746,12 @@ export default {
/** /**
* 表单 * 表单
*/ */
//
uploadLimit: {
file_uploads: true,
upload_max_filesize: 0,
post_max_size: 0,
},
//SVN //SVN
formRepAdd: { formRepAdd: {
rep_name: "", rep_name: "",
@ -1081,7 +1093,6 @@ export default {
// console.log(writer); // console.log(writer);
// console.log('test-end'); // console.log('test-end');
// writableStream.abort(); // writableStream.abort();
// // also possible to call abosrt on the writer you got from `getWriter()` // // also possible to call abosrt on the writer you got from `getWriter()`
// writer.abort(); // writer.abort();
@ -2233,6 +2244,8 @@ export default {
this.modalRepAdvance = true; this.modalRepAdvance = true;
// //
this.GetRepDetail(); this.GetRepDetail();
//
this.GetUploadSize();
}, },
/** /**
* 获取仓库的属性内容key-vlaue的形式 * 获取仓库的属性内容key-vlaue的形式
@ -2283,10 +2296,32 @@ export default {
*/ */
ChangeRadioUploadType(value) { ChangeRadioUploadType(value) {
this.formUploadBackup.selectType = value; this.formUploadBackup.selectType = value;
if (value == "2") { if (value == "1") {
//php
this.GetUploadSize();
} else if (value == "2") {
this.GetBackupList(); 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() { BeforeUpload() {
this.loadingUploadBackup = true; this.loadingUploadBackup = true;

3
02.php/api.php

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

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

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

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

@ -3,7 +3,7 @@
* @Author: witersen * @Author: witersen
* @Date: 2022-04-24 23:37:05 * @Date: 2022-04-24 23:37:05
* @LastEditors: witersen * @LastEditors: witersen
* @LastEditTime: 2022-05-09 17:08:00 * @LastEditTime: 2022-05-09 18:57:10
* @Description: QQ:1801168257 * @Description: QQ:1801168257
*/ */
@ -1278,11 +1278,40 @@ class Svnrep extends Base
$transfer->send(); $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() 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)) { if (array_key_exists('file', $_FILES)) {
//扩展名 //扩展名
$fileType = substr(strrchr($_FILES['file']['name'], '.'), 1); $fileType = substr(strrchr($_FILES['file']['name'], '.'), 1);

46
02.php/config/database.php

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

16
02.php/server/install.php

@ -3,7 +3,7 @@
* @Author: witersen * @Author: witersen
* @Date: 2022-05-08 13:31:07 * @Date: 2022-05-08 13:31:07
* @LastEditors: witersen * @LastEditors: witersen
* @LastEditTime: 2022-05-09 16:28:17 * @LastEditTime: 2022-05-09 17:39:28
* @Description: QQ:1801168257 * @Description: QQ:1801168257
*/ */
@ -264,7 +264,7 @@ CON;
file_put_contents(BASE_PATH . '/../config/bin.php', $binCon); file_put_contents(BASE_PATH . '/../config/bin.php', $binCon);
/** /**
* 相关文件配置 * 3、相关文件配置
*/ */
$templete_path = BASE_PATH . '/../templete/'; $templete_path = BASE_PATH . '/../templete/';
@ -317,7 +317,17 @@ CON;
echo '===============================================' . PHP_EOL; 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; echo '清理之前注册的svnserve服务' . PHP_EOL;

Loading…
Cancel
Save