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 actionVasRegister() { $package_id = Yii::app()->request->getParam('package'); $phone = yii::app()->user->getState('msisdn'); $back_link = Yii::app()->request->getParam('back_link', ''); if ($back_link != '') { Yii::app()->session['back_link'] = $back_link; } 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) { if (Formatter::formatPhone($phone) == Formatter::formatPhone($msisdnResponse)) { $this->_register($phone, $package_id, true); $this->redirect(Yii::app()->session['back_link']); } } else { $this->redirect($this->createUrl("/site")); } } else { $check_promotion = $this->check_promotion($phone); $pDetail = PackageModel::model()->findByPk($package_id); $price = $pDetail->fee; $packageCode = $pDetail->code; /*if($check_promotion){ $price = 0; }*/ 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; if ($vasGate->save()) { $urlGen = new UrlGenerator($this->spId, $vasGate->transaction_id, $packageCode, $price, 'http://amusic.vn/account/vasRegister', $fee); $url = $urlGen->generateUrl($this->aes); $this->redirect($url); } $this->redirect('/'); } }
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; }
/** * PackageModel::getPackageOrderDetails() * 获取一个或多个订单详情 * @param string $poid 订单号 * @return array */ public static function getPackageOrderDetails($poid) { self::initDB(); $sql = "SELECT a.*,b.goodsName,b.id as goodsId,b.goodsCost FROM `ph_order_detail` as a\n\t\t\t\t\tINNER JOIN `pc_goods` as b ON a.sku = b.sku\n\t\t\t\t\tWHERE a.po_id IN ({$poid})"; $query = self::$dbConn->query($sql); if ($query) { $res = self::$dbConn->fetch_array_all($query); return $res; } else { self::$errCode = 10000; self::$errMsg = "获取数据失败"; return false; } }
public function actionSet() { $cids = Yii::app()->request->getParam('cid'); $page = Yii::app()->request->getParam('page'); $fileId = Yii::app()->request->getParam('fileId'); $sql = "SELECT t1.*, t2.* FROM import_user_content t1\n LEFT JOIN import_user_file t2 ON t1.file_id = t2.id\n WHERE t1.file_id = :FID"; $dataCmd = Yii::app()->db->createCommand($sql); $dataCmd->bindParam(":FID", $fileId, PDO::PARAM_INT); $dataList = $dataCmd->queryAll(); foreach ($dataList as $item) { //dk cho tap thue bao $phone = Formatter::formatPhone($item['msisdn']); $data = Yii::app()->request->getParam('data', ''); $package = PackageModel::model()->findByPk($item['package_id']); $packageCode = $package->code; $packageCode = trim($packageCode); $bmUrl = yii::app()->params['bmConfig']['remote_wsdl']; $client = new SoapClient($bmUrl, array('trace' => 1)); if ($item['content_type'] == 'subscribe') { $params = array('phone' => $phone, 'package' => $packageCode, 'source' => 'cskh', 'promotion' => 0, 'bundle' => 0, 'smsId' => null, 'note_event' => ''); $rt = $client->__soapCall('userRegister', $params); } else { //huy $params = array('user_id' => 0, 'user_phone' => $phone, 'package' => $packageCode, 'source' => 'cskh'); $rt = $client->__soapCall('userUnRegister', $params); } if ($rt->errorCode == 0) { $status = 1; } else { $status = 0; } $model = ImportUserContentModel::model()->findByAttributes(array('msisdn' => $phone, 'package_id' => $item['package_id'])); $model->status = $status; $model->return_code = $rt->errorCode; $model->save(false); // } $this->redirect(array('view', 'id' => $fileId, 'page' => $page)); }
/** * PackageAct::getPackageOrderDetail() * 获取一个或多个订单详情 * @param string $po_id 订单号 * @return array */ public static function getPackageOrderDetail() { $poid = isset($_REQUEST["po_id"]) ? post_check($_REQUEST["po_id"]) : ""; if (empty($poid)) { self::$errCode = 10000; self::$errMsg = "订单编号参数有误"; return false; } $res = PackageModel::getPackageOrderDetails($poid); self::$errCode = PackageModel::$errCode; self::$errMsg = PackageModel::$errMsg; return $res; }
</tr> </thead> <tbody> <tr> <td><?php echo $phone; ?> </td> <td><?php echo $subscribe->status == 1 ? "Đang hoạt động" : "Không hoạt động"; ?> </td> <td> <?php if ($subscribe) { $package = PackageModel::model()->findByPk($subscribe->package_id); if ($package) { echo $package->name; } } ?> </td> <td><?php if ($subscribe) { echo $subscribe->last_subscribe_time; } ?> </td> <td><?php if ($subscribe) { echo $subscribe->expired_time;
public function __construct() { $this->models = PackageModel::all(); }
<?php echo $form->labelEx($model, 'action'); ?> <?php $data = array('not_subscribe' => 'Không đăng ký', 'subscribe' => 'Đăng ký'); echo $form->dropDownList($model, 'action', $data); ?> <?php echo $form->error($model, 'action'); ?> <div id="package"> <?php echo $form->labelEx($model, 'package_id', array('style' => 'margin-left: 10px; width: 60px;')); ?> <?php $data = CHtml::listData(PackageModel::model()->findAll(), 'id', 'name'); echo $form->dropdownList($model, 'package_id', $data, array('prompt' => '---Chọn gói cước---')); ?> </div> </div> <div class="row"> <?php echo $form->labelEx($model, 'domain'); ?> <?php $data = array('http://amusic.vn' => 'http://amusic.vn'); echo $form->dropDownList($model, 'domain', $data); ?> <?php
<?php $this->menu = array(array('label' => 'Danh sách File', 'url' => array('index'))); $this->pageLabel = "Danh sách file \"" . $model->file_name . "\""; ?> <?php $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'file_name', 'file_path', array('label' => yii::t('admin', 'Gói cước'), 'value' => PackageModel::model()->findbyPk($model->package_id)->code), array('label' => yii::t('admin', 'Created By'), 'value' => AdminAdminUserModel::model()->findbyPk($model->created_by)->username), 'created_time', 'content_type'))); ?> <div class="submenu title-box"> <div class="page-title">Danh sách thuê bao</div> <ul class="operations menu-toolbar"> <?php if ($content_type == 'subscribe') { ?> <li><a href="#" id="update-content">Đăng ký</a></li> <?php } else { ?> <li><a href="#" id="update-content">Hủy đăng ký</a></li> <?php } ?> <li><a href="#" id="delete-content">Xóa</a></li> <!-- <li><a href="#" id="map-content">Map nội dung</a></li> --> <li><a href="#" id="export-xls-not-mapped" title="Export danh sách bài không map được">Export xls</a></li> </ul> </div> <div id="mapping-zone" style="height: 250px;overflow-y:auto; width: 90%;border: 1px solid #DDD; margin: 10px auto;display: none;"> </div> <?php