Ejemplo n.º 1
0
 private function readTxt($txtUrl)
 {
     if (file_exists($txtUrl)) {
         $content = file_get_contents($txtUrl);
         $content = str_replace("\r\n", ' ', $content);
         //把换行符 替换成空格
         $contentArr = explode(' ', $content);
         $contentArr = array_filter($contentArr);
         $txt = true;
         foreach ($contentArr as $key => $val) {
             if (!intval($val)) {
                 $txt = false;
                 break;
             }
         }
         if (!$txt) {
             return false;
         }
         Comparison::deleteAll(['type' => Yii::$app->request->post('type')]);
         $model = new Comparison();
         $model->txt = file_get_contents($txtUrl);
         $model->type = Yii::$app->request->post('type');
         $model->time = time();
         $model->save();
         return true;
     }
 }
Ejemplo n.º 2
0
 public function actionIndex()
 {
     $model = Comparison::findOne(['type' => 2]);
     return $this->render('index', ['data' => $model]);
 }
Ejemplo n.º 3
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);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * 解析 上传数据
  */
 private function analysisCode()
 {
     //天津时时彩的数据包1
     $model = Comparison::findOne(['type' => 3]);
     $data = $model->txt;
     $this->data_packet_txt = $model->txt;
     $dataTxts = str_replace("\r\n", ' ', $data);
     //将回车转换为空格
     $dataArr = explode(' ', $dataTxts);
     $dataArr = array_filter($dataArr);
     $this->data_packet = $dataArr;
     //天津时时彩的数据包2
     $model = Comparison::findOne(['type' => 33]);
     $data = $model->txt;
     $this->data_packet_txt_2 = $model->txt;
     $dataTxts = str_replace("\r\n", ' ', $data);
     //将回车转换为空格
     $dataArr = explode(' ', $dataTxts);
     $dataArr = array_filter($dataArr);
     $this->data_packet_2 = $dataArr;
 }
Ejemplo n.º 5
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);
                 }
             }
         }
     }
 }