切换导航条
此项目
正在载入...
登录
周海龙
/
mail-serve
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
邓超
2 years ago
提交
841c766769c67b0b490a629dc8f7c194739d3ed7
1 个父辈
7ee01ac4
1
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
78 行增加
和
4 行删除
controller/Home.php
lang/zh.php
lib/App.php
lib/UploadFile.php
route.php
controller/Home.php
查看文件 @
841c766
...
...
@@ -4,6 +4,7 @@ namespace Controller;
use
Lib\Mail\Mail
;
use
Lib\Mail\MailFun
;
use
Lib\UploadFile
;
use
Lib\Verify
;
use
Model\bodySql
;
use
Model\emailSql
;
...
...
@@ -209,6 +210,24 @@ class Home extends Base {
}
}
}
// 远程路径,云文件
$attachmentUrl
=
app
()
->
request
(
'attachmentUrl'
);
if
(
is_array
(
$attachmentUrl
)){
foreach
(
$attachmentUrl
as
$file
){
$file
=
is_array
(
$file
)
?
$file
:
json_decode
(
$file
,
true
);
if
(
!
empty
(
$file
[
'url'
])
&&
!
empty
(
$file
[
'name'
])){
$file
=
new
UploadFile
(
$file
[
'name'
],
$file
[
'url'
]);
if
(
$file
->
move
()){
// 添加到邮箱中
$mail
->
addAttachment
(
$file
->
savePath
.
$file
->
saveName
,
$file
->
name
);
//Add attachments
}
else
{
app
()
->
e
([
'attachment_upload_error'
,
$file
->
name
]);
}
}
}
}
// 回执,阅读后收回执的邮箱
if
(
!
empty
(
$formData
[
'receipt'
])){
...
...
@@ -288,6 +307,9 @@ class Home extends Base {
$emails
=
$this
->
getEmails
();
$mail_ids
=
app
()
->
request
(
'mail_ids'
);
if
(
!
(
$mail_ids
&&
is_array
(
$mail_ids
))){
app
()
->
e
(
'param_request_error'
);
}
foreach
(
$mail_ids
as
$k
=>
$id
){
if
(
!
is_numeric
(
$id
)){
unset
(
$mail_ids
[
$k
]);
...
...
@@ -366,6 +388,9 @@ class Home extends Base {
$emails
=
$this
->
getEmails
();
$mail_ids
=
app
()
->
request
(
'mail_ids'
);
if
(
!
(
$mail_ids
&&
is_array
(
$mail_ids
))){
app
()
->
e
(
'param_request_error'
);
}
foreach
(
$mail_ids
as
$k
=>
$id
){
if
(
!
is_numeric
(
$id
)){
unset
(
$mail_ids
[
$k
]);
...
...
lang/zh.php
查看文件 @
841c766
...
...
@@ -75,10 +75,11 @@ return [
'mail_not'
=>
'邮件不存在'
,
'mail_body_error'
=>
'邮件内容拉取失败'
,
'tos_verify_error'
=>
'收件人邮箱地址错误 %s'
'tos_verify_error'
=>
'收件人邮箱地址错误 %s'
,
'upload_file_load_error'
=>
'上传文件加载失败'
...
...
lib/App.php
查看文件 @
841c766
...
...
@@ -252,7 +252,12 @@ class App {
public
function
e
(
$message
,
$status
=
400
){
if
(
is_array
(
$message
)){
$this
->
data
[
'error_message'
]
=
__
(
$message
[
0
]);
$this
->
data
[
'error_message'
]
=
sprintf
(
$this
->
data
[
'error_message'
],
...
$message
[
1
]);
if
(
is_array
(
$message
[
1
])){
$this
->
data
[
'error_message'
]
=
sprintf
(
$this
->
data
[
'error_message'
],
...
$message
[
1
]);
}
else
{
unset
(
$message
[
0
]);
$this
->
data
[
'error_message'
]
=
sprintf
(
$this
->
data
[
'error_message'
],
...
$message
);
}
}
else
{
$this
->
data
[
'error_message'
]
=
__
(
$message
);
}
...
...
lib/UploadFile.php
查看文件 @
841c766
...
...
@@ -2,6 +2,7 @@
namespace
Lib
;
/**
* 文件
* @author:dc
...
...
@@ -44,6 +45,11 @@ class UploadFile
public
string
$savePath
=
''
;
/**
* @var bool
*/
private
$isUpload
=
true
;
/**
* UploadFile constructor.
* @param $name
* @param $tempFile
...
...
@@ -53,6 +59,37 @@ class UploadFile
$this
->
name
=
$name
;
// 不是临时文件
if
(
!
is_file
(
$tempFile
)){
$this
->
isUpload
=
false
;
// 是不是远程路径
if
(
str_starts_with
(
$tempFile
,
'http://'
)
||
str_starts_with
(
$tempFile
,
'https://'
)){
$content
=
@
file_get_contents
(
$tempFile
);
}
// 以文件内容的形式保存
else
{
$content
=
$tempFile
;
}
if
(
!
$content
){
throw
new
Err
(
'upload_file_load_error'
,
600
);
}
// 临时路径
$tempFile
=
PUBLIC_PATH
.
'/temp/'
.
md5
(
$tempFile
);
if
(
!
is_dir
(
dirname
(
$tempFile
))){
@
mkdir
(
dirname
(
$tempFile
),
0775
,
true
);
}
// 保存失败
if
(
!@
file_put_contents
(
$tempFile
,
$content
)){
throw
new
Err
(
'upload_file_load_error'
,
601
);
}
}
$this
->
tempFile
=
$tempFile
;
// kb
...
...
@@ -83,7 +120,13 @@ class UploadFile
// 保存的文件
$this
->
saveName
=
$name
?
$name
:
md5_file
(
$this
->
tempFile
)
.
'.'
.
$this
->
ext
;
return
move_uploaded_file
(
$this
->
tempFile
,
$this
->
savePath
.
$this
->
saveName
);
if
(
$this
->
isUpload
){
return
move_uploaded_file
(
$this
->
tempFile
,
$this
->
savePath
.
$this
->
saveName
);
}
else
{
$ret
=
copy
(
$this
->
tempFile
,
$this
->
savePath
.
$this
->
saveName
);
@
unlink
(
$this
->
tempFile
);
return
$ret
;
}
}
...
...
route.php
查看文件 @
841c766
...
...
@@ -34,7 +34,7 @@ return [
// 标记为已读
'seen_2_unseen'
=>
[
\Controller\Home
::
class
,
'seen_2_unseen'
],
// 标记为已回复/未回复
'answered_2_unanswered'
=>
[
\Controller\Home
::
class
,
'
seen_2_unseen
'
],
'answered_2_unanswered'
=>
[
\Controller\Home
::
class
,
'
answered_2_unanswered
'
],
// 邮件移动文件夹
'move'
=>
[
\Controller\Home
::
class
,
'move'
],
// 检查邮箱状态
...
...
请
注册
或
登录
后发表评论