protected function renderMenuItem($item) { if (isset($item['icon'])) { $item['label'] .= Theme::img('icons/' . $item['icon'] . '.png'); } return parent::renderMenuItem($item); }
echo CHtml::encode(@$info->version) . ')'; echo '<br/><br/>'; form($plugin->name, Yii::t('mc', 'Enable'), 'enable', $d); form($plugin->name, Yii::t('mc', 'Remove'), 'remove', $d); } else { echo Yii::t('mc', 'Not installed'); echo '<br/><br/>'; form($plugin->name, Yii::t('mc', 'Install'), 'install', $d); } } } echo '</div>'; echo '<div id="pending"' . ($i == $show ? ' style="display: none"' : '') . '>'; ?> <div class="pluginActionPending"><?php echo Theme::img('gridview/loading.gif'); ?> </div> <?php echo Yii::t('mc', 'Please wait for the action to complete.'); ?> </div> <?php if ($i != $show) { echo CHtml::script(' function refresh() { ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'success' => 'js:set_status', 'data' => array('ajax' => 'get_status', Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken))) . ' } function set_status(data)
"> <?php $img = Theme::img('installer/' . $s . '.png', '', array('class' => 'step')); if ($step == 'welcome') { echo $img . '<br/><br/><center style="font-size: 11px">' . preg_replace('/ /', '', $labels[$s]) . '</center>'; } else { echo CHtml::link($img, array('index', 'step' => $s)); } ?> </div> <?php if ($s != end($steps)) { ?> <div class="nextbox"> <?php echo CHtml::link(Theme::img('installer/next.png'), array('index', 'step' => $s)); ?> </div> <?php } ?> <?php } ?> <div style="clear: both"></div> </div> <br/> <?php } if (count($p['actions'])) { ?>
?> </td> </tr> <?php echo CHtml::css('.adv { display: none; }'); $i = 0; $adv = false; foreach ($settings as $name => $setting) { if (@$setting['adv'] && !$adv) { ?> <tr class="<?php echo $i++ % 2 ? 'even' : 'odd'; ?> "style="height: 32px" > <td><?php echo Theme::img('icons/closed.png', '', array('id' => 'advImg', 'onclick' => 'return checkAdv()')); ?> </td> <td><?php echo CHtml::link(Yii::t('admin', 'Show Advanced Options'), '#', array('id' => 'advTxt', 'onclick' => 'return checkAdv()')); ?> </td> <td></td> </tr> <?php $adv = true; } ?> <tr class="<?php echo $i++ % 2 ? 'even' : 'odd'; echo @$setting['adv'] ? ' adv' : '';
<body> <div id="frame"> <div id="border-left"></div> <div id="border-right"></div> <div class="container" id="page"> <div id="header"> <div id="logo"> <div id="logo_icon"><?php echo Theme::img('multicraft.png'); ?> </div> <div id="logo_text"><?php echo Theme::img('logo.png'); ?> </div> <div id="header_text"> <?php echo CHtml::encode(Yii::app()->name); ?> <br/><span style="font-size: 12px"><?php echo Yii::t('mc', 'Minecraft Server Manager'); ?> </span></div> </div> </div><!-- header --> <div id="mainmenu"> <?php $items = array();
/** * Renders the detail view. * This is the main entry of the whole detail view rendering. */ public function run() { $formatter = $this->getFormatter(); if ($this->tagName !== null) { echo CHtml::openTag($this->tagName, $this->htmlOptions); } $i = 0; $n = is_array($this->itemCssClass) ? count($this->itemCssClass) : 0; foreach ($this->attributes as $attribute) { if (is_string($attribute)) { if (!preg_match('/^([\\w\\.]+)(:(\\w*))?(:(.*))?$/', $attribute, $matches)) { throw new CException(Yii::t('zii', 'The attribute must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.')); } $attribute = array('name' => $matches[1], 'type' => isset($matches[3]) ? $matches[3] : 'text'); if (isset($matches[5])) { $attribute['label'] = $matches[5]; } } if (isset($attribute['visible']) && !$attribute['visible']) { continue; } $tr = array('{label}' => '', '{class}' => $n ? $this->itemCssClass[$i % $n] : ''); if (isset($attribute['cssClass'])) { $tr['{class}'] = $attribute['cssClass'] . ' ' . ($n ? $tr['{class}'] : ''); } if (isset($attribute['label'])) { $tr['{label}'] = $attribute['label']; } else { if (isset($attribute['name'])) { if ($this->data instanceof CModel) { $tr['{label}'] = $this->data->getAttributeLabel($attribute['name']); } else { $tr['{label}'] = ucwords(trim(strtolower(str_replace(array('-', '_', '.'), ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \\0', $attribute['name']))))); } } } if (!isset($attribute['type'])) { $attribute['type'] = 'text'; } if (isset($attribute['value'])) { $value = $attribute['value']; } else { if (isset($attribute['name'])) { $value = CHtml::value($this->data, $attribute['name']); } else { $value = null; } } $tr['{value}'] = $value === null ? $this->nullDisplay : $formatter->format($value, $attribute['type']); if (strlen(@$attribute['hint'])) { $tr['{hint}'] = '<div class="hint">' . Theme::img('icons/hint.png', '', array('class' => 'hintIcon')) . '<span class="hintText">' . $attribute['hint'] . '</span></div>'; } else { $tr['{hint}'] = ''; } $this->renderItem($attribute, $tr); $i++; } if ($this->tagName !== null) { echo CHtml::closeTag($this->tagName); } }
private function ajaxRefresh($server, $type) { $all = $type === 'all'; if (!is_array($type)) { $type = array($type); } $ret = array(); $status = False; if ($all || in_array('players', $type)) { $error = false; ob_start(); if (!Yii::app()->user->can($server->id, 'get players')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'get players', $players)) { $error = McBridge::get()->lastError(); } } $i = 0; if (is_array($players) && count($players)) { $kick = Yii::app()->user->can($server->id, 'kick'); foreach ($players as $player) { ?> <tr class="<?php if (!($i % 2)) { echo 'even'; } else { echo 'odd'; } ?> "> <td> <?php $nick = '<span' . ($this->ip == @$player['ip'] ? ' style="font-weight: bold; color: blue"' : '') . '>' . CHtml::encode(@$player['name']) . '</span>'; if (@$player['id']) { echo CHtml::link($nick, array('player/view', 'id' => $player['id'])); } else { echo $nick; } ?> <?php if ($kick) { ?> <div style="float: right"> <?php echo CHtml::link('Kick', 'javascript:kickPlayer(\'' . addslashes(@$player['name']) . '\')'); ?> </div> <?php } ?> </td> </tr> <?php $i++; } } else { ?> <tr> <td class="odd" style="text-align: center"> <?php if (strlen($error)) { echo Yii::t('mc', 'Error getting player list: ') . $this->errStr($error); } else { echo Yii::t('mc', 'No players online'); } ?> </td> </tr> <?php } $ret['players'] = ob_get_clean(); } if ($all || in_array('chat', $type)) { $error = false; ob_start(); if (!Yii::app()->user->can($server->id, 'get chat')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'get chat', $chat)) { $error = McBridge::get()->lastError(); } } if (strlen($error)) { echo Yii::t('mc', 'Couldn\'t get chat: ') . $this->errStr($error); } else { for ($i = count($chat) - 1; $i >= 0; $i--) { echo @strftime('%H:%M:%S', $chat[$i]['time']) . ' ' . str_pad('<' . $chat[$i]['name'] . '>', 25) . $chat[$i]['text'] . "\n"; } echo "\n"; } $ret['chat'] = ob_get_clean(); } if ($all || in_array('status', $type) || in_array('statusdetail', $type) || in_array('statusicon', $type)) { $error = false; ob_start(); if (!Yii::app()->user->can($server->id, 'get status')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'get status', $status)) { $ret['status'] = McBridge::get()->lastError(); } } if (strlen($error)) { echo Yii::t('mc', 'Error getting server status: ') . $this->errStr($error); } else { $ret['statusdetail'] = Yii::t('mc', 'Offline'); $st = @$status[0]; switch (@$st['status']) { case 'running': echo Yii::t('mc', 'The server is online!'); $ret['statusdetail'] = Yii::t('mc', 'Online') . ', ' . @$st['players'] . '/' . @$st['maxPlayers'] . ' ' . Yii::t('mc', 'players'); $ret['statusicon'] = Theme::img('online.png'); break; case 'stopped': echo Yii::t('mc', 'The server is offline.'); $ret['statusicon'] = Theme::img('offline.png'); break; default: echo Yii::t('mc', 'The server status is currently changing.'); $ret['statusicon'] = Theme::img('changing.png'); } if (@$st['pid'] && Yii::app()->user->isSuperuser()) { $ret['statusdetail'] .= ' (' . Yii::t('mc', 'PID') . ': ' . @$st['pid'] . ')'; } } $ret['status'] = ob_get_clean(); } if ($all || in_array('resources', $type)) { $error = false; ob_start(); if (!Yii::app()->user->can($server->id, 'get log')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'get resources', $res)) { $error = McBridge::get()->lastError(); } } if (!strlen($error)) { $st = @$res[0]; $this->renderPartial('resources', array('cpu' => @$st['cpu'], 'memory' => @$st['memory'])); } $ret['resources'] = ob_get_clean(); } if ($all || in_array('log', $type)) { $error = false; ob_start(); if (!Yii::app()->user->can($server->id, 'get log')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'get log', $log)) { $error = McBridge::get()->lastError(); } } if (strlen($error)) { echo Yii::t('mc', 'Couldn\'t get log: ') . $this->errStr($error); } else { for ($i = count($log) - 1; $i >= 0; $i--) { echo @$log[$i]['line'] . "\n"; } } $ret['log'] = ob_get_clean(); } if ($all || in_array('buttons', $type)) { $error = false; ob_start(); if (!$status) { if (!Yii::app()->user->can($server->id, 'get status')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'get status', $status)) { $error = McBridge::get()->lastError(); } } } $off = '1'; $on = '0'; $b1 = $b2 = $b3 = $off; if (Yii::app()->user->can($server->id, 'start')) { $b1 = $on; } if (Yii::app()->user->can($server->id, 'stop')) { $b2 = $on; } if (Yii::app()->user->can($server->id, 'restart')) { $b3 = $on; } switch (@$status[0]['status']) { case 'running': $b1 = $off; break; case 'stopped': $b2 = $off; break; default: $b1 = $b3 = $off; } echo $b1 . $b2 . $b3; $ret['buttons'] = ob_get_clean(); } if (in_array('backup', $type)) { $error = false; ob_start(); if (!Yii::app()->user->can($server->id, 'get backup')) { $error = Yii::t('mc', 'Permission denied.'); } else { if (!McBridge::get()->serverCmd($server->id, 'backup status', $backup)) { $error = McBridge::get()->lastError(); } } $dis = array('disabled' => 'disbled'); $start = $download = false; $cls = 'flash-success'; switch ($backup[0]['status']) { case 'none': $content = Yii::t('mc', 'No backup in progress'); $start = true; break; case 'done': $content = Yii::t('mc', 'Backup done, ready for download. (Created: {date})', array('{date}' => @date('Y-m-d H:i', $backup[0]['time']))); $start = $download = true; break; case 'running': $content = Yii::t('mc', 'Backup in progress, please wait'); break; case 'error': default: if (!$error) { $error = $backup[0]['message']; } $content = $error ? $error : Yii::t('mc', 'Error during backup, please check the daemon log'); $cls = 'flash-error'; $start = true; break; } echo '<div class="' . $cls . '">' . CHtml::encode($content) . '</div>'; if (Yii::app()->user->can($server->id, 'start backup')) { echo CHtml::ajaxButton(Yii::t('mc', 'Start'), '', array('type' => 'POST', 'data' => array('ajax' => 'start', Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken), 'success' => 'backup_response'), $start ? array() : $dis); } if (@is_readable($backup[0]['file'])) { $opt = $download ? array() : $dis; $opt['onClick'] = 'backup_download()'; echo CHtml::button(Yii::t('mc', 'Download'), $opt); } else { if (@$backup[0]['ftp']) { echo '<br/>'; echo '<br/>'; if (@Yii::app()->params['ftp_client_disabled'] !== true) { echo Yii::t('mc', 'You can use the {link} to access your backup. For all other FTP clients, please use the information below.', array('{link}' => CHtml::link('Multicraft FTP client', array('/ftpClient', 'id' => $server->id)))); echo '<br/>'; echo '<br/>'; } echo Yii::t('mc', 'The backup is available as "<b>{file}</b>" on the following FTP server:', array('{file}' => CHtml::encode(basename($backup[0]['file'])))) . '<br/>'; $ftp = explode(':', $backup[0]['ftp']); $ip = @$ftp[0]; $port = @$ftp[1]; $dmn = Daemon::model()->findByPk($server->daemon_id); if ($dmn && isset($dmn->ftp_ip) && isset($dmn->ftp_port)) { $ip = $dmn->ftp_ip; $port = $dmn->ftp_port; } $attr = array(); $attr[] = array('label' => Yii::t('mc', 'Host'), 'value' => $ip); $attr[] = array('label' => Yii::t('mc', 'Port'), 'value' => $port); $attr[] = array('label' => Yii::t('mc', 'User'), 'value' => Yii::app()->user->name . '.' . $server->id); $attr[] = array('label' => Yii::t('mc', 'Password'), 'value' => Yii::t('mc', 'Your Multicraft login password')); $this->widget('zii.widgets.CDetailView', array('data' => array(), 'attributes' => $attr)); } else { if ($download) { echo Yii::t('mc', 'Your backup is available as "<b>{file}</b>" in your servers base directory.', array('{file}' => CHtml::encode(basename($backup[0]['file'])))); } } } $ret['backup'] = ob_get_clean(); } if ($all || in_array('movestatus', $type)) { $error = false; ob_start(); try { $sql = 'select `src_dmn`, `dst_dmn`, `status`, `message` from `move_status` where `server_id`=?'; $cmd = Yii::app()->bridgeDb->createCommand($sql); $cmd->bindValue(1, $server->id); $row = $cmd->queryRow(false); } catch (Exception $e) { $row = array(0, 0, 'error', 'Failed to load status from database.'); } if ($row && Yii::app()->user->isSuperuser()) { $flash = 'success'; if ($row[2] == 'error') { $flash = 'error'; } $msg = array('started' => Yii::t('mc', 'Server move started'), 'packing' => Yii::t('mc', 'Packing server files on source daemon'), 'uploading' => Yii::t('mc', 'Uploading server files to new daemon'), 'notifying' => Yii::t('mc', 'Notifying new daemon of completed transfer'), 'transferred' => Yii::t('mc', 'Transfer complete, starting unpack'), 'unpacking' => Yii::t('mc', 'Unpacking server files on destination daemon'), 'unsuspending' => Yii::t('mc', 'Unsuspending server'), 'done' => Yii::t('mc', 'Servermove completed.'), 'error' => Yii::t('mc', 'Server move failed, please check the server console and multicraft.log. Last error:')); $msg = @$msg[$row[2]]; if (!$msg) { $msg = $row[2]; } ?> <div class="flash-<?php echo $flash; ?> "> <span style="float: right"> <?php echo CHtml::link(Yii::t('mc', 'Dismiss'), array('dismiss', 'id' => $server->id)); ?> </span> <?php echo Yii::t('mc', 'Server move status from daemon {a} to daemon {b}:', array('{a}' => $row[0], '{b}' => $row[1])); ?> <br/> <?php echo $msg; ?> <br/> <?php echo $row[3]; ?> </div> <?php } $ret['movestatus'] = ob_get_clean(); } return $ret; }
} if (Yii::app()->user->isSuperuser() || $settings->user_jar && in_array($model->jardir, array('server', 'server_base'))) { if ($jars) { $attribs[] = array('label' => '', 'type' => 'raw', 'value' => CHtml::dropDownList('jar-select', $model->jarfile, $jars), 'hint' => Yii::t('mc', 'JAR file selection')); } $attribs[] = array('label' => $form->labelEx($model, 'jarfile'), 'type' => 'raw', 'value' => $form->textField($model, 'jarfile') . ' ' . $form->error($model, 'jarfile'), 'hint' => Yii::t('mc', 'Empty for default file.')); } else { if ($jars && $settings->user_jar) { $attribs[] = array('label' => Yii::t('mc', 'Server JAR'), 'type' => 'raw', 'value' => CHtml::dropDownList('jar-select', $model->jarfile, $jars)); } } if (Yii::app()->user->isSuperuser()) { $attribs[] = array('label' => $form->labelEx($settings, 'user_jar'), 'type' => 'raw', 'value' => $form->checkBox($settings, 'user_jar') . ' ' . $form->error($settings, 'user_jar')); $attribs[] = array('label' => $form->labelEx($settings, 'user_name'), 'type' => 'raw', 'value' => $form->checkBox($settings, 'user_name') . ' ' . $form->error($settings, 'user_name')); } $attribs[] = array('label' => Theme::img('icons/closed.png', '', array('id' => 'advImg')), 'type' => 'raw', 'value' => CHtml::link(Yii::t('mc', 'Show Advanced Options'), '#', array('id' => 'advTxt', 'onclick' => 'return checkAdv()'))); if (Yii::app()->user->isSuperuser()) { $attribs[] = array('label' => $form->labelEx($model, 'world'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->textField($model, 'world') . ' ' . $form->error($model, 'world'), 'hint' => Yii::t('mc', 'Leave empty for "world"')); $attribs[] = array('label' => $form->labelEx($model, 'dir'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->textField($model, 'dir') . ' ' . $form->error($model, 'dir'), 'hint' => Yii::t('mc', 'Contains all files for this server')); $attribs[] = array('label' => $form->labelEx($model, 'start_memory'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->textField($model, 'start_memory') . ' ' . $form->error($model, 'start_memory'), 'hint' => Yii::t('mc', 'In MB. Empty for same as Max. Memory')); $attribs[] = array('label' => $form->labelEx($model, 'autostart'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->checkBox($model, 'autostart') . ' ' . $form->error($model, 'autostart'), 'hint' => Yii::t('mc', 'Start this server automatically when Multicraft restarts')); $attribs[] = array('label' => $form->labelEx($settings, 'user_schedule'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->checkBox($settings, 'user_schedule') . ' ' . $form->error($settings, 'user_schedule'), 'hint' => Yii::t('mc', 'Owner can create scheduled tasks and change the autosave setting')); $attribs[] = array('label' => $form->labelEx($settings, 'user_ftp'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->checkBox($settings, 'user_ftp') . ' ' . $form->error($settings, 'user_ftp'), 'hint' => Yii::t('mc', 'Owner can give FTP access to other users')); $attribs[] = array('label' => $form->labelEx($settings, 'user_visibility'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->checkBox($settings, 'user_visibility') . ' ' . $form->error($settings, 'user_visibility'), 'hint' => Yii::t('mc', 'Owner can change the server visibility and Default Role')); $attribs[] = array('label' => $form->labelEx($settings, 'user_players'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->checkBox($settings, 'user_players') . ' ' . $form->error($settings, 'user_players')); if (Yii::app()->params['user_mysql']) { $attribs[] = array('label' => $form->labelEx($settings, 'user_mysql'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->checkBox($settings, 'user_mysql') . ' ' . $form->error($settings, 'user_mysql')); } $attribs[] = array('label' => $form->labelEx($model, 'jardir'), 'type' => 'raw', 'cssClass' => 'adv', 'value' => $form->dropDownList($model, 'jardir', Server::getJardirs()) . ' ' . $form->error($model, 'jardir'), 'hint' => Yii::t('mc', '(* Warning: Be sure to run Multicraft in "multiuser" mode with this!)')); } else { if (Yii::app()->params['show_memory']) {
$pl = $data->getOnlinePlayers(); $img = $pl >= 0 ? 'online.png' : 'offline.png'; ?> <table style="height: 100%; table-layout: fixed"> <colgroup> <col style="width: 35px"/> <col/> <col/> </colgroup> <tr> <td style="padding-left: 10px" id="sv_icon_<?php echo $data->id; ?> "> <?php echo Theme::img($img); ?> </td> <td style="width: 50%; max-width: 330px; overflow: hidden; vertical-align: middle"> <?php echo CHtml::link(CHtml::encode($data->name), array('server/view', 'id' => $data->id), array('style' => 'display: block; max-height: 28px')); ?> </a> </td> <td> <span id="sv_status_<?php echo $data->id; ?> "> <?php if ($data->suspended) {
$("#"+name+"_main").children("img").attr("src", !menuShown[name] ? imgClosed : imgOpen); $("#"+name).stop(true, true).slideToggle(menuShown[name]); } '); if (!!Yii::app()->params['ajax_serverlist']) { echo CHtml::script(' function get_status(server) { ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'data' => array('ajax' => 'get_status', 'server' => 'js:server', Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken), 'success' => 'status_response')) . ' } function status_response(data) { id = parseInt(data["id"]); pl = parseInt(data["pl"]); img = pl >= 0 ? \'' . Theme::img('online.png') . '\' : \'' . Theme::img('offline.png') . '\'; $("#sv_icon_"+id).html(img); if (pl >= 0) { str = pl; $("#sv_maxplr_"+id).show(); $("#sv_chatlink_"+id).show(); } else { str = "' . Yii::t('mc', 'Offline') . '" + (pl == -2 ? " (' . Yii::t('mc', 'error') . ')" : ""); } $("#sv_status_"+id).html(str); } '); }
</tr> <tr> <td class="left"> <?php echo CHtml::link(Theme::img('about/net2ftp.png'), 'http://www.net2ftp.com/'); ?> </td> <td> <?php echo CHtml::link(Theme::img('about/oil.png'), 'http://openiconlibrary.sourceforge.net'); ?> </td> </tr> <tr> <td colspan="2"> <?php echo CHtml::link(Theme::img('about/xhost.png'), 'http://www.xhost.ch/'); ?> </td> </tr> <tr> <td colspan="2"> <?php echo CHtml::link(Theme::img('about/multicraft.png'), 'http://www.multicraft.org/'); ?> </td> </tr> </table> <br/> <br/>
</td> </tr> </table> <span style="float:right; font-size: 10px"><?php echo Yii::t('admin', 'Values in brackets include suspended servers.'); ?> </span> <br/> <table class="detail-view"> <tr class="titlerow"> <td><?php echo Yii::t('admin', 'Live Statistics'); ?> </td> <td width="200" height="30" id="status"><?php echo Theme::img('changing.png'); ?> pending</td> </tr> <tr class="<?php trclass(true); ?> "> <td><?php echo Yii::t('admin', 'Online servers'); ?> </td> <td id="servers"></td> </tr> <tr class="<?php trclass();