コード例 #1
0
ファイル: Ajax.php プロジェクト: lmkhang/mcntw
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-10
  * Check email for signing contract
  */
 public function checkSignContract(Request $request)
 {
     //check sign contract
     if ($this->_user['sign_contract'] == 1) {
         //set Flash Message
         die;
     }
     $message = 'This email is not available';
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         $post = $request->all();
         $sign_contract = $this->trim_all($post['sign_contract']);
         $user = new \App\User();
         if (!$user->checkExistedPaymentEmail($this->_user_id, $sign_contract['email'])) {
             $message = '';
         }
         header('Content-Type: application/json');
         echo json_encode(['message' => $message]);
         exit;
     }
 }
コード例 #2
0
ファイル: Unverify.php プロジェクト: lmkhang/mcntw
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-10
  * Active sign contract
  */
 public function activeSignContract($code)
 {
     //Check Status
     if ($this->_stop) {
         return Redirect::intended(url($this->_redirectTo));
     }
     $hours = \App\Config::where(['prefix' => 'site', 'name' => 'active_expire', 'del_flg' => 1])->get()[0]['value'];
     $salt = \App\Config::where(['prefix' => 'site', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
     //Check valid
     $decryptString = '';
     try {
         $decryptString = $this->ytb_decrypt($code, $salt);
         list($create_date, $confirm_payment_code, $emailGet) = explode('---', $decryptString);
     } catch (\Exception $e) {
         //set Flash Message
         $this->setFlash('message', 'The code is not valid!');
         return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not valid!');
     }
     if (!$decryptString || !$confirm_payment_code || !$emailGet) {
         //set Flash Message
         $this->setFlash('message', 'The code is not valid!');
         return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not valid!');
     }
     //Check Email is existed
     if ($this->_user->payment_email != $emailGet) {
         //set Flash Message
         $this->setFlash('message', 'The code is not match with email which had signed!');
         return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not match with email which had signed contract!');
     }
     //check code
     $now = time();
     $compareTime = $now - $hours * 60 * 60;
     if ($this->_user->confirm_payment_code != $confirm_payment_code || $compareTime > $create_date) {
         //set Flash Message
         $this->setFlash('message', 'The code is not valid or expired!');
         return Redirect::intended('/dashboard/sign_contract')->with('message', 'The code is not valid or expired!');
     }
     //check existed email
     $user_check_pm = new \App\User();
     if ($user_check_pm->checkExistedPaymentEmail($this->_user_id, $this->_user->payment_email)) {
         //set Flash Message
         $this->setFlash('message', 'The payment email had been activated by other person!');
         return Redirect::intended('/dashboard/sign_contract')->with('message', 'The payment email had been activated by other person!');
     }
     //Good status
     $this->_user->sign_contract = 1;
     $this->_user->confirm_payment_code = '';
     $this->_user->save();
     //Send mail - congrats
     $this->_sendMailSignContractCongrats();
     //set Flash Message
     $this->setFlash('message', $this->getName() . ' signed contract successfully: ' . $this->_user->payment_email);
     return Redirect::intended('/dashboard')->with('message', $this->getName() . ' signed contract successfully: ' . $this->_user->payment_email);
 }