예제 #1
0
 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));
 }