function subscribeUpdate()
 {
     $task = $_POST['task'];
     $serialId = $_POST['serial_id'];
     $userId = $_SESSION['user']['id'];
     if ($task == 1) {
         $model = new UserSubscribeModel();
         $model->serial_id = $serialId;
         $model->user_id = $userId;
         $model->save();
     } else {
         UserSubscribeModel::model()->where(" `serial_id`='{$serialId}' AND `user_id`='{$userId}'")->delete();
     }
 }
Esempio n. 2
0
 public function authenticate()
 {
     $phone = Formatter::formatPhone($this->username);
     $user = WebUserModel::model()->findByPhone($phone);
     $keySession = session_id();
     $numberFailLogin = isset(Yii::app()->session[$keySession]) ? Yii::app()->session[$keySession] : 0;
     if ($numberFailLogin >= Yii::app()->params['login']['limit_block']) {
         $this->errorCode = self::ERROR_LIMITED_LOGIN;
         return !$this->errorCode;
         Yii::app()->end();
     }
     if ($user === null) {
         $numberFailLogin += 1;
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== ($this->auto ? $this->password : UserIdentity::encodePassword($this->password))) {
             $numberFailLogin += 1;
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($user->validate_phone != 1) {
                 $numberFailLogin += 1;
                 $this->errorCode = self::ERROR_NO_VALID_PHONE;
             } else {
                 $userSub = UserSubscribeModel::model()->get($user->phone);
                 if ($userSub && !empty($userSub->package_id)) {
                     $package = PackageModel::model()->findByPk($userSub->package_id)->code;
                 } else {
                     $package = "";
                 }
                 $this->_id = $user->id;
                 $this->setState('lastLoginTime', $user->login_time);
                 $this->setState('fullname', $user->fullname);
                 $this->setState('username', $user->username);
                 $this->setState('email', $user->email);
                 $this->setState('phone', $user->phone);
                 $this->setState('new', !$user->login_time);
                 $this->setState('userSub', $userSub);
                 $this->setState('packageCode', $package);
                 $this->errorCode = self::ERROR_NONE;
                 $user->login_time = date('Y-m-d H:i:s');
                 $user->save();
             }
         }
     }
     Yii::app()->session[$keySession] = $numberFailLogin;
     if ($numberFailLogin == Yii::app()->params['login']['limit_block']) {
         Yii::app()->session[$keySession . '_time'] = time();
     }
     return !$this->errorCode;
 }
 public function notificationNewSeries()
 {
     $subject = "http://" . $_SERVER['SERVER_NAME'] . " Здравствуйте, у нас есть обновления по вашим подпискам";
     $headers = "Content-type: text/html; charset=utf-8 \r\n";
     $headers .= "From: support@cpiki.com";
     $users = UsersModel::model()->where(" `subscribe_new_series` = '1' ")->findAll();
     foreach ($users as $user) {
         echo $to = $user->email;
         $body = "<table width='700'><tr><td style='background-color: black;color: white;font-size: 22px;line-height: 40px; color:#fff;  padding-left: 20px;'>cpiki</td></tr><tr><td style='  font-size: 20px;  line-height: 100px;padding-left: 50px;'>Здравствуйте, у нас есть обновления по вашим подпискам</td></tr><tr><td>";
         $body .= "<table>";
         $num = 0;
         $serials = UserSubscribeModel::model()->where("`user_id` = {$user->id} ")->findAll();
         foreach ($serials as $serial) {
             $movie = MoviesModel::model()->where("`id` = {$serial->serial_id} ")->findRow();
             $seasons = SeasonModel::model()->where("`serial_id` = '{$movie->id}'")->findAll();
             foreach ($seasons as $season) {
                 $series = SeriesModel::model()->where(" `season_id` = {$season->id} ")->findAll();
                 foreach ($series as $single) {
                     if (SeriesModel::isNewSeries($single->date)) {
                         $sdSrc = $movie->poster;
                         if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $sdSrc)) {
                             $sdSrc = "/assets/images/templates/no_image.png";
                         }
                         $body .= "<tr><td style='  line-height: 40px;'><img width='150' src='http://" . $_SERVER['SERVER_NAME'] . $sdSrc . "' /></td>";
                         $body .= "<td style='  vertical-align: top;  padding-left: 20px;' ><p style='  line-height: 80px;  font-size: 20px;'><a href='http://" . $_SERVER['SERVER_NAME'] . "/serials/" . $movie->seo_url . "' >" . $movie->en_name . "</a></p>";
                         $body .= "<p style='  font-size: 16px;  color: rgb(126, 126, 126);'>" . $single->sort . " серия " . $season->sort . "-го сезона </p></td></tr>";
                         $num++;
                     }
                 }
             }
         }
         $body .= "</table></td></tr></table>";
         echo $body . "<br/>";
         if ($num > 0) {
             mail($to, $subject, $body, $headers);
         }
     }
 }
 public function actionLanding()
 {
     $package_id = (int) Yii::app()->request->getParam('id');
     $phone = Yii::app()->user->getState('msisdn');
     $phone = Formatter::formatPhone($phone);
     //check xem đã đk chưa
     $check_user_sub = UserSubscribeModel::model()->findByAttributes(array('user_phone' => $phone, 'status' => UserSubscribeModel::ACTIVE));
     if (empty($check_user_sub)) {
         if (isset($_GET['link'])) {
             $requestData = $this->aes->decrypt("{$_GET['link']}");
             $composition = explode('&', $requestData);
             $transactionID = $composition[0];
             $msisdnResponse = $composition[1];
             $confirm = $composition[2];
             $transactionVAS = VasGateModel::model()->findByAttributes(array('transaction_id' => $transactionID));
             $package_id = $transactionVAS->package_id;
             if ($confirm == 1) {
                 $msg = $this->_register($phone, $package_id, true);
             }
         } else {
             $check_promotion = UserSubscribeModel::model()->check_promotion($phone);
             $pDetail = PackageModel::model()->findByPk($package_id);
             $price = $pDetail->fee;
             $packageCode = $pDetail->code;
             if ($check_promotion) {
                 $price = 0;
                 if ($package_id == 1) {
                     $fee = ' 2000 đồng/1 ngày';
                 } else {
                     $fee = ' 7000 đồng/7 ngày';
                 }
                 $fee .= "|| Khuyến mại 5 ngày";
             } else {
                 if ($package_id == 1) {
                     $fee = '1 ngày';
                 } else {
                     $fee = '7 ngày';
                 }
             }
             $convmap = array(0x80, 0xffff, 0, 0xffff);
             $fee = mb_encode_numericentity($fee, $convmap, 'UTF-8');
             $fee = str_replace("&#", "##", $fee);
             $vasGate = new VasGateModel();
             $vasGate->transaction_id = time() . $phone;
             $vasGate->package_id = $pDetail->id;
             $vasGate->information = $pDetail->code;
             $vasGate->price = $price;
             $vasGate->msisdn = $phone;
             $vasGate->created_time = date("Y-m-d H:i:s");
             if ($vasGate->save()) {
                 $urlGen = new UrlGenerator($this->spId, $vasGate->transaction_id, $packageCode, $price, 'http://amusic.vn/account/landing', $fee);
                 $url = $urlGen->generateUrl($this->aes);
                 $this->redirect($url);
             }
         }
     }
     $this->redirect(Yii::app()->createUrl('/site'));
 }
Esempio n. 5
0
 private function _register($phone, $package_id)
 {
     try {
         if (!isset($phone)) {
             $this->redirect(Yii::app()->createUrl('account/login', array('back' => Yii::app()->createUrl('/account/package'))));
         }
         $package = PackageModel::model()->findByPk($package_id);
         $packageCode = $package->code;
         if (isset(Yii::app()->session['source']) && !empty(Yii::app()->session['source'])) {
             $source = Yii::app()->session['source'];
         } else {
             $source = '';
         }
         $res1 = true;
         if ($res1) {
             $bmUrl = yii::app()->params['bmConfig']['remote_wsdl'];
             $client = new SoapClient($bmUrl, array('trace' => 1));
             $params = array('phone' => yii::app()->user->getState('msisdn'), 'package' => $packageCode, 'source' => 'wap', 'promotion' => 0, 'bundle' => 0, 'smsId' => null, 'note_event' => $source);
             $result = $client->__soapCall('userRegister', $params);
         } else {
             $this->redirect(Yii::app()->createUrl("account/index"));
             exit;
         }
         $return_msg = false;
         if (strrpos(strtolower($result->message), "success") !== false) {
             $return_msg = true;
         }
         $smswap = array('success_am' => 'success_msg_am', 'success_km_am' => 'success_msg_km_am', 'success_am7' => 'success_msg_am7', 'success_km_am7' => 'success_msg_km_am7');
         if (array_key_exists($result->message, $smswap)) {
             $result->message = $smswap[$result->message];
         }
         if ($return_msg || $result->message == 'success_a1' || $result->message == 'success_a7') {
             // success
             //display success page
             $msg = Yii::app()->params['subscribe_msg'][$result->message];
             $userSub = UserSubscribeModel::model()->get(yii::app()->user->getState('msisdn'));
             Yii::app()->user->setState('userSub', $userSub);
             /*Yii::app()->user->setFlash('msg', $msg);
               $this->redirect(Yii::app()->createUrl("account/index", array('reloadPackage' => 1)));*/
         } else {
             //display error page
             if (isset(Yii::app()->params['subscribe_msg'][$result->message])) {
                 $msg = Yii::app()->params['subscribe_msg'][$result->message];
                 if (strpos($msg, ':EXPIRED') !== false) {
                     $userSub = $this->userSub;
                     //WapUserSubscribeModel::model()->getUserSubscribe(yii::app()->user->getState('msisdn'));
                     $msg = Yii::t('wap', Yii::app()->params['subcsriber_wap'][$result->message], array(':EXPIRED' => date("H:i:s d/m/Y", strtotime($userSub->expired_time))));
                 }
             } else {
                 $msg = Yii::app()->params['subscribe_msg']['default'];
             }
             Yii::app()->user->setFlash('msg', $msg);
         }
     } catch (Exception $e) {
         Yii::log($e->getMessage(), "error", "exeption.BMException");
         $msg = $e->getMessage();
     }
     return $msg;
 }
Esempio n. 6
0
 public function actionShow()
 {
     $id = Auth::getUser()['id'];
     $model = UsersModel::model()->where("`id`='{$id}'")->findRow();
     if (isset($_POST['user_data'])) {
         $model->email = $_POST['email'];
         $model->name = $_POST['name'];
         $model->save();
         Auth::logOut();
         Auth::login($model->login, $model->password);
     }
     if (isset($_POST['passwrds'])) {
         if (Auth::hashPassword($_POST['altpass']) != $model->password) {
             Error::setError("password", "Вы указали неверный пароль.");
             //echo "<script>alert('ne ok')</script>";
         } else {
             if ($_POST['password1']) {
                 $model->password = Auth::hashPassword($_POST['password1']);
             }
             $model->save();
             Auth::logOut();
             Auth::login($model->login, $model->password);
             //Message::setMessage("success", Lang::get("data_success"));
             //echo "<script>alert('ne ok')</script>";
         }
     }
     if (isset($_POST['updates'])) {
         // echo "1111";
     }
     if (isset($_POST['subscribe'])) {
         //  echo "11111";
     }
     if (isset($_POST['avatar_update'])) {
         $max_size = 400 * 1024;
         $valid_types = array("image/jpg", "image/jpeg");
         if ($_FILES['image']['name']) {
             $f_size = $_FILES['image']['size'];
             $f_type = $_FILES['image']['type'];
             if ($f_size > $max_size) {
                 echo 'wrong_size';
             } else {
                 if (!in_array($f_type, $valid_types)) {
                     echo 'wrong_type';
                 } else {
                     $model->user_avatar = File::save($_FILES['image'], "assets/images/avatar");
                     File::resizeImage($model->user_avatar, 300, 300);
                     $model->save();
                     $this->redirect("/profile");
                 }
             }
         }
     }
     if (isset($_POST['deleteProfile'])) {
         $id = Auth::getUser()['id'];
         $_SESSION["login"] = "";
         $_SESSION["id"] = "";
         $_SESSION["password"] = "";
         $_SESSION["admin"] = "";
         $_SESSION["email"] = "";
         Auth::logOut();
         UsersModel::model()->where("`id`='" . $id . "'")->delete();
         $this->redirect("/");
     }
     if (isset($_POST['deleteAvatar'])) {
         $model->user_avatar = "";
         $model->save();
         $this->redirect("/profile");
     }
     $viewed_series = UserSeriesViewedModel::model()->order("date DESC")->where("user_id=" . Auth::getUser()['id'])->findAll();
     $serials = MoviesModel::model()->findAll();
     $userId = Auth::getUser()['id'];
     $favors = FavoritesModel::model()->where("`user_id`='{$userId}'")->findAll();
     $in = "(";
     foreach ($favors as $favor) {
         $in .= "'{$favor->video_id}'" . ", ";
     }
     $in = substr($in, 0, -2);
     $in .= ")";
     if ($in == ")") {
         $movies = array();
     } else {
         $movies_count = MoviesModel::model()->where("`id` IN {$in}")->countAll();
     }
     $movies = MoviesModel::model()->where("`id` IN {$in}")->findAll();
     $dicts = DictModel::model()->where("`user_id`='" . Auth::getUser()['id'] . "'")->countAll();
     $userSubscribe = UserSubscribeModel::model()->where("`user_id`=" . Auth::getUser()['id'])->findAll();
     $this->view("profile/show", array("serials" => $serials, "user" => $model, "movies" => $movies, "movies_count" => $movies_count, "viewed_series" => $viewed_series, "dicts" => $dicts, "user_subscribe" => $userSubscribe), false);
 }
Esempio n. 7
0
 /**
  * clone a Group 
  */
 public function actionCloneFilter()
 {
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $id = Yii::app()->request->getParam("id");
     $oldmodel = GroupModel::model()->findByPk($id);
     $model = new GroupModel();
     foreach ($oldmodel->attributes as $key => $val) {
         if ($key != "id") {
             if ($key == "name") {
                 $val .= " -- CLONE";
             }
             $model[$key] = $val;
         }
     }
     if ($model->save()) {
         $phoneList = PhoneModel::model()->getPhoneGroup($id);
         $arrayVal = array();
         foreach ($phoneList as $phone) {
             $phoneNum = $phone['phone'];
             if ($phoneNum == '84946760402') {
                 $exist = false;
             } else {
                 $exist = UserSubscribeModel::model()->exists("user_phone = :user_phone and expired_time >= '" . date("Y-m-d H:i:s") . "'", array(':user_phone' => $phoneNum));
             }
             if ($exist == false) {
                 $exist3 = DeletedPhoneModel::model()->exists('phone = :phone', array(':phone' => $phoneNum));
                 if ($exist3 == false) {
                     $created_time = date("Y-m-d H:i:s");
                     $mId = $model->id;
                     $arrayVal[] = "('{$phoneNum}',{$mId},0,'{$created_time}')";
                 }
             }
         }
         /**
          * Start insert here: split each 200 phone
          */
         $arrs = array_chunk($arrayVal, 200);
         foreach ($arrs as $arr) {
             $vals = implode(",", $arr);
             $sql = "INSERT INTO spam_sms_phone (`phone`,`group_id`,`status`,`created_time`) VALUES {$vals}";
             $command = Yii::app()->db->createCommand($sql);
             $command->execute();
         }
         $this->redirect(array('view', 'id' => $model->id));
     }
 }
Esempio n. 8
0
 public function wLogEvent($user_id, $user_phone, $eventId, $source, $contentId = '', $contentName = '', $transaction = '', $transactionId = 0, $transaction_name, $log_point)
 {
     try {
         $log = new KLogger('log_event_users_transaction', KLogger::INFO);
         $event = EventModel::model()->findByPk(new MongoId($eventId));
         $point = $event->point;
         if ($log_point == 0) {
             $point = 0;
         }
         $log->LogInfo("{$transaction}|{$user_phone}|{$contentId}|{$point}", false);
         $userSubscribe = true;
         switch ($transaction) {
             case 'play_song':
                 $transactionValid = $this->isContent24h($contentId, $eventId, $user_phone, $transaction);
                 $point = $this->getPoint($contentId, $transaction, $point);
                 $pointValid = $this->isPoint24h($point, $user_phone);
                 break;
             case 'play_video':
                 $transactionValid = $this->isContent24h($contentId, $eventId, $user_phone, $transaction);
                 $point = $this->getPoint($contentId, $transaction, $point);
                 $pointValid = $this->isPoint24h($point, $user_phone);
                 break;
             case 'play_album':
                 $transactionValid = $this->isContent24h($contentId, $eventId, $user_phone, $transaction);
                 $point = $this->getPoint($contentId, $transaction, $point);
                 $pointValid = $this->isPoint24h($point, $user_phone);
                 $userSubscribe = UserSubscribeModel::model()->get($user_phone);
                 break;
             default:
                 $transactionValid = true;
                 $pointValid = true;
                 break;
         }
         if ($transactionValid && $pointValid && $userSubscribe) {
             if ($event && (!empty($user_id) || !empty($user_phone))) {
                 $eventName = $event->name;
                 $groupEventId = $event->group_id;
                 $groupEventName = $event->group_name;
                 $model = new self();
                 $model->user_id = (int) $user_id;
                 $model->user_phone = !empty($user_phone) ? $user_phone : 0;
                 $model->event_id = $eventId;
                 $model->event_name = $eventName;
                 $model->group_id = $groupEventId;
                 $model->group_name = $groupEventName;
                 $model->content_id = $contentId;
                 $model->content_name = $contentName;
                 $model->transaction = $transaction;
                 $model->transaction_name = $transaction_name;
                 $model->transaction_id = (string) $transactionId;
                 $model->point = (int) $point;
                 $model->method = $source;
                 $model->created_time = date('Y-m-d H:i:s');
                 $model->updated_time = date('Y-m-d H:i:s');
                 $res = $model->save();
                 $log->LogInfo('write log ' . $transaction . ' | ' . $user_phone . '|' . $transaction . '|event:' . $eventId . '|' . json_encode($res), false);
                 if (!$res) {
                     $errors = $model->getErrors();
                     $log->LogInfo('update log new:' . json_encode($errors), false);
                 } else {
                     $updatePoint = self::model()->updatePoint($user_id, $user_phone, $point, $event->reset);
                     $log->LogInfo('update point|' . $user_id . '|' . json_encode($user_phone) . ':' . json_encode($updatePoint), false);
                     return $updatePoint;
                 }
                 //return $res;
             }
         }
     } catch (Exception $e) {
         //$e->getMessage();
         $log->LogInfo('update log exception:' . $e->getMessage());
         return false;
     }
     return false;
 }
Esempio n. 9
0
 public function actionLimitCtkm()
 {
     $userPhone = Yii::app()->user->getState('msisdn');
     $userPhone = Formatter::formatPhone($userPhone);
     $user_sub = UserSubscribeModel::model()->get($userPhone);
     if (!$user_sub) {
         $promotion = 0;
         $check_promotion = UserSubscribeModel::model()->check_promotion($userPhone);
         if ($check_promotion) {
             $promotion = 1;
         }
         $session = isset(Yii::app()->session['free_ctkm']) ? Yii::app()->session['free_ctkm'] : 1;
         Yii::app()->session['free_ctkm'] = Yii::app()->session['free_ctkm'] + 1;
         $data = array('session' => $session, 'promotion' => $promotion);
         header("Content-type: application/json");
         echo json_encode($data);
     } else {
         echo json_encode(new stdClass());
     }
     Yii::app()->end();
 }
Esempio n. 10
0
 /**
  * Log nhan dien thue bao
  * @param string $phone
  * @param string $type
  */
 public static function _logDetectMSISDN($phone, $type, $channel = 'wap', $deviceId = null)
 {
     if (!isset($deviceId)) {
         $deviceId = yii::app()->session['deviceId'];
     }
     // log to file
     $xAddress = isset($_SERVER['HTTP_X_IPADDRESS']) ? $_SERVER['HTTP_X_IPADDRESS'] : '';
     VegaCommonFunctions::logFile('PHONE:' . $phone . ' |-|REMOTE_ADDR:' . $_SERVER['REMOTE_ADDR'] . ' |-| HTTP_X_IPADDRESS:' . $xAddress . ' |-|DEVICE:' . Yii::app()->session['deviceId'], 'detectMsisdn', $type);
     $os = self::$_os;
     // log to DB
     $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
     $userSubscribe = UserSubscribeModel::model()->get($phone);
     //get user_subscribe record by phone
     $packageId = $userSubscribe ? $userSubscribe->package_id : 0;
     $event = $userSubscribe ? $userSubscribe->event : '';
     $referral = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : "";
     LogDetectMsisdnModel::model()->logDetect($phone, $_SERVER['REMOTE_ADDR'], $deviceId, $channel, 1, $type, $os, $userAgent, $packageId, $event, $referral, $uri);
 }
Esempio n. 11
0
$controller = Yii::app()->controller->id;
$action = Yii::app()->controller->action->id;
if (!($controller == 'account' && in_array($action, array('login', 'package')))) {
    if (!$this->userPhone) {
        ?>
        <p class="pad-10" style="text-align: left;padding-left: 10px;"><a class="c_red" href="<?php 
        echo Yii::app()->createUrl('/account/login');
        ?>
"><?php 
        echo 'Quý khách vui lòng đăng nhập tại đây hoặc chuyển sang truy cập bằng 3G/GPRS của MobiFone';
        ?>
</a></p>
    <?php 
    } else {
        if (!$this->userSub) {
            $is_km = UserSubscribeModel::model()->checkPromotion($phone);
            if ($is_km) {
                ?>
                <p class="pad-10" style="text-align: left;padding-left: 10px;"><a class="c_red" href="<?php 
                echo Yii::app()->createUrl('/account/welcome');
                ?>
"><?php 
                echo 'MIỄN PHÍ 5 ngày nghe xem tải không giới hạn. Miễn cước data 3G/GPRS. Đăng ký ngay!';
                ?>
</a></p>
            <?php 
            } else {
                ?>
                <p class="pad-10" style="text-align: left;padding-left: 10px;"><a class="c_red" href="<?php 
                echo Yii::app()->createUrl('/account/welcome');
                ?>