| 
...
 | 
...
 | 
@@ -472,55 +472,63 @@ function folder2int($folder):int { | 
| 
 | 
 | 
  * @author:dc
 | 
| 
 | 
 | 
  * @time 2025/6/11 10:49
 | 
| 
 | 
 | 
  */
 | 
| 
 | 
 | 
 function isAiAutoMail($from,$subject,$body=''){
 | 
| 
 | 
 | 
 function isAiAutoMail($from,$subject,$body='',$return_keyword=false){
 | 
| 
 | 
 | 
     // 读取fob设置的过滤词
 | 
| 
 | 
 | 
     $temp = function ($re = false){
 | 
| 
 | 
 | 
         $filter = redis()->get('ai_email_filter_lists',[]);
 | 
| 
 | 
 | 
     $temp = function ($type = 0){
 | 
| 
 | 
 | 
         $type = $type?1:0; // 是否白名单
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $filter = redis()->get('fob:ai_email_filter_lists'.$type,[]);
 | 
| 
 | 
 | 
         $filter = is_array($filter) ? $filter : [];
 | 
| 
 | 
 | 
         if($filter && !$re){
 | 
| 
 | 
 | 
             return $filter;
 | 
| 
 | 
 | 
         if(!$filter){
 | 
| 
 | 
 | 
             try {
 | 
| 
 | 
 | 
                 $filter = fob_mysql()->throw()->all('select `type`,`text` from `email_filter_rule` where `is_white` = '.$type);
 | 
| 
 | 
 | 
             }catch (Throwable $e){
 | 
| 
 | 
 | 
                 $filter = redis()->get('fob:ai_email_filter_lists_a'.$type,[]);
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
         $redisfilter = $filter;
 | 
| 
 | 
 | 
             // 7天过期的
 | 
| 
 | 
 | 
             redis()->set('fob:ai_email_filter_lists_a'.$type,$filter,86400*7);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $filter = @file_get_contents('https://fob.ai.cc/api/mail/ai_inbox_filter/'.md5('aicc.'.date('ymdh')));
 | 
| 
 | 
 | 
         $filter = @json_decode($filter,true);
 | 
| 
 | 
 | 
         if(!is_array($filter)){
 | 
| 
 | 
 | 
             if($redisfilter){
 | 
| 
 | 
 | 
                 return $redisfilter;
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
             return [];
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
             $filters = [];
 | 
| 
 | 
 | 
             array_map(function ($v) use (&$filters){
 | 
| 
 | 
 | 
             $filters[] = [
 | 
| 
 | 
 | 
                 $v['type'],
 | 
| 
 | 
 | 
                 $v['text'],
 | 
| 
 | 
 | 
             ];
 | 
| 
 | 
 | 
         },$filter[0]);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                 $filters[] = [$v['type'], $v['text'],];
 | 
| 
 | 
 | 
             },$filter);
 | 
| 
 | 
 | 
             if($filters){
 | 
| 
 | 
 | 
             redis()->set('ai_email_filter_lists',$filters,86400);
 | 
| 
 | 
 | 
                 // 5分钟过期的
 | 
| 
 | 
 | 
                 redis()->set('fob:ai_email_filter_lists'.$type,$filters,300);
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
             return  $filters;
 | 
| 
 | 
 | 
         }else{
 | 
| 
 | 
 | 
             return $filter;
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
     };
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     // 是否是更新索引
 | 
| 
 | 
 | 
     if($from===true&&$subject===true) {
 | 
| 
 | 
 | 
         return $temp(true);
 | 
| 
 | 
 | 
         return $temp();
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
     $haystacks = [
 | 
| 
 | 
 | 
         1   =>  $from,
 | 
| 
 | 
 | 
         2   =>  $subject,
 | 
| 
 | 
 | 
         3   =>  $body,
 | 
| 
 | 
 | 
     ];
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     // 是否是自动回复
 | 
| 
 | 
 | 
     foreach ($temp() as $f){
 | 
| 
 | 
 | 
     // 是否在白名单
 | 
| 
 | 
 | 
     foreach ($temp(1) as $f){
 | 
| 
 | 
 | 
         list($t,$str) = $f;
 | 
| 
 | 
 | 
         $haystack = '';
 | 
| 
 | 
 | 
         if($t==2){
 | 
| 
 | 
 | 
             $haystack = $subject;
 | 
| 
 | 
 | 
         }elseif ($t==1){
 | 
| 
 | 
 | 
             $haystack = $from;
 | 
| 
 | 
 | 
         }elseif ($t==3&&$body){
 | 
| 
 | 
 | 
             $haystack = $body;
 | 
| 
 | 
 | 
         $haystack = $haystacks[$t]??'';
 | 
| 
 | 
 | 
         if($haystack && $str && stripos($haystack,$str)!==false){
 | 
| 
 | 
 | 
             return 0;
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     // 是否在黑名单中
 | 
| 
 | 
 | 
     foreach ($temp() as $f){
 | 
| 
 | 
 | 
         list($t,$str) = $f;
 | 
| 
 | 
 | 
         $haystack = $haystacks[$t]??'';
 | 
| 
 | 
 | 
         if($haystack && $str && stripos($haystack,$str)!==false){
 | 
| 
 | 
 | 
             if($return_keyword){
 | 
| 
 | 
 | 
                 return $str;
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
             return 1;
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
     }
 | 
...
 | 
...
 | 
 |