mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
#331 gameserver console
This commit is contained in:
parent
1dd50a529f
commit
db90e373d4
@ -50,8 +50,9 @@ include(EASYWIDIR . '/stuff/config.php');
|
||||
include(EASYWIDIR . '/stuff/keyphrasefile.php');
|
||||
include(EASYWIDIR . '/stuff/methods/functions.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_validator.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_ts3.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_ftp.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_app.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_ts3.php');
|
||||
include(EASYWIDIR . '/stuff/methods/functions_ts3.php');
|
||||
include(EASYWIDIR . '/stuff/methods/vorlage.php');
|
||||
include(EASYWIDIR . '/stuff/settings.php');
|
||||
@ -309,7 +310,7 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') {
|
||||
require_once(EASYWIDIR . '/stuff/ajax/stats_voicestats.php');
|
||||
die;
|
||||
|
||||
} else if (($pa['gserver'] or $pa['restart']) and (isset($user_id) or isset($admin_id)) and $ui->w('d', 9, 'get') == 'serverLog' and $ui->id('id', 10, 'get')) {
|
||||
} else if (($pa['gserver'] or $pa['restart']) and isset($user_id) and $ui->w('d', 9, 'get') == 'serverLog' and $ui->id('id', 10, 'get')) {
|
||||
|
||||
require_once(EASYWIDIR . '/stuff/ajax/server_log.php');
|
||||
die;
|
||||
|
@ -1,141 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: serverlog.php.
|
||||
* Author: Ulrich Block
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
define('EASYWIDIR', dirname(__FILE__));
|
||||
include(EASYWIDIR . '/stuff/methods/functions.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_validator.php');
|
||||
include(EASYWIDIR . '/stuff/methods/class_ftp.php');
|
||||
include(EASYWIDIR . '/stuff/methods/vorlage.php');
|
||||
include(EASYWIDIR . '/stuff/settings.php');
|
||||
include(EASYWIDIR . '/stuff/keyphrasefile.php');
|
||||
|
||||
if (!isset($user_id) and !isset($admin_id)) {
|
||||
header('Location: login.php');
|
||||
die('Please allow redirection');
|
||||
}
|
||||
|
||||
if (!isset($resellerLockupID)) {
|
||||
$resellerLockupID = $reseller_id;
|
||||
}
|
||||
|
||||
if ($ui->id('id', 10, 'get')) {
|
||||
|
||||
if (isset($admin_id)) {
|
||||
|
||||
$query = $sql->prepare("SELECT u.`id`,u.`cname` FROM `gsswitch` g LEFT JOIN `userdata` u ON g.`userid`=u.`id` WHERE g.`id`=? AND g.`resellerid`=? LIMIT 1");
|
||||
$query->execute(array($ui->id('id', 10, 'get'), $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$username = $row['cname'];
|
||||
$user_id = $row['id'];
|
||||
}
|
||||
|
||||
} else {
|
||||
$username = getusername($user_id);
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT g.`id`,g.`newlayout`,g.`rootID`,g.`serverip`,g.`port`,g.`protected`,AES_DECRYPT(g.`ftppassword`,?) AS `dftppass`,AES_DECRYPT(g.`ppassword`,?) AS `decryptedftppass`,s.`servertemplate`,t.`binarydir`,t.`shorten` FROM `gsswitch` g LEFT JOIN `serverlist` s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`id`=? AND g.`userid`=? AND g.`resellerid`=? LIMIT 1");
|
||||
$query->execute(array($aeskey, $aeskey, $ui->id('id', 10, 'get'), $user_id, $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
$protected = $row['protected'];
|
||||
$servertemplate = $row['servertemplate'];
|
||||
$rootID = $row['rootID'];
|
||||
$serverip = $row['serverip'];
|
||||
$port = $row['port'];
|
||||
$shorten = $row['shorten'];
|
||||
$binarydir = $row['binarydir'];
|
||||
$ftppass = $row['dftppass'];
|
||||
|
||||
if ($row['newlayout'] == 'Y') {
|
||||
$username .= '-' . $row['id'];
|
||||
}
|
||||
|
||||
if ($protected == 'N' and $servertemplate > 1) {
|
||||
$shorten .= '-' . $servertemplate;
|
||||
$pserver = 'server/';
|
||||
} else if ($protected == 'Y') {
|
||||
$username .= '-p';
|
||||
$ftppass = $row['decryptedftppass'];
|
||||
$pserver = '';
|
||||
} else {
|
||||
$pserver = 'server/';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($rootID)) {
|
||||
|
||||
$query = $sql->prepare("SELECT `ip`,`ftpport` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
||||
$query->execute(array($rootID, $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
$ftpport = $row['ftpport'];
|
||||
$ip = $row['ip'];
|
||||
|
||||
$ftpConnect = new EasyWiFTP($ip, $ftpport, $username, $ftppass);
|
||||
|
||||
$downloadChrooted = $ftpConnect->removeSlashes($pserver . $serverip . '_' . $port . '/' . $shorten . '/' . $binarydir . '/screenlog.0');
|
||||
|
||||
if ($ftpConnect->ftpConnection) {
|
||||
|
||||
if (!$ftpConnect->downloadToTemp($downloadChrooted, 32768)) {
|
||||
$error = 'Cannot download screenlog from ' . $downloadChrooted;
|
||||
}
|
||||
|
||||
} else {
|
||||
$error = 'Cannot connect to FTP Server ' . $ip . ':' . $ftpport;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($ip)) {
|
||||
|
||||
$log = (isset($error)) ? $error : nl2br($ftpConnect->getTempFileContent());
|
||||
|
||||
$ftpConnect->tempHandle = null;
|
||||
$ftpConnect = null;
|
||||
|
||||
} else {
|
||||
$log = 'Error: wrong rootID';
|
||||
}
|
||||
|
||||
} else {
|
||||
$log = 'Error: No rootID';
|
||||
}
|
||||
}
|
||||
|
||||
include(IncludeTemplate($template_to_use, 'gameserverlog.tpl'));
|
||||
$sql = null;
|
@ -45,63 +45,39 @@ if (!isset($resellerLockupID)) {
|
||||
$resellerLockupID = $reseller_id;
|
||||
}
|
||||
|
||||
$array = array('lastLog' => 0, 'log' => '');
|
||||
|
||||
if (isset($admin_id)) {
|
||||
|
||||
$query = $sql->prepare("SELECT u.`id`,u.`cname` FROM `gsswitch` g LEFT JOIN `userdata` u ON g.`userid`=u.`id` WHERE g.`id`=? AND g.`resellerid`=? LIMIT 1");
|
||||
$query->execute(array($ui->id('id', 10, 'get'), $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$username = $row['cname'];
|
||||
$user_id = $row['id'];
|
||||
}
|
||||
|
||||
} else {
|
||||
$username = getusername($user_id);
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT g.`id`,g.`newlayout`,g.`rootID`,g.`serverip`,g.`port`,g.`protected`,AES_DECRYPT(g.`ftppassword`,?) AS `dftppass`,AES_DECRYPT(g.`ppassword`,?) AS `decryptedftppass`,s.`servertemplate`,t.`binarydir`,t.`shorten` FROM `gsswitch` g LEFT JOIN `serverlist` s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`id`=? AND g.`userid`=? AND g.`resellerid`=? LIMIT 1");
|
||||
$query = $sql->prepare("SELECT r.`ip` AS `ftp_ip`,r.`ftpport`,u.`cname`,g.`id`,g.`newlayout`,g.`rootID`,g.`serverip`,g.`port`,g.`protected`,AES_DECRYPT(g.`ftppassword`,?) AS `dftppass`,AES_DECRYPT(g.`ppassword`,?) AS `decryptedftppass`,s.`servertemplate`,t.`binarydir`,t.`shorten` FROM `gsswitch` AS g INNER JOIN `userdata` AS u ON u.`id`=g.`userid` INNER JOIN `rserverdata` AS r ON r.`id`=g.`rootID` INNER JOIN `serverlist` AS s ON g.`serverid`=s.`id` INNER JOIN `servertypes` AS t ON s.`servertype`=t.`id` WHERE g.`id`=? AND g.`userid`=? AND g.`resellerid`=? LIMIT 1");
|
||||
$query->execute(array($aeskey, $aeskey, $ui->id('id', 10, 'get'), $user_id, $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
$protected = $row['protected'];
|
||||
$servertemplate = $row['servertemplate'];
|
||||
$rootID = $row['rootID'];
|
||||
$serverip = $row['serverip'];
|
||||
$port = $row['port'];
|
||||
$shorten = $row['shorten'];
|
||||
$binarydir = $row['binarydir'];
|
||||
$ftppass = $row['dftppass'];
|
||||
if ($ui->escaped('cmd', 'post')) {
|
||||
|
||||
if ($row['newlayout'] == 'Y') {
|
||||
$username .= '-' . $row['id'];
|
||||
}
|
||||
$appServer = new AppServer($row['rootID']);
|
||||
$appServer->getAppServerDetails($ui->id('id', 10, 'get'));
|
||||
$appServer->shellCommand($ui->escaped('cmd', 'post'));
|
||||
$appServer->execute();
|
||||
|
||||
if ($protected == 'N' and $servertemplate > 1) {
|
||||
$shorten .= '-' . $servertemplate;
|
||||
$pserver = 'server/';
|
||||
} else if ($protected == 'Y') {
|
||||
$username .= '-p';
|
||||
$ftppass = $row['decryptedftppass'];
|
||||
$pserver = '';
|
||||
} else {
|
||||
$pserver = 'server/';
|
||||
}
|
||||
}
|
||||
|
||||
$array = array('lastLog' => 0, 'log' => '');
|
||||
$shorten = $row['shorten'];
|
||||
$ftppass = $row['dftppass'];
|
||||
$username = ($row['newlayout'] == 'Y') ? $row['cname'] . '-' . $row['id'] : $row['cname'];
|
||||
|
||||
if (isset($rootID)) {
|
||||
if ($row['protected'] == 'N' and $row['servertemplate'] > 1) {
|
||||
$shorten .= '-' . $row['servertemplate'];
|
||||
$pserver = 'server/';
|
||||
} else if ($row['protected'] == 'Y') {
|
||||
$username .= '-p';
|
||||
$ftppass = $row['decryptedftppass'];
|
||||
$pserver = '';
|
||||
} else {
|
||||
$pserver = 'server/';
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT `ip`,`ftpport` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
||||
$query->execute(array($rootID, $resellerLockupID));
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$ftpConnect = new EasyWiFTP($row['ftp_ip'], $row['ftpport'], $username, $ftppass);
|
||||
|
||||
$ftpport = $row['ftpport'];
|
||||
$ip = $row['ip'];
|
||||
|
||||
$ftpConnect = new EasyWiFTP($ip, $ftpport, $username, $ftppass);
|
||||
|
||||
$downloadChrooted = $ftpConnect->removeSlashes($pserver . $serverip . '_' . $port . '/' . $shorten . '/' . $binarydir . '/screenlog.0');
|
||||
$downloadChrooted = $ftpConnect->removeSlashes($pserver . $row['serverip'] . '_' . $row['port'] . '/' . $shorten . '/' . $row['binarydir'] . '/screenlog.0');
|
||||
|
||||
if ($ftpConnect->ftpConnection) {
|
||||
|
||||
@ -113,20 +89,12 @@ if (isset($rootID)) {
|
||||
}
|
||||
|
||||
} else {
|
||||
$array['error'] = 'Cannot connect to FTP Server ' . $ip . ':' . $ftpport;
|
||||
$array['error'] = 'Cannot connect to FTP Server ' . $row2['ip'] . ':' . $row2['ftpport'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($query->rowCount() > 0) {
|
||||
|
||||
$ftpConnect->tempHandle = null;
|
||||
$ftpConnect = null;
|
||||
|
||||
} else {
|
||||
$array['error'] = 'Error: wrong rootID';
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($query->rowCount() < 1) {
|
||||
$array['error'] = 'Error: No rootID';
|
||||
}
|
||||
|
||||
|
@ -2131,6 +2131,34 @@ class AppServer {
|
||||
}
|
||||
}
|
||||
|
||||
private function shellCommandLinux($command) {
|
||||
|
||||
$scriptName = $this->removeSlashes('/home/' . $this->appMasterServerDetails['ssh2User'] . '/temp/execute-cmd-' . $this->appServerDetails['userNameExecute'] . '-' . $this->appServerDetails['serverIP'] . '-' . $this->appServerDetails['port'] . '.sh');
|
||||
$screenName = $this->appServerDetails['serverIP'] . '_' . $this->appServerDetails['port'];
|
||||
|
||||
$script = $this->shellScriptHeader;
|
||||
$script .= 'rm -f ' . $scriptName . "\n";
|
||||
|
||||
$script .= 'screen -S ' . $screenName . ' -X stuff $\'' . $command . '\n\'';
|
||||
|
||||
$this->addLinuxScript($scriptName, $script);
|
||||
|
||||
$this->addLogline('app_server.log', 'App console command' . $this->appServerDetails['serverIP'] . '_' . $this->appServerDetails['port'] . ' owned by user ' . $this->appServerDetails['userNameExecute'] . ' executed');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function shellCommand($command) {
|
||||
|
||||
// Linux and Windows deamon are reached via SSH2.
|
||||
|
||||
if ($this->appMasterServerDetails['os'] == 'L') {
|
||||
return $this->shellCommandLinux($command);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getKeyAndOrPassword () {
|
||||
|
||||
if ($this->appMasterServerDetails['ssh2Publickey'] != 'N' and file_exists($this->appMasterServerDetails['privateKey'])) {
|
||||
|
@ -218,7 +218,6 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
|
||||
$port = $row['port'];
|
||||
|
||||
$appServer = new AppServer($row['rootID']);
|
||||
|
||||
$appServer->getAppServerDetails($id);
|
||||
|
||||
if ($ui->st('d', 'get') == 'rs') {
|
||||
|
@ -1,19 +0,0 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel"><?php echo $ewCfg['title'] . ' ' . $serverip .':' . $port;?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?php echo $log;?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-warning" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<script type='text/javascript'>
|
||||
$( ".modal-body" ).ready(function() {
|
||||
var modalContent = $('.modal-body');
|
||||
modalContent.css('overflow-y', 'auto');
|
||||
modalContent.css('max-height', $(window).height() * 0.7);
|
||||
});
|
||||
</script>
|
@ -18,11 +18,11 @@
|
||||
</div>
|
||||
|
||||
<div class="box-footer">
|
||||
<?php if ($liveConsole=='Z') { ?>
|
||||
<?php if ($liveConsole=='Y') { ?>
|
||||
<div class="input-group">
|
||||
<input id="inputCommand" type="text" class="form-control" name="command" value="">
|
||||
<input id="inputCommand" type="text" class="form-control" name="command" value="" onkeydown="enterUsed(event)">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary btn-flat" type="button" onclick="submitForm();"><i class="fa fa-play-circle"></i></button>
|
||||
<button class="btn btn-primary btn-flat" type="button" onclick="submitForm()"><i class="fa fa-play-circle"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
<?php } ?>
|
||||
@ -34,33 +34,65 @@
|
||||
<script type='text/javascript'>
|
||||
|
||||
var lastLog = 0;
|
||||
var getRequestStarted = false;
|
||||
|
||||
function enterUsed(event) {
|
||||
if (event.keyCode === 13) {
|
||||
submitForm();
|
||||
}
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
|
||||
$('#inputCommand').val('');
|
||||
var inputCommand = $('#inputCommand');
|
||||
|
||||
$.ajax({
|
||||
url: 'ajax.php?d=serverLog&id=<?php echo $id;?>&lastLog=' + lastLog,
|
||||
cache: false
|
||||
}).done(function(jsonReturn) {
|
||||
|
||||
var jsonParsed = JSON.parse(jsonReturn);
|
||||
|
||||
if (jsonParsed.error) {
|
||||
|
||||
alert(jsonParsed.error);
|
||||
|
||||
} else {
|
||||
|
||||
lastLog = jsonParsed.lastLog;
|
||||
|
||||
if (jsonParsed.log.length > 0) {
|
||||
var boxBody = $('#boxBody');
|
||||
boxBody.append(jsonParsed.log);
|
||||
boxBody.scrollTop(boxBody.prop("scrollHeight"));
|
||||
}
|
||||
url: 'ajax.php?d=serverLog&id=<?php echo $id;?>',
|
||||
cache: false,
|
||||
method: 'POST',
|
||||
data: {
|
||||
cmd: inputCommand.val()
|
||||
}
|
||||
}).done(function(jsonReturn) {
|
||||
setTimeout(function(){getLog()},1000);
|
||||
});
|
||||
|
||||
inputCommand.val('');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getLog() {
|
||||
|
||||
if (getRequestStarted === false) {
|
||||
|
||||
getRequestStarted = true;
|
||||
|
||||
$.ajax({
|
||||
url: 'ajax.php?d=serverLog&id=<?php echo $id;?>&lastLog=' + lastLog,
|
||||
cache: false
|
||||
}).done(function(jsonReturn) {
|
||||
|
||||
getRequestStarted = false;
|
||||
|
||||
var jsonParsed = JSON.parse(jsonReturn);
|
||||
|
||||
if (jsonParsed.error) {
|
||||
|
||||
alert(jsonParsed.error);
|
||||
|
||||
} else {
|
||||
|
||||
lastLog = jsonParsed.lastLog;
|
||||
|
||||
if (jsonParsed.log.length > 0) {
|
||||
var boxBody = $('#boxBody');
|
||||
boxBody.append(jsonParsed.log);
|
||||
boxBody.scrollTop(boxBody.prop("scrollHeight"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function resizeHeigth() {
|
||||
@ -74,8 +106,8 @@
|
||||
|
||||
$(function(){
|
||||
resizeHeigth();
|
||||
submitForm();
|
||||
getLog();
|
||||
|
||||
setInterval(function(){submitForm()},3000);
|
||||
setInterval(function(){getLog()},3000);
|
||||
});
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user