/** * Authenticates a user. * @return boolean whether authentication succeeds. */ public function authenticate() { $user = AdminAdminUserModel::model()->find('LOWER(username)=?', array(strtolower($this->username))); if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif ($user->status == 0) { $this->errorCode = self::ERROR_STATUS_INVALID; } else { if (!isset(Yii::app()->session[$user->username . "_" . $user->id])) { Yii::app()->session[$user->username . "_" . $user->id] = 0; } $timeBlock = Yii::app()->params['login']['time_block']; if (time() - $user->last_block_login <= $timeBlock * 60) { Yii::app()->session[$user->username . "_" . $user->id] = 0; $_GET['rank'] = $timeBlock * 60 - (time() - $user->last_block_login); //Yii::app()->getRequest()->redirect(Yii::app()->createUrl("admin/blockLogin")); Yii::app()->getController()->forward("admin/blockLogin", true); } $count = Yii::app()->session[$user->username . "_" . $user->id]; if ($user->password != Common::endcoderPassword($this->password)) { Yii::app()->session[$user->username . "_" . $user->id] = $count + 1; if ($count >= Yii::app()->params['login']['limit_block']) { $user->last_block_login = time(); } $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $user->id; $this->errorCode = self::ERROR_NONE; $this->setState('username', $user->username); $this->setState('cp_id', $user->cp_id); $this->setState('ccp_id', $user->ccp_id); $assigns = AdminAccessAssignmentsModel::model()->getRoles($user->id); $this->setState('roles', $assigns); $user->last_block_login = 0; Yii::app()->session[$user->username . "_" . $user->id] = 0; $effectPass = time() - strtotime($user->last_updatepass); $effectPass = ceil($effectPass / (24 * 60 * 60)); if ($user->require_changepass) { //Lan dau login yc change pass $this->setState('change_pass', 2); } else { if ($effectPass > 90) { // Sau 90 ngay can change pass $this->setState('change_pass', 3); } else { if ($effectPass >= 7) { // Truoc 7 ngay expired Pass, co thong bao $this->setState('change_pass', 1); } else { // Password van con hieu luc $this->setState('change_pass', 0); } } } } $user->update(); } return $this->errorCode == self::ERROR_NONE; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = AdminAdminUserModel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?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