正在显示
4 个修改的文件
包含
36 行增加
和
14 行删除
| @@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
| 9 | "ext-redis": "*", | 9 | "ext-redis": "*", | 
| 10 | "ext-mbstring": "*", | 10 | "ext-mbstring": "*", | 
| 11 | "ext-json": "*", | 11 | "ext-json": "*", | 
| 12 | + "ext-iconv": "*", | ||
| 12 | "phpmailer/phpmailer": "^6.7" | 13 | "phpmailer/phpmailer": "^6.7" | 
| 13 | }, | 14 | }, | 
| 14 | "require-dev": { | 15 | "require-dev": { | 
| @@ -49,7 +49,7 @@ class App { | @@ -49,7 +49,7 @@ class App { | ||
| 49 | * 输出到前端的数据 | 49 | * 输出到前端的数据 | 
| 50 | * @var mixed | 50 | * @var mixed | 
| 51 | */ | 51 | */ | 
| 52 | - private mixed $data; | 52 | + private mixed $data = []; | 
| 53 | 53 | ||
| 54 | /** | 54 | /** | 
| 55 | * 表单文件 | 55 | * 表单文件 | 
| @@ -274,16 +274,26 @@ class App { | @@ -274,16 +274,26 @@ class App { | ||
| 274 | } | 274 | } | 
| 275 | 275 | ||
| 276 | 276 | ||
| 277 | - | 277 | + /** | 
| 278 | + * @param $data | ||
| 279 | + * @param int $http_code | ||
| 280 | + * @author:dc | ||
| 281 | + * @time 2023/3/27 10:53 | ||
| 282 | + */ | ||
| 278 | public static function echo($data, $http_code = 200){ | 283 | public static function echo($data, $http_code = 200){ | 
| 279 | 284 | ||
| 285 | + | ||
| 286 | + if(php_sapi_name()=='cli'){ | ||
| 287 | + return $data; | ||
| 288 | + } | ||
| 289 | + | ||
| 280 | http_response_code($http_code); | 290 | http_response_code($http_code); | 
| 281 | 291 | ||
| 282 | if(is_array($data)){ | 292 | if(is_array($data)){ | 
| 283 | - header("Content-Type:application/json;Charset=UTF-8;"); | 293 | + @header("Content-Type:application/json;Charset=UTF-8;"); | 
| 284 | echo json_encode($data,JSON_UNESCAPED_UNICODE); | 294 | echo json_encode($data,JSON_UNESCAPED_UNICODE); | 
| 285 | }else{ | 295 | }else{ | 
| 286 | - header("Content-Type:text/html;Charset=UTF-8;"); | 296 | + @header("Content-Type:text/html;Charset=UTF-8;"); | 
| 287 | echo $data; | 297 | echo $data; | 
| 288 | } | 298 | } | 
| 289 | } | 299 | } | 
| @@ -617,8 +617,9 @@ class Imap { | @@ -617,8 +617,9 @@ class Imap { | ||
| 617 | foreach($matches as $match){ | 617 | foreach($matches as $match){ | 
| 618 | $match[2] = str_replace(['_(_(_(_0_)_)_)_'],[':'],$match[2]); | 618 | $match[2] = str_replace(['_(_(_(_0_)_)_)_'],[':'],$match[2]); | 
| 619 | if(strpos($match[2],'=?')!==false){ | 619 | if(strpos($match[2],'=?')!==false){ | 
| 620 | - $match2=iconv_mime_decode($match[2],ICONV_MIME_DECODE_CONTINUE_ON_ERROR,'utf-8'); | ||
| 621 | - $match[2] = $match2; | 620 | + $match[2] = mb_decode_mimeheader($match[2]); | 
| 621 | +// $match2=iconv_mime_decode($match[2],ICONV_MIME_DECODE_CONTINUE_ON_ERROR,'utf-8'); | ||
| 622 | +// if($match2) $match[2] = $match2; | ||
| 622 | } | 623 | } | 
| 623 | 624 | ||
| 624 | if(isset($headers[$match[1]]) && is_array($headers[$match[1]])){ | 625 | if(isset($headers[$match[1]]) && is_array($headers[$match[1]])){ | 
| @@ -317,18 +317,28 @@ class Mail { | @@ -317,18 +317,28 @@ class Mail { | ||
| 317 | $body = $body[0]['RFC822.TEXT']??''; | 317 | $body = $body[0]['RFC822.TEXT']??''; | 
| 318 | 318 | ||
| 319 | if(!empty($body)){ | 319 | if(!empty($body)){ | 
| 320 | - $db->insert(bodySql::$table,[ | ||
| 321 | - 'lists_id' => $id, | ||
| 322 | - 'text_html' => base64_encode(json_encode($body)) // todo::因为邮件会出现多编码问题,会导致数据库写不进去 | ||
| 323 | - ],false); | ||
| 324 | - | ||
| 325 | $description = ''; | 320 | $description = ''; | 
| 326 | - foreach ($body as $item){ | ||
| 327 | - if(in_array($item['type'],['text/html','text/plain'])){ | 321 | + foreach ($body as $key=>$item){ | 
| 322 | + if(!$description && in_array($item['type'],['text/html','text/plain'])){ | ||
| 328 | $description = mb_substr(trim(strip_tags($item['body'])),0,190); | 323 | $description = mb_substr(trim(strip_tags($item['body'])),0,190); | 
| 329 | - break; | ||
| 330 | } | 324 | } | 
| 325 | + if(!empty($body[$key]['body'])){ | ||
| 326 | + $body[$key]['body'] = base64_encode($body[$key]['body']); | ||
| 327 | + } | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + try { | ||
| 331 | + $db->insert(bodySql::$table,[ | ||
| 332 | + 'lists_id' => $id, | ||
| 333 | + 'text_html' => $body // todo::因为邮件会出现多编码问题,会导致数据库写不进去 | ||
| 334 | + ],false); | ||
| 335 | + }catch (\Throwable $e){ | ||
| 336 | + $db->update(bodySql::$table,[ | ||
| 337 | + 'text_html' => $body // todo::因为邮件会出现多编码问题,会导致数据库写不进去 | ||
| 338 | + ],dbWhere(['lists_id' => $id]),false); | ||
| 331 | } | 339 | } | 
| 340 | + | ||
| 341 | + | ||
| 332 | // 更新描述 | 342 | // 更新描述 | 
| 333 | $db->update(listsSql::$table,[ | 343 | $db->update(listsSql::$table,[ | 
| 334 | 'description' => $description | 344 | 'description' => $description | 
- 
请 注册 或 登录 后发表评论