/** * Главная страница сайта */ public function actionIndex() { // Вытаскиваем 10 последних банов $dependecy = new CDbCacheDependency('SELECT MAX(`bid`) FROM {{bans}}'); $bans = new CActiveDataProvider(Bans::model()->cache(300, $dependecy), array('criteria' => array('condition' => Yii::app()->config->auto_prune ? 'expired = 0' : null, 'order' => 'bid DESC', 'limit' => 10), 'pagination' => false)); $this->render('index', array('bans' => $bans, 'servers' => Serverinfo::model()->findAll())); }
/** * Главная страница сайта */ public function actionIndex() { // Вытаскиваем 10 последних банов $dependecy = new CDbCacheDependency('SELECT MAX(`bid`) FROM {{bans}}'); $bans = new CActiveDataProvider(Bans::model()->cache(300, $dependecy), array('criteria' => array('condition' => Yii::app()->config->auto_prune ? 'expired = 0' : null, 'order' => 'bid DESC', 'limit' => 10), 'pagination' => false)); // Вытаскиваем 10 лучших игроков $dependecy = new CDbCacheDependency('SELECT MAX(`id`) FROM `bio_players`'); $players = new CActiveDataProvider(Players::model()->cache(300, $dependecy), array('criteria' => array('select' => '`id`, `nick`, ' . Players::sql_skill_formula() . ' AS `skill`', 'order' => '`skill` DESC, `id` ASC', 'condition' => 'last_seen > ' . (time() - 60 * 60 * 24 * 7), 'limit' => 10), 'pagination' => false)); $this->render('index', array('bans' => $bans, 'players' => $players, 'servers' => Serverinfo::model()->findAll())); }
/** * Главная страница админцентра * @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()))); }
/** * Загрузка модели по ID * @param integer ID бана */ public function loadModel($id) { $model = Bans::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
protected function beforeValidate() { if ($this->isNewRecord) { if (!filter_var($this->player_ip, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4))) { return $this->addError($this->player_ip, 'Неверно введен IP'); } if ($this->player_ip && Bans::model()->count('`player_ip` = :ip AND (`ban_length` = 0 OR `ban_created` + (`ban_length` * 60) >= UNIX_TIMESTAMP())', array(':ip' => $this->player_ip))) { return $this->addError($this->player_ip, 'Этот IP уже забанен'); } if ($this->player_id && Bans::model()->count('`player_id` = :id AND (`ban_length` = 0 OR `ban_created` + (`ban_length` * 60) >= UNIX_TIMESTAMP())', array(':id' => $this->player_id))) { return $this->addError($this->player_id, 'Этот STEAMID уже забанен'); } } return parent::beforeValidate(); }
/** * Главная страница админцентра * @throws CHttpException */ public function actionIndex() { // Если гость, выдаем эксепшн if (Yii::app()->user->isGuest) { throw new CHttpException(403, 'У Вас недостаточно прав'); } $this->render('index', array('sysinfo' => array('bancount' => Bans::model()->cache(300)->count(), 'activebans' => Bans::model()->cache(300)->count(), 'filescount' => Files::model()->cache(300)->count(), 'commentscount' => Comments::model()->cache(300)->count()))); }
/** *Главная страница серверов */ public function actionIndex() { $model = new Serverinfo('search'); $model->unsetAttributes(); if (isset($_GET['Serverinfo'])) { $model->attributes = $_GET['Serverinfo']; } $allbans = Bans::model()->cache(600)->count(); $activebans = Bans::model()->cache(600)->count('((ban_created+(ban_length*60)) > :time OR ban_length = 0) AND `expired` = 0', array(':time' => time())); $permbans = Bans::model()->cache(600)->count('ban_length = 0'); $this->render('index', array('servers' => Serverinfo::model()->cache(600)->findAll(array('order' => '`hostname` ASC')), 'info' => array('bancount' => $allbans, 'actbans' => $activebans, 'permbans' => $permbans, 'tempbans' => $activebans - $permbans, 'admins' => Amxadmins::model()->cache(600)->count(), 'serversCount' => Serverinfo::model()->cache(600)->count()))); }