public function authenticate() { $record = Account::model()->findByAttributes(array('memb___id' => $this->username)); $getChar = AccountCharacter::model()->findByAttributes(array('Id' => $this->username)); if ($this->getFConfig('md5') == 0) { if ($record === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($record->memb__pwd != $this->password) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $record->memb_guid; $this->username = $record->memb___id; $this->setState('guid', $record->memb_guid); $this->setState('char', $getChar->GameIDC); $this->setState('username', $record->memb___id); $this->setState('role', $record->status); $this->errorCode = self::ERROR_NONE; } } } else { if ($record === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($record->memb__pwd != md5($this->password . $this->username)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $record->memb_guid; $this->memb___id = $record->memb___id; $this->setState('char', $getChar->GameIDC); $this->setState('account', $record->memb___id); $this->setState('role', $record->status); $this->errorCode = self::ERROR_NONE; } } } return !$this->errorCode; }
public function getOInfo($acc, $char) { $online = MEMBSTAT::model()->find(array('select' => 'ConnectStat', 'condition' => 'memb___id=:memb___id', 'params' => array(':memb___id' => $acc))); $model = AccountCharacter::model()->find(array('select' => 'GameIDC', 'condition' => 'Id=:Id', 'params' => array(':Id' => $acc))); if ($model->GameIDC == $char && $online->ConnectStat == 1) { return 1; } else { if ($model->GameIDC == $char && $online->ConnectStat == 0) { return 0; } else { return 0; } } }
public function actionLogin() { if (!Yii::app()->user->isGuest) { $this->redirect('index'); } $model = new Account(); $this->performAjaxValidation($model); if (isset($_POST['Account'])) { if ($_POST['Account']['memb___id'] == "" || $_POST['Account']['memb__pwd'] == "") { Yii::app()->user->setFlash('warn', Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Need to fill in login and password')); $this->refresh(); } $this->_identity = new UserIdentity($_POST['Account']['memb___id'], $_POST['Account']['memb__pwd']); if ($this->_identity->authenticate()) { $model = Account::model()->findByAttributes(array('memb___id' => $_POST['Account']['memb___id'])); $getChars = AccountCharacter::model()->findByAttributes(array('Id' => $_POST['Account']['memb___id'])); if ($getChars->GameID1 == "" && $getChars->GameID2 == "" && $getChars->GameID3 == "" && $getChars->GameID4 == "" && $getChars->GameID5 == "") { Yii::app()->user->setFlash('delete', Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'You must create character in the game before login on the site')); $this->refresh(); } elseif ($model->bloc_code == '1') { Yii::app()->user->setFlash('delete', Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Your account has been banned')); $this->refresh(); } else { Yii::app()->user->login($this->_identity); $this->redirect('index'); } } else { Yii::app()->user->setFlash('delete', Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Login or password is not correct')); $this->refresh(); } } if (Yii::app()->session->get('registered') == 1) { Yii::app()->user->setFlash('success', Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Congratulations! Your account has been successfully registered. Login to your account using your username and password.')); } $this->pageTitle = Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Sign in') . ' / ' . $this->getFConfig('logTitle') . ' / ' . $this->getFConfig('serverName'); $this->pageH1 = Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Sign in'); $this->breadcrumbs = array(Yii::t('' . Yii::app()->request->cookies['language']->value . '', 'Sign in')); Yii::app()->clientScript->registerMetaTag($this->getFConfig('metaDescLog'), 'description'); Yii::app()->clientScript->registerMetaTag($this->getFConfig('metaKeyLog'), 'keywords'); $this->layout = 'loginPage'; $this->render('auth', array('model' => $model)); }