Exemplo n.º 1
0
 /**
  * Sends an email to the specified email address using the information collected by this model.
  * @return boolean whether the model passes validation
  */
 public function add()
 {
     if ($this->validate()) {
         $code = new Code(['code' => $this->code, 'language' => $this->language, 'author' => $this->author, 'title' => $this->title, 'description' => $this->description, 'approved' => 0, 'ip' => ip2long(Yii::$app->request->userIP)]);
         if (!$code->save()) {
             return false;
         }
         $this->sendMails($code);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Enregistre le nouveau code dans la base de données après la création.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     try {
         $input = Input::all();
         $code = new Code();
         $code->nom = $input['nom'];
         $code->abreviation = $input['abreviation'];
         $code->description = $input['description'];
     } catch (ModelNotFoundException $e) {
         App::abort(404);
     }
     if ($code->save()) {
         return Redirect::action('CodesController@index');
     } else {
         return Redirect::back()->withInput()->withErrors($code->validationMessages());
     }
 }
Exemplo n.º 3
0
 function html_str($url)
 {
     /*
     $qihao = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('em[class=red]',0)->innertext;
     $code1 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',0)->innertext;
     $code2 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',1)->innertext;
     $code3 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',2)->innertext;
     $code4 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',3)->innertext;
     $code5 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',4)->innertext;
     $msg = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('p[class=kj-date]',0)->find('em[class=kj-date-txt]',0)->innertext;
     
     echo $qihao.'<br/>';
     echo $code1.'<br/>';
     echo $code2.'<br/>';
     echo $code3.'<br/>';
     echo $code4.'<br/>';
     echo $code5.'<br/>';
     echo $msg.'<br/>';
     exit;
     */
     $qihao2 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 0)->plaintext;
     $code = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 1)->plaintext;
     if ($code != '--') {
         // == '--' 正在开奖中
         $isKaiJiang = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->plaintext;
         if ($isKaiJiang != '--' && $isKaiJiang != '开奖中') {
             //能读取到数据
             $sizeProportion = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 0)->plaintext;
             $jioubili = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 1)->plaintext;
             $codeArr = explode(" ", $code);
             list($one, $two, $three, $four, $five) = $codeArr;
             $result = Code::findOne(['qishu' => $qihao2, 'type' => $this->codeType[$url]]);
             if ($result) {
                 $urlName = array_keys($this->urlArr, $url);
                 echo $urlName[0] . ' - [新时时彩] 最新数据已经采集过了<br/>';
                 return;
             }
             $model = new Code();
             $model->qishu = $qihao2;
             $model->one = $one;
             $model->two = $two;
             $model->three = $three;
             $model->four = $four;
             $model->five = $five;
             $model->type = $this->codeType[$url];
             $model->size = $sizeProportion;
             $model->jiou = $jioubili;
             $model->time = time();
             if ($model->validate() && $model->save()) {
                 $urlName = array_keys($this->urlArr, $url);
                 $logModel = new Log();
                 $logModel->type = 1;
                 $logModel->content = $urlName[0] . '.开奖信息抓取成功';
                 $logModel->time = time();
                 $logModel->save();
                 echo $urlName[0] . '.开奖信息抓取成功-[新时时彩]<br/>';
                 $this->find($qihao2, $urlName[0], $codeArr, $model->id);
                 return;
             }
         } else {
             $urlName = array_keys($this->urlArr, $url);
             echo $urlName[0] . '等待开奖...<br/>';
         }
     } else {
         $urlName = array_keys($this->urlArr, $url);
         echo $urlName[0] . ' -[新时时彩] 等待开奖...<br/>';
         return;
     }
 }
 public function postCode(Request $request)
 {
     $validationMessages = ['name.required' => 'Numele este obligatoriu.', 'name.max' => 'Numele trebuie sa aiba sub 255 de caractere.', 'email.required' => 'Email-ul este obligatoriu.', 'phone.required' => 'Telefonul este obligatoriu.', 'phone.regex' => 'Telefonul continue caractere care nu sunt cifre.', 'phone.size' => 'Telefonul nu are numarul corespunzator de cifre.', 'code.unique' => 'Codul a fost deja folosit.', 'dream.max' => 'Visul trebuie sa aiba maxim 500 de caractere.'];
     $validator = \Validator::make($request->all(), ['name' => 'required|max:255', 'email' => 'required', 'phone' => 'required|string|size:10|regex:/[0-9]/', 'code' => 'unique:codes', 'dream' => 'max:500'], $validationMessages);
     $validCode = false;
     $validDream = false;
     if ($validator->passes()) {
         $user_cookie = $this->userService->cookie();
         if ($this->userService->user() == null || $this->userService->user()->email != $request->email) {
             $new_user = new User();
             $new_user->name = $request->input("name");
             $new_user->phone = $request->input("phone");
             $new_user->email = $request->input("email");
             $new_user->cookie = $this->userService->getCookie();
             $new_user->save();
         }
         if ($request->input('code') != null) {
             $api_response = $this->codeService->checkCode($request->input('code'), $request->input('phone'), $request->has('dream') ? 1 : 0);
             // $api_response = "CORRECT";
             $status = true;
             switch ($api_response) {
                 case "INVALIDPARAMS":
                     $status = false;
                     $messages = "INVALID PARAMS";
                     break;
                 case "TIMEOUT":
                     $status = false;
                     $messages = "Serviciu este momentan indisponibil. Va rugam incercati din nou in cateva minute.";
                     break;
                 case "DUBLA":
                     $status = false;
                     $messages = "Codul inserat a fost deja inregistrat.";
                     break;
                 case "CORECT":
                     break;
                 case "INCORECT":
                     $status = false;
                     $messages = "Codul inserat nu este valid.";
                     break;
                 case "PREMIU":
                     break;
                 case "ACCESDENIED":
                     $status = false;
                     $messages = "Serviciu indisponibil.";
             }
             if ($status == false) {
                 return response()->json(['status' => "ERROR", 'data' => "", 'messages' => $messages]);
             }
             $code = new Code();
             $code->id_user = $this->userService->user()->id;
             $code->code = $request->input('code');
             $code->save();
             $validCode = true;
         }
         if ($request->input('dream') != null) {
             $dream = new Dream();
             $dream->id_user = $this->userService->user()->id;
             $dream->content = $request->input('dream');
             $dream->save();
             $validDream = true;
         }
     } else {
         $messages = $validator->messages()->all();
         return response()->json(['status' => "ERROR", 'data' => "", 'messages' => $messages]);
     }
     if ($validCode) {
         $message = "Cod validat.";
     } elseif ($validDream) {
         $message = "Vis salvat.";
     }
     \Mail::send('emails.validCode', ['validDream' => $validDream, 'validCode' => $validCode, 'user' => $this->userService->user()], function ($message) {
         $message->from('*****@*****.**', 'Avon');
         $message->to($this->userService->user()->email, $this->userService->user()->email)->subject('Competitie Avon!');
     });
     return response()->json(['status' => "OK", 'data' => "", 'messages' => $message]);
 }
 /**
  * Execute Job
  */
 public function handle()
 {
     $this->code->setAttribute('user_id', null);
     $this->code->save();
     event(new CodeUnlinkUpdated($this->code));
 }
Exemplo n.º 6
0
 public function createSpecificCode($bezeichnung = null)
 {
     /*if($bezeichnung == null){
           $banks = Bank::find()->where('klasse = :klasse', ['klasse' => $this->f_klasse])->all();
           $b_id = $banks[0]->b_id;
       }else{
           $banks = Bank::find()->where('bezeichnung = :bezeichnung', ['bezeichnung' => $bezeichnung])->all();
           $b_id = $banks[0]->b_id;
       }*/
     $b_id = $bezeichnung;
     $code = new Code();
     $code->z_b_id = $b_id;
     $code->z_p_id = $this->f_p_id;
     $code->code = Code::generateCode();
     $code->used = 0;
     $code->count = 1;
     $code->save();
     return $code;
 }