/** * Вывод всех банов */ 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) AND `expired` = 0"; $dataProvider = new CActiveDataProvider('Bans', 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 = Bans::model()->count("`player_ip` = :ip AND " . $select, array(':ip' => Prefs::getRealIp())); $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model, 'check' => $check > 0 ? true : false)); }
<?php /** * Вьюшка просмотра деталей админа серверов */ /** * @author Craft-Soft Team * @package CS:Bans * @version 1.0 beta * @copyright (C)2013 Craft-Soft.ru. Все права защищены. * @link http://craft-soft.ru/ * @license http://creativecommons.org/licenses/by-nc-sa/4.0/deed.ru «Attribution-NonCommercial-ShareAlike» */ $this->pageTitle = Yii::app()->name . ' :: Админцентр - Редактировать админа'; $this->breadcrumbs = array('Админцентр' => array('/admin/index'), 'AmxModX админы' => array('admin'), 'Админ ' . $model->nickname); $this->renderPartial('/admin/mainmenu', array('active' => 'server', 'activebtn' => 'servamxadmins')); $this->menu = array(array('label' => 'Добавить AmxModX админа', 'url' => array('create')), array('label' => 'Управление AmxModX админами', 'url' => array('admin'))); ?> <h2>Детали админа «<?php echo $model->nickname; ?> »</h2> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array(array('name' => 'flags', 'value' => Amxadmins::getAuthType($model->flags)), 'username', 'nickname', 'steamid', 'access', 'icq', array('name' => 'ashow', 'value' => $model->ashow == 1 ? 'Да' : 'Нет'), array('name' => 'created', 'type' => 'datetime', 'value' => $model->created), array('name' => 'expired', 'value' => $model->expired == 0 ? 'Навсегда' : date('d.m.Y H:i', $model->expired)), 'days')));
</div> <?php } $this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'flagsmodal', 'htmlOptions' => array('style' => 'width: 600px; margin-left: -300px'))); ?> <div class="modal-header"> <a class="close" data-dismiss="modal" rel="tooltip" data-placement="left" title="Закрыть">×</a> <h4>Выбор флагов доступа</h4> </div> <div class="modal-body"> <label class="checkbox"> <input type="checkbox" id="checkAllFlags"> Выбрать все (кроме z) </label> <?php echo $form->checkboxListRow($model, 'accessflags', Amxadmins::getFlags(), array('class' => 'adminflag')); ?> </div> <div class="modal-footer"> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => 'Установить', 'type' => 'primary', 'htmlOptions' => array('id' => 'setFlags'))); $this->widget('bootstrap.widgets.TbButton', array('label' => 'Отмена', 'url' => '#', 'htmlOptions' => array('data-dismiss' => 'modal'))); ?> </div> <?php $this->endWidget(); if ($model->isNewRecord) { ?> <hr class="row-divider"> <button class="btn btn-info" type="button" onclick="$('#webrights').slideToggle('slow');">Добавить WEB админа</button> <div id="webrights" style="display: none"><br>
protected function beforeSave() { $removePwd = filter_input(INPUT_POST, 'removePwd', FILTER_VALIDATE_BOOLEAN); if ($removePwd) { $this->password = ''; } if ($this->isNewRecord) { $this->created = time(); if ($this->password && $this->scenario != 'buy') { $this->password = md5($this->password); } if ($this->flags != 'a' && !$this->password) { $this->flags .= 'e'; } $this->expired = $this->days != 0 ? $this->days * 86400 + time() : 0; } else { if ($this->password) { $this->password = md5($this->password); } else { $oldadmin = Amxadmins::model()->findByPk($this->id); if ($oldadmin->password && !$removePwd) { $this->password = $oldadmin->password; } elseif ($this->flags != 'a') { $this->flags .= 'e'; } } if ($this->expired == 0) { $this->expired = time(); } switch ($this->addtake) { case '1': $this->expired = $this->expired - $this->change * 86400; $this->days = $this->days - $this->change; break; case '0': $this->expired = $this->expired + $this->change * 86400; $this->days = $this->days + $this->change; break; default: $this->expired = 0; $this->days = 0; } } return parent::beforeSave(); }
/** * Загрузка модели по ID * Если не найдено, выводим эксепшн * @param integer ID админа */ public function loadModel($id) { $model = Amxadmins::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
} $this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'flagsmodal')); ?> <div class="modal-header"> <a class="close" data-dismiss="modal" rel="tooltip" data-placement="left" title="Закрыть">×</a> <h4>Выбор флагов доступа</h4> </div> <div class="modal-body"> <!--label class="checkbox"> <input type="checkbox" id="checkAllFlags"> Выбрать все (кроме z) </label--> <!--?php echo $form->checkboxListRow($model, 'accessflags', Amxadmins::getFlags(), array('class' => 'adminflag')); ?--> <?php echo $form->radioButtonListRow($model, 'accessflags', Amxadmins::getFlags(), array('class' => 'adminflag')); ?> </div> <div class="modal-footer"> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => 'Установить', 'type' => 'primary', 'htmlOptions' => array('id' => 'setFlags'))); $this->widget('bootstrap.widgets.TbButton', array('label' => 'Отмена', 'url' => '#', 'htmlOptions' => array('data-dismiss' => 'modal'))); ?> </div> <?php $this->endWidget(); if ($model->isNewRecord) { ?> <!--hr class="row-divider"> <button class="btn btn-info" type="button" onclick="$('#webrights').slideToggle('slow');">Добавить WEB админа</button> <div id="webrights" style="display: none"><br-->
<?php /** * Вьюшка просмотра деталей админа серверов */ /** * @author Craft-Soft Team * @package CS:Bans * @version 1.0 beta * @copyright (C)2013 Craft-Soft.ru. Все права защищены. * @link http://craft-soft.ru/ * @license http://creativecommons.org/licenses/by-nc-sa/4.0/deed.ru «Attribution-NonCommercial-ShareAlike» */ $this->pageTitle = Yii::app()->name . ' :: Админцентр - Редактировать админа'; $this->breadcrumbs = array('Админцентр' => array('/admin/index'), 'AmxModX админы' => array('admin'), 'Админ ' . $model->nickname); $this->renderPartial('/admin/mainmenu', array('active' => 'server', 'activebtn' => 'servamxadmins')); $this->menu = array(array('label' => 'Добавить AmxModX админа', 'url' => array('create')), array('label' => 'Управление AmxModX админами', 'url' => array('admin'))); ?> <h2>Детали админа «<?php echo $model->nickname; ?> »</h2> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('nickname', 'username', 'password', array('name' => 'flags', 'value' => Amxadmins::getAuthType($model->flags)), 'access', 'icq', array('name' => 'is_active', 'value' => $model->is_active ? 'Да' : 'Нет'), array('name' => 'ashow', 'value' => $model->ashow ? 'Да' : 'Нет'), array('name' => 'created', 'type' => 'datetime', 'value' => $model->created))));
?> </div> <?php $this->endWidget(); ?> <div style="width: 200px; margin: 0 auto; text-align: center"> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => 'Информация доступа', 'url' => '#', 'htmlOptions' => array('onclick' => '$("#info_access").slideToggle("slow"); return false;'))); ?> </div> <div id="info_access" class="row-fluid" style="display: none"> <div class="span6"> <h3 class="muted">Права доступа</h3> <?php foreach (Amxadmins::getFlags(TRUE) as $flag => $desc) { echo $flag . ' - ' . $desc . '<br />'; } ?> </div> <div class="span6"> <h3 class="muted">Флаги доступа</h3> a - Кикать игрока при вводе некорректного пароля<br /> b - Тег клана<br /> c - Для SteamID<br /> d - Для IP<br /> e - Пароль не требуется (важен только SteamID либо IP )<br /> k - Имя или тег (С УчёТом РеГистРа!). </div> </div>
/** *Главная страница серверов */ 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()))); }
<?php echo $form->textFieldRow($model, 'player_id', array('maxlength' => 20)); ?> <?php if (Webadmins::checkAccess('ip_view')) { echo $form->textFieldRow($model, 'player_ip', array('maxlength' => 15)); } ?> <?php echo $form->textFieldRow($model, 'ban_reason', array('maxlength' => 100)); ?> <?php echo $form->dropDownListRow($model, 'admin_nick', Amxadmins::getList(), array('empty' => '', 'maxlength' => 100)); ?> <label for="Bans_ban_created" class="required">Дата бана</label> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'id' => 'ban_created', 'attribute' => 'ban_created', 'language' => 'ru', 'i18nScriptFile' => 'jquery-ui-i18n.min.js', 'htmlOptions' => array('id' => 'ban_created', 'size' => '10'), 'options' => array('showAnim' => 'fold'))); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Искать')); ?> </div> <?php $this->endWidget();