コード例 #1
0
ファイル: UserIdentity.php プロジェクト: BroneKot/CS-Bans
 /**
  * Аутентификация пользователя.
  * @return boolean если аутентификация успешна.
  */
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = Webadmins::model()->find('LOWER(username)=?', array($username));
     Yii::import('ext.kcaptcha.KCaptchaValidator');
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif ($user->try >= 3 && empty($_POST['verify'])) {
         Yii::app()->request->cookies['captcha_auth'] = new CHttpCookie('captcha_auth', '1');
         Yii::app()->controller->refresh();
     } elseif ($user->try >= 3 && !KCaptchaValidator::testCode($_POST['verify'])) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } elseif (!$user->validatePassword($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         $user->try++;
         $user->scenario = 'auth';
         $user->save();
     } else {
         $this->_id = $user->id;
         $this->setState('email', $user->email);
         $this->username = $user->username;
         $this->errorCode = self::ERROR_NONE;
         // Лог входа, добавить запись
         $user->last_action = time();
         $user->try = 0;
         $user->scenario = 'auth';
         $user->save();
         unset(Yii::app()->request->cookies['captha_auth']);
     }
     return $this->errorCode == self::ERROR_NONE;
 }
コード例 #2
0
ファイル: LevelsController.php プロジェクト: BroneKot/CS-Bans
 public function actionAdmin()
 {
     if (!Webadmins::checkAccess('websettings_view')) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     $model = new Levels('search');
     $model->unsetAttributes();
     if (isset($_GET['Levels'])) {
         $model->attributes = $_GET['Levels'];
     }
     $this->render('admin', array('model' => $model));
 }
コード例 #3
0
 public function actionAdmin()
 {
     // Проверяем права
     if (!Webadmins::checkAccess('webadmins_edit')) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     $model = new Webconfig('search');
     $model->unsetAttributes();
     if (isset($_GET['Webconfig'])) {
         $model->attributes = $_GET['Webconfig'];
     }
     $this->render('admin', array('model' => $model));
 }
コード例 #4
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (!Webadmins::checkAccess('websettings_edit')) {
         throw new CHttpException(403, 'У Вас недостаточно прав');
     }
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $this->loadModel($id)->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
コード例 #5
0
ファイル: LogsController.php プロジェクト: BroneKot/CS-Bans
 public function actionAdmin()
 {
     // Проверка прав
     if (!Webadmins::checkAccess('websettings_edit')) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     $model = new Logs('search');
     $model->unsetAttributes();
     if (isset($_GET['Logs'])) {
         $model->attributes = $_GET['Logs'];
     }
     if (isset($_POST['clearlog']) && Yii::app()->request->isAjaxRequest) {
         $this->layout = FALSE;
         $tr = Yii::app()->db->createCommand()->truncateTable('{{logs}}');
         exit("{$tr}");
     }
     $this->render('admin', array('model' => $model));
 }
コード例 #6
0
ファイル: AdminController.php プロジェクト: DmitriyS/CS-Bans
 /**
  * Настройки сайта
  * @throws CHttpException
  */
 public function actionWebsettings()
 {
     // Проверяем права пользователя
     if (!Webadmins::checkAccess('websettings_view')) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     // Вытаскиваем модель
     $model = Webconfig::getCfg();
     $themes = array();
     // Ищем папки тем в themes
     foreach (glob(ROOTPATH . '/themes/*') as $t) {
         $themes[basename($t)] = basename($t);
     }
     if (isset($_POST['Webconfig'])) {
         if (!Webadmins::checkAccess('websettings_edit')) {
             throw new CHttpException(403, "У Вас недостаточно прав");
         }
         $model->attributes = $_POST['Webconfig'];
         if ($model->save()) {
             $this->redirect(array('websettings'));
         }
     }
     $this->render('websettings', array('model' => $model, 'themes' => $themes));
 }
コード例 #7
0
ファイル: BansController.php プロジェクト: DmitriyS/CS-Bans
 /**
  * Вывод данных о бане в модальке
  */
 public function actionBandetail()
 {
     if (is_numeric($_POST['bid'])) {
         $model = Bans::model()->with('admin')->findByPk($_POST['bid']);
         if ($model === null) {
             Yii::app()->end('alert("Ошибка!")');
         }
         $js = "\$('#bandetail-nick').html('" . CHtml::encode($model->player_nick) . "');";
         $js .= "\$('#bandetail-steam').html('" . $model->player_id . "');";
         //$js .= "$('#bandetail-steamcommynity').html('" . Prefs::steam_convert($model->player_id, true) . "');";
         $js .= "\$('#bandetail-ip').html('" . (Webadmins::checkAccess('ip_view') ? $model->player_ip : 'Cкрыт') . "');";
         //$js .= "$('#bandetail-type').html('" . Prefs::getBanType($model->ban_type) . "');";
         $js .= "\$('#bandetail-datetime').html('" . date('d.m.y - H:i:s', $model->ban_created) . "');";
         $js .= "\$('#bandetail-expired').html('" . ($model->ban_length == '-1' ? 'Разбанен' : Prefs::date2word($model->ban_length) . ($model->expired == 1 ? ' (истек)' : '')) . "');";
         $js .= "\$('#bandetail-map').html('" . $model->map_name . "');";
         $js .= "\$('#bandetail-reason').html('" . CHtml::encode($model->ban_reason) . "');";
         $js .= "\$('#bandetail-admin').html('" . CHtml::encode($model->admin_nick) . "');";
         $js .= "\$('#bandetail-server').html('" . CHtml::encode($model->server_name) . "');";
         //$js .= "$('#bandetail-kicks').html('" . $model->ban_kicks . "');";
         $js .= "\$('#loading').hide();";
         $js .= "\$('#viewban').attr({'href': '" . Yii::app()->urlManager->createUrl('/bans/view', array('id' => $_POST['bid'])) . "'});";
         $js .= "\$('#BanDetail').modal('show');";
         echo $js;
     }
     Yii::app()->end();
 }
コード例 #8
0
ファイル: view.php プロジェクト: DmitriyS/CS-Bans
}
?>

<h2>Подробности истории бана <i><?php 
echo CHtml::encode($model->player_nick);
?>
</i></h2>
<div style="float: right">
	<?php 
if (Webadmins::checkAccess('bans_edit', $model->admin_nick)) {
    echo CHtml::link('<i class="icon-edit"></i>', $this->createUrl('/bans/update', array('id' => $model->bhid)), array('rel' => 'tooltip', 'title' => 'Редактировать'));
}
?>
	&nbsp;
	<?php 
if (Webadmins::checkAccess('bans_delete', $model->admin_nick)) {
    echo CHtml::ajaxLink('<i class="icon-trash"></i>', $this->createUrl('/bans/delete', array('id' => $model->bhid, 'ajax' => 1)), array('type' => 'post', 'beforeSend' => 'function() {if(!confirm("Удалить бан?")) {return false;} }', 'success' => 'function() {alert("Бан удален"); document.location.href="' . $this->createUrl('/bans/index') . '"}'), array('rel' => 'tooltip', 'title' => 'Удалить бан'));
}
?>
</div>

<?php 
$this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'type' => array('condensed', 'bordered'), 'htmlOptions' => array('style' => 'text-align: left'), 'attributes' => array('player_nick', array('name' => 'player_id', 'type' => 'raw', 'value' => Prefs::steam_convert($model->player_id, TRUE) ? CHtml::link($model->player_id, 'http://steamcommunity.com/profiles/' . Prefs::steam_convert($model->player_id), array('target' => '_blank')) : $model->player_id), array('name' => 'player_ip', 'type' => 'raw', 'value' => $geo['city'] ? CHtml::link($model->player_ip, '#', array('onclick' => '$("#modal-map").modal("show");', 'rel' => 'tooltip', 'title' => 'Подробности IP адреса')) : $model->player_ip, 'visible' => $ipaccess), array('name' => 'ban_created', 'value' => date('d.m.Y - H:i:s', $model->ban_created)), array('name' => 'ban_length', 'type' => 'raw', 'value' => $length), 'map_name', 'ban_reason', 'admin_nick', 'server_name')));
?>

<hr>
<p class="text-success">
	<i class="icon-calendar"></i>
	История банов
</p>
<?php 
コード例 #9
0
 public function loadModel($id)
 {
     $model = Webadmins::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #10
0
ファイル: view.php プロジェクト: BroneKot/CS-Bans
					?
				"Разбанен"
					:
				Prefs::date2word($data->ban_length) .
				($data->expired == 1 ? " (истек)" : "")'))));
?>
<hr>
<p class="text-success">
	<i class="icon-comment"></i>
	Комментарии
</p>

<?php 
$this->widget('bootstrap.widgets.TbGridView', array('type' => 'striped bordered condensed', 'id' => 'comments-grid', 'template' => '{items}', 'dataProvider' => $c, 'enableSorting' => FALSE, 'rowHtmlOptionsExpression' => 'array(
		"id" => "$data->id"
	)', 'columns' => array(array('header' => 'Дата', 'value' => 'date("d.m.Y", $data->date)', 'htmlOptions' => array('style' => 'width:80px')), array('header' => 'Комментарий', 'value' => '$data->comment'), 'name', array('name' => 'addr', 'value' => '$data->addr', 'htmlOptions' => array('style' => 'width:100px'), 'visible' => $ipaccess), array('name' => 'email', 'value' => '$data->email', 'htmlOptions' => array('style' => 'width:200px')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'header' => 'Действия', 'template' => '{update} {delete}', 'buttons' => array('delete' => array('label' => 'Удалить', 'icon' => 'trash', 'url' => 'Yii::app()->createUrl("/comments/delete", array("id"=>$data->id))'), 'update' => array('label' => 'Редактировать', 'icon' => 'pencil', 'url' => 'Yii::app()->createUrl("/comments/update", array("id"=>$data->id, "bid" => $data->bid))')), 'htmlOptions' => array('style' => 'width: 80px; text-align:center'), 'visible' => Webadmins::checkAccess('bans_edit', $model->admin_nick)))));
if (Yii::app()->config->use_comment && (!Yii::app()->user->isGuest || Yii::app()->config->comment_all)) {
    ?>
	<div style="width: auto; margin: 0 auto">
		<?php 
    $this->widget('bootstrap.widgets.TbButton', array('label' => 'Добавить комментарий', 'buttonType' => 'button', 'size' => 'small', 'htmlOptions' => array('onclick' => '$("#addcomment").slideToggle("slow");')));
    ?>
	</div>
	<div style="width: 100%; display: none" id="addcomment">
		<?php 
    echo CHtml::form('', 'post');
    ?>
		<?php 
    echo CHtml::errorSummary($comments);
    ?>
		<table class="table table-bordered">
コード例 #11
0
ファイル: _search.php プロジェクト: DmitriyS/CS-Bans
		return false;
	});
');
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
?>

    <?php 
echo $form->textFieldRow($model, 'nick', array('maxlength' => 32));
?>

	<?php 
echo $form->textFieldRow($model, 'steam_id', array('maxlength' => 20));
?>

    <?php 
if (Webadmins::checkAccess('ip_view')) {
    echo $form->textFieldRow($model, 'ip', array('maxlength' => 15));
}
?>

	<label for="Players_last_seen" class="required">Последний онлайн</label>
	<?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'id' => 'last_seen', 'attribute' => 'last_seen', 'language' => 'ru', 'i18nScriptFile' => 'jquery-ui-i18n.min.js', 'htmlOptions' => array('id' => 'last_seen', 'size' => '10'), 'options' => array('showAnim' => 'fold')));
?>

    <div class="form-actions"> 
        <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Искать'));
?>
    </div> 
コード例 #12
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     if (!Webadmins::checkAccess('websettings_edit')) {
         throw new CHttpException(403, 'У Вас недостаточно прав');
     }
     $model = new Usermenu('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Usermenu'])) {
         $model->attributes = $_GET['Usermenu'];
     }
     $this->render('admin', array('model' => $model));
 }
コード例 #13
0
ファイル: Webadmins.php プロジェクト: BroneKot/CS-Bans
 public function beforeValidate()
 {
     parent::beforeValidate();
     if (!$this->isNewRecord) {
         $oldRecord = Webadmins::model()->findByPk($this->id);
         if ($this->password && $oldRecord->password !== $this->password) {
             $this->password = md5($this->password);
         } else {
             $this->password = $oldRecord->password;
         }
     } else {
         $this->password = md5($this->password);
     }
     return TRUE;
 }
コード例 #14
0
ファイル: admin.php プロジェクト: urichalex/CS-Bans
 * @copyright (C)2016 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'), 'Системный лог');
$this->menu = array(array('label' => 'Удалить все записи', 'url' => '#', 'linkOptions' => array('id' => 'clearLog')));
Yii::app()->clientScript->registerScript('', '
	$("a#clearLog").click(function(){
		if(!confirm("Удалить все записи лога?"))
			return false;

		var ret = "";

		$.post("", {"clearlog": 1}, function(data){
			jQuery("#logs-grid").yiiGridView("update");
			alert("Лог очищен");
		});
		return false;
	});
');
$this->renderPartial('/admin/mainmenu', array('active' => 'site', 'activebtn' => 'logs'));
?>

<h2>Системный лог</h2>

<?php 
$criteria = new CDbCriteria();
$criteria->group = 'username';
$this->widget('bootstrap.widgets.TbGridView', array('id' => 'logs-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => array(array('name' => 'timestamp', 'type' => 'datetime', 'value' => '$data->timestamp', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'id' => 'timestamp', 'attribute' => 'timestamp', 'language' => 'ru', 'i18nScriptFile' => 'jquery-ui-i18n.min.js', 'htmlOptions' => array('id' => 'timestamp', 'size' => '10'), 'options' => array('showAnim' => 'fold')), true)), array('name' => 'username', 'value' => '$data->username', 'filter' => CHtml::listData(Webadmins::model()->findAll(), 'username', 'username')), array('name' => 'action', 'value' => 'Logs::getLogType($data->action)', 'filter' => Logs::getLogType(FALSE, TRUE)), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{view} {delete}'))));
Yii::app()->clientScript->registerScript('re-install-date-picker', "\r\n\tfunction reinstallDatePicker(id, data) {\r\n\t\t\$('#timestamp').datepicker(jQuery.extend({showMonthAfterYear:false},jQuery.datepicker.regional['ru'],{'showAnim':'fold'}));\r\n\t}\r\n");
コード例 #15
0
ファイル: main.php プロジェクト: DmitriyS/CS-Bans
								</form>
							</p>
						</li>
					</ul>
					<?php 
} else {
    ?>
					<a href="javascript:;" data-toggle="dropdown">
						<?php 
    echo Yii::app()->user->name;
    ?>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<?php 
    if (Webadmins::is_main_admin()) {
        ?>
						<li>
							<?php 
        echo CHtml::link('<i class="icon-globe"></i> Админцентр', Yii::app()->createUrl('/admin/index'));
        ?>
						</li>
						<li>
							<hr />
						</li>
						<?php 
    }
    ?>
						<li>
							<?php 
    echo CHtml::link('<i class="icon-off"></i> Выйти', Yii::app()->createUrl('/site/logout'));
コード例 #16
0
 /**
  * Управление серверами
  */
 public function actionAdmin()
 {
     if (!Webadmins::checkAccess('servers_edit')) {
         throw new CHttpException(403, 'У Вас недостаточно прав');
     }
     $model = new Serverinfo('search');
     $model->unsetAttributes();
     if (isset($_GET['Serverinfo'])) {
         $model->attributes = $_GET['Serverinfo'];
     }
     $this->render('admin', array('model' => $model));
 }