예제 #1
0
 public function actionIndex()
 {
     // 推荐产品
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_recommend', 1);
     $criteria->compare('t.is_released', 1);
     $criteria->order = 't.sort_order ASC';
     $products = Product::model()->localized()->findAll($criteria);
     // 推荐品牌
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_recommend', 1);
     $criteria->compare('t.is_released', 1);
     $criteria->order = 't.sort_order ASC';
     $brands = Brand::model()->localized()->findAll($criteria);
     // 推荐服务
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_recommend', 1);
     $criteria->compare('t.is_released', 1);
     $criteria->order = 't.sort_order ASC';
     $servers = Server::model()->localized()->findAll($criteria);
     $this->layout = 'main';
     $this->pageTitle = Yii::t('common', '首页') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $this->metaKeywords = Setting::getValueByCode('meta_keywords', true);
     $this->metaDescription = Setting::getValueByCode('meta_description', true);
     $this->render('index', array('products' => $products, 'brands' => $brands, 'servers' => $servers));
     //$this->renderPartial('index');
 }
예제 #2
0
 /**
  * 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 Server the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Server::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #3
0
 public function actionMonitorDetail($id, $serverId)
 {
     $namaTabel = "{$serverId}_{$id}";
     $model = new MonitorDetail($namaTabel);
     $model->scenario = 'search';
     $monitor = Monitor::model()->findByPk($id);
     $server = Server::model()->findByPk($serverId);
     $this->render('monitor_detail', ['model' => $model, 'server' => $server, 'monitor' => $monitor]);
 }
예제 #4
0
 public function actionView()
 {
     // 当前新闻
     if (isset($_GET['id'])) {
         $id = Yii::app()->request->getQuery('id');
         $server = Server::model()->localized()->findByPk($id);
     } else {
         $server = null;
     }
     if (empty($server)) {
         throw new CHttpException(404);
     }
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 3);
     $banner = Banner::model()->localized()->find($criteria);
     $this->layout = 'main';
     $this->pageTitle = $server->name . "-" . Yii::t('common', '服务中心');
     $this->render('view', array('server' => $server, 'banner' => $banner));
 }
 public function actionIndex($id)
 {
     $sv = Server::model()->findByPk((int) $id);
     if (!$sv) {
         throw new Exception('Server not found');
     }
     $cfg = ServerConfig::model()->findByPk((int) $id);
     $pl = $sv->getOnlinePlayers();
     $st = $pl >= 0 ? 'online' : 'offline';
     $image = $this->getImg(Theme::themeFilePath('images/status/' . $this->banner));
     $statusIcon = $this->getImg(Theme::themeFilePath('images/status/' . $this->statusIcons[$st == 'online' ? 0 : 1]));
     $font = Theme::themeFilePath('images/status/' . $this->font);
     $color = imagecolorallocate($image, $this->color[0], $this->color[1], $this->color[2]);
     //Status icon
     imagecopy($image, $statusIcon, $this->textX, $this->iconY, 0, 0, imagesx($statusIcon), imagesy($statusIcon));
     imagedestroy($statusIcon);
     //Server name
     imagettftext($image, $this->titleSize, 0, $this->textX, $this->titleY, $color, $font, $sv->name);
     //Server IP
     $ipStr = trim($cfg && $cfg->display_ip ? $cfg->display_ip : $sv->ip);
     if (!strlen($ipStr) || $ipStr == '0.0.0.0') {
         if ($dmn = Daemon::model()->findByPk($sv->daemon_id)) {
             $ipStr = $dmn->ip;
         }
     }
     $ipStr = 'IP: ' . $ipStr . ':' . $sv->port;
     $sz = imagettfbbox($this->ipSize, 0, $font, $ipStr);
     imagettftext($image, $this->ipSize, 0, imagesx($image) - ($sz[2] - $sz[0]) - $this->ipOffset, $this->statusY, $color, $font, $ipStr);
     //Server status
     if ($st == 'online') {
         imagettftext($image, $this->statusSize, 0, $this->textX + $this->statusOffset, $this->statusY, $color, $font, $pl . ' / ' . $sv->players . ' ' . Yii::t('mc', 'Players'));
     } else {
         imagettftext($image, $this->statusSize, 0, $this->textX + $this->statusOffset, $this->statusY, $color, $font, Yii::t('mc', 'Offline'));
     }
     imagecolordeallocate($image, $color);
     header('Content-type: image/png');
     imagepng($image);
     imagedestroy($image);
 }
예제 #6
0
파일: Monitor.php 프로젝트: sufehmi/ahadmon
 public function listServerAktif()
 {
     $query = Yii::app()->db->createCommand()->select('sr.id, sr.nama')->from(ServerMonitor::model()->tableName() . ' sm')->join(Server::model()->tableName() . ' sr', 'sm.server_id=sr.id')->where('monitor_id=:monitorId and aktif=1', array(':monitorId' => $this->id))->queryAll();
     return $query;
 }
예제 #7
0
 public function actionListServersByOwner($user_id)
 {
     $this->check();
     $sql = 'select `server_id` from `user_server` where `user_id`=? and `role`=?';
     $cmd = Yii::app()->db->createCommand($sql);
     $cmd->bindValue(1, (int) $user_id);
     $cmd->bindValue(2, 'owner');
     $serverIds = $cmd->queryColumn();
     $svs = Server::model()->findAllByAttributes(array('id' => $serverIds));
     $this->ls('Server', $svs);
 }
 public function actionCreate($sv = false)
 {
     if (!Yii::app()->user->isSuperuser() && !Yii::app()->user->can($sv, 'manage players', true)) {
         Yii::app()->user->deny();
     }
     $server = Server::model()->findByPk((int) $sv);
     $model = new Player();
     $model->server_id = $sv;
     $model->level = 1;
     $playerRoles = $this->possiblePlayerRoles($model);
     if (isset($_POST['Player'])) {
         if (Yii::app()->user->isSuperuser()) {
             $model->scenario = 'superuser';
         }
         $model->attributes = $_POST['Player'];
         if (array_search($model->level, array_keys($playerRoles)) === false) {
             $model->level = 0;
         }
         //no permission
         $user = (int) @$_POST['user-assign'];
         $userModel = User::model()->findByPk($user);
         if ($userModel && array_search($userModel->getLevel($sv), array_keys($playerRoles)) === false) {
             $user = 0;
         }
         if ($model->save()) {
             Yii::log('Created player ' . $model->id);
             if ($model->user != $user) {
                 $model->user = $user;
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $users = User::model()->findAll($this->getUserCondition($model->id));
     $this->render('view', array('model' => $model, 'sv' => $sv, 'edit' => true, 'playerRoles' => $playerRoles, 'users' => $users));
 }
예제 #9
0
 public function beforeDelete()
 {
     $cmd = 'delinstance ' . $this->id;
     if ($this->deleteDir === 'yes') {
         if (!McBridge::get()->serverCmd($this->id, 'get status', $status)) {
             $this->addError('deleteDir', Yii::t('mc', 'Cannot delete base directory: ') . McBridge::get()->lastError());
             return false;
         }
         if (@$status[0]['status'] != 'stopped') {
             $this->addError('deleteDir', Yii::t('mc', 'Cannot delete base directory: ') . Yii::t('mc', 'Server still running'));
             return false;
         }
         $shared = Server::model()->findAllByAttributes(array('daemon_id' => $this->daemon_id, 'dir' => $this->dir));
         if (count($shared) > 1) {
             $this->addError('deleteDir', Yii::t('mc', 'Cannot delete base directory: ') . Yii::t('mc', 'Base directory is still in use by other servers'));
             return false;
         }
         $cmd .= ' deleteDir';
         //Delete the database as well
         $this->deleteDatabase();
     }
     McBridge::get()->cmd($this->daemon_id, $cmd);
     if ($this->prevDaemon && $this->prevDaemon != $this->daemon_id) {
         McBridge::get()->cmd($this->prevDaemon, $cmd);
     }
     return true;
 }
예제 #10
0
<?php

/**
 *
 *   Copyright © 2010-2012 by xhost.ch GmbH
 *
 *   All rights reserved.
 *
 **/
$this->pageTitle = Yii::app()->name . ' - ' . Yii::t('mc', 'Scheduled Tasks');
$this->breadcrumbs = array(Yii::t('mc', 'Servers') => array('server/index'), Server::model()->findByPk((int) $sv)->name => array('server/view', 'id' => $sv), Yii::t('mc', 'Scheduled Tasks'));
$this->menu = array(array('label' => Yii::t('mc', 'New Task'), 'url' => array('create', 'sv' => $sv), 'icon' => 'schedule_new'), array('label' => Yii::t('mc', 'Manage Tasks'), 'url' => array('admin'), 'visible' => Yii::app()->user->isSuperuser(), 'icon' => 'schedule'), array('label' => Yii::t('mc', 'Back'), 'url' => array('server/view', 'id' => $sv), 'icon' => 'back'));
?>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'schedule-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'ajaxUpdate' => false, 'columns' => array(array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), array("schedule/view", "id"=>$data->id))'), array('name' => 'scheduled_ts', 'value' => '$data->scheduled_ts ? @date("' . Yii::t('mc', 'd. M Y, H:i') . '", (int)$data->scheduled_ts) : "' . Yii::t('mc', 'Not Scheduled') . '"'), array('name' => 'interval', 'value' => '$data->intervalString'), array('name' => 'status', 'value' => '@Schedule::getStatusValues($data->status)'), array('name' => 'last_run_ts', 'value' => '$data->last_run_ts ? @date("' . Yii::t('mc', 'd. M Y, H:i') . '", (int)$data->last_run_ts) : "' . Yii::t('mc', 'Never') . '"'), array('name' => 'hidden', 'value' => '$data->hidden ? "' . Yii::t('mc', 'Yes') . '" : "' . Yii::t('mc', 'No') . '"', 'htmlOptions' => array('style' => 'width: 40px'), 'visible' => Yii::app()->user->isSuperuser()))));
 public function actionStatistics()
 {
     if (isset($_POST['ajax'])) {
         if ($_POST['ajax'] === 'stats') {
             $svs = Server::model()->findAllByAttributes(array('suspended' => 0));
             $players = 0;
             $servers = 0;
             $memory = 0;
             foreach ($svs as $sv) {
                 $pl = $sv->getOnlinePlayers();
                 if ($pl >= 0) {
                     $servers++;
                     $players += $pl;
                     $memory += $sv->memory;
                 }
             }
             $data = array();
             $data['servers'] = $servers;
             $data['players'] = $players;
             $data['avg_players'] = $servers ? number_format($players / $servers, 2) : 0;
             $data['memory'] = number_format($memory) . ' ' . Yii::t('admin', 'MB');
             echo CJSON::encode($data);
         }
         Yii::app()->end();
     }
     $sql = 'select count(*), sum(`players`), sum(`memory`) from `server`';
     $cmd = Yii::app()->bridgeDb->createCommand($sql);
     $row = $cmd->queryRow(false);
     $servers = $row[0];
     $players = $row[1];
     $memory = $row[2];
     $sql = 'select count(*), sum(`players`), sum(`memory`) from `server` where `suspended`!=1';
     $cmd = Yii::app()->bridgeDb->createCommand($sql);
     $row = $cmd->queryRow(false);
     $activeServers = $row[0];
     $activePlayers = $row[1];
     $activeMemory = $row[2];
     $sql = 'select count(*) from `daemon`';
     $cmd = Yii::app()->bridgeDb->createCommand($sql);
     $dmns = $cmd->queryScalar();
     $this->render('statistics', array('servers' => $servers, 'activeServers' => $activeServers, 'daemons' => $dmns, 'svPerDaemon' => $dmns ? $servers / $dmns : 0, 'activeSvPerDaemon' => $dmns ? $activeServers / $dmns : 0, 'slots' => $players, 'activeSlots' => $activePlayers, 'memory' => number_format($memory) . ' ' . Yii::t('admin', 'MB'), 'activeMemory' => number_format($activeMemory) . ' ' . Yii::t('admin', 'MB')));
 }
 public function actionLoadServer()
 {
     if (!empty($_POST['Notifikasi']['monitor_id']) || $_POST['Notifikasi']['monitor_id'] == '0') {
         $monitorId = $_POST['Notifikasi']['monitor_id'];
         if ($monitorId == 0) {
             /* Untuk uptime monitor, tampilkan semua server */
             $servers = CHtml::listData(Server::model()->findAll(array('select' => 'id, nama', 'order' => 'nama')), 'id', 'nama');
             foreach ($servers as $id => $nama) {
                 echo CHtml::tag('option', array('value' => $id), CHtml::encode($nama), true);
             }
         } else {
             $monitor = Monitor::model()->findByPk($monitorId);
             $servers = $monitor->listServerAktif();
             foreach ($servers as $server) {
                 echo CHtml::tag('option', array('value' => $server['id']), CHtml::encode($server['nama']), true);
             }
         }
     } else {
         echo CHtml::tag('option', array('value' => ''), CHtml::encode('Pilih monitor..'), true);
     }
 }
예제 #13
0
		<?php 
echo Helper::fieldTips('如果你已知道数据编号,可用 #编号 来搜索数据,如:#12');
?>
		<?php 
echo CHtml::endForm();
?>
	</div>
	
	<div class="clearfix">

		<?php 
echo CHtml::form(array('batchDelete'), 'post', array('id' => "form", 'onsubmit' => 'batchDelete("确认要删除选中数据吗?", this, "server_id[]"); return false;'));
?>

		<?php 
$this->widget('zii.widgets.grid.CGridView', array('pager' => array('cssFile' => false), 'cssFile' => false, 'htmlOptions' => array('class' => 'list-view'), 'itemsCssClass' => 'list tree-table', 'loadingCssClass' => 'list-view-loading', 'dataProvider' => $dataProvider, 'selectableRows' => 2, 'columns' => array(array('class' => 'CCheckBoxColumn', 'id' => 'server_id', 'headerHtmlOptions' => array('style' => 'width:20px;'), 'htmlOptions' => array('align' => 'center')), array('name' => 'server_id', 'headerHtmlOptions' => array('style' => 'width:80px;'), 'htmlOptions' => array('align' => 'center')), array('name' => 'image_path', 'header' => '缩略图', 'value' => 'CHtml::image($data->getThumbFileUrl(),$data->server_id,array("width"=>200,"height"=>100))', 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width:20%;'), 'htmlOptions' => array('class' => 'id-column', 'align' => 'center')), array('name' => 'name', 'value' => '$data->getI18nColumn("name", true)', 'evaluateHtmlOptions' => true, 'htmlOptions' => array('class' => '"{$data->getClass($data->is_recommend)}"'), 'type' => 'html'), array('class' => 'CButtonColumn', 'header' => Server::model()->getAttributeLabel('sort_order'), 'headerHtmlOptions' => array('style' => 'width:100px;'), 'htmlOptions' => array('align' => 'center'), 'template' => '{sort_first} {sort_previous} {sort_next} {sort_last} {sort_specify}', 'buttons' => array('sort_first' => array('label' => '置顶', 'url' => 'array("sortFirst", "id" => $data->primaryKey)', 'click' => 'function(){ Sort.toFirst(this); return false; }', 'imageUrl' => 'image/sort_first.png'), 'sort_previous' => array('label' => '向上', 'url' => 'array("sortPrevious", "id" => $data->primaryKey)', 'click' => 'function(){ Sort.toPrevious(this); return false; }', 'imageUrl' => 'image/sort_previous.png'), 'sort_next' => array('label' => '向下', 'url' => 'array("sortNext", "id" => $data->primaryKey)', 'click' => 'function(){ Sort.toNext(this); return false; }', 'imageUrl' => 'image/sort_next.png'), 'sort_last' => array('label' => '置低', 'url' => 'array("sortLast", "id" => $data->primaryKey)', 'click' => 'function(){ Sort.toLast(this); return false; }', 'imageUrl' => 'image/sort_last.png'), 'sort_specify' => array('label' => '指定位置', 'url' => 'array("sortSpecify", "id" => $data->primaryKey)', 'click' => 'function(){ Sort.toSpecify(this); return false; }', 'imageUrl' => 'image/sort_specify.png')), 'visible' => Yii::app()->user->checkAccess('updateServer')), array('name' => 'sort_order', 'header' => Server::model()->getAttributeLabel('sort_order') . '2', 'headerHtmlOptions' => array('style' => 'width:90px;'), 'htmlOptions' => array('align' => 'center'), 'value' => 'CHtml::textField("sort_order_" . $data->primaryKey, $data->sort_order, array("class" => "sort-field"))', 'type' => 'raw', 'visible' => Yii::app()->user->checkAccess('updateServer')), array('class' => 'CButtonColumn', 'header' => '操作', 'headerHtmlOptions' => array('style' => 'width:100px;'), 'htmlOptions' => array('align' => 'center'), 'template' => '{update} {delete} {common}', 'buttons' => array('common' => array('label' => '首页推荐', 'imageUrl' => Yii::app()->request->baseUrl . '/image/common.gif', 'url' => 'array("commend", "id" => $data->primaryKey)'), 'update' => array('url' => 'array("update", "id" => $data->primaryKey, "return_url" => Yii::app()->request->url)', 'visible' => 'Yii::app()->user->checkAccess("updateServer")'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("deleteServer")'))))));
?>

		<?php 
if (Yii::app()->user->checkAccess('deleteServer')) {
    ?>
		<input type="submit" value="删除选中项" />
		<input type="button" value="推荐选中项" onclick="recommendFn();" />
		<input type="button" value="取消推荐选中项" onclick="unRecommendFn();" />	
		<?php 
}
?>
		<?php 
echo CHtml::endForm();
?>
예제 #14
0
 public function actionView($id)
 {
     if (!Yii::app()->user->isSuperuser() && Yii::app()->params['hide_userlist'] === true && Yii::app()->user->id != $id) {
         throw new CHttpException(403, Yii::t('mc', 'You are not authorized to perform this action.'));
     }
     $model = $this->loadModel($id);
     $model->scenario = Yii::app()->user->isSuperuser() ? 'superuserUpdate' : 'update';
     $edit = Yii::app()->user->isSuperuser() || Yii::app()->user->name == $model->name;
     if (isset($_POST['User']) && $edit) {
         if (Yii::app()->params['demo_mode'] == 'enabled' && in_array($model->name, array('admin', 'owner', 'user'))) {
             Yii::app()->user->setFlash('user', Yii::t('mc', 'Function disabled in demo mode.'));
             $this->redirect(array('view', 'id' => $model->id));
         }
         if (Yii::app()->user->name !== Yii::app()->user->superuser && $model->name == Yii::app()->user->superuser) {
             Yii::app()->user->setFlash('user', Yii::t('mc', 'Access Denied'));
             $this->redirect(array('view', 'id' => $model->id));
         }
         $nameBackup = $model->name;
         $pwBackup = $model->password;
         $model->attributes = $_POST['User'];
         if (!strlen($_POST['User']['password'])) {
             $model->password = $pwBackup;
         }
         $model->sendData = @$_POST['send_data'];
         if (!Yii::app()->user->isSuperuser() || $model->name == Yii::app()->user->superuser || $nameBackup == Yii::app()->user->superuser) {
             $model->name = $nameBackup;
         }
         if ($model->save()) {
             Yii::log('Updated user ' . $model->id);
             Yii::app()->user->setFlash('user', Yii::t('mc', 'User saved.'));
             $this->redirect(array('view', 'id' => $model->id));
         }
     } else {
         if (isset($_POST['action']) && Yii::app()->user->isSuperuser()) {
             switch ($_POST['action']) {
                 case 'new_api_key':
                     $model->api_key = substr(md5((string) microtime(true)), 0, 20);
                     $model->save(false);
                     Yii::log('Generated API key for user ' . $model->id);
                     Yii::app()->user->setFlash('user', Yii::t('mc', 'New API key generated.'));
                     $this->redirect(array('view', 'id' => $model->id));
                     break;
                 case 'del_api_key':
                     $model->api_key = '';
                     $model->save(false);
                     Yii::log('Deleted API key for user ' . $model->id);
                     Yii::app()->user->setFlash('user', Yii::t('mc', 'API key deleted.'));
                     $this->redirect(array('view', 'id' => $model->id));
                     break;
             }
         }
     }
     $model->password = '';
     $allRoles = array_combine(User::$roles, User::getRoleLabels());
     $allRoles['superuser'] = Yii::t('mc', 'Superuser');
     $servers = array();
     $spp = 10;
     if (Yii::app()->user->isSuperuser()) {
         if ($spp = Setting::model()->findByPk('serversPerPage')) {
             $spp = max(1, (int) $spp->value);
         }
         $sql = 'select `server_id` from `user_server` where `user_id`=? and `role`=\'owner\'';
         $cmd = Yii::app()->db->createCommand($sql);
         $cmd->bindValue(1, $model->id);
         $ids = $cmd->queryColumn();
         $servers = Server::model()->findAllByAttributes(array('id' => array_values($ids)));
     }
     $this->render('view', array('model' => $model, 'allRoles' => $allRoles, 'edit' => $edit, 'servers' => new CArrayDataProvider($servers, array('sort' => array('attributes' => array('name')), 'pagination' => array('pageSize' => $spp)))));
 }
 public function actionBrowse($id, $partial = false)
 {
     $server = Server::model()->findByPk((int) $id);
     if (!$server) {
         throw new CHttpException(404, Yii::t('mc', 'The requested page does not exist.'));
     }
     $this->net2FtpDefines();
     global $net2ftp_result, $net2ftp_settings, $net2ftp_globals;
     require_once dirname(__FILE__) . '/../extensions/net2ftp/main.inc.php';
     require_once dirname(__FILE__) . '/../extensions/net2ftp/includes/errorhandling.inc.php';
     $ftpSv = $this->getFtpServer($server);
     $sessKey = 'net2ftp_password_encrypted_' . $ftpSv['ip'] . $this->getUsername($server);
     if (!isset($_SESSION[$sessKey])) {
         if (!isset($_SESSION['net2ftp_password_encrypted'])) {
             Yii::log('No valid FTP session found, redirecting to login form');
             $this->redirect(array('ftpClient/login', 'id' => $id));
         }
         $_SESSION[$sessKey] = $_SESSION['net2ftp_password_encrypted'];
     }
     set_error_handler('net2ftpErrorHandler');
     if (!@$_REQUEST['state']) {
         $net2ftp_globals['state'] = 'browse';
         $net2ftp_globals['state2'] = 'main';
     } else {
         $net2ftp_globals['state'] = $_REQUEST['state'];
         $net2ftp_globals['state2'] = $_REQUEST['state2'];
     }
     $net2ftp_globals['ftpserver'] = $ftpSv['ip'];
     $net2ftp_globals['ftpserverport'] = $ftpSv['port'];
     $net2ftp_globals['language'] = Yii::app()->language;
     $net2ftp_globals['username'] = $this->getUsername($server);
     $net2ftp_globals['action_url'] = CHtml::normalizeUrl(array('browse', 'id' => $id, 'partial' => $partial));
     net2ftp("sendHttpHeaders");
     //print_r($net2ftp_globals);
     if ($net2ftp_result["success"] == false) {
         throw new CHttpException(404, Yii::t('mc', 'Error in the FTP client module.'));
     }
     ob_start();
     net2ftp("printJavascript");
     $js = ob_get_contents();
     ob_clean();
     net2ftp("printCss");
     $css = ob_get_contents();
     ob_clean();
     net2ftp("printBodyOnload");
     $onload = ob_get_contents();
     ob_clean();
     global $controller;
     $controller = $this;
     net2ftp("printBody");
     $body = ob_get_contents();
     ob_clean();
     if ($net2ftp_result["success"] == false) {
         require_once $net2ftp_globals["application_rootdir"] . "/skins/" . $net2ftp_globals["skin"] . "/error.template.php";
         $body = ob_get_contents();
         ob_clean();
     }
     $func = $partial ? 'renderPartial' : 'render';
     $this->{$func}('browse', array('js' => $js, 'css' => $css, 'onload' => $onload, 'body' => $body, 'server' => $server));
 }
예제 #16
0
 /**
  * Returns the current users role if it corresponds to the specified player
  */
 private function playerRole($player, $serverRole)
 {
     if ($this->isGuest) {
         if ($player->status == 'online' && $this->ip == $player->ip) {
             $sv = Server::model()->findByPk($player->server_id);
             $role = $sv ? $sv->getIpAuthRole() : 'none';
             return $this->checkSvRole($sv, $role);
         }
     } else {
         if ($player->user == $this->id) {
             return $serverRole;
         }
     }
     return '';
 }
예제 #17
0
    $this->menu = array(array('label' => Yii::t('mc', 'Delete Player'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('mc', 'Are you sure you want to delete this player?'), 'csrf' => true), 'visible' => $edit, 'icon' => 'player_del'));
}
$this->menu[] = array('label' => Yii::t('mc', 'Back'), 'url' => $sv ? array('player/index', 'sv' => $sv) : array('player/admin'), 'icon' => 'back');
?>

<?php 
if (!$edit) {
    $attribs = array('name', 'level' => array('name' => 'level', 'value' => User::getRoleLabel(User::getLevelRole($model->level))));
    $user = User::model()->findByPk((int) $model->user);
    if ($user) {
        $attribs[] = array('label' => Yii::t('mc', 'Belongs to'), 'type' => 'raw', 'value' => CHtml::encode($user->name));
    }
} else {
    $form = $this->beginWidget('CActiveForm', array('id' => 'player-form', 'enableAjaxValidation' => false));
    if (!$sv) {
        $attribs[] = array('label' => $form->labelEx($model, 'server_id'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'server_id', CHtml::listData(Server::model()->findAll(), 'id', 'name')) . ' ' . $form->error($model, 'server_id'));
    }
    $attribs[] = array('label' => $form->labelEx($model, 'name'), 'type' => 'raw', 'value' => $form->textField($model, 'name') . ' ' . $form->error($model, 'name'));
    $attribs[] = array('label' => $form->labelEx($model, 'level'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'level', $playerRoles) . ' ' . $form->error($model, 'level'));
    if (count(@$users)) {
        $attribs[] = array('label' => Yii::t('mc', 'Assign to user'), 'type' => 'raw', 'value' => CHtml::dropDownList('user-assign', $model->user, array('0' => Yii::t('mc', 'None')) + CHtml::listData($users, 'id', 'name')));
    }
    $attribs[] = array('label' => $form->labelEx($model, 'banned'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'banned', array('' => Yii::t('mc', 'False'), 'true' => Yii::t('mc', 'True'))));
    $attribs[] = array('label' => '', 'type' => 'raw', 'value' => CHtml::submitButton($model->isNewRecord ? Yii::t('mc', 'Create') : Yii::t('mc', 'Save')));
}
if (!$model->isNewRecord) {
    $attribs[] = 'status';
    $attribs[] = array('name' => 'lastseen', 'value' => $model->lastseen ? @date(Yii::t('mc', 'd. M Y, H:i'), (int) $model->lastseen) : Yii::t('mc', 'Never'));
    if ($viewDetails) {
        $attribs = array_merge($attribs, array('ip', 'previps', 'quitreason'));
    }
예제 #18
0
<?php

/**
 *
 *   Copyright © 2010-2012 by xhost.ch GmbH
 *
 *   All rights reserved.
 *
 **/
$this->pageTitle = Yii::app()->name . ' - ' . Yii::t('mc', 'Command List');
$this->breadcrumbs = array(Yii::t('mc', 'Servers') => array('server/index'), Server::model()->findByPk($sv)->name => array('server/view', 'id' => $sv), Yii::t('mc', 'Commands'));
$this->menu = array(array('label' => Yii::t('mc', 'Create Command'), 'url' => array('create', 'sv' => $sv), 'icon' => 'command_new'), array('label' => Yii::t('mc', 'Manage Commands'), 'url' => array('admin'), 'visible' => Yii::app()->user->isSuperuser(), 'icon' => 'command'), array('label' => Yii::t('mc', 'Back'), 'url' => array('server/view', 'id' => $sv), 'icon' => 'back'));
?>

<?php 
$columns = array(array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), array("command/view", "id"=>$data->id))'), array('name' => 'level', 'value' => 'User::getRoleLabel(User::getLevelRole($data->level))'), 'chat');
if ($model->hasAttribute('hidden')) {
    $columns[] = array('name' => 'hidden', 'value' => '$data->hidden ? "' . Yii::t('mc', 'Yes') . '" :
        "' . Yii::t('mc', 'No') . '"', 'htmlOptions' => array('style' => 'width: 40px'), 'visible' => Yii::app()->user->isSuperuser());
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'command-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'ajaxUpdate' => false, 'columns' => $columns));
예제 #19
0
 public function actionBatchUnCommend()
 {
     $idList = Yii::app()->request->getPost('server_id', array());
     if (count($idList) > 0) {
         $criteria = new CDbCriteria();
         $criteria->addInCondition('server_id', $idList);
         $servers = Server::model()->findAll($criteria);
         $flag = 0;
         foreach ($servers as $server) {
             $server->is_recommend = 0;
             if ($server->save()) {
                 $flag++;
             }
         }
         if ($flag > 0) {
             $this->setFlashMessage('服务取消推荐成功');
         } else {
             $this->setFlashMessage('服务取消推荐失败', 'warn');
         }
     } else {
         $this->setFlashMessage('没有记录被选中', 'warn');
     }
     $this->redirect(array('index'));
 }
예제 #20
0
 public function getNamaServer()
 {
     $server = Server::model()->findByPk($this->server_id);
     return $server->nama;
 }
예제 #21
0
<?php

/**
 *
 *   Copyright © 2010-2012 by xhost.ch GmbH
 *
 *   All rights reserved.
 *
 **/
$this->breadcrumbs = array(Yii::t('mc', 'Servers') => array('server/index'), $sv ? @Server::model()->findByPk($sv)->name : Yii::t('mc', 'All') => $sv ? array('server/view', 'id' => $sv) : array('/server'), Yii::t('mc', 'Commands') => $sv ? array('command/index', 'sv' => $sv) : array('command/admin'), $model->isNewRecord ? Yii::t('mc', 'New Command') : CHtml::encode($model->name));
if (!$model->isNewRecord) {
    $this->menu = array(array('label' => Yii::t('mc', 'Delete Command'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('mc', 'Are you sure you want to delete this item?'), 'csrf' => true), 'visible' => $edit, 'icon' => 'command_del'));
}
$this->menu[] = array('label' => Yii::t('mc', 'Back'), 'url' => $sv ? array('command/index', 'sv' => $sv) : array('command/admin'), 'icon' => 'back');
?>

<?php 
if (!$edit) {
    $attribs = array('name', 'level', 'prereq', 'chat', 'response', 'run');
} else {
    $form = $this->beginWidget('CActiveForm', array('id' => 'command-form', 'enableAjaxValidation' => false));
    $userRoles = array_combine(User::$roleLevels, User::getRoleLabels());
    $userRoles[0] = Yii::t('mc', 'None');
    if (Yii::app()->user->isSuperuser()) {
        $attribs[] = array('label' => $form->labelEx($model, 'server_id'), 'type' => 'raw', 'value' => $form->textField($model, 'server_id') . ' ' . $form->error($model, 'server_id'), 'hint' => Yii::t('mc', 'The server ID, use 0 for "Global"'));
        $attribs[] = array('label' => $form->labelEx($model, 'hidden'), 'type' => 'raw', 'value' => $form->checkBox($model, 'hidden') . ' ' . $form->error($model, 'hidden'), 'hint' => Yii::t('mc', 'Only show this command to other superusers'));
    }
    $attribs[] = array('label' => $form->labelEx($model, 'name'), 'type' => 'raw', 'value' => $form->textField($model, 'name') . ' ' . $form->error($model, 'name'));
    $attribs[] = array('label' => $form->labelEx($model, 'level'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'level', $userRoles) . ' ' . $form->error($model, 'level'));
    $attribs[] = array('label' => $form->labelEx($model, 'prereq'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'prereq', array('0' => 'None') + CHtml::listData(Command::model()->findAllByAttributes(array('server_id' => $sv)), 'id', 'name')) . ' ' . $form->error($model, 'prereq'), 'hint' => Yii::t('mc', 'This command has to be run before'));
    $attribs[] = array('label' => $form->labelEx($model, 'chat'), 'type' => 'raw', 'value' => $form->textField($model, 'chat') . ' ' . $form->error($model, 'chat'), 'hint' => Yii::t('mc', 'The users message has to begin with this'));
예제 #22
0
<?php

/**
 *
 *   Copyright © 2010-2012 by xhost.ch GmbH
 *
 *   All rights reserved.
 *
 **/
$this->pageTitle = Yii::app()->name . ' - ' . Yii::t('mc', 'View Task');
$this->breadcrumbs = array(Yii::t('mc', 'Servers') => array('server/index'), $sv ? @Server::model()->findByPk((int) $sv)->name : Yii::t('mc', 'All') => $sv ? array('server/view', 'id' => $sv) : array('/server'), Yii::t('mc', 'Scheduled Tasks') => $sv ? array('index', 'sv' => $sv) : array('admin'), $model->isNewRecord ? Yii::t('mc', 'New Task') : CHtml::encode($model->name));
if (!$model->isNewRecord) {
    $this->menu = array(array('label' => Yii::t('mc', 'Delete Task'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('mc', 'Are you sure you want to delete this task?'), 'csrf' => true), 'icon' => 'schedule_del'));
}
$this->menu[] = array('label' => Yii::t('mc', 'Back'), 'url' => $sv ? array('schedule/index', 'sv' => $sv) : array('schedule/admin'), 'icon' => 'back');
echo CHtml::css('#ival_do {width: auto;}');
echo CHtml::css('#ival_nr {min-width: 10px; display: none;}');
echo CHtml::css('#ival_type {min-width: 10px; display: none;}');
$form = $this->beginWidget('CActiveForm', array('id' => 'user-form', 'enableAjaxValidation' => false));
$attribs = array();
if (Yii::app()->user->isSuperuser()) {
    $attribs[] = array('label' => $form->labelEx($model, 'server_id'), 'type' => 'raw', 'value' => $form->textField($model, 'server_id') . ' ' . $form->error($model, 'server_id'), 'hint' => Yii::t('mc', 'The server ID, use 0 for "Global"'));
    $attribs[] = array('label' => $form->labelEx($model, 'hidden'), 'type' => 'raw', 'value' => $form->checkBox($model, 'hidden') . ' ' . $form->error($model, 'hidden'), 'hint' => Yii::t('mc', 'Only show this task to other superusers'));
}
$attribs[] = array('label' => $form->labelEx($model, 'name'), 'type' => 'raw', 'value' => $form->textField($model, 'name') . ' ' . $form->error($model, 'name'));
if (!$model->isNewRecord) {
    $attribs[] = array('label' => $form->labelEx($model, 'last_run_ts'), 'value' => ($model->last_run_ts ? @date(Yii::t('mc', 'd. M Y, H:i'), $model->last_run_ts) : Yii::t('mc', 'Never')) . $form->error($model, 'last_run_ts'));
    $attribs[] = array('label' => $form->labelEx($model, 'status'), 'value' => Schedule::getStatusValues($model->status));
}
$attribs[] = array('label' => $model->isNewRecord ? $form->labelEx($model, 'status') : Yii::t('mc', 'Change status to'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'status', array(0 => Schedule::getStatusValues(0), 3 => Schedule::getStatusValues(3))) . ' ' . $form->error($model, 'status'));
$attribs[] = array('label' => $form->labelEx($model, 'scheduled_ts'), 'type' => 'raw', 'value' => $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('value' => @date(Yii::t('mc', 'd. M Y H:i'), $model->scheduled_ts ? $model->scheduled_ts : time()), 'name' => 'scheduled_ts', 'options' => array('dateFormat' => Yii::t('mc', 'dd. M yy'))), true) . ' ' . $form->error($model, 'scheduled_ts'));