作者 邓超

调优

@@ -16,4 +16,6 @@ public/storage @@ -16,4 +16,6 @@ public/storage
16 cmd/*.log 16 cmd/*.log
17 *.log 17 *.log
18 .htaccess 18 .htaccess
19 -404.html  
  19 +404.html
  20 +shell
  21 +public/svg
  1 +<?php
  2 +// 这个是提交脚本
  3 +\Co\run(function(){
  4 + while (1){
  5 + $body = db()->first("select * from `bodies` limit 1 ");
  6 + if(!$body || $body['lists_id']>300000000){
  7 + echo "执行完成\n";
  8 + break;
  9 + }
  10 +
  11 + $d = 0;
  12 + $len = \Swlib\SaberGM::post('http://172.19.0.5:9527?id='.$body['lists_id'],['body'=>$body['text_html']])->getBody()->getContents();
  13 + if(is_numeric($len)&&$len){
  14 + $d = db()->delete('bodies',['lists_id'=>$body['lists_id']]);
  15 + }
  16 + _echo('成功 '.$body['lists_id'].' == '.$d.' == '.$len);
  17 +
  18 +
  19 + }
  20 +
  21 +});
  22 +
  23 +// 这个是读取备份内容
  24 +\Co\run(function(){
  25 +
  26 + $body = \Swlib\SaberGM::get('http://172.19.0.5:9527?id='.$body['lists_id'])->getBody()->getContents();
  27 +
  28 +});
  29 +
  30 +exit();
  31 +?>
  32 +
  33 +这里是2个文件哦
  34 +------------------------------------------------------------------------------
  35 +
  36 +<?php
  37 +
  38 +/**
  39 + * 这个是一个http服务,邮件服务的body内容太大了,把body内容备份到其他服务器,
  40 + * 其他服务器放入这个代码 并运行
  41 + * 走内网 提交数据
  42 + * post 为提交
  43 + * get 为获取
  44 + *
  45 + */
  46 +
  47 +
  48 +
  49 +ini_set("memory_limit", "512M");
  50 +
  51 +// 关闭错误提示 其实这个可有可无 显示了错误也不会输出到前端
  52 +//ini_set("display_errors","off");
  53 +// 错误级别
  54 +error_reporting(E_ALL);
  55 +
  56 +// 时区设置
  57 +date_default_timezone_set('Asia/Shanghai');
  58 +
  59 +// 定义 root 目录
  60 +define('root_path', __DIR__);
  61 +
  62 +
  63 +
  64 +/**
  65 + * 服务
  66 + * @author:dc
  67 + * @time 2025/4/18 15:44
  68 + * Class mmd_serv
  69 + */
  70 +class mmd_serv
  71 +{
  72 +
  73 + /**
  74 + * 这个是http服务,对外的
  75 + * @var Swoole\Http\Server
  76 + */
  77 + private $server;
  78 +
  79 +
  80 + public function __construct()
  81 + {
  82 +
  83 + $this->init_http();
  84 + }
  85 +
  86 +
  87 + /**
  88 + * 前端请求处理
  89 + * @param \Swoole\Http\Request $request
  90 + * @param \Swoole\Http\Response $response
  91 + * @author:dc
  92 + * @time 2025/4/30 15:42
  93 + */
  94 + public function request(\Swoole\Http\Request $request, \Swoole\Http\Response $response)
  95 + {
  96 +
  97 + $len = 0;
  98 + if($request->server['request_uri']){
  99 +
  100 + }
  101 + // print_r($request->get);
  102 + $id = intval($request->get['id']??0);
  103 + $path = root_path.'/mail/'.($id%10000).'/'.$id.'.log';
  104 +
  105 + $m = strtoupper($request->getMethod());
  106 + // get 获取数据
  107 + if($m=='GET'){
  108 + $len = file_get_contents($path);
  109 + }
  110 + // 删除数据
  111 + elseif($m == 'DELETE'){
  112 + $len = unlink($path)?1:0;
  113 + }
  114 + elseif($m == 'POST'){
  115 + $body = $request->post['body']??'';
  116 + if($id && $body){
  117 +
  118 + if(!is_dir(dirname($path))){
  119 + mkdir(dirname($path),0775,true);
  120 + }
  121 + $len = file_put_contents($path,$body);
  122 + }
  123 + }
  124 +
  125 + $response->header("Content-Type", 'text/html; charset=UTF-8');
  126 + $response->end($len);
  127 +
  128 + }
  129 +
  130 +
  131 +
  132 + /**
  133 + * 初始
  134 + * @author:dc
  135 + * @time 2025/4/30 14:50
  136 + */
  137 + private function init_http()
  138 + {
  139 + // 实例一个服务
  140 + $this->server = new Swoole\Http\Server("0.0.0.0", 9527);
  141 + // 服务设置
  142 + $this->server->set([
  143 + // 'open_http2_protocol' => true, // http2协议
  144 + // 'log_file' => __DIR__.'/error.log',
  145 + // 'log_level' => 0,
  146 + 'package_max_length' => 20 * 1024 * 1024, // 可以post多大数据
  147 + // 'daemonize' => true
  148 + ]);
  149 +
  150 + // 前端请求时
  151 + $this->server->on('request', [$this, 'request']);
  152 +
  153 +
  154 + }
  155 +
  156 +
  157 + /**
  158 + * 启动http 服务
  159 + * @author:dc
  160 + * @time 2025/5/10 21:57
  161 + */
  162 + public function start()
  163 + {
  164 + $this->server->start();
  165 + }
  166 +
  167 +}
  168 +
  169 +
  170 +(new mmd_serv())->start();
@@ -26,7 +26,7 @@ class SyncMail { @@ -26,7 +26,7 @@ class SyncMail {
26 public function __construct(int $id, array $data) 26 public function __construct(int $id, array $data)
27 { 27 {
28 28
29 - $this->db = db(); 29 +// $this->db = db();
30 30
31 if($data['is_hots']){ 31 if($data['is_hots']){
32 return true; 32 return true;
@@ -34,18 +34,15 @@ class SyncMail { @@ -34,18 +34,15 @@ class SyncMail {
34 34
35 35
36 // 是否在指定文件夹内 36 // 是否在指定文件夹内
37 - $f = $this->db->value(folderSql::first($data['folder_id'],'folder'));  
38 - if(!$f){  
39 - return true;  
40 - }  
41 - $f = folderAlias($f); 37 +// $f = $this->db->value(folderSql::first($data['folder_id'],'folder'));
  38 +// if(!$f){
  39 +// return true;
  40 +// }
  41 +// $f = folderAlias($f);
42 42
43 43
44 // 不是预热邮箱 44 // 不是预热邮箱
45 - if($f=='收件箱'){  
46 -  
47 - // $this->auto_mail($id,$data);  
48 - 45 +// if($f=='收件箱'){
49 46
50 // 邮件过滤 这些邮箱都是系统邮箱 47 // 邮件过滤 这些邮箱都是系统邮箱
51 // if(!$this->checkEmail($data['from']) && !$this->checkSubject($data['subject'])){ 48 // if(!$this->checkEmail($data['from']) && !$this->checkSubject($data['subject'])){
@@ -68,82 +65,7 @@ class SyncMail { @@ -68,82 +65,7 @@ class SyncMail {
68 } 65 }
69 66
70 67
71 - }  
72 -  
73 -  
74 - }  
75 -  
76 -  
77 -  
78 - /**  
79 - * 自动回复邮箱  
80 - * @param $id  
81 - * @param $data  
82 - * @author:dc  
83 - * @time 2024/9/12 15:29  
84 - */  
85 - private function auto_mail($id,$data){  
86 -  
87 - $filter = redis()->get('ai_email_filter_lists',[]);  
88 - if(!$filter || !is_array($filter)){  
89 - $filter = '2 Automatic reply  
90 -2 Delivery  
91 -2 Automatische Antwort  
92 -2 Undeliverable  
93 -2 Failure  
94 -2 Undelivered  
95 -1 noreply  
96 -1 postmaster  
97 -1 email-notifications  
98 -1 mailer-daemon  
99 -1 no-reply  
100 -2 自动回复  
101 -2 Returned mail  
102 -2 Autosvar  
103 -2 Out Of Office Re  
104 -2 Change_of_email_address  
105 -2 delivered  
106 -2 automatique  
107 -2 Reply auto  
108 -2 automatic  
109 -2 Request received  
110 -2 Automatisch  
111 -2 Unzustellbar  
112 -2 Notification  
113 -2 Invitation  
114 -2 Automatyczna  
115 -2 代开  
116 -2 expired';  
117 - $filter = explode("\n",$filter);  
118 - $filter = array_map(function ($v){  
119 - list($t,$str) = [  
120 - intval(mb_substr($v,0,1)),  
121 - trim(mb_substr($v,1,99)),  
122 - ];  
123 - return [$t,$str];  
124 - },$filter);  
125 - }  
126 -  
127 - foreach ($filter as $f){  
128 -  
129 - $t = $f[0]??''; // 类型  
130 - $str = $f[1]??''; // 值  
131 - if(!$str) continue;  
132 -  
133 - $haystack = '';  
134 - if($t==2){  
135 - $haystack = $data['subject'];  
136 - }elseif ($t==1){  
137 - $haystack = $data['from'];  
138 - }  
139 - if(stripos($haystack,$str)!==false){  
140 - try {  
141 - $this->db->create('lists_auto',['list_id'=>$id],false);  
142 - }catch (\Throwable $e){}  
143 - break;  
144 - }  
145 - }  
146 - 68 +// }
147 69
148 70
149 } 71 }
@@ -16,6 +16,7 @@ use Model\bodySql; @@ -16,6 +16,7 @@ use Model\bodySql;
16 use Model\emailSql; 16 use Model\emailSql;
17 use Model\folderSql; 17 use Model\folderSql;
18 use Model\listsSql; 18 use Model\listsSql;
  19 +use Swlib\SaberGM;
19 20
20 /** 21 /**
21 * 同步邮件 22 * 同步邮件
@@ -528,12 +529,26 @@ class SyncMail { @@ -528,12 +529,26 @@ class SyncMail {
528 } 529 }
529 530
530 // 新邮件标记 531 // 新邮件标记
531 - if($item->getFolderName() == 'INBOX') 532 + if($item->getFolderName() == 'INBOX' && !$data['is_hots']){
532 redis()->incr('have_new_mail_'.$this->emailId(),120); 533 redis()->incr('have_new_mail_'.$this->emailId(),120);
533 - // 执行事件  
534 - $data['Aicc-Hot-Mail'] = $item->header->get('Aicc-Hot-Mail'); 534 + // 通知
  535 + if(stripos(trim($data['subject']),'re:')===0){
  536 + // 通知黑格 2024-08-22 新上 这个是异步的不会阻塞当前进程
  537 + try {
  538 + SaberGM::post('https://fob.ai.cc/api/email_new_push',[
  539 + 'sign' => md5(date('ymd').'fob.ai.cc.email'),
  540 + 'id' => $id,
  541 + 'subject' => $data['subject'],
  542 + 'udate' => $data['udate'],
  543 + 'from' => $data['from'],
  544 + 'tos' => array_column($data['to_name'],'email')
  545 + ]);
  546 + }catch (\Throwable $e){
  547 + // 就算异常了也不在推送了
  548 + }
535 549
536 - Event::call('mail_sync_list',$id, $data); 550 + }
  551 + }
537 552
538 } 553 }
539 else{ 554 else{