当前位置: 首页>>代码示例>>PHP>>正文


PHP Daemon::model方法代码示例

本文整理汇总了PHP中Daemon::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::model方法的具体用法?PHP Daemon::model怎么用?PHP Daemon::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Daemon的用法示例。


在下文中一共展示了Daemon::model方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDaemonIds

 public function getDaemonIds()
 {
     if (!$this->daemonIds) {
         $cmd = Daemon::model()->getDbConnection()->createCommand('select `id` from `daemon`');
         $this->daemonIds = $cmd->queryColumn();
     }
     return $this->daemonIds;
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:8,代码来源:McBridge.php

示例2: actionLogin

 public function actionLogin($id = 0)
 {
     if (isset($_POST['password'])) {
         $pw = $_POST['password'];
         $id = (int) $_POST['server_id'];
         $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/authorizations.inc.php';
         $ftpSv = $this->getFtpServer($server);
         if (strlen($pw)) {
             $_SESSION['net2ftp_password_encrypted'] = encryptPassword($pw);
             $sessKey = 'net2ftp_password_encrypted_' . $ftpSv['ip'] . $this->getUsername($server);
             unset($_SESSION[$sessKey]);
         }
         Yii::log('Logging in to FTP server for server ' . $id);
         $this->redirect(array('ftpClient/browse', 'id' => $id));
     }
     $ftpUser = FtpUser::model()->findByAttributes(array('name' => Yii::app()->user->name));
     $daemons = array();
     $serverList = array();
     $sel = Yii::t('mc', 'Please select a server');
     if ($ftpUser) {
         $c = new CDbCriteria();
         $c->join = 'join `ftp_user_server` on `t`.`id`=`server_id`';
         $c->condition = '`user_id`=? and `perms`!=\'\'';
         $c->params = array((int) $ftpUser->id);
         $svs = Server::model()->findAll($c);
         $serverList = array(0 => Yii::t('mc', 'Select'));
         foreach ($svs as $sv) {
             $dmn = Daemon::model()->findByPk($sv->daemon_id);
             $dmnInfo = array('ip' => '', 'port' => '');
             if (!$dmn) {
                 $dmnInfo['ip'] = Yii::t('mc', 'No daemon found for this server.');
             } else {
                 if (isset($dmn->ftp_ip) && isset($dmn->ftp_port)) {
                     $dmnInfo = array('ip' => $dmn->ftp_ip, 'port' => $dmn->ftp_port);
                 } else {
                     $dmnInfo['ip'] = Yii::t('mc', 'Daemon database not up to date, please run the Multicraft installer.');
                 }
             }
             $daemons[$sv->id] = $dmnInfo;
             $serverList[$sv->id] = $sv->name;
         }
     } else {
         $serverList = array(0 => Yii::t('mc', 'No FTP account found'));
         $sel = Yii::t('mc', 'See the "Users" menu of your server for a list of FTP accounts');
     }
     $this->render('login', array('id' => $id, 'havePw' => isset($_SESSION['net2ftp_password_encrypted']), 'serverList' => $serverList, 'daemons' => $daemons, 'sel' => $sel));
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:54,代码来源:FtpClientController.php

示例3: getConnection

 public function getConnection($id)
 {
     if (@isset($this->connections[$id])) {
         return $this->connections[$id];
     }
     $daemon = Daemon::model()->findByPk((int) $id);
     if (!$daemon) {
         return null;
     }
     $con = new McConnectionDemo($this, $id, $daemon->name, $daemon->ip, $daemon->port, '');
     return $this->connections[$id] = $con;
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:12,代码来源:McBridgeDemo.php

示例4: actionRemoveDaemon

 public function actionRemoveDaemon($id)
 {
     Daemon::model()->deleteByPk($id);
     $this->redirect(array('index', 'step' => 'connection'));
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:5,代码来源:InstallController.php

示例5: actionFtp

 public function actionFtp($id)
 {
     Yii::app()->user->can($id, 'manage players', true);
     $model = $this->loadModel($id);
     $dmnInfo = array('ip' => '', 'port' => '');
     if (!Yii::app()->user->model || !Yii::app()->user->model->getServerFtpAccess($model->id)) {
         $dmnInfo['error'] = Yii::t('mc', 'You don\'t have an FTP account for this server.');
     } else {
         $dmn = Daemon::model()->findByPk($model->daemon_id);
         if (!$dmn) {
             $dmnInfo['error'] = Yii::t('mc', 'No daemon found for this server.');
         } else {
             if (isset($dmn->ftp_ip) && isset($dmn->ftp_port)) {
                 $dmnInfo = array('ip' => $dmn->ftp_ip, 'port' => $dmn->ftp_port);
             } else {
                 $dmnInfo['error'] = Yii::t('mc', 'Daemon database not up to date, please run the Multicraft installer.');
             }
         }
     }
     $this->render('ftp', array('model' => $model, 'dmnInfo' => $dmnInfo));
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:21,代码来源:ServerController.php

示例6: array

}
?>

<?php 
$statusDetail = false;
if (@$data['statusdetail']) {
    $statusDetail = array('label' => Yii::t('mc', 'Status'), 'type' => 'raw', 'value' => '<nobr><div id="statusdetail-ajax">' . CHtml::encode($data['statusdetail']) . '</div></nobr>');
}
$statusBanner = false;
if (!!Yii::app()->params['status_banner'] && !$model->isNewRecord) {
    $bannerUrl = CHtml::normalizeUrl(array('status/' . $model->id . '.png'));
    $statusBanner = array('label' => Yii::t('mc', 'Status Banner'), 'type' => 'raw', 'value' => CHtml::link(Yii::t('mc', 'Show'), $bannerUrl));
}
$ip = trim($settings && $settings->display_ip ? $settings->display_ip : $model->ip);
if (!strlen($ip) || $ip == '0.0.0.0') {
    if ($dmn = Daemon::model()->findByPk($model->daemon_id)) {
        $ip = $dmn->ip;
    }
}
$attribs = array();
$attribs[] = array('label' => $statusIcon, 'type' => 'raw', 'value' => $statusButtons, 'cssClass' => 'titlerow', 'template' => "<tr class=\"{class}\"><th>{label}</th><td colspan=\"2\">{value}</td></tr>\n");
if (!$edit) {
    if ($ip && $ip != '0.0.0.0') {
        $attribs[] = array('label' => CHtml::activeLabel($model, 'ip'), 'type' => 'raw', 'value' => '<nobr>' . CHtml::encode($ip) . '</nobr>');
    }
    $attribs[] = 'port';
    if ($statusDetail) {
        $attribs[] = $statusDetail;
    }
    if ($statusBanner) {
        $attribs[] = $statusBanner;
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:31,代码来源:view.php

示例7: actionRemoveDaemon

 public function actionRemoveDaemon($id)
 {
     Daemon::model()->deleteByPk($id);
     $this->redirect(array('status'));
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:5,代码来源:DaemonController.php

示例8: 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);
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:39,代码来源:StatusController.php

示例9: getMysqlInfo

 public function getMysqlInfo()
 {
     if ($this->_mysqlInfo) {
         return $this->_mysqlInfo;
     }
     $info = @(include dirname(__FILE__) . '/../config/user_databases.php');
     $info = @$info[$this->daemon_id];
     if (!is_array($info)) {
         $info = array('host' => Yii::app()->params['user_mysql_host']);
     } else {
         if (!isset($info['host'])) {
             $info['host'] = '*';
         }
     }
     if (!@$info['user']) {
         $info['user'] = Yii::app()->params['user_mysql_user'];
         $info['pass'] = Yii::app()->params['user_mysql_pass'];
     } else {
         if (!@$info['pass']) {
             $info['pass'] = '';
         }
     }
     $dmn = Daemon::model()->findByPk($this->daemon_id);
     if ($info['host'] == '*') {
         if ($dmn) {
             $info['host'] = $dmn->ip;
         } else {
             $info['host'] = false;
         }
     } else {
         if ($info['host'] == '') {
             $info['host'] = false;
         }
     }
     if (!isset($info['prefix'])) {
         $info['prefix'] = Yii::app()->params['user_mysql_prefix'];
     }
     if (!isset($info['link'])) {
         $info['link'] = Yii::app()->params['user_mysql_admin'];
     }
     if ($dmn && $info['link']) {
         $info['link'] = str_replace('*', $dmn->ip, $info['link']);
     }
     return $this->_mysqlInfo = $info;
 }
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:45,代码来源:Server.php


注:本文中的Daemon::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。