切换导航条
此项目
正在载入...
登录
周海龙
/
mail-serve
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
邓超
6 months ago
提交
46c01d76a15a4fa5d584bb5fae8243c08e4b9523
2 个父辈
504c2a09
5641e188
Merge remote-tracking branch 'origin/master'
# Conflicts: # lib/DbQuery.php
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
37 行增加
和
20 行删除
controller/Home.php
lib/DbQuery.php
lib/Mail/Mail.php
lib/Mail/MailFun.php
controller/Home.php
查看文件 @
46c01d7
...
...
@@ -132,10 +132,16 @@ class Home extends Base {
if
(
app
()
->
requestHas
(
'from'
)){
// 如果是发件箱
if
(
$folder
==
'发件箱'
){
$where
[
'to'
]
=
app
()
->
request
(
'from'
);
if
(
!
$where
[
'to'
]){
$tos
=
app
()
->
request
(
'from'
);
if
(
!
$tos
){
// 不让查询数据
$where
[
'id'
]
=
0
;
}
else
{
$tos
=
array_map
(
function
(
$v
){
return
"find_in_set('"
.
addcslashes
(
$v
,
"'"
)
.
"',`to`)"
;
},
is_array
(
$tos
)
?
$tos
:
[
$tos
]);
$where
[
'_'
][]
=
'('
.
implode
(
' or '
,
$tos
)
.
')'
;
}
}
else
{
$where
[
'from'
]
=
app
()
->
request
(
'from'
);
...
...
lib/DbQuery.php
查看文件 @
46c01d7
...
...
@@ -28,6 +28,12 @@ trait DbQuery {
*/
protected
int
$cache
=
0
;
/**
* 没有数据时 也缓存
* @var bool
*/
protected
bool
$cacheNoData
=
true
;
public
function
getClient
()
{
...
...
@@ -51,8 +57,9 @@ trait DbQuery {
* @author:dc
* @time 2024/8/14 14:04
*/
public
function
cache
(
int
$ttl
){
public
function
cache
(
int
$ttl
,
bool
$noData
=
true
){
$this
->
cache
=
$ttl
;
$this
->
cacheNoData
=
$noData
;
return
$this
;
}
...
...
@@ -254,9 +261,7 @@ trait DbQuery {
* @time 2023/2/17 11:03
*/
public
function
value
(
string
|
array
$sql
){
return
$this
->
getCacheData
(
$sql
,
null
,
\PDO
::
FETCH_COLUMN
);
$query
=
$this
->
query
(
$sql
);
if
(
$query
){
return
$query
->
fetch
(
\PDO
::
FETCH_COLUMN
);
...
...
@@ -280,7 +285,13 @@ trait DbQuery {
$key
=
'data:'
.
md5
(
is_string
(
$sql
)
?
$sql
:
json_encode
(
$sql
));
if
(
redis
()
->
has
(
$key
)){
$this
->
cache
=
0
;
return
redis
()
->
get
(
$key
,
$default
);
$data
=
redis
()
->
get
(
$key
,
$default
);
if
(
!
$this
->
cacheNoData
){
if
(
$data
||
$data
===
0
){
return
$data
;
}
}
}
}
$query
=
$this
->
query
(
$sql
);
...
...
lib/Mail/Mail.php
查看文件 @
46c01d7
...
...
@@ -251,7 +251,7 @@ class Mail {
$blacklist
=
redis
()
->
get
(
'blacklist:'
.
$email_id
);
$blackFolder
=
''
;
if
(
$blacklist
){
$blackFolder
=
$db
->
value
(
folderSql
::
originFolder
(
$email_id
,
'垃圾箱'
));
$blackFolder
=
$db
->
cache
(
86400
*
30
)
->
value
(
folderSql
::
originFolder
(
$email_id
,
'垃圾箱'
));
}
//
...
...
@@ -281,11 +281,11 @@ class Mail {
$uids
=
array_column
(
$uids
,
'UID'
);
$existsUids
=
$db
->
all
(
listsSql
::
getUids
(
$email_id
,
$folder_id
,
$uids
));
if
(
$existsUids
){
$existsUids
=
array_column
(
$existsUids
,
'uid'
);
// 获取不存在数据库的uid
$uids
=
array_diff
(
$uids
,
$existsUids
);
foreach
(
$uids
as
$k
=>
$uid
){
if
(
$db
->
cache
(
86400
*
30
,
false
)
->
value
(
listsSql
::
first
(
dbWhere
([
'email_id'
=>
$email_id
,
'folder_id'
=>
$folder_id
,
'uid'
=>
$uid
]),
'count(*) as c'
))){
unset
(
$uids
[
$k
]);
}
}
...
...
@@ -313,7 +313,7 @@ class Mail {
$unseen
=
$db
->
count
(
listsSql
::
listCount
(
dbWhere
([
'seen'
=>
0
,
'deleted'
=>
0
,
'email_id'
=>
$email_id
,
//
'email_id' => $email_id,
'folder_id'
=>
$folder_id
,
])));
$db
->
update
(
...
...
lib/Mail/MailFun.php
查看文件 @
46c01d7
...
...
@@ -37,14 +37,14 @@ class MailFun {
* @time 2023/3/27 13:55
*/
public
static
function
mb_coding
(
string
$str
,
array
$appcode
=
[]){
$str
=
trim
(
$str
,
"
\t\n\r
"
);
$str
=
trim
(
$str
);
$str
=
(
new
Header
())
->
decode
(
$str
);
try
{
$encode
=
mb_detect_encoding
(
$str
,
array
(
"ASCII"
,
'UTF-8'
,
"GB2312"
,
"GBK"
,
'BIG5'
));
if
(
$encode
&&
$encode
!=
'UTF-8'
){
$str
=
mb_convert_encoding
(
$str
,
'UTF-8'
,
$encode
);
}
}
catch
(
\Throwable
$e
){}
// try {
// $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'));
// if($encode && $encode != 'UTF-8'){
// $str = mb_convert_encoding($str, 'UTF-8', $encode);
// }
// }catch (\Throwable $e){}
return
$str
;
...
...
请
注册
或
登录
后发表评论