作者 邓超

x

... ... @@ -86,6 +86,20 @@ class MailListV2 extends Base {
}
/**
* 处理like条件
* @param $str
* @return string
* @author:dc
* @time 2024/9/4 11:14
*/
private function getLikeStr($str){
if(str_starts_with($str, '^')){
return addslashes($str).'%%';
}
return '%%'.addslashes($str).'%%';
}
/**
* 邮件列表
* 接收参数
* page 分页
... ... @@ -182,7 +196,7 @@ class MailListV2 extends Base {
if($subject){
$subject = is_array($subject) ? $subject : [$subject];
foreach ($subject as $k=>$sub){
$subject[$k] = '`subject` '.(empty($is_auto_inbox)?' not ':'').'like "%%'.addslashes($sub).'%%"';
$subject[$k] = '`subject` '.(empty($is_auto_inbox)?' not ':'').'like "'.$this->getLikeStr($sub).'"';
}
}
// 不在此邮箱中的
... ... @@ -190,7 +204,7 @@ class MailListV2 extends Base {
if($from_not_in_like){
$from_not_in_like = is_array($from_not_in_like) ? $from_not_in_like : [$from_not_in_like];
foreach ($from_not_in_like as $k=>$sub){
$from_not_in_like[$k] = '`from` '.(empty($is_auto_inbox)?' not ':'').'like "%%'.addslashes($sub).'%%"';
$from_not_in_like[$k] = '`from` '.(empty($is_auto_inbox)?' not ':'').'like "'.$this->getLikeStr($sub).'"';
}
}
... ... @@ -291,7 +305,7 @@ class MailListV2 extends Base {
if($subject){
$subject = is_array($subject) ? $subject : [$subject];
foreach ($subject as $k=>$sub){
$subject[$k] = '`subject` not like "%%'.addslashes($sub).'%%"';
$subject[$k] = '`subject` not like "'.$this->getLikeStr($sub).'"';
}
}
// 不在此邮箱中的
... ... @@ -299,7 +313,7 @@ class MailListV2 extends Base {
if($from_not_in_like){
$from_not_in_like = is_array($from_not_in_like) ? $from_not_in_like : [$from_not_in_like];
foreach ($from_not_in_like as $k=>$sub){
$from_not_in_like[$k] = '`from` not like "%%'.addslashes($sub).'%%"';
$from_not_in_like[$k] = '`from` not like "'.$this->getLikeStr($sub).'"';
}
}
... ...