/** * Главная страница админцентра * @throws CHttpException */ public function actionIndex() { // Если гость, выдаем эксепшн if (Yii::app()->user->isGuest) { throw new CHttpException(403, 'У Вас недостаточно прав'); } // Только главный админ имеет право входить в аминцентр if (Yii::app()->user->id != '1') { throw new CHttpException(403, 'У Вас недостаточно прав'); } $this->render('index', array('sysinfo' => array('bancount' => History::model()->cache(300)->count(), 'activebans' => Bans::model()->cache(300)->count(), 'filescount' => Files::model()->cache(300)->count(), 'commentscount' => Comments::model()->cache(300)->count()))); }
/** * 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 primary key value. Defaults to null, meaning using the 'id' GET variable */ public function loadHistory($id = null) { if ($this->_model === null) { if ($id !== null || isset($_GET['id'])) { $this->_model = History::model()->findbyPk($id !== null ? $id : $_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
/** * Вывод всех банов */ public function actionIndex() { if (Yii::app()->request->isAjaxRequest && isset($_POST['server'])) { if ($_POST['server'] == 0) { Yii::app()->end('$("#Bans_admin_nick").html("<option value=\\"0\\">Не выбрано</option>");'); } $amxadmins = Amxadmins::model()->with('servers')->findAll('`address` = :addr', array(':addr' => $_POST['server'])); $js = "<option>Любой админ</option>"; foreach ($amxadmins as $admin) { $js .= "<option value=\"{$admin->steamid}\">{$admin->nickname}</option>"; } Yii::app()->end("\$('#Bans_admin_nick').html('{$js}')"); } $model = new Bans('search'); $model->unsetAttributes(); if (isset($_GET['Bans'])) { $model->attributes = $_GET['Bans']; } $select = "(ban_created+(ban_length*60)) < UNIX_TIMESTAMP() OR ban_length = 0"; $dataProvider = new CActiveDataProvider('History', array('criteria' => array('condition' => Yii::app()->config->auto_prune ? $select : null, 'order' => '`ban_created` DESC'), 'pagination' => array('pageSize' => Yii::app()->config->bans_per_page))); // Проверяем IP посетителя, есть ли он в активных банах $check = History::model()->count("`player_ip` = :ip AND " . $select, array(':ip' => Prefs::getRealIp())); $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model, 'check' => $check > 0 ? true : false)); }
/** * 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 $id the ID of the model to be loaded * @return History the loaded model * @throws CHttpException */ public function loadModel($id) { $model = History::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }