public function actionRepassword()
 {
     $error = "";
     $phone = Yii::app()->request->getParam('phone');
     if (Yii::app()->request->isPostRequest) {
         if (!empty($phone)) {
             $phone = Formatter::formatPhone($phone);
             if (Formatter::isPhoneNumber(Formatter::removePrefixPhone($phone))) {
                 $user = WapUserModel::model()->findByPhone($phone);
                 if (!empty($user)) {
                     // check 3 lan trong ngay
                     $action = "updatepass";
                     $check_otp = UserVerifyModel::model()->checkOtp($phone, $action);
                     if ($check_otp) {
                         // gửi ma otp xac thuc
                         $verify_code = rand(1000, 9999);
                         $userVerify = new UserVerifyModel();
                         $userVerify->msisdn = $phone;
                         $userVerify->created_time = new CDbExpression('NOW()');
                         $userVerify->verify_code = $verify_code;
                         $userVerify->action = $action;
                         $userVerify->save();
                         $sentMsg = Yii::t('wap', Yii::app()->params['subscribe']['success_otp_password'], array(":OTP" => $verify_code));
                         $smsClient = new SmsClient();
                         $smsClient->sentSmsText($phone, $sentMsg);
                         Yii::app()->session['user_phone'] = $phone;
                         $this->redirect(Yii::app()->createUrl("/account/activeOtp", array('action' => 'updatepass')));
                     } else {
                         $error = Yii::t("wap", "You only use this feature three times a day. Thank you very much.");
                     }
                 } else {
                     $error = Yii::t("wap", "Phone number not found");
                 }
             } else {
                 $error = Yii::t("wap", "Phone number incorrect!");
             }
         } else {
             $error = Yii::t("wap", "Please put your phone number");
         }
     }
     $this->render('repassword', compact('error'));
 }
示例#2
0
if ($topContent->type == 'album') {
    $userType = "GUEST";
    $phone = Yii::app()->user->getState('phone');
    if ($phone) {
        $userType = "MEMBER";
    }
    $userSub = Yii::app()->user->getState('userSub');
    $packageCode = Yii::app()->user->getState('packageCode');
    if ($userSub) {
        $userType = "SUB_" . $packageCode;
    }
    $perLimit = ContentLimitModel::getPermision($topContent->content_id, "album", $userType, "WAP");
    $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($topContent->content_id);
    $like = null;
    if ($phone) {
        $userId = WapUserModel::model()->findByAttributes(array('phone' => $phone))->id;
        $like = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $albumId, 'msisdn' => $phone));
    }
    $this->renderPartial('_albumView', compact('content', 'perLimit', 'songsOfAlbum', 'like'));
} elseif ($topContent->type == 'video_playlist') {
    $list_video_playlist = WapVideoModel::model()->getVideosOfVideoPlaylist($topContent->content_id);
    //check noi dung doc quyen
    $userType = "GUEST";
    $phone = Yii::app()->user->getState('phone');
    if ($phone) {
        $userType = "MEMBER";
    }
    $userSub = Yii::app()->user->getState('userSub');
    $packageCode = Yii::app()->user->getState('packageCode');
    if ($userSub) {
        $userType = "SUB_" . $packageCode;
 public function actionLike()
 {
     $this->layout = false;
     $type = htmlspecialchars(Yii::app()->request->getparam('type', 'song'));
     $id = (int) Yii::app()->request->getparam('id', 0);
     $phone = Formatter::formatPhone(Yii::app()->user->getState('msisdn'));
     if (empty($phone)) {
         echo 'phone_not_detect';
         Yii::app()->end();
     }
     $criteria = new CDbCriteria();
     $criteria->condition = "phone=:phone";
     $criteria->params = array(':phone' => $phone);
     $userId = WapUserModel::model()->find($criteria)->id;
     if (empty($userId)) {
         echo 'phone_not_register';
         Yii::app()->end();
     }
     switch ($type) {
         case 'video':
             $video = WapFavouriteVideoModel::model()->findByAttributes(array('video_id' => $id, 'msisdn' => $phone));
             if (!isset($video)) {
                 $videoModel = new WapFavouriteVideoModel();
                 $videoModel->video_id = $id;
                 $videoModel->msisdn = $phone;
                 $videoModel->created_time = date('Y-m-d H:i:s');
                 $videoModel->save();
             }
             echo 'success';
             break;
         case 'videoPlaylist':
             $video = FavouriteVideoPlaylistModel::model()->findByAttributes(array('video_playlist_id' => $id, 'msisdn' => $phone));
             if (!isset($video)) {
                 $videoModel = new FavouriteVideoPlaylistModel();
                 $videoModel->msisdn = $phone;
                 $videoModel->video_playlist_id = $id;
                 $videoModel->created_time = date('Y-m-d H:i:s');
                 $videoModel->save();
             }
             echo 'success';
             break;
         case 'album':
             $album = FavouriteAlbumModel::model()->findByAttributes(array('album_id' => $id, 'msisdn' => $phone));
             if (!isset($album)) {
                 $albumModel = new FavouriteAlbumModel();
                 $albumModel->msisdn = $phone;
                 $albumModel->album_id = $id;
                 $albumModel->created_time = date('Y-m-d H:i:s');
                 $albumModel->save();
             }
             break;
         default:
             //song
             $song = WapFavouriteSongModel::model()->findByAttributes(array('song_id' => $id, 'msisdn' => $phone));
             if (!isset($song)) {
                 $songModel = new WapFavouriteSongModel();
                 $songModel->msisdn = $phone;
                 $songModel->song_id = $id;
                 $songModel->created_time = date('Y-m-d H:i:s');
                 $songModel->save();
             }
             echo 'success';
             break;
     }
     Yii::app()->end();
 }
示例#4
0
 /**
  * function userAuthenticate
  * call after detect phone number, save phone number and package to session
  *
  * @param string $type
  * @return bool
  */
 public function userAuthenticate($type, $os)
 {
     Yii::app()->user->setState('is3g', 0);
     if ($type == 'autoLogin') {
         $msisdn = self::_detectMSISDN('wap', NULL, $os);
         if ($msisdn) {
             //xác thực qua 3G
             Yii::app()->user->setState('is3g', 1);
             // get user info from phone
             if ($user = UserModel::model()->findByAttributes(array("phone" => $msisdn))) {
                 if (!empty($user->suggested_list)) {
                     $this->setState('_user', array('id' => $user->id, 'suggested_list' => $user->suggested_list));
                 } else {
                     $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
                 }
             } else {
                 $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
             }
             $this->_msisdn = $msisdn;
             $this->errorCode = self::ERROR_NONE;
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         }
         $this->_id = $msisdn;
     } else {
         $user = WapUserModel::model()->findByUsername($this->username);
         if (empty($user)) {
             $phone = Formatter::formatPhone($this->username);
             $user = WapUserModel::model()->findByPhone($phone);
         }
         if ($user === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if ($user->password !== Common::endcoderPassword($this->password)) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 if ($user->status != UserModel::ACTIVE) {
                     Yii::app()->request->redirect("/account/ActiveOtp?phone=" . Formatter::formatPhone($this->username));
                     Yii::app()->end();
                 } else {
                     $this->_id = $user->id;
                     $this->setState('username', $user->username);
                     $this->setState('phone', $user->phone);
                     $this->errorCode = self::ERROR_NONE;
                     $user->login_time = new CDbExpression("NOW()");
                     $user->save();
                     $this->_msisdn = $user->phone;
                 }
             }
         }
     }
     if ($this->_msisdn) {
         $this->setState('msisdn', $this->_msisdn);
     }
     $package = WapUserSubscribeModel::model()->getUserSubscribe($this->_msisdn);
     // get user_subscribe record by phone
     if ($package) {
         $packageObj = WapPackageModel::model()->findByPk($package->package_id);
         $this->setState('package', $packageObj->code);
     }
     return !$this->errorCode;
 }