Ejemplo n.º 1
0
 public function actionIndex()
 {
     $return = array('error' => 0, 'msg' => '');
     if (Yii::app()->request->isPostRequest) {
         $phone = Formatter::formatPhone($_POST['phone']);
         if (Formatter::isVinaphoneNumber($phone)) {
             if (!isset($_COOKIE["verifyWifiEvent"])) {
                 if (isset($_SESSION['countverifyWifiEvent'])) {
                     unset($_SESSION['countverifyWifiEvent']);
                 }
                 $_SESSION['countverifyWifiEvent'] = 1;
                 $_SESSION['phoneverifyWifiEvent'] = $phone;
                 setcookie("verifyWifiEvent", 1, time() + 600);
             } else {
                 $_SESSION['countverifyWifiEvent']++;
                 if ($_SESSION['countverifyWifiEvent'] > 3) {
                     $return['error'] = 1;
                     $return['msg'] = "Quí khách đã vượt quá số lần xác thực. Vui lòng thử lại sau ít phút.";
                 }
             }
             if ($return['error'] == 0) {
                 try {
                     $userVerify = UserVerifyModel::model()->findByAttributes(array('msisdn' => $phone, 'action' => 'register_event83'));
                     if (!empty($userVerify)) {
                         $verifyCode = $userVerify->verify_code;
                     } else {
                         $verifyCode = rand(1000, 9999);
                         $verifyModel = new UserVerifyModel();
                         $verifyModel->setAttribute('created_time', date("Y-m-d H:i:s"));
                         $verifyModel->setAttribute('msisdn', $phone);
                         $verifyModel->setAttribute('verify_code', $verifyCode);
                         $verifyModel->setAttribute('action', 'register_event83');
                         $verifyModel->save();
                     }
                     $sms = new SmsClient();
                     $content = "Ma xac thuc dang ky tren chacha la: " . $verifyCode;
                     $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234);
                     $this->redirect('/event/register/verifyWifi');
                 } catch (Exception $exc) {
                     echo $exc->getTraceAsString();
                 }
             }
         } else {
             $return['error'] = 2;
             $return['msg'] = "Số điện thoại của bạn không phải là thuê bao Vinaphone!";
         }
     }
     $this->render('index', array('return' => $return));
 }
Ejemplo n.º 2
0
 public function actionShare()
 {
     $userPhone = yii::app()->user->getState('msisdn');
     $isShare = GameEventActivityModel::isShareOnDay($userPhone, date('Y-m-d'));
     if ($isShare) {
         $this->redirect('/event/play/thank');
         Yii::app()->end();
     }
     $error = 0;
     $isSend = false;
     if (Yii::app()->request->isPostRequest) {
         $isSend = 0;
         $phoneList = $_POST['phone_list'];
         if ($phoneList != '') {
             $phoneArr = explode(',', $phoneList);
             if ($phoneArr) {
                 foreach ($phoneArr as $key => $value) {
                     $phone = Formatter::formatPhone($value);
                     if (Formatter::isVinaphoneNumber($phone)) {
                         $isSend++;
                         $sms = new SmsClient();
                         $content = 'DV Chacha - Vinaphone kinh chao Quy Khach. Quy Khach vua duoc thue bao ' . $userPhone . ' moi dua tai trong chuong trinh "Vui cung Chacha - Nhan qua nhu y" voi giai thuong hap dan len toi 20 trieu dong. Chi tiet moi Quy Khach xem tai day http://m.chacha.vn/event';
                         $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234);
                     }
                 }
                 if ($isSend > 0) {
                     //chia se it nhat duoc 1 so vinaphone
                     $gameActivity = new GameEventActivityModel();
                     $gameActivity->setAttribute('user_phone', $userPhone);
                     $gameActivity->setAttribute('activity', 'share');
                     $gameActivity->setAttribute('point', 1);
                     $gameActivity->setAttribute('updated_time', date('Y-m-d H:i:s'));
                     $gameActivity->setAttribute('note', $phoneList, PDO::PARAM_STR);
                     $gameActivity->save();
                     $this->redirect('/event/play/thank');
                 }
             }
         } else {
             //ko có sô dt nao
             $error = 1;
         }
     }
     $this->render('share', array('isShare' => $isShare, 'error' => $error, 'isSend' => $isSend));
 }