コード例 #1
0
ファイル: SiteController.php プロジェクト: urichalex/CS-Bans
 /**
  * Главная страница сайта
  */
 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()));
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: DmitriyS/CS-Bans
 /**
  * Главная страница сайта
  */
 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()));
 }
コード例 #3
0
ファイル: AdminController.php プロジェクト: DmitriyS/CS-Bans
 /**
  * Управление серверами
  * @throws CHttpException
  */
 public function actionServers()
 {
     if (Yii::app()->user->isGuest) {
         throw new CHttpException(403, 'У Вас недостаточно прав');
     }
     $model = new Serverinfo('search');
     $model->unsetAttributes();
     if (isset($_GET['Serverinfo'])) {
         $model->attributes = $_GET['Serverinfo'];
     }
     $servers = new CActiveDataProvider('Serverinfo', array('pagination' => array('pageSize' => Yii::app()->config->bans_per_page)));
     $this->render('servers', array('servers' => $servers, 'model' => $model));
 }
コード例 #4
0
ファイル: _form.php プロジェクト: BroneKot/CS-Bans
echo $form->dropDownListRow($model, 'flags', Amxadmins::getAuthType(), array('class' => 'span6', 'maxlength' => 32));
echo $form->textFieldRow($model, 'nickname', array('class' => 'span6', 'maxlength' => 32));
echo $form->textFieldRow($model, 'steamid', array('class' => 'span6', 'maxlength' => 32));
echo $form->textFieldRow($model, 'username', array('class' => 'span6', 'maxlength' => 32));
if (!$model->isNewRecord && $model->flags != 'a' && $model->password) {
    $htmlOptions = array('append' => '<label>' . CHtml::checkBox('removePwd') . ' Удалить пароль</label>', 'style' => 'width: 167px', 'value' => isset($_POST['Amxadmins']['password']) ? CHtml::encode($_POST['Amxadmins']['password']) : '');
} else {
    $htmlOptions = array('class' => 'span6', 'value' => isset($_POST['Amxadmins']['password']) ? CHtml::encode($_POST['Amxadmins']['password']) : '');
}
echo $form->passwordFieldRow($model, 'password', $htmlOptions);
echo $form->textFieldRow($model, 'access', array('style' => 'width: 233px', 'append' => '<span id="flagsselector" style="cursor: pointer">Выбрать</span>'));
echo $form->textFieldRow($model, 'icq', array('class' => 'span6'));
echo $form->dropDownListRow($model, 'ashow', array('Нет', 'Да'), array('class' => 'span6'));
if ($model->isNewRecord) {
    echo $form->textFieldRow($model, 'days', array('class' => 'span6', 'value' => '30', 'append' => '<label>' . CHtml::checkBox('', false, array('id' => 'forever')) . ' навсегда</label>'));
    echo $form->checkBoxListRow($model, 'servers', CHtml::listData(Serverinfo::model()->findAll(), 'id', 'hostname'), array('multiple' => true));
} else {
    if ($model->expired != 0) {
        echo $form->textFieldRow($model, 'long', array('class' => 'span6', 'disabled' => 'disabled'));
    }
    ?>
	<label for="Amxadmins_change">Изменить срок админки</label>
	<div class="row-fluid">
		<div class="span2">

			<label class="radio"><input id="Amxadmins_addtake_0" value="0" type="radio" name="Amxadmins[addtake]" checked /> Добавить</label>

			<?php 
    if ($model->long > 0) {
        ?>
コード例 #5
0
 public function actionAdminsonservers()
 {
     // Проверка прав
     if (!Webadmins::checkAccess('amxadmins_edit')) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     $this->layout = '//layouts/main';
     // Сохранение параметров админа
     if (Yii::app()->request->isAjaxRequest && isset($_POST['sid']) && isset($_POST['aid'])) {
         $exit = "alert('Ошибка');";
         if (isset($_POST['active'])) {
             if (!empty($_POST['customflags']) && !preg_match('#^([a-z]+)$#', $_POST['customflags'])) {
                 Yii::app()->end("alert('Ошибка!В флаги нужно прописывать только буквы латинского алфавита');");
             }
             $adm = AdminsServers::model()->findByAttributes(array('admin_id' => $_POST['aid'], 'server_id' => $_POST['sid']));
             if ($adm === NULL) {
                 $adm = new AdminsServers();
                 $adm->admin_id = $_POST['aid'];
                 $adm->server_id = $_POST['sid'];
             }
             $adm->flags = isset($_POST['customflags']) ? str_split($_POST['customflags']) : array();
             $adm->use_static_bantime = $_POST['staticbantime'];
             if ($adm->save()) {
                 $exit = "alert('Сохранено');";
             }
         } else {
             $admin = Amxadmins::model()->findByPk($_POST['aid']);
             $res = AdminsServers::model()->deleteAllByAttributes(array('admin_id' => $_POST['aid'], 'server_id' => $_POST['sid']));
             if ($res) {
                 $hash = crc32($admin->steamid);
                 $exit = "alert('Удалено'); \$('.input{$hash}').hide();";
             }
         }
         Yii::app()->end($exit);
     } elseif (Yii::app()->request->isAjaxRequest && isset($_POST['sid']) && is_numeric($_POST['sid'])) {
         $sid = $_POST['sid'];
         $admins = Amxadmins::model()->sort()->findAll();
         $server = Serverinfo::model()->findByPk($sid);
         // Шапка таблицы с админами
         $js = "<table class=\"table table-bordered table-stripped\"><thead><tr class=\"info\"><th colspan=5>{$server->hostname}</th></tr></tr><tr><th>Ник</th><th>Steam/IP/Ник</th><th>Доп. флаги</th><th>Установленное время бана</th><th>Вкл</th><th>Сохранить</th></thead><tbody>";
         foreach ($admins as $admin) {
             $customflags = NULL;
             $staticbantime = NULL;
             $active = NULL;
             $link = NULL;
             $checked = FALSE;
             $display = 'display: none';
             $name1 = NULL;
             $name2 = NULL;
             $class = $admin->expired && $admin->expired <= time() ? ' class="error"' : '';
             $s = AdminsServers::model()->findByAttributes(array('admin_id' => $admin->id, 'server_id' => $sid));
             if ($s !== NULL) {
                 $checked = TRUE;
                 $display = NULL;
                 $name1 = $s->custom_flags;
                 $name2 = $s->use_static_bantime;
             }
             $customflags = CHtml::textField('customflags', $name1, array('class' => 'input' . $admin->id, 'style' => $display));
             $staticbantime = CHtml::dropDownList('staticbantime', $name2, array('no' => 'Нет', 'yes' => 'Да'), array('class' => 'input' . $admin->id, 'style' => $display));
             $link = CHtml::link('<i class="icon-ok-sign"></i>', '#', array('onclick' => '$.post("", $("#tr' . $admin->id . ' input, #tr' . $admin->id . ' select").serialize(), function(data){ eval(data); }); return false;', 'rel' => 'tooltip', 'title' => 'Сохранить'));
             $js .= "<tr id='tr" . $admin->id . "'{$class}>";
             $js .= CHtml::form('', 'post', array('id' => 'form' . $admin->id));
             $js .= "<td id=\"nickname\">" . CHtml::encode($admin->nickname) . '</td>';
             $js .= "<td id=\"\">{$admin->steamid}</td>";
             $js .= "<td id=\"customflags\">{$customflags}</td>";
             $js .= "<td id=\"staticbantime\">{$staticbantime}</td>";
             $js .= "<td style=\"text-align: center; vertical-alifn: middle\">" . CHtml::checkBox('active', $checked, array('id' => 'active' . $admin->id, 'onclick' => 'checkaccess("' . $admin->id . '");')) . "</td>";
             $js .= "<td style=\"text-align: center; vertical-alifn: middle\">{$link}</td>";
             $js .= CHtml::hiddenField('aid', $admin->id);
             $js .= CHtml::hiddenField('sid', $sid);
             $js .= CHtml::endForm();
             $js .= "</tr>";
         }
         $js .= '</tbody></table>';
         Yii::app()->end($js);
     }
     $this->render('adminsonservers', array('servers' => Serverinfo::model()->cache(600)->findAll()));
 }
コード例 #6
0
ファイル: Amxadmins.php プロジェクト: BroneKot/CS-Bans
 public function afterSave()
 {
     if (!empty($this->servers) && $this->isNewRecord) {
         foreach ($this->servers as $is) {
             $inservers = new AdminsServers();
             $inservers->unsetAttributes();
             if (!Serverinfo::model()->findByPk($is)) {
                 continue;
             }
             $inservers->admin_id = $this->id;
             $inservers->server_id = intval($is);
             $inservers->use_static_bantime = 'no';
             if (!$inservers->save()) {
                 continue;
             }
         }
     }
     if ($this->isNewRecord) {
         Syslog::add(Logs::LOG_ADDED, 'Добавлен новый AmxModX админ <strong>' . $this->nickname . '</strong>');
     } else {
         Syslog::add(Logs::LOG_EDITED, 'Изменены детали AmxModX админа <strong>' . $this->nickname . '</strong>');
     }
     return parent::afterSave();
 }
コード例 #7
0
ファイル: _form.php プロジェクト: urichalex/CS-Bans
}
echo $form->dropDownListControlGroup($model, 'flags', Amxadmins::getAuthType(), array('maxlength' => 32));
echo $form->textFieldControlGroup($model, 'nickname', array('maxlength' => 32));
echo $form->textFieldControlGroup($model, 'steamid', array('maxlength' => 32));
echo $form->textFieldControlGroup($model, 'username', array('maxlength' => 32));
if (!$model->isNewRecord && $model->flags != 'a' && $model->password) {
    $htmlOptions = array('append' => CHtml::checkBox('removePwd') . ' Удалить пароль', 'value' => isset($_POST['Amxadmins']['password']) ? CHtml::encode($_POST['Amxadmins']['password']) : '');
} else {
    $htmlOptions = array('value' => isset($_POST['Amxadmins']['password']) ? CHtml::encode($_POST['Amxadmins']['password']) : '');
}
echo $form->passwordFieldControlGroup($model, 'password', $htmlOptions);
echo $form->textFieldControlGroup($model, 'access', array('append' => '<span id="flagsselector" style="cursor: pointer">Выбрать</span>'));
echo $form->textFieldControlGroup($model, 'icq', array('class' => 'span6'));
if ($model->isNewRecord) {
    echo $form->textFieldControlGroup($model, 'days', array('value' => '30', 'append' => CHtml::checkBox('', false, array('id' => 'forever')) . ' навсегда'));
    echo $form->checkBoxListControlGroup($model, 'servers', CHtml::listData(Serverinfo::model()->findAll(), 'id', 'hostname'));
} else {
    if ($model->expired != 0) {
        echo $form->textFieldControlGroup($model, 'long', array('disabled' => 'disabled'));
    }
    ?>
        
        <div class="form-group">
            <label for="Amxadmins_change">Изменить срок админки</label>
            <div class="input-group">
                <span class="input-group-addon">
                    <input id="Amxadmins_addtake_0" value="0" type="radio" name="Amxadmins[addtake]" checked />
                    Добавить
                </span>

            <?php 
コード例 #8
0
ファイル: _form.php プロジェクト: urichalex/CS-Bans
<?php 
if (!$model->isNewrecord && $model->rcon) {
    ?>
<table class="table table-bordered">
	<thead>
		<tr>
			<th>
				Отправить RCON команду на сервер
			</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
				<?php 
    echo CHtml::dropDownList('', '', Serverinfo::getCommands(), array('id' => 'commandlist', 'style' => 'margin-top: 10px'));
    ?>
				&nbsp;
				<?php 
    echo CHtml::textField('', '', array('id' => 'command', 'style' => 'margin-top: 10px'));
    ?>
				&nbsp;
				<?php 
    echo CHtml::button('Отправить', array('id' => 'sendcommand', 'class' => 'btn btn-info'));
    ?>
			</td>
		</tr>
		<tr>
			<td>
				<pre id="output" style="min-height: 400px; font-size: 12px"></pre>
			</td>
コード例 #9
0
 /**
  * Вывод инфы о сервере в модальке
  * @throws CHttpException
  */
 public function actionServerdetail()
 {
     $model = Serverinfo::model()->findByPk($_POST['sid']);
     $info = $model->getInfo();
     $players = "";
     if (empty($info['playersinfo']) || !is_array($info['playersinfo'])) {
         $players .= "<table class=\"items table table-bordered table-condensed\">";
         $players .= "<tr class=\"odd\"><td width=\"100%\" style=\"text-align:center\">Нет игроков</td></tr></table>";
     } else {
         $players .= "<table class=\"items table table-bordered table-condensed\">";
         $players .= "<tr class=\"odd\">";
         $players .= "<td width=\"70%\"><b>Ник</b></td>";
         $players .= "<td><b>Счёт</b></td>";
         $players .= "<td><b>Время</b></td>";
         foreach ($info['playersinfo'] as $player_key => $player) {
             $players .= "<tr class=\"odd\">";
             $players .= "<td width=\"70%\">" . CHtml::encode($player['name']) . "</td>";
             $players .= "<td style=\"text-align:center\">" . intval($player['score'], ENT_QUOTES) . "</td>";
             $players .= "<td>" . (function_exists('query_live') ? $player['time'] : Prefs::date2word(intval($player['time']), FALSE, TRUE)) . "</td>";
             $players .= "</tr>";
         }
         $players .= "</table>";
     }
     $js = "\$('#server-name').html('" . CJavaScript::quote($info['name']) . "');";
     $js .= "\$('#serverlink').html('" . CJavaScript::quote($info['name']) . "').attr({'href': '" . Yii::app()->createUrl('serverinfo/view', array('id' => $model->id)) . "'});";
     $js .= "\$('#server-address').html('" . CJavaScript::quote($model->address) . "');";
     $js .= "\$('#steam-connect').attr({'href': 'steam://connect/" . CJavaScript::quote($model->address) . "'});";
     $js .= "\$('#hlws-add').attr({'href': 'hlsw://" . CJavaScript::quote($model->address) . "'});";
     $js .= "\$('#server-map').html('" . CJavaScript::quote($info['map']) . "');";
     $js .= "\$('#server-players').html('" . $info['players'] . '/' . $info['playersmax'] . "');";
     $js .= "\$('#serverinfo-players').html('" . CJavaScript::quote($players) . "');";
     $js .= "\$('#server-mapimage').html('" . CJavaScript::quote($info['mapimg']) . "');";
     $js .= "\$('#loading').hide();";
     $js .= "\$('#ServerDetail').modal('show');";
     Yii::app()->end($js);
 }
コード例 #10
0
ファイル: _form.php プロジェクト: urichalex/CS-Bans
    ?>
<table class="table table-bordered">
	<thead>
		<tr>
			<th>
				Отправить RCON команду на сервер
			</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
                <div class="input-group">
                    <span class="input-group-btn">
                        <?php 
    echo CHtml::dropDownList('', '', Serverinfo::getCommands(), array('id' => 'commandlist', 'class' => 'form-control', 'style' => 'width: 150px'));
    ?>
                    </span>
                    <input type="text" class="form-control" id="command">
                    <span class="input-group-btn">
                        <button type="button" class="btn btn-info" id="sendcommand">Отправить</button>
                    </span>
                </div>
			</td>
		</tr>
		<tr>
			<td>
				<pre id="output" style="min-height: 400px; font-size: 12px"></pre>
			</td>
		</tr>
	</tbody>