本文整理汇总了PHP中Server::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::model方法的具体用法?PHP Server::model怎么用?PHP Server::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
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: loadModel
/**
* 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: actionMonitorDetail
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: actionView
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));
}
示例5: actionIndex
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: listServerAktif
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: actionListServersByOwner
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);
}
示例8: actionCreate
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: beforeDelete
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: array
<?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()))));
示例11: actionStatistics
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')));
}
示例12: actionLoadServer
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: array
<?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: actionView
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)))));
}
示例15: actionBrowse
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));
}