Jelajahi Sumber

修改日志记录方式 然后替换日志表

lvhao 1 Minggu lalu
induk
melakukan
77f0ea5e3c
1 mengubah file dengan 42 tambahan dan 42 penghapusan
  1. 42 42
      core/CoreApp/models/Model_logic_ding.php

+ 42 - 42
core/CoreApp/models/Model_logic_ding.php

@@ -18,54 +18,54 @@ class Model_logic_ding extends Lin_Model {
         return $this->key;
     }
 
-    public function sendToDing($error_msg){
-        $this->zzerrlog->insert([
-            'content'=>$error_msg,
-            'created_time'=>date("Y-m-d H:i:s"),
-            'time'=>time(),      
-        ]);
-    }
-    // public $url = "https://1.wepolicy.cn/errorlog/ding";
-   
     // public function sendToDing($error_msg){
-    //     $data = [
-    //         'bs'=>$this->logic_tools->toolsjiami($this->key),
+    //     $this->zzerrlog->insert([
     //         'content'=>$error_msg,
-    //     ];
-    //     $data = json_encode($data,JSON_UNESCAPED_UNICODE);
-    //     $ch = curl_init($this->url);
-    //     // 设置cURL选项 
-    //     $options = array(
-    //         CURLOPT_SSL_VERIFYPEER=>false,
-    //         CURLOPT_SSL_VERIFYHOST=>false,
-    //         CURLOPT_RETURNTRANSFER => true,   
-    //         CURLOPT_POST => true,             
-    //         CURLOPT_POSTFIELDS => $data,  
-    //         CURLOPT_HTTPHEADER => [
-    //             'Content-Type: application/json'
-    //         ],
-    //         CURLOPT_ENCODING => "gzip,deflate"
-    //     );
-    //     // 应用这些选项到cURL会话
-    //     curl_setopt_array($ch, $options);
+    //         'created_time'=>date("Y-m-d H:i:s"),
+    //         'time'=>time(),      
+    //     ]);
+    // }
+    public $url = "https://1.wepolicy.cn/errorlog/ding";
+   
+    public function sendToDing($error_msg){
+        $data = [
+            'bs'=>$this->logic_tools->toolsjiami($this->key),
+            'content'=>$error_msg,
+        ];
+        $data = json_encode($data,JSON_UNESCAPED_UNICODE);
+        $ch = curl_init($this->url);
+        // 设置cURL选项 
+        $options = array(
+            CURLOPT_SSL_VERIFYPEER=>false,
+            CURLOPT_SSL_VERIFYHOST=>false,
+            CURLOPT_RETURNTRANSFER => true,   
+            CURLOPT_POST => true,             
+            CURLOPT_POSTFIELDS => $data,  
+            CURLOPT_HTTPHEADER => [
+                'Content-Type: application/json'
+            ],
+            CURLOPT_ENCODING => "gzip,deflate"
+        );
+        // 应用这些选项到cURL会话
+        curl_setopt_array($ch, $options);
 
-    //     // 执行cURL会话并获取响应
-    //     $response = curl_exec($ch);
+        // 执行cURL会话并获取响应
+        $response = curl_exec($ch);
        
         
-    //       // 检查是否有错误发生
-    //    if ($response === false) {
-    //        $error = curl_error($ch);
-    //        curl_close($ch);
-    //        return [
-    //            "code"=> -1,
-    //            "msg"=> $error
-    //        ];
-    //    }
+          // 检查是否有错误发生
+       if ($response === false) {
+           $error = curl_error($ch);
+           curl_close($ch);
+           return [
+               "code"=> -1,
+               "msg"=> $error
+           ];
+       }
       
-    //    // 关闭cURL会话
-    //    curl_close($ch);  
-    // }
+       // 关闭cURL会话
+       curl_close($ch);  
+    }
     /**
      * 添加到执行队列上
      */