1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- /**
- * 由于钉釘现在接口限流了 没办法这边写一个接收器 作为接收需要监听信息的日志记录
- * 除此之外也开始监听其他错误
- */
- class Errorlog extends Start_Controller {
- private $ip = ['127.0.0.1','47.105.156.18'];
- public function __construct(){
- parent::__construct();
- $this->load->_model("Model_logic_tools","logic_tools");
- $this->load->_model("Model_logic_ding","logic_ding");
- $this->load->_model("Model_zzerrlog","zzerrlog");
- $this->load->_model("Model_zzjobs","zzjobs");
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- if(!in_array($ip,$this->ip)){
- exit("Unauthorized access");
- }
- if($arg == 'ding')//添加
- {
- $this->_ding();
- }
- elseif($arg == 'printouttime')//
- {
- $this->_print_outtime();
- }
- else
- {
- die('No direct script access allowed');
- }
- }
- public function _ding(){
- //$ip = $_SERVER['REMOTE_ADDR']; 后期仅仅限制部署服务器的ip就好
- $param = json_decode(file_get_contents('php://input'), true);
- $key = $param['bs'];//核验秘钥
-
- $key = $this->logic_tools->toolsjiemi($key);
-
- $check_key = $this->logic_ding->getKey();
-
- if($check_key != $key){
- die('No direct script access allowed');
- }
- $content = $param['content'];
- if(!is_string( $content)){
- $content = json_encode($content);
- }
- //保存要监听的数据到日志表中
- $this->zzerrlog->insert([
- 'content'=>$content,
- 'created_time'=>date("Y-m-d H:i:s"),
- 'time'=>time(),
- ]);
- }
- public function _print_outtime(){
- $number = $this->input->get('number');
- if(empty($number)){
- echo "SUCCESS";
- }else{
- $this->zzjobs->insert([
- 'status'=>0,
- 'quque'=>"outtime_order",
- 'payload'=>json_encode(['number'=>$number]),
- 'do_interval'=>1,
- 'create_time'=>time(),
- ]);
- echo "SUCCESS";
- }
- }
- }
|