Exemplo n.º 1
0
 public function actionIndex()
 {
     $model = Configure::findOne(['type' => 1]);
     //新时时彩
     $modelOld = Configure::findOne(['type' => 2]);
     //重庆时时彩 数据包1 报警设置
     $modelCq2 = Configure::findOne(['type' => 22]);
     //重庆时时彩 数据包2 报警设置
     $modelTj = Configure::findOne(['type' => 3]);
     //天津时时彩 数据包1 报警设置
     $modelTj2 = Configure::findOne(['type' => 33]);
     //天津时时彩 数据包2 报警设置
     $modelXj = Configure::findOne(['type' => 4]);
     //新疆时时彩 数据包1 报警设置
     $modelXj2 = Configure::findOne(['type' => 44]);
     //新疆时时彩 数据包2 报警设置
     if (Yii::$app->request->isPost) {
         $post = Yii::$app->request->post('Configure');
         $type = $post['type'];
         if ($type == 1) {
             $model = $model;
             //新时时彩
         }
         if ($type == 2) {
             $model = $modelOld;
             //重庆时时彩 数据包1 报警设置
         }
         if ($type == 22) {
             $model = $modelCq2;
             //重庆时时彩 数据包2 报警设置
         }
         if ($type == 3) {
             $model = $modelTj;
             //天津时时彩 数据包1 报警设置
         }
         if ($type == 33) {
             $model = $modelTj2;
             //天津时时彩 数据包2 报警设置
         }
         if ($type == 4) {
             $model = $modelXj;
             //新疆时时彩 数据包1 报警设置
         }
         if ($type == 44) {
             $model = $modelXj2;
             //新疆时时彩 数据包2 报警设置
         }
         $model->load(Yii::$app->request->post());
         if ($model->validate() && $model->save()) {
             return $this->render('index', ['msg' . $type => '修改成功', 'model' => $model, 'modelOld' => $modelOld, 'modelCq2' => $modelCq2, 'modelTj' => $modelTj, 'modelTj2' => $modelTj2, 'modelXj' => $modelXj, 'modelXj2' => $modelXj2]);
         }
     }
     return $this->render('index', ['model' => $model, 'modelOld' => $modelOld, 'modelCq2' => $modelCq2, 'modelTj' => $modelTj, 'modelTj2' => $modelTj2, 'modelXj' => $modelXj, 'modelXj2' => $modelXj2]);
 }
Exemplo n.º 2
0
 function find($qihao, $urlName, $codeArr, $code_id)
 {
     sort($codeArr);
     //数组从小到大排序 用户需求
     //数据分析
     $config = Configure::findOne(['type' => 1]);
     //系统报警配置
     //记录中奖与未中奖号码
     $model = Comparison::findOne(['type' => 1]);
     $data = $model->txt;
     $dataTxts = str_replace("\r\n", ' ', $data);
     //将回车转换为空格
     $dataArr = explode(' ', $dataTxts);
     $dataArr = array_filter($dataArr);
     $dataArr = array_chunk($dataArr, 5);
     //当前开奖号码 对比 数据库
     $lucky = array();
     //中奖号
     $regret = $dataArr;
     //未中奖号
     foreach ($dataArr as $key => $val) {
         sort($val);
         // 从小到大排序
         if ($codeArr == $val) {
             //中奖号组
             array_push($lucky, $val);
             unset($regret[$key]);
         }
     }
     //将中奖与未中奖的数组 转换为用户上传数据本的 格式 存入数据库
     $luckyStr = null;
     $regretStr = null;
     if (count($lucky) != 0) {
         //有中奖号码 记录数据库
         foreach ($lucky as $luc) {
             foreach ($luc as $l) {
                 $luckyStr .= $l . ' ';
             }
             $luckyStr .= "\r\n";
         }
     }
     if (count($regret) != 0) {
         //有未中奖号码 记录数据库
         foreach ($regret as $reg) {
             foreach ($reg as $r) {
                 $regretStr .= $r . ' ';
             }
             $regretStr .= "\r\n";
         }
     }
     //分析数据本与当前这期开奖号码 记录数据本里面 中奖号码与未中奖的号码 到数据库中
     $analysis = new Analysis();
     $analysis->codi_id = $code_id;
     $analysis->lucky_txt = $luckyStr;
     $analysis->regret_txt = $regretStr;
     $analysis->data_txt = $data;
     $analysis->time = time();
     $analysis->save();
     if ($config->state == 1) {
         //系统开启邮件 通知
         if (date('H', time()) > intval($config->start_time) && date('H', time()) < intval($config->end_time)) {
             //            if(true){
             //报警时间段内
             if ($config->forever == 1) {
                 //每一期 邮件通知打开
                 $cfg = array('type' => 1, 'qihao' => $qihao, 'codeArr' => $codeArr, 'urlName' => $urlName, 'luckyStr' => $luckyStr, 'regretStr' => $regretStr);
                 $this->send($cfg);
             }
             // 用户设置 几期都未中奖 报警通知
             $NewestCodes = Code::find()->orderBy('time DESC')->limit($config->regret_number)->all();
             if (count($NewestCodes) == $config->regret_number) {
                 //所有的最新的数据 必须 等于 用户设置的报警期数
                 $codeLucky = true;
                 foreach ($NewestCodes as $codeold) {
                     if (!empty($codeold->analysis->lucky_txt)) {
                         //N 期内有中奖 不发送报警
                         $codeLucky = false;
                         break;
                     }
                 }
                 if ($codeLucky) {
                     //发送报警通知 当前 $config->regret_number 内 都未中奖
                     $cfg = array('type' => 2, 'regret_number' => $config->regret_number, 'NewestCodes' => $NewestCodes);
                     $this->send($cfg);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * 获取警报设置配置项
  */
 private function get_config()
 {
     if ($this->type == 'cq') {
         $this->config_one = Configure::findOne(['type' => 2]);
         //重庆时时彩  数据包1 报警设置
         $this->config_two = Configure::findOne(['type' => 22]);
         //重庆时时彩 数据包2 报警设置
     }
     if ($this->type == 'tj') {
         $this->config_one = Configure::findOne(['type' => 3]);
         //天津时时彩 数据包1 报警设置
         $this->config_two = Configure::findOne(['type' => 33]);
         //天津时时彩 数据包2 报警设置
     }
     if ($this->type == 'xj') {
         $this->config_one = Configure::findOne(['type' => 4]);
         //新疆时时彩 数据包1 报警设置
         $this->config_two = Configure::findOne(['type' => 44]);
         //新疆时时彩 数据包2 报警设置
     }
 }
Exemplo n.º 4
0
 private function find($qihao, $urlName, $code, $code_id)
 {
     //数据分析
     $config = Configure::findOne(['type' => 2]);
     //旧时时彩 系统报警配置
     $model = Comparison::findOne(['type' => 2]);
     //旧时时彩 数据本
     $data = $model->txt;
     //记录中奖与未中奖号码
     $dataTxts = str_replace("\r\n", ' ', $data);
     //将回车转换为空格
     $dataArr = explode(' ', $dataTxts);
     $dataArr = array_filter($dataArr);
     //将中奖号码前三 后三
     $codeTxts = str_replace(" ", '', $code);
     $qian3 = $codeTxts[0] . $codeTxts[1] . $codeTxts[2];
     $center3 = $codeTxts[1] . $codeTxts[2] . $codeTxts[3];
     $hou3 = $codeTxts[2] . $codeTxts[3] . $codeTxts[4];
     $qian3 = intval($qian3);
     $center3 = intval($center3);
     $hou3 = intval($hou3);
     //当前开奖号码 对比 数据库
     $qian3_lucky = array();
     $qian3_regret = $dataArr;
     $center3_lucky = array();
     $center3_regret = $dataArr;
     $hou3_lucky = array();
     $hou3_regret = $dataArr;
     foreach ($dataArr as $key => $val) {
         //前三对比
         if (intval($val) == $qian3) {
             array_push($qian3_lucky, $val);
             // 添加到前三中奖数据里
             unset($qian3_regret[$key]);
         }
         //中三对比
         if (intval($val) == $center3) {
             array_push($center3_lucky, $val);
             // 添加到前三中奖数据里
             unset($center3_regret[$key]);
         }
         //后三对比
         if (intval($val) == $hou3) {
             array_push($hou3_lucky, $val);
             // 添加到后三中奖数据里
             unset($hou3_regret[$key]);
         }
     }
     //分析的数据转换成 上传数据本的格式
     $qian3_lucky_txt = null;
     foreach ($qian3_lucky as $key => $val) {
         $qian3_lucky_txt .= $val . "\r\n";
     }
     $qian3_regret_txt = null;
     foreach ($qian3_regret as $key => $val) {
         $qian3_regret_txt .= $val . "\r\n";
     }
     $center3_lucky_txt = null;
     foreach ($center3_lucky as $key => $val) {
         $center3_lucky_txt .= $val . "\r\n";
     }
     $center3_regret_txt = null;
     foreach ($center3_regret as $key => $val) {
         $center3_regret_txt .= $val . "\r\n";
     }
     $hou3_lucky_txt = null;
     foreach ($hou3_lucky as $key => $val) {
         $hou3_lucky_txt .= $val . "\r\n";
     }
     $hou3_regret_txt = null;
     foreach ($hou3_regret as $key => $val) {
         $hou3_regret_txt .= $val . "\r\n";
     }
     //分析后的数据 存入数据库
     $analysisold = new Analysisold();
     $analysisold->code_id = $code_id;
     $analysisold->front_three_lucky_txt = $qian3_lucky_txt;
     $analysisold->front_three_regret_txt = $qian3_regret_txt;
     $analysisold->center_three_lucky_txt = $center3_lucky_txt;
     $analysisold->center_three_regret_txt = $center3_regret_txt;
     $analysisold->after_three_lucky_txt = $hou3_lucky_txt;
     $analysisold->after_three_regret_txt = $hou3_regret_txt;
     $analysisold->data_txt = $data;
     $analysisold->time = time();
     $analysisold->save();
     $config = Configure::findOne(['type' => 2]);
     //旧时时彩 系统报警配置
     if ($config->state == 1) {
         //系统开启邮件 通知
         if (date('H', time()) > intval($config->start_time) && date('H', time()) < intval($config->end_time)) {
             //            if(true ) {
             //报警时间段内
             if ($config->forever == 1) {
                 //每一期 邮件通知打开
                 $cfg = array('type' => 1, 'qihao' => $qihao, 'code' => $code, 'urlName' => $urlName, 'qian3_lucky_txt' => $qian3_lucky_txt, 'qian3_regret_txt' => $qian3_regret_txt, 'center3_lucky_txt' => $center3_lucky_txt, 'center3_regret_txt' => $center3_regret_txt, 'hou3_lucky_txt' => $hou3_lucky_txt, 'hou3_regret_txt' => $hou3_regret_txt);
                 $this->send($cfg);
             }
             // 用户设置 几期都未中奖 报警通知
             $NewestCodes = Codeold::find()->orderBy('time DESC')->limit($config->regret_number)->all();
             if (count($NewestCodes) == $config->regret_number) {
                 $codeQian3Lucky = true;
                 $codeCenter3Lucky = true;
                 $codeHou3Lucky = true;
                 $q3_number = 0;
                 $c3_number = 0;
                 $h3_number = 0;
                 foreach ($NewestCodes as $codeold) {
                     if (!empty($codeold->analysisolds->front_three_lucky_txt)) {
                         //前三有中奖
                         $codeQian3Lucky = false;
                         $q3_number += 1;
                     }
                     if (!empty($codeold->analysisolds->center_three_lucky_txt)) {
                         //中三有中奖
                         $codeCenter3Lucky = false;
                         $c3_number += 1;
                     }
                     if (!empty($codeold->analysisolds->after_three_lucky_txt)) {
                         //后三有中奖
                         $codeHou3Lucky = false;
                         $h3_number += 1;
                     }
                 }
                 if ($codeQian3Lucky || $codeHou3Lucky) {
                     //发送报警通知 当前 $config->regret_number 内 都未中奖
                     $cfg = array('type' => 2, 'regret_number' => $config->regret_number, 'NewestCodes' => $NewestCodes, 'q3' => $q3_number, 'c3' => $c3_number, 'h3' => $h3_number);
                     $this->send($cfg);
                 }
             }
         }
     }
 }