コード例 #1
0
ファイル: ServerTest.php プロジェクト: Saltly/SourceBans
 public function testCreate()
 {
     $game = $this->games('tf');
     $model = new SBServer();
     $model->host = '1.2.3.4';
     $model->game_id = $game->id;
     $this->assertTrue($model->save());
 }
コード例 #2
0
 private function _rconServer($command, $id = null)
 {
     if (empty($id)) {
         $servers = SBServer::model()->findAll();
     } else {
         if (is_array($id)) {
             $servers = SBServer::model()->findAllByPk($id);
         } else {
             $servers = array(SBServer::model()->findByPk($id));
         }
     }
     $results = array();
     foreach ($servers as $server) {
         $rcon = new ServerRcon($server->host, $server->port, $server->rcon);
         $result = array('id' => $server->id, 'host' => $server->host, 'port' => $server->port);
         if (!$rcon->auth()) {
             $result['error'] = array('code' => 'ERR_INVALID_PASSWORD', 'message' => Yii::t('yii', '{attribute} is invalid.', array('{attribute}' => $server->getAttributeLabel('rcon'))));
         } else {
             $result['result'] = $rcon->execute($command);
         }
         $results[] = $result;
     }
     return empty($id) || is_array($id) ? $results : $results[0];
 }
コード例 #3
0
 /**
  * Displays the servers page
  */
 public function actionServers()
 {
     $this->pageTitle = Yii::t('sourcebans', 'controllers.default.servers.title');
     $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.default.servers.title'));
     $servers = SBServer::model()->search();
     $servers->criteria->scopes = 'enabled';
     $servers->pagination = false;
     $this->render('servers', array('servers' => $servers));
 }
コード例 #4
0
ファイル: _search.php プロジェクト: Saltly/SourceBans
    <?php 
echo $form->label($model, 'admin_id', array('class' => 'control-label'));
?>
    <div class="controls">
      <?php 
echo $form->dropDownList($model, 'admin_id', CHtml::listData(SBAdmin::model()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => '- ' . Yii::t('sourcebans', 'None') . ' -'));
?>
    </div>
  </div>

  <div class="control-group">
    <?php 
echo $form->label($model, 'server_id', array('class' => 'control-label'));
?>
    <div class="controls">
      <?php 
echo $form->dropDownList($model, 'server_id', CHtml::listData(SBServer::model()->enabled()->with('game')->findAll(array('order' => 'game.name, t.host, t.port')), 'id', 'address', 'game.name'), array('empty' => '- ' . Yii::t('sourcebans', 'None') . ' -'));
?>
    </div>
  </div>

  <div class="control-group buttons">
    <div class="controls">
      <?php 
echo CHtml::submitButton(Yii::t('sourcebans', 'Search'), array('class' => 'btn'));
?>
    </div>
  </div>

<?php 
$this->endWidget();
コード例 #5
0
ファイル: AdminController.php プロジェクト: Saltly/SourceBans
 /**
  * Displays the 'servers' admin page
  */
 public function actionServers()
 {
     $this->pageTitle = Yii::t('sourcebans', 'controllers.admin.servers.title');
     $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.admin.index.title') => array('admin/index'), Yii::t('sourcebans', 'controllers.admin.servers.title'));
     $this->menu = array(array('label' => Yii::t('sourcebans', 'controllers.admin.servers.menu.list'), 'url' => '#list', 'visible' => Yii::app()->user->data->hasPermission('LIST_SERVERS')), array('label' => Yii::t('sourcebans', 'controllers.admin.servers.menu.add'), 'url' => '#add', 'visible' => Yii::app()->user->data->hasPermission('ADD_SERVERS')), array('label' => Yii::t('sourcebans', 'controllers.servers.config.title'), 'url' => array('servers/config'), 'visible' => Yii::app()->user->data->hasFlag(SM_CONFIG)));
     $server = new SBServer();
     $servers = new SBServer('search');
     $servers->unsetAttributes();
     // clear any default values
     if (isset($_GET['SBServer'])) {
         $servers->attributes = $_GET['SBServer'];
     }
     $this->render('servers', array('server' => $server, 'servers' => $servers));
 }