|
@@ -145,13 +145,13 @@ class Imap { |
|
@@ -145,13 +145,13 @@ class Imap { |
145
|
* 调试模式
|
145
|
* 调试模式
|
146
|
* @var bool
|
146
|
* @var bool
|
147
|
*/
|
147
|
*/
|
148
|
- private $debug = false;
|
148
|
+ static bool $debug = false;
|
149
|
|
149
|
|
150
|
/**
|
150
|
/**
|
151
|
* 调试,记录日志的目录
|
151
|
* 调试,记录日志的目录
|
152
|
* @var string
|
152
|
* @var string
|
153
|
*/
|
153
|
*/
|
154
|
- private $debugWritePath = '';
|
154
|
+ static string $debugWritePath = '';
|
155
|
|
155
|
|
156
|
/**
|
156
|
/**
|
157
|
* 登录imap服务器
|
157
|
* 登录imap服务器
|
|
@@ -1052,8 +1052,8 @@ class Imap { |
|
@@ -1052,8 +1052,8 @@ class Imap { |
1052
|
* @time 2022/12/6 11:10
|
1052
|
* @time 2022/12/6 11:10
|
1053
|
*/
|
1053
|
*/
|
1054
|
public function debug($debug=true,$logPath=''){
|
1054
|
public function debug($debug=true,$logPath=''){
|
1055
|
- $this->debug = $debug;
|
|
|
1056
|
- $this->debugWritePath = $logPath ? $logPath : LOG_PATH;
|
1055
|
+ $this::$debug = $debug;
|
|
|
1056
|
+ $this::$debugWritePath = $logPath ? $logPath : LOG_PATH;
|
1057
|
}
|
1057
|
}
|
1058
|
|
1058
|
|
1059
|
/**
|
1059
|
/**
|
|
@@ -1063,11 +1063,16 @@ class Imap { |
|
@@ -1063,11 +1063,16 @@ class Imap { |
1063
|
* @time 2022/12/6 11:13
|
1063
|
* @time 2022/12/6 11:13
|
1064
|
*/
|
1064
|
*/
|
1065
|
private function log(string $message){
|
1065
|
private function log(string $message){
|
1066
|
- if($this->debug){
|
|
|
1067
|
- if(!is_dir($this->debugWritePath)){
|
|
|
1068
|
- @mkdir($this->debugWritePath,0775,true);
|
1066
|
+ if($this::$debug){
|
|
|
1067
|
+ if($this::$debugWritePath == 'echo'){
|
|
|
1068
|
+ echo $message."\n";
|
|
|
1069
|
+ }else{
|
|
|
1070
|
+ if(!is_dir($this::$debugWritePath)){
|
|
|
1071
|
+ @mkdir($this::$debugWritePath,0775,true);
|
|
|
1072
|
+ }
|
|
|
1073
|
+ @file_put_contents($this::$debugWritePath.'/imap.log',date('Y-m-d H:i:s ').$message.PHP_EOL,FILE_APPEND);
|
1069
|
}
|
1074
|
}
|
1070
|
- @file_put_contents($this->debugWritePath.'/imap.log',date('Y-m-d H:i:s ').$message.PHP_EOL,FILE_APPEND);
|
1075
|
+
|
1071
|
}
|
1076
|
}
|
1072
|
}
|
1077
|
}
|
1073
|
|
1078
|
|
|
@@ -1131,6 +1136,9 @@ class Imap { |
|
@@ -1131,6 +1136,9 @@ class Imap { |
1131
|
if($status == 'bad'){
|
1136
|
if($status == 'bad'){
|
1132
|
logs($cmd);
|
1137
|
logs($cmd);
|
1133
|
throw new \Exception('request bad:'.$line);
|
1138
|
throw new \Exception('request bad:'.$line);
|
|
|
1139
|
+ }elseif($status == 'no'){
|
|
|
1140
|
+ logs($cmd);
|
|
|
1141
|
+ throw new \Exception('命令失败 NO:'.$line);
|
1134
|
}
|
1142
|
}
|
1135
|
}else{
|
1143
|
}else{
|
1136
|
if(!preg_match("/^\*\s\w/",$line)){
|
1144
|
if(!preg_match("/^\*\s\w/",$line)){
|