public function actionLogin() { if (!Yii::app()->user->isGuest) { if ($this->layout == 'application.views.touch.layouts.main') { $this->redirect($this->createUrl("/account/view")); } else { $this->redirect($this->createUrl("/account/index")); } return; } $model = new LoginForm(); $errorMsg = $errorMsg_Wap = ""; if ($msg = Yii::app()->request->getParam('msg', false)) { $errorMsg = $msg; } if (Yii::app()->request->isPostRequest) { if (empty($_POST['LoginForm']['phone'])) { $errorMsg_Wap = "Số điện thoại không được để trống"; } else { $model->attributes = $_POST['LoginForm']; $model->phone = Formatter::formatPhone($_POST['LoginForm']['phone']); if ($model->validate() && $model->login()) { MainUserIdentity::_logDetectMSISDN($_POST['LoginForm']['phone'], "F5", 'wap'); //LogDetectMsisdnModel::model()->logDetect(Formatter::formatPhone($_POST['LoginForm']['phone']), $_SERVER['REMOTE_ADDR'], 'F5', 'wap' , 1, "F5", NULL, NULL, $this->userSub->package_id, NULL, NULL, $_SERVER['REQUEST_URI']); $back = Yii::app()->request->getParam('back', false); if ($back) { $this->redirect($back); } $this->redirect(Yii::app()->createUrl("/site")); } else { $errors = $model->getErrors(); foreach ($errors as $key => $err) { $errorMsg .= "<div class='errormsg'>{$err[0]}</div>"; } } } } $this->render('login', array('model' => $model, 'errorMsg' => $errorMsg, 'errorMsg_Wap' => $errorMsg_Wap)); }
/** * function _detectMSISDN * call to detect user phone number * @return string $phone */ static function _detectMSISDN($channel = 'wap', $deviceId = NULL, $os = '') { if (isset($_GET['test']) && $_GET['test'] != "") { switch ($_GET['test']) { case 1: $phone = "841266046664"; break; case 2: $phone = "841205126493"; break; } return $phone; } self::$_os = !empty($os) ? $os : ''; $msisdn = ''; // F5: 10.x.y.z $F5IPPattern = "/^10(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}\$/"; // WAPGW: 172.16.30.[11-12], 113.185.0.16 $WAPGWIPPattern = "/^(172\\.16\\.30\\.1[1-2]|113\\.185\\.0\\.16)\$/"; // Dai ip 113.185.[1-31].0/24 thuoc F5 tuy nhien khong nhan dien duoc $OtherIpPattern = "/^113\\.185\\.([1-9]|1[0-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\$/"; $remoteIp = rtrim(ltrim($_SERVER['REMOTE_ADDR'])); $userAgent = $_SERVER['HTTP_USER_AGENT']; if (strpos($userAgent, 'Opera') !== false) { $isOpera = true; $remoteIp = isset($_SERVER['HTTP_X_IPADDRESS']) ? $_SERVER['HTTP_X_IPADDRESS'] : $_SERVER['REMOTE_ADDR']; $remoteIp = trim($remoteIp); } else { $isOpera = false; } /*if(YII_DEBUG){ $check_mobifone_ip = IpHelper::getIspNameByIp($remoteIp); }*/ $check_mobifone_ip = IpHelper::getIspNameByIp($remoteIp); if ($check_mobifone_ip == 'MOBIFONE') { if ($msisdn == '') { $msisdn = isset($_SERVER['HTTP_X_WAP_MSISDN']) && $_SERVER['HTTP_X_WAP_MSISDN'] ? $_SERVER['HTTP_X_WAP_MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['X_WAP_MSISDN']) && $_SERVER['X_WAP_MSISDN'] ? $_SERVER['X_WAP_MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['X-WAP-MSISDN']) && $_SERVER['X-WAP-MSISDN'] ? $_SERVER['X-WAP-MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['X-Wap-MSISDN']) && $_SERVER['X-Wap-MSISDN'] ? $_SERVER['X-Wap-MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['MSISDN']) && $_SERVER['MSISDN'] ? $_SERVER['MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['msisdn']) && $_SERVER['msisdn'] ? $_SERVER['msisdn'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['HTTP-X-WAP-MSISDN']) && $_SERVER['HTTP-X-WAP-MSISDN'] ? $_SERVER['HTTP-X-WAP-MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['HTTP_X_WAP_MSISDN']) && $_SERVER['HTTP_X_WAP_MSISDN'] ? $_SERVER['HTTP_X_WAP_MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['HTTP-MSISDN']) && $_SERVER['HTTP-MSISDN'] ? $_SERVER['HTTP-MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['HTTP_MSISDN']) && $_SERVER['HTTP_MSISDN'] ? $_SERVER['HTTP_MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['X-MSISDN']) && $_SERVER['X-MSISDN'] ? $_SERVER['X-MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['X_MSISDN']) && $_SERVER['X_MSISDN'] ? $_SERVER['X_MSISDN'] : $msisdn; } if ($msisdn == '') { $msisdn = isset($_SERVER['HTTP_X_UP_CALLING_LINE_ID']) && $_SERVER['HTTP_X_UP_CALLING_LINE_ID'] ? $_SERVER['HTTP_X_UP_CALLING_LINE_ID'] : $msisdn; } $lastLog = isset(Yii::app()->session['log_detect']) ? Yii::app()->session['log_detect'] : 0; if (time() - $lastLog > 600) { self::_logDetectMSISDN($msisdn, "F5", $channel, $deviceId); Yii::app()->session['log_detect'] = time(); } } $type = ''; // Truy cap tu mang Mobifone, ko nhan dien dc => sau 10ph log vao DB de thong ke /* if ((!$msisdn || $msisdn == '') && (preg_match($F5IPPattern, $remoteIp))) { $lastTimeLog = isset(Yii::app()->session['fail_detect']) ? Yii::app()->session['fail_detect'] : 0; if (time() - $lastTimeLog > 600) { self::_logDetectMSISDN("", $type, $channel, $deviceId); Yii::app()->session['fail_detect'] = time(); } } */ return $msisdn; }