#30 New template with bootstrap 3

Complete rework of the gameserver management
This commit is contained in:
Ulrich Block 2014-09-29 00:07:35 +02:00
parent 5729db2e4b
commit b2d507e67b
22 changed files with 2430 additions and 1299 deletions

View File

@ -50,6 +50,7 @@ include(EASYWIDIR . '/stuff/methods/functions.php');
include(EASYWIDIR . '/stuff/methods/class_validator.php');
include(EASYWIDIR . '/stuff/methods/vorlage.php');
include(EASYWIDIR . '/stuff/config.php');
include(EASYWIDIR . '/stuff/keyphrasefile.php');
include(EASYWIDIR . '/stuff/settings.php');
if (!isset($admin_id) and !isset($user_id)) {
@ -75,78 +76,118 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') {
$sSearch = (strlen($ui->escaped('sSearch', 'get')) > 0) ? $ui->escaped('sSearch', 'get') : false;
// Userlog
if (($ui->smallletters('d', 7, 'get') == 'userlog' and isset($user_id)) or ($ui->smallletters('d', 12, 'get') =='adminuserlog' and isset($admin_id)) and $pa['log']) {
if (($ui->smallletters('d', 7, 'get') == 'userlog' and isset($user_id)) or ($ui->smallletters('d', 12, 'get') == 'adminuserlog' and isset($admin_id)) and $pa['log']) {
$adminLookup = ($ui->smallletters('d', 12, 'get') =='adminuserlog' and isset($admin_id)) ? true : false;
$adminLookup = ($ui->smallletters('d', 12, 'get') == 'adminuserlog' and isset($admin_id)) ? true : false;
require_once(EASYWIDIR . '/stuff/ajax/datatable_userlog.php');
// Mail log
} else if ($ui->smallletters('d', 7, 'get') =='maillog' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['jobs']) {
} else if ($ui->smallletters('d', 7, 'get') == 'maillog' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['jobs']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_maillog.php');
// Job log
} else if ($ui->smallletters('d', 6, 'get') =='joblog' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['jobs']) {
} else if ($ui->smallletters('d', 6, 'get') == 'joblog' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['jobs']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_joblog.php');
// IP bans
} else if ($ui->smallletters('d', 6, 'get') =='ipbans' and isset($admin_id) and isset($reseller_id) and $reseller_id == 0 and $pa['ipBans']) {
} else if ($ui->smallletters('d', 6, 'get') == 'ipbans' and isset($admin_id) and isset($reseller_id) and $reseller_id == 0 and $pa['ipBans']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_ipbans.php');
// custom module
} else if ($ui->smallletters('d', 12, 'get') =='custommodule' and isset($admin_id) and isset($reseller_id) and $reseller_id == 0 and $pa['root']) {
} else if ($ui->smallletters('d', 12, 'get') == 'custommodule' and isset($admin_id) and isset($reseller_id) and $reseller_id == 0 and $pa['root']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_custommodule.php');
// List of imported news feeds
} else if ($ui->smallletters('d', 16, 'get') =='feedsnewsentries' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
} else if ($ui->smallletters('d', 16, 'get') == 'feedsnewsentries' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_feedsnewsentries.php');
// List of feeds
} else if ($ui->smallletters('d', 5, 'get') =='feeds' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
} else if ($ui->smallletters('d', 5, 'get') == 'feeds' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_feeds.php');
// App (GS + Tools) masterserver
} else if ($ui->smallletters('d', 15, 'get') =='appmasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) {
} else if ($ui->smallletters('d', 15, 'get') == 'appmasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_appmasterserver.php');
// GS images
} else if ($ui->smallletters('d', 10, 'get') =='gameimages' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['gimages']) {
} else if ($ui->smallletters('d', 10, 'get') == 'gameimages' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['gimages']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_gameimages.php');
// GS addons
} else if ($ui->smallletters('d', 16, 'get') =='gameserveraddons' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
} else if ($ui->smallletters('d', 16, 'get') == 'gameserveraddons' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_gameaddons.php');
// App server
} else if ($ui->smallletters('d', 9, 'get') =='appserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['roots']) {
} else if ($ui->smallletters('d', 9, 'get') == 'appserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['roots']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_appserver.php');
// Code wise it seems odd, but this way we can get plausible userIDs for following queries up front
// Code wise it seems odd, but this way we can get plausible userIDs for following queries up front without having to repeat ourselves
} else {
// When searching a table combination that should provide a server and user´s loginname, firstname, lastname. First do a search at usertable and get IDs.
// This IDs should be used for doing a `ID` IN (implode(',', $foundIDs)) as it will be faster.
if ($sSearch) {
$userIDs = array();
$query = $sql->prepare("SELECT `id`,`cname`,CONCAT(`vname`,' ',`name`) AS `full_name` FROM `userdata` WHERE `resellerid`=:reseller_id HAVING (`cname` LIKE :search OR `full_name` LIKE :search)");
$query->execute(array(':search' => '%' . $sSearch . '%',':reseller_id' => $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$userIDs[] = $row['id'];
}
}
if ($ui->smallletters('d', 10, 'get') == 'gameserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_gameserver.php');
/*
} else if ($ui->smallletters('d', 10, 'get') == 'voiceserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_voiceserver.php');
*/
}
}
die(json_encode($array));
// App master server updates. Triggered asyncronous with ajax to avoid 5xx errors
} else if ($ui->smallletters('d', 21, 'get') =='masterappserverupdate' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) {
} else if ($ui->smallletters('d', 21, 'get') == 'masterappserverupdate' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_update.php');
die;
} else if (isset($admin_id) and $pa['gserver'] and $ui->smallletters('d', 14, 'get') == 'appmasterusage' and $ui->id('id', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_usage.php');
die;
} else if ($ui->smallletters('d', 18, 'get') == 'appmasterportusage' and isset($admin_id) and $pa['gserver'] and $ui->ip4('ip', 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_port_usage.php');
die;
} else if ($ui->smallletters('d', 17, 'get') == 'appmasterportbest' and isset($admin_id) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_port_best.php');
die;
} else if ($ui->smallletters('d', 19, 'get') == 'appmasterappdetails' and isset($admin_id) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_app_details.php');
die;
} else if (isset($admin_id) and $pa['dedicatedServer'] and $ui->smallletters('d', 7, 'get') == 'freeips' and $reseller_id == 0) {
if ($ui->id('userID', 10, 'get')) {

View File

@ -106,6 +106,7 @@
<port_gs>Gameserverport</port_gs>
<premoved>Serverpasswort entfernt</premoved>
<protect>Protection Modus</protect>
<raminstalled>Zugewiesener Ram</raminstalled>
<ramMax>Maximaler Ram</ramMax>
<ramMin>Minimaler Ram</ramMin>
<rcon>RCON Passwort</rcon>
@ -149,7 +150,7 @@
<usage>Serverbelegung</usage>
<usedports>Benutzte Ports</usedports>
<user>Benutzername</user>
<useredit>Veränderbar vom User</useredit>
<useredit>veränderbar vom User</useredit>
<user_add>User auf dem Server erfolgreich angelegt.</user_add>
<war>Clanserver</war>
<webFtp>Web FTP</webFtp>

View File

@ -77,6 +77,7 @@
<port_gs>Spilserverport</port_gs>
<premoved>Serveradgangskode fjernet</premoved>
<protect>Beskyttelse tilstand</protect>
<raminstalled></raminstalled>
<ramMax>Maksimale Hukommelse</ramMax>
<ramMin>Minimum Hukommelse</ramMin>
<rcon>Fjernbetjening adgangskode (RCON)</rcon>

View File

@ -112,6 +112,7 @@
<protect>Protection mode</protect>
<ramMax>Maximum RAM</ramMax>
<ramMin>Minimum RAM</ramMin>
<raminstalled>Assigned ram</raminstalled>
<rcon>Remote password (RCON)</rcon>
<recover>Recover</recover>
<reinstall>Reinstall</reinstall>
@ -153,7 +154,7 @@
<usage>Server allocation</usage>
<usedports>Used ports</usedports>
<user>User name</user>
<useredit>Editable by user</useredit>
<useredit>editable by user</useredit>
<user_add>Successfully added the user on the root server.</user_add>
<war>Private server</war>
<webFtp>Web FTP</webFtp>

View File

@ -0,0 +1,767 @@
<?php
/**
* File: gameserver.php.
* Author: Ulrich Block
* Date: 29.05.14
* 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/>.
*/
if ((!isset($admin_id) or $main != 1) or (isset($admin_id) and !$pa['gserver'])) {
header('Location: admin.php');
die;
}
include(EASYWIDIR . '/stuff/keyphrasefile.php');
include(EASYWIDIR . '/stuff/methods/functions_gs.php');
include(EASYWIDIR . '/stuff/methods/functions_ssh_exec.php');
$sprache = getlanguagefile('gserver', $user_language, $resellerLockupID);
$loguserid = $admin_id;
$logusername = getusername($admin_id);
$logusertype = 'admin';
if ($reseller_id == 0) {
$logreseller = 0;
$logsubuser = 0;
} else {
$logsubuser = (isset($_SESSION['oldid'])) ? $_SESSION['oldid'] : 0;
$logreseller = 0;
}
// Define the ID variable which will be used at the form and SQLs
$id = $ui->id('id', 10, 'get');
// CSFR protection with hidden tokens. If token(true) returns false, we likely have an attack
if ($ui->w('action',4, 'post') and !token(true)) {
unset($header, $text);
$template_file = $spracheResponse->token;
// Add and modify entries. Same validation can be used.
} else if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
// Add jQuery plugin chosen to the header
$htmlExtraInformation['css'][] = '<link href="css/adminlte/chosen/chosen.min.css" rel="stylesheet" type="text/css">';
$htmlExtraInformation['js'][] = '<script src="js/adminlte/plugins/chosen/chosen.jquery.min.js" type="text/javascript"></script>';
// Error handling. Check if required attributes are set and can be validated
$errors = array();
// Add or mod is opened
if (!$ui->st('action', 'post')) {
// Gather data for adding if needed and define add template
if ($ui->st('d', 'get') == 'ad') {
$table = getUserList($resellerLockupID);
$table2 = getAppMasterList($resellerLockupID);
$template_file = 'admin_gserver_add.tpl';
// Gather data for modding in case we have an ID and define mod template
} else if ($ui->st('d', 'get') == 'md' and $id) {
$query = $sql->prepare("SELECT `serverip`,`port`,`port2`,`port3`,`port4`,`port5`,`userid`,`rootID`,`externalID`,`active`,`autoRestart`,`lendserver`,`eacallowed`,`slots`,`pallowed`,`pallowed`,`pallowed`,`brandname`,`war`,`tvenable`,`minram`,`maxram`,AES_DECRYPT(`ftppassword`,?) AS `ftpPassword`,(SELECT `servertype` FROM `serverlist` WHERE `id`=g.`serverid` LIMIT 1) AS `gameID` FROM `gsswitch` AS g WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($aeskey, $id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$ip = $row['serverip'];
$port = $row['port'];
$port2 = ($row['port2'] == 0) ? '' : $row['port2'];
$port3 = ($row['port3'] == 0) ? '' : $row['port3'];
$port4 = ($row['port4'] == 0) ? '' : $row['port4'];
$port5 = ($row['port5'] == 0) ? '' : $row['port5'];
$userID = $row['userid'];
$rootID = $row['rootID'];
$externalID = $row['externalID'];
$active = $row['active'];
$autoRestart = $row['autoRestart'];
$lendServer = $row['lendserver'];
$ftpPassword = $row['ftpPassword'];
$eacAllowed = $row['eacallowed'];
$slots = $row['slots'];
$protectionAllowed = $row['pallowed'];
$brandname = $row['brandname'];
$war = $row['war'];
$tvEnable = $row['tvenable'];
$minRam = $row['minram'];
$maxRam = $row['maxram'];
$currentGameID = $row['gameID'];
}
$table = getAppMasterList($resellerLockupID);
// Check if database entry exists and if not display 404 page
$template_file = ($query->rowCount() > 0) ? 'admin_gserver_md.tpl' : 'admin_404.tpl';
// Show 404 if GET parameters did not add up or no ID was given with mod
} else {
$template_file = 'admin_404.tpl';
}
// Form is submitted
} else if ($ui->st('action', 'post') == 'md' or $ui->st('action', 'post') == 'ad') {
$gamesToBeRemoved = array();
$gamesToBeInstalled = array();
$gameDetails = array();
$usedCores = array();
$installedGames = array();
$rowCount = 0;
$technicalUser = '';
$oldProtected = '';
$oldIp = '';
$oldPort = 0;
$oldRootID = 0;
$oldActiveGame = 0;
$oldFtpPassword = '';
$oldActive = '';
$userID = $ui->id('userID', 10, 'post');
$rootID = $ui->id('rootID', 10, 'post');
$active = $ui->active('active', 'post');
$autoRestart = $ui->active('autoRestart', 'post');
$lendServer = $ui->active('lendserver', 'post');
$ftpPassword = $ui->password('ftpPassword', 50, 'post');
$eacAllowed = $ui->active('eacAllowed', 'post');
$protectionAllowed = $ui->active('protectionAllowed', 'post');
$brandname = $ui->active('brandname', 'post');
$war = $ui->active('war', 'post');
$tvEnable = $ui->active('tvEnable', 'post');
$ip = $ui->ip4('ip', 'post');
$port = $ui->port('port', 'post');
$slots = ($ui->id('slots', 5, 'post')) ? $ui->id('slots', 5, 'post') : 12;
$minRam = ($ui->id('minRam', 5, 'post')) ? $ui->id('minRam', 5, 'post') : 512;
$maxRam = ($ui->id('maxRam', 5, 'post')) ? $ui->id('maxRam', 5, 'post') : 1024;
// Array conversion allows easier handling
$gameIDs = (array) $ui->id('gameIDs', 10, 'post');
// Get old data, so we can see, if shell commands need to be run
$query = $sql->prepare("SELECT g.`serverip`,g.`port`,g.`pallowed`,g.`rootID`,g.`serverid`,g.`active`,AES_DECRYPT(`ftppassword`,?) AS `ftpPassword`,u.`cname` FROM `gsswitch` AS g INNER JOIN `userdata` AS u ON u.`id`=g.`userid` WHERE g.`id`=? AND g.`resellerid`=? LIMIT 1");
$query->execute(array($aeskey, $id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$technicalUser = $row['cname'];
$oldProtected = $row['pallowed'];
$oldIp = $row['serverip'];
$oldPort = $row['port'];
$oldRootID = $row['port'];
$oldActiveGame = $row['serverid'];
$oldActive = $row['active'];
$oldFtpPassword = $row['ftpPassword'];
}
if (!$active) {
$errors['active'] = $sprache->active;
}
if (!$ip) {
$errors['ip'] = $sprache->ip;
}
if (!$port) {
$errors['port'] = $sprache->port . ' 1';
}
// Check if IP and Port are already in use by another server daemon
if ($ip != $oldIp or $port != $oldPort) {
$usedPorts = usedPorts(array($ip));
if (in_array($port, $usedPorts['ports'])) {
$errors['ip'] = $sprache->ip;
$errors['port'] = $sprache->port . ' 1';
}
}
// Root send and allowed?
if (!$rootID) {
$errors['rootID'] = $sprache->root;
} else {
$query = $sql->prepare("SELECT `hyperthreading`,`cores` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($rootID, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$coreCount = ($row['hyperthreading'] == 'Y') ? $row['cores'] * 2 : $row['cores'];
$postCores = (isset($ui->post['cores'])) ? (array) $ui->post['cores'] : array();
for ($c = 0; $c < $coreCount; $c++) {
if (in_array($c, $postCores)) {
$usedCores[] = $c;
}
}
}
$usedCores = implode(',', $usedCores);
if (!isset($coreCount)) {
$errors['rootID'] = $sprache->root;
}
}
// We need to check if we have gameIDs at all, and if yes, if they add up with our database
// First check against DB and remove from array if given gameID does not add up
// We will store the found shorten in an array to avoid another SQL at a later point
$query = $sql->prepare("SELECT t.`shorten`,t.`modcmds`,t.`gamemod`,t.`gamemod2` FROM `rservermasterg` AS m INNER JOIN `servertypes` AS t ON t.`id`=m.`servertypeid` WHERE m.`servertypeid`=? AND m.`serverid`=? AND m.`resellerid`=? LIMIT 1");
foreach ($gameIDs as $key => $gameID) {
$query->execute(array($gameID, $rootID, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
// We will run the if/else case within the previous as the install logic differs from the general existence of games in the form data
if ($ui->st('action', 'post') == 'ad') {
// Game is primary or all games should be installed
if (($ui->id('installGames', 1, 'post') == 2 and $gameID == $ui->id('primary', 10, 'post')) or $ui->id('installGames', 1, 'post') == 1) {
$gamesToBeInstalled[$gameID] = $row['shorten'];
}
} else {
$gamesToBeInstalled[$gameID] = $row['shorten'];
}
// In case a game has mod commands, we need to get the deault, or any, if none is set
// If we do not do this, the initial start command might fail and the customer raise a ticket
$doNot = false;
$modCmd = '';
foreach (explode("\r\n", $row['modcmds']) as $line) {
if (preg_match('/^(\[[\w\/\.\-\_\= ]{1,}\])$/', $line)) {
$name = trim($line, '[]');
$ex = preg_split("/\=/", $name, -1, PREG_SPLIT_NO_EMPTY);
if (isset($ex[1]) and trim($ex[1]) == 'default') {
$modCmd = trim($ex[0]);
$doNot = true;
}
if ($doNot === false) {
$modCmd = trim($ex[0]);
}
}
}
$gameDetails[$gameID] = array('modCmd' => $modCmd, 'gamemod' => $row['gamemod'], 'gamemod2' => $row['gamemod2']);
}
if ($query->rowCount() == 0) {
unset($gameIDs[$key]);
}
}
// Now check if any games are left
// A form submit without any valid game needs to be aborted
if (count($gameIDs) == 0) {
$errors['gameIDs'] = $sprache->games;
}
// User send and allowed during add server? Login name will be part of linux user name. So grab it while we can
if ($ui->st('action', 'post') == 'ad') {
if (!$userID) {
$errors['userID'] = $sprache->user;
} else {
$query = $sql->prepare("SELECT `cname` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($userID, $resellerLockupID));
$technicalUser = $query->fetchColumn();
if (strlen($technicalUser) == 0) {
$errors['userID'] = $sprache->user;
}
}
}
// Submitted values are OK
if (count($errors) == 0) {
// We need to check the installed games in order to know what needs to be removed
$query = $sql->prepare("SELECT l.`id`,l.`servertype`,t.`shorten` FROM `serverlist` AS l INNER JOIN `gsswitch` AS g ON g.`id`=l.`switchID` INNER JOIN `servertypes` AS t ON t.`id`=l.`servertype` WHERE g.`id`=? AND g.`resellerid`=?");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
// In case the gameID has not been submitted flag for removal
if (!in_array($row['servertype'], $gameIDs)) {
$gamesToBeRemoved[$row['servertype']] = $row['shorten'];
}
// Avoid overhead with adding server types during modify operations
if (isset($gamesToBeInstalled[$row['servertype']])) {
unset($gamesToBeInstalled[$row['servertype']]);
unset($gameDetails[$row['servertype']]);
$installedGames[] = $row['id'];
}
}
// Make the inserts or updates define the log entry and get the affected rows from insert
if ($ui->st('action', 'post') == 'ad') {
$query = $sql->prepare("INSERT INTO `gsswitch` (`active`,`taskset`,`cores`,`userid`,`pallowed`,`eacallowed`,`lendserver`,`serverip`,`rootID`,`tvenable`,`port`,`port2`,`port3`,`port4`,`port5`,`minram`,`maxram`,`slots`,`war`,`brandname`,`autoRestart`,`ftppassword`,`resellerid`,`serverid`,`stopped`,`externalID`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,AES_ENCRYPT(?,?),?,1,'Y',?)");
$query->execute(array($active, $ui->active('taskset', 'post'), $usedCores, $userID, $protectionAllowed, $eacAllowed, $lendServer, $ip, $rootID, $tvEnable, $port, $ui->port('port2', 'post'), $ui->port('port3', 'post'), $ui->port('port4', 'post'), $ui->port('port5', 'post'), $minRam, $maxRam, $slots, $war, $brandname, $autoRestart, $ftpPassword, $aeskey, $resellerLockupID, $ui->w('externalID',255, 'post')));
$id = $sql->lastInsertId();
$rowCount += $query->rowCount();
$loguseraction = '%add% %gserver% ' . $ip . ':' . $port;
} else if ($ui->st('action', 'post') == 'md' and $id) {
// We need to correct the active game in case the current one is not existing anymore
if ($oldActiveGame == null or !in_array($oldActiveGame, $installedGames) or isset($gamesToBeRemoved[$oldActiveGame])) {
reset($installedGames);
$currentActiveGame = (isset($insertedServerIDs[0])) ? $insertedServerIDs[0] : current($installedGames);
} else {
$currentActiveGame = $oldActiveGame;
}
$query = $sql->prepare("UPDATE `gsswitch` SET `active`=?,`taskset`=?,`cores`=?,`pallowed`=?,`eacallowed`=?,`lendserver`=?,`serverip`=?,`tvenable`=?,`port`=?,`port2`=?,`port3`=?,`port4`=?,`port5`=?,`minram`=?,`maxram`=?,`slots`=?,`war`=?,`brandname`=?,`autoRestart`=?,`ftppassword`=AES_ENCRYPT(?,?),`serverid`=?,`externalID`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($active, $ui->active('taskset', 'post'), $usedCores, $protectionAllowed, $eacAllowed, $lendServer, $ip, $tvEnable, $port, $ui->port('port2', 'post'), $ui->port('port3', 'post'), $ui->port('port4', 'post'), $ui->port('port5', 'post'), $minRam, $maxRam, $slots, $war, $brandname, $autoRestart, $ftpPassword, $aeskey, $currentActiveGame, $ui->w('externalID',255, 'post'), $id, $resellerLockupID));
$rowCount += $query->rowCount();
$loguseraction = '%mod% %gserver% ' . $ip . ':' . $port;
}
// Insert new games
$query = $sql->prepare("INSERT INTO `serverlist` (`servertype`,`anticheat`,`switchID`,`fps`,`map`,`mapGroup`,`cmd`,`modcmd`,`owncmd`,`tic`,`gamemod`,`gamemod2`,`userfps`,`usertick`,`usermap`,`user_uploaddir`,`upload`,`uploaddir`,`resellerid`) VALUES (?,1,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,AES_ENCRYPT(?,?),?)");
foreach ($gameDetails as $gameID => $gameValues) {
$query->execute(array($gameID, $id, $ui->id('fps', 6, 'post', $gameID), $ui->mapname('map', 'post', $gameID), $ui->mapname('mapGroup', 'post', $gameID), $ui->startparameter('cmd', 'post', $gameID), $gameValues['modCmd'], $ui->active('ownCmd', 'post', $gameID), $ui->id('tic', 5, 'post', $gameID), $gameValues['gamemod'], $gameValues['gamemod2'], $ui->active('userFps', 'post', $gameID), $ui->active('userTick', 'post', $gameID), $ui->active('userMap', 'post', $gameID), $ui->active('userUploadDir', 'post', $gameID), $ui->id('upload', 1, 'post', $gameID), $ui->url('uploadDir', 'post', $gameID), $aeskey, $resellerLockupID));
$insertedServerIDs[] = $sql->lastInsertId();
$rowCount += $query->rowCount();
};
// Updating the serverlist if not set to be added, we need to run the update
$query = $sql->prepare("UPDATE `serverlist` SET `fps`=?,`map`=?,`mapGroup`=?,`cmd`=?,`owncmd`=?,`tic`=?,`userfps`=?,`usertick`=?,`usermap`=?,`user_uploaddir`=?,`upload`=?,`uploaddir`=AES_ENCRYPT(?,?) WHERE `switchID`=? AND `servertype`=? AND `resellerid`=? LIMIT 1");
foreach ($gameIDs as $gameID) {
if (!isset($gameDetails[$gameID])) {
$query->execute(array($ui->id('fps', 6, 'post', $gameID), $ui->mapname('map', 'post', $gameID), $ui->mapname('mapGroup', 'post', $gameID), $ui->startparameter('cmd', 'post', $gameID), $ui->active('ownCmd', 'post', $gameID), $ui->id('tic', 5, 'post', $gameID), $ui->active('userFps', 'post', $gameID), $ui->active('userTick', 'post', $gameID), $ui->active('userMap', 'post', $gameID), $ui->active('userUploadDir', 'post', $gameID), $ui->id('upload', 1, 'post', $gameID), $ui->url('uploadDir', 'post', $gameID), $aeskey, $id, $gameID, $resellerLockupID));
$rowCount += $query->rowCount();
}
}
// If a servertype has been added, update gsswitch, so joins add up
if ($ui->st('action', 'post') == 'ad' and isset($insertedServerIDs) and count($insertedServerIDs) > 0) {
$query = $sql->prepare("UPDATE `gsswitch` SET `serverid`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array((in_array($ui->id('primary', 10, 'post'), $insertedServerIDs)) ? $ui->id('primary', 10, 'post') : $insertedServerIDs[0], $id, $resellerLockupID));
$rowCount += $query->rowCount();
// Else something went wrong and we need to clean up and give an error
} else if ($ui->st('action', 'post') == 'ad') {
$query = $sql->prepare("DELETE FROM `gsswitch` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
// Setting $rowCount to 0 will result in DB insert error shown to user
$rowCount = 0;
}
// Delete deselected games
$query = $sql->prepare("DELETE FROM `serverlist` WHERE `servertype`=? AND `switchID`=? AND `resellerid`=? LIMIT 1");
foreach ($gamesToBeRemoved as $gameID => $shorten) {
$query->execute(array($gameID, $id, $resellerLockupID));
$rowCount += $query->rowCount();
}
// If not checked like this we might get true for general server insert in add cases, when it failed
if (($ui->st('action', 'post') == 'ad' and $rowCount > 0) or $ui->st('action', 'post') == 'md') {
// customColumns will return amount of changed columns
$rowCount += customColumns('G', $id, 'save');
}
// Check if a row was affected during insert or update
if ($rowCount > 0) {
$gamesRemoveAmount = count($gamesToBeRemoved);
$gamesAmount = count($gamesToBeInstalled);
// We will run the add user command in nearly any case
// Reasons are that we ensure FTP password correctness and existence of linux user
// Also we will add the protected user with variable 5
if ($oldFtpPassword != $ftpPassword or $oldActive != $active or $ip != $oldIp or $port != $oldPort or $oldProtected != $protectionAllowed or $gamesRemoveAmount > 0 or $gamesAmount > 0) {
$addProtectedUser = ($protectionAllowed == 'Y') ? passwordgenerate(10) : '';
$cmds[] = "./control.sh useradd {$technicalUser}-{$id} {$ftpPassword} \"/home/\" {$addProtectedUser}";
}
if ($ui->st('action', 'post') == 'md' and ($oldFtpPassword != $ftpPassword or $oldActive != $active)) {
if ($oldActive == 'Y') {
$ftpPassword = passwordgenerate(10);
}
$cmds[] = "./control.sh usermod {$technicalUser}-{$id} {$ftpPassword}";
}
if ($ui->st('action', 'post') == 'md' and (($oldActive == 'Y' and $active == 'N') or $ip != $oldIp or $port != $oldPort)) {
$stopCmds = gsrestart($id, 'so', $aeskey, $resellerLockupID);
if (is_array($stopCmds)) {
foreach ($stopCmds as $cmd) {
if (strpos($cmd, 'addserver') === false) {
$cmds[] = $cmd;
}
}
}
}
// Send delete request for protected user in case it has been removed from server
if ($ui->st('action', 'post') == 'md' and $protectionAllowed == 'N' and $oldProtected == 'Y') {
$cmds[] = "./control.sh delSingleUser {$technicalUser}-{$id}-p";
}
// Remove if games got deselected. Cannot happen during gameserver adding
if ($gamesRemoveAmount > 0) {
$loguseraction .= ', %del%: ' . implode(', ', $gamesToBeRemoved);
$gamesRemoveString = $gamesRemoveAmount . '_' . implode('_', $gamesToBeRemoved);
$cmds[] = "sudo -u {$technicalUser}-{$id} ./control.sh delserver {$technicalUser}-{$id} {$gamesRemoveString} {$oldIp}_{$oldPort}";
}
// Admin has changed the ip or the main port. Now we need to move the server. Can only happen during server edit.
// Should be done after possible deletes and before we add additional data
if ($ui->st('action', 'post') == 'md' and ($ip != $oldIp or $port != $oldPort)) {
$cmds[] = "sudo -u {$technicalUser}-{$id} ./control.sh ip_port_change {$technicalUser}-{$id} {$oldIp}_{$oldPort} {$ip}_{$port} \"/home\"";
}
if ($gamesAmount > 0) {
$loguseraction .= ', %add%: ' . implode(', ', $gamesToBeInstalled);
$gamesAddString = $gamesAmount . '_' . implode('_', $gamesToBeInstalled);
$limitInstall = ($ui->id('installGames', 1, 'post') == 2) ? 1 : '';
$cmds[] = "sudo -u {$technicalUser}-{$id} ./control.sh addserver {$technicalUser}-{$id} {$gamesAddString} {$ip}_{$port} {$limitInstall}";
}
$insertlog->execute();
$template_file = $spracheResponse->table_add;
if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1 and isset($cmds) and count($cmds) > 0) {
$template_file .= '<br><pre>' . implode("\r\n", $cmds) . "\r\n" . ssh2_execute('gs', $rootID, $cmds) . '</pre>';
}
// No update or insert failed
} else {
$template_file = $spracheResponse->error_table;
}
// An error occurred during validation unset the redirect information and display the form again
} else {
unset($header, $text);
$table = getUserList($resellerLockupID);
$table2 = getAppMasterList($resellerLockupID);
$template_file = ($ui->st('d', 'get') == 'ad') ? 'admin_gserver_add.tpl' : 'admin_gserver_md.tpl';
}
}
// Remove entries in case we have an ID given with the GET request
} else if ($ui->st('d', 'get') == 'dl' and $id) {
$query = $sql->prepare("SELECT g.`id`,g.`serverip`,g.`port`,g.`newlayout`,g.`rootID`,u.`cname`,u.`vname`,u.`name`,u.`mail` FROM `gsswitch` AS g LEFT JOIN `userdata` AS u ON u.`id`=g.`userid` WHERE g.`id`=? AND g.`resellerid`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$ip = $row['serverip'];
$port = $row['port'];
$rootID = $row['rootID'];
$user = trim($row['cname'] . ' ' . $row['vname'] . ' ' . $row['name'] . ' (' . $row['mail'] . ')');
$gameServerUser = ($row['newlayout'] == 'Y') ? $row['cname'] . '-' . $row['id'] : $row['cname'];
// If set to "D" the user requested to remove from only from DB
if ($ui->w('safeDelete', 1, 'post') and $ui->w('safeDelete', 1, 'post') != 'D') {
$cmds = gsrestart($id, 'so', $aeskey, $resellerLockupID);
$cmds[] = "sudo -u {$gameServerUser} ./control.sh delscreen {$gameServerUser}" ;
$cmds[] = "sudo -u {$gameServerUser}-p ./control.sh delscreen {$gameServerUser}-p";
$cmds[] = "./control.sh delCustomer {$gameServerUser}";
}
}
// Nothing submitted yet, display the delete form
if (!$ui->st('action', 'post')) {
// Check if we could find an entry and if not display 404 page
$template_file = ($query->rowCount() > 0) ? 'admin_gserver_dl.tpl' : 'admin_404.tpl';
// User submitted remove the entry
} else if ($ui->st('action', 'post') == 'dl') {
// Check if a row was affected meaning an entry could be deleted. If yes add log entry and display success message
if ($query->rowCount() > 0 and isset($rootID)) {
$return = true;
if (count($cmds) > 1) {
// Unset the add command generated by the restart function
unset($cmds[0]);
$return = ssh2_execute('gs', $rootID, $cmds);
}
if (($return !== false and $ui->w('safeDelete', 1, 'post') == 'S') or in_array($ui->w('safeDelete', 1, 'post'), array('A', 'D'))) {
// Wenn the gsswitch entry is removed, we cannot resolve the rest of the mappings.
// Left Loins will result NULL and we can use for deleting
$query = $sql->prepare("DELETE FROM `gsswitch` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
$query = $sql->prepare("DELETE s.* FROM `serverlist` s LEFT JOIN `gsswitch` g ON s.`switchID`=g.`id` WHERE g.`id` IS NULL");
$query->execute();
$query = $sql->prepare("DELETE a.* FROM `addons_installed` a LEFT JOIN `serverlist` s ON a.`serverid`=s.`id` WHERE s.`id` IS NULL");
$query->execute();
$query = $sql->prepare("DELETE a.* FROM `addons_installed` a LEFT JOIN `userdata` u ON a.`userid`=u.`id` WHERE u.`id` IS NULL");
$query->execute();
$query = $sql->prepare("DELETE FROM `gserver_restarts` WHERE `switchID`=? AND `resellerid`=?");
$query->execute(array($id, $resellerLockupID));
customColumns('G', $id, 'del');
}
$loguseraction = '%del% %gserver% ' . $ip . ':' . $port;
$insertlog->execute();
$template_file = $spracheResponse->table_del;
if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
$template_file .= '<br><pre>' . implode("\r\n", $cmds) . "\r\n" . $return . '</pre>';
}
// Nothing was deleted, display an error
} else {
$template_file = $spracheResponse->error_table;
}
// GET Request did not add up. Display 404 error.
} else {
$template_file = 'admin_404.tpl';
}
// Gameserver Reinstall
} else if ($ui->st('d', 'get') == 'ri' and $id) {
if (!$ui->w('action', 4, 'post')) {
$table = array();
$shorten = '';
$query = $sql->prepare("SELECT `serverip`,`port`,`serverid` FROM `gsswitch` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query2 = $sql->prepare("SELECT s.`id`,s.`servertemplate`,t.`shorten`,t.`description` FROM `serverlist` s LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`switchID`=? AND s.`resellerid`=?");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$serverip = $row['serverip'];
$port = $row['port'];
$query2->execute(array($id, $resellerLockupID));
while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
if (strlen($shorten) == 0) {
$shorten = $row2['shorten'];
}
$servertemplate = ($row['serverid'] == $row2['id']) ? $row2['servertemplate'] : '';
$table[] = array('id' => $row2['id'], 'description' => $row2['description'], 'shorten' => $row2['shorten'], 'servertemplate' => $servertemplate);
}
}
$template_file = (isset($serverip) and isset($port)) ? 'admin_gserver_ri.tpl' : 'admin_404.tpl';
} else if ($ui->st('action', 'post') == 'ri') {
$i = 0;
$gamestring = array();
$template = array();
$query = $sql->prepare("SELECT AES_DECRYPT(g.`ftppassword`,?) AS `cftppass`,AES_DECRYPT(g.`ppassword`,?) AS `pftppass`,g.`id`,g.`newlayout`,g.`rootID`,g.`serverip`,g.`port`,g.`pallowed`,g.`protected`,u.`cname` FROM `gsswitch` g INNER JOIN `userdata` u ON g.`userid`=u.`id` WHERE g.`id`=? AND g.`resellerid`=? LIMIT 1");
$query->execute(array($aeskey, $aeskey, $ui->id('id', 10, 'get'), $reseller_id));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$customer = $row['cname'];
$ftppass = ($row['pallowed'] == 'Y' and $row['protected'] == 'Y') ? $row['pftppass'] : $row['cftppass'];
$rootID = $row['rootID'];
$serverip = $row['serverip'];
$port = $row['port'];
$gsfolder = $serverip . '_' . $port;
$addProtectedUser = ($row['pallowed'] == 'Y') ? passwordgenerate(10) : '';
if ($row['newlayout'] == 'Y') {
$customer = $customer . '-' . $row['id'];
}
}
# https://github.com/easy-wi/developer/issues/69
$game = $ui->id('game',10, 'post');
$template = (in_array($ui->id('template', 10, 'post'), array(1, 2, 3, 4))) ? $ui->id('template', 10, 'post') : 4;
if ($ui->active('type', 'post') == 'Y') {
$query = $sql->prepare("DELETE FROM `addons_installed` WHERE `serverid`=? AND `resellerid`=?");
$query->execute(array($game, $reseller_id));
}
$query = $sql->prepare("SELECT s.`gamemod`,s.`gamemod2`,t.`shorten` FROM `serverlist` s INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`id`=? AND s.`resellerid`=? LIMIT 1");
$query->execute(array($game, $reseller_id));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$shorten = $row['shorten'];
$gamemod2 = $row['gamemod2'];
$gamestring[]=($row['gamemod'] == 'Y') ? $shorten . $gamemod2 : $shorten;
}
if (isset($gsfolder) and count($gamestring) > 0 and $ui->active('type', 'post')) {
$cmds = array();
$gamestring = count($gamestring) . '_' . implode('_',$gamestring);
$rdata = serverdata('root', $rootID, $aeskey);
$sship = $rdata['ip'];
$sshport = $rdata['port'];
$sshuser = $rdata['user'];
$sshpass = $rdata['pass'];
if ($ui->active('type', 'post') == 'Y') {
$cmds[] = "./control.sh useradd ${customer} ${ftppass} \"/home/\" {$addProtectedUser}";
$cmds[] = "sudo -u ${customer} ./control.sh reinstserver ${customer} ${gamestring} ${gsfolder} \"${template}\"";
$loguseraction = "%reinstall% %gserver% ${serverip}:${port}";
} else {
$cmds[] = "sudo -u ${customer} ./control.sh addserver ${customer} ${gamestring} ${gsfolder} \"${template}\"";
$loguseraction = "%resync% %gserver% ${serverip}:${port}";
}
$return = ssh2_execute('gs', $rootID, $cmds);
$template_file = $sprache->server_installed;
if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
$template_file .= '<br><pre>' . implode("\r\n", $cmds) . "\r\n" . $return . '</pre>';
}
$insertlog->execute();
} else {
$template_file = 'admin_404.tpl';
}
} else {
$template_file = 'admin_404.tpl';
}
// Gameserver Restart
} else if (in_array($ui->st('d', 'get'), array('rs','st','du')) and $ui->id('id', 10, 'get')) {
$query = $sql->prepare("SELECT `serverip`,`port`,`rootID` FROM `gsswitch` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$gsip = $row['serverip'];
$port = $row['port'];
$port = $row['port'];
$rootID = $row['rootID'];
}
if ($query->rowCount() > 0) {
if ($ui->st('d', 'get') == 'rs') {
$template_file = $sprache->serverrestart;
$cmds = gsrestart($id, 're', $aeskey, $resellerLockupID);
$loguseraction = '%start% %gserver% ' . $gsip . ':' . $port;
} else if ($ui->st('d', 'get') == 'st') {
$template_file = $sprache->serverstop;
$cmds = gsrestart($id, 'so', $aeskey, $resellerLockupID);
$loguseraction = '%stop% %gserver% ' . $gsip . ':' . $port;
}
if (isset($cmds) and is_array($cmds) and count($cmds) > 0) {
$return = ssh2_execute('gs', $rootID, $cmds);
if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
$template_file .= '<br><pre>' . implode("\r\n", $cmds) . "\r\n" . $return . '</pre>';
}
}
$insertlog->execute();
} else {
$template_file = 'admin_404.tpl';
}
// List the available entries
} else {
configureDateTables('-1, -2', '0, "asc"', 'ajax.php?w=datatable&d=gameserver');
$template_file = 'admin_gserver_list.tpl';
}

File diff suppressed because it is too large Load Diff

View File

@ -157,7 +157,7 @@ if ($reseller_id == 0) {
if ($easywiModules['gs'] === true) {
$what_to_be_included_array['ro'] = 'roots.php';
$what_to_be_included_array['ma'] = 'masterserver.php';
$what_to_be_included_array['gs'] = 'gserver.php';
$what_to_be_included_array['gs'] = 'gameserver.php';
$what_to_be_included_array['gt'] = 'global_gserver_file_templates.php';
$what_to_be_included_array['ad'] = 'addons.php';
$what_to_be_included_array['im'] = 'images.php';

View File

@ -0,0 +1,100 @@
<?php
/**
* File: app_master_app_details.php.
* Author: Ulrich Block
* Date: 27.09.14
* 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/>.
*/
if (!defined('AJAXINCLUDED')) {
die('Do not access directly!');
}
$sprache = getlanguagefile('gserver', $user_language, $resellerLockupID);
$table = array();
$ids = (array) $ui->id('id', 10, 'get');
$query = $sql->prepare("SELECT `id`,`shorten`,`description`,`steamgame`,`fps`,`map`,`mapGroup`,`cmd`,`tic`,`gamebinary` FROM `servertypes` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query2 = $sql->prepare("SELECT `fps`,`map`,`mapGroup`,`cmd`,`owncmd`,`tic`,`userfps`,`usertick`,`usermap`,`user_uploaddir`,`upload`,AES_DECRYPT(`uploaddir`,?) AS `upload_dir` FROM `serverlist` WHERE `switchID`=? AND `servertype`=? AND `resellerid`=? LIMIT 1");
foreach ($ids as $id) {
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
if ($ui->id('gameServerID', 10, 'get')) {
unset($fps, $map, $mapGroup, $cmd, $ownCmd, $tic, $userFps, $userTick, $userMap, $userUploaddir, $upload, $uploadDir);
$query2->execute(array($aeskey, $ui->id('gameServerID', 10, 'get'), $id, $resellerLockupID));
while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
$fps = $row2['fps'];
$map = $row2['map'];
$mapGroup = $row2['mapGroup'];
$cmd = stripslashes($row2['cmd']);
$ownCmd = $row2['owncmd'];
$tic = $row2['tic'];
$userFps = $row2['userfps'];
$userTick = $row2['usertick'];
$userMap = $row2['usermap'];
$userUploadDir = $row2['user_uploaddir'];
$upload = $row2['upload'];
$uploadDir = $row2['upload_dir'];
}
}
$uploadType = ($row['gamebinary'] == 'srcds_run') ? 1 : 0;
$table[] = array(
'id' => $row['id'],
'shorten' => $row['shorten'],
'description' => $row['description'],
'steamgame' => $row['steamgame'],
'fps' => (isset($fps))? $fps : $row['fps'],
'userFps' => (isset($userFps))? $userFps : 'N',
'map' => (isset($map)) ? $map : $row['map'],
'mapGroup' => (isset($mapGroup)) ? $mapGroup : $row['mapGroup'],
'userMap' => (isset($userMap))? $userMap : 'Y',
'cmd' => (isset($cmd)) ? $cmd : stripslashes($row['cmd']),
'ownCmd' => (isset($ownCmd))? $ownCmd : 'N',
'tic' => (isset($tic)) ? $tic : $row['tic'],
'userTick' => (isset($userTick))? $userTick : 'N',
'upload' => (isset($upload)) ? $upload : $uploadType,
'uploadDir' => (isset($uploadDir)) ? $uploadDir : ''
);
}
}
require_once IncludeTemplate($template_to_use, 'ajax_admin_app_details.tpl', 'ajax');

View File

@ -0,0 +1,112 @@
<?php
/**
* File: app_master_port_best.php.
* Author: Ulrich Block
* Date: 27.09.14
* 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/>.
*/
if (!defined('AJAXINCLUDED')) {
die('Do not access directly!');
}
$sprache = getlanguagefile('gserver', $user_language, $resellerLockupID);
$used = usedPorts(array($ui->ip4('ip', 'get')));
$ports = $used['ports'];
$port = '';
$port2 = '';
$port3 = '';
$port4 = '';
$port5 = '';
$portStep = false;
$portMax = false;
$query = $sql->prepare("SELECT * FROM `servertypes` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($ui->id('id', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$portStep = $row['portStep'];
$portMax = $row['portMax'];
$port = $row['portOne'];
$port2 = $row['portTwo'];
$port3 = $row['portThree'];
$port4 = $row['portFour'];
$port5 = $row['portFive'];
}
if ($portMax > 0) {
while (in_array($port, $ports)) {
$port += $portStep;
}
} else {
$port2 = '';
$port3 = '';
$port4 = '';
$port5 = '';
}
if ($portMax > 1) {
while (in_array($port2, $ports)) {
$port2 += $portStep;
}
} else {
$port3 = '';
$port4 = '';
$port5 = '';
}
if ($portMax > 2) {
while (in_array($port3, $ports)) {
$port3 += $portStep;
}
} else {
$port4 = '';
$port5 = '';
}
if ($portMax > 3) {
while (in_array($port4, $ports)) {
$port4 += $portStep;
}
} else {
$port5 = '';
}
if ($portMax > 4) {
while (in_array($port5, $ports)) {
$port5 += $portStep;
}
}
require_once IncludeTemplate($template_to_use, 'ajax_admin_appmaster_ports_best.tpl', 'ajax');

View File

@ -0,0 +1,45 @@
<?php
/**
* File: app_master_port_usage.php.
* Author: Ulrich Block
* Date: 27.09.14
* 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/>.
*/
if (!defined('AJAXINCLUDED')) {
die('Do not access directly!');
}
$used = usedPorts(array($ui->ip4('ip', 'get')));
echo (count($used['ports']) > 0) ? implode(', ', $used['ports']) : 'None';

View File

@ -0,0 +1,147 @@
<?php
/**
* File: app_master_usage.php.
* Author: Ulrich Block
* Date: 27.09.14
* 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/>.
*/
if (!defined('AJAXINCLUDED')) {
die('Do not access directly!');
}
$sprache = getlanguagefile('gserver', $user_language, $resellerLockupID);
$maxSlots = 0;
$maxServer = 0;
$maxRam = 0;
$installedServer = 0;
$installedSlots = 0;
$installedRam = 0;
$c = 0;
$cores = array();
$ips = array();
$table = array();
$usedPorts = array();
$query = $sql->prepare("SELECT r.`connect_ip_only`,r.`ip`,r.`altips`,r.`maxslots`,r.`maxserver`,r.`ram`,r.`cores`,r.`hyperthreading`,COUNT(g.`id`) AS `installedServer`,SUM(g.`slots`) AS `installedSlots`,SUM(g.`maxram`) AS `installedRam` FROM `rserverdata` AS r LEFT JOIN `gsswitch` AS g ON g.`rootID`=r.`id` WHERE r.`id`=? AND r.`resellerid`=? LIMIT 1");
$query->execute(array($ui->id('id', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$maxSlots = (int) $row['maxslots'];
$maxServer = (int) $row['maxserver'];
$maxRam = (int) $row['ram'];
$installedServer = (int) $row['installedServer'];
$installedSlots = (int) $row['installedSlots'];
$installedRam = (int) $row['installedRam'];
if ($row['connect_ip_only'] != 'Y' and isip($row['ip'], 'ip4')) {
$ips[] = $row['ip'];
}
foreach (preg_split('/\r\n/', $row['altips'], -1, PREG_SPLIT_NO_EMPTY) as $ip) {
if (isip($ip, 'ip4')) {
$ips[] = $ip;
}
}
$coreCount = ($row['hyperthreading'] == 'Y') ? $row['cores'] * 2 : $row['cores'];
for ($c = 0; $c < $coreCount; $c++) {
$cores[$c] = 0;
}
}
$query = $sql->prepare("SELECT t.`id`,t.`description`,t.`shorten` FROM `servertypes` t WHERE t.`resellerid`=? AND EXISTS (SELECT m.`id` FROM `rservermasterg` m WHERE m.`serverid`=? AND m.`servertypeid`=t.`id` LIMIT 1) ORDER BY t.`description` ASC");
$query->execute(array($resellerLockupID, $ui->id('id', 10, 'get')));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$table[$row['id']] = array('shorten' => $row['shorten'], 'description' => $row['description']);
}
$used = usedPorts(($ui->id('currentRootID', 10, 'get') == $ui->id('id', 10, 'get')) ? array($ui->ip4('currentIP', 'get')) : $ips);
$ports = (count($used['ports']) > 0) ? implode(', ', $used['ports']) : 'None';
$ip = $used['ip'];
$query = $sql->prepare("SELECT `cores`,`taskset` FROM `gsswitch` WHERE `rootID`=? AND `resellerid`=?");
$query->execute(array($ui->id('id', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$ce = explode(',', $row['cores']);
$cc = count($ce);
if ($row['taskset'] == 'Y' and $cc > 0) {
foreach ($ce as $uc) {
$cores[$uc] = $cores[$uc] + round(1 / $cc, 2);
}
}
}
// During edit we need additional data
// To avoid PHP notice during add, we need to define up front
$currentIP = '';
$port = '';
$port2 = '';
$port3 = '';
$port4 = '';
$port5 = '';
$taskset = '';
$usedCores = array();
$installedGames = array();
if ($ui->id('gameServerID', 10, 'get')) {
$query = $sql->prepare("SELECT `serverip`,`port`,`port2`,`port3`,`port4`,`port5`,`taskset`,`cores` FROM `gsswitch` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($ui->id('gameServerID', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$currentIP = $row['serverip'];
$port = $row['port'];
$port2 = ($row['port2'] == 0) ? '' : $row['port2'];
$port3 = ($row['port3'] == 0) ? '' : $row['port3'];
$port4 = ($row['port4'] == 0) ? '' : $row['port4'];
$port5 = ($row['port5'] == 0) ? '' : $row['port5'];
$taskset = $row['taskset'];
foreach (preg_split('/\,/', $row['cores'], -1, PREG_SPLIT_NO_EMPTY) as $core) {
$usedCores[] = $core;
}
}
$query = $sql->prepare("SELECT `servertype` FROM `serverlist` WHERE `switchID`=? AND `resellerid`=?");
$query->execute(array($ui->id('gameServerID', 10, 'get'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$installedGames[] = $row['servertype'];
}
}
require_once IncludeTemplate($template_to_use, 'ajax_admin_appserver_usage.tpl', 'ajax');

View File

@ -0,0 +1,150 @@
<?php
/**
* File: datatable_gameserver.php.
* Author: Ulrich Block
* Date: 26.09.14
* 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/>.
*/
if (!defined('AJAXINCLUDED')) {
die('Do not access directly!');
}
$query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `gsswitch` WHERE `resellerid`=?");
$query->execute(array($resellerLockupID));
$array['iTotalRecords'] = $query->fetchColumn();
if ($sSearch) {
$userInQuery = (count($userIDs) > 0) ? ' OR `userid` IN (' . implode(',', $userIDs) . ')' : '';
$toLower = strtolower($sSearch);
$statusQuery = array();
if (strpos(strtolower($gsprache->status_crashed), $toLower) !== false) {
$statusQuery[] = 'OR `status`=2';
}
if (strpos(strtolower($gsprache->status_inactive), $toLower) !== false or strpos(strtolower($gsprache->status_stop), $toLower) !== false) {
$statusQuery[] = 'OR `status`=3';
}
if (strpos(strtolower($gsprache->status_ok), $toLower) !== false) {
$statusQuery[] = 'OR `status`=0';
}
if (strpos(strtolower($gsprache->status_password), $toLower) !== false or strpos(strtolower($gsprache->status_server_tag), $toLower) !== false) {
$statusQuery[] = 'OR `status`=1';
}
$statusQuery = (count($statusQuery) > 0) ? implode(' ', $statusQuery) : '';
$query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `gsswitch` AS g JOIN (SELECT g.`id`,g.`userid`,t.`shorten`,CONCAT(`serverip`,'',`port`) AS `address`,CASE WHEN g.`active` = 'N' OR g.`stopped` = 'Y' THEN 3 WHEN g.`queryName` = 'OFFLINE' AND g.`stopped` = 'N' AND g.`notified`>=:downchecks THEN 2 WHEN (g.`war` = 'Y' AND g.`queryPassword` = 'N') OR (g.`brandname` = 'Y' AND LOWER(g.`queryName`) NOT LIKE :brandname) THEN 1 ELSE 0 END AS `status` FROM `gsswitch` AS g LEFT JOIN `serverlist` AS s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` AS t ON s.`servertype`=t.`id` LEFT JOIN `userdata` AS u ON g.`userid`=u.`id` WHERE g.`resellerid`=:reseller_id HAVING (g.`id` LIKE :search OR t.`shorten` LIKE :search OR `address` LIKE :search {$userInQuery} {$statusQuery})) AS g2 ON g2.`id`=g.`id`");
$query->execute(array(':downchecks' => $rSA['down_checks'], ':brandname' => '%'. strtolower($rSA['brandname']) . '%', ':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
$array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
$array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`address`', 1 => 'g.`id`', 2 => '`status`', 3 => '`full_name`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
$orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
$orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
} else {
$orderBy = 'g.`id` DESC';
}
if ($sSearch) {
$query = $sql->prepare("SELECT g.`id`,CONCAT(g.`serverip`,':',g.`port`) AS `address`,g.`active`,g.`stopped`,g.`queryName`,g.`queryPassword`,g.`war`,g.`brandname`,g.`userid`,g.`jobPending`,t.`shorten`,u.`cname`,CONCAT(u.`name`,' ',u.`vname`) AS `full_name`,CASE WHEN g.`active` = 'N' OR g.`stopped` = 'Y' THEN 3 WHEN g.`queryName` = 'OFFLINE' AND g.`stopped` = 'N' AND g.`notified`>=:downchecks THEN 2 WHEN (g.`war` = 'Y' AND g.`queryPassword` = 'N') OR (g.`brandname` = 'Y' AND LOWER(g.`queryName`) NOT LIKE :brandname) THEN 1 ELSE 0 END AS `status` FROM `gsswitch` AS g LEFT JOIN `serverlist` AS s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` AS t ON s.`servertype`=t.`id` LEFT JOIN `userdata` AS u ON g.`userid`=u.`id` WHERE g.`resellerid`=:reseller_id HAVING (g.`id` LIKE :search OR t.`shorten` LIKE :search OR `address` LIKE :search {$userInQuery} {$statusQuery}) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}");
$query->execute(array(':downchecks' => $rSA['down_checks'], ':brandname' => '%'. strtolower($rSA['brandname']) . '%', ':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
$query = $sql->prepare("SELECT g.`id`,CONCAT(g.`serverip`,':',g.`port`) AS `address`,g.`active`,g.`stopped`,g.`queryName`,g.`queryPassword`,g.`war`,g.`brandname`,g.`userid`,g.`jobPending`,t.`shorten`,u.`cname`,CONCAT(u.`name`,' ',u.`vname`) AS `full_name`,CASE WHEN g.`active` = 'N' OR g.`stopped` = 'Y' THEN 3 WHEN g.`queryName` = 'OFFLINE' AND g.`stopped` = 'N' AND g.`notified`>=? THEN 2 WHEN (g.`war` = 'Y' AND g.`queryPassword` = 'N') OR (g.`brandname` = 'Y' AND LOWER(g.`queryName`) NOT LIKE ?) THEN 1 ELSE 0 END AS `status` FROM `gsswitch` AS g LEFT JOIN `serverlist` AS s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` AS t ON s.`servertype`=t.`id` LEFT JOIN `userdata` AS u ON g.`userid`=u.`id` WHERE g.`resellerid`=? ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}");
$query->execute(array($rSA['down_checks'], '%'. strtolower($rSA['brandname']) . '%', $resellerLockupID));
}
$query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='gs' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1");
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$tobeActive = false;
$jobPending = '';
$statusMessage = $gsprache->status_ok;
if (isset($row['jobPending']) and $row['jobPending'] == 'Y') {
$query2->execute(array($row['id'], $row['resellerid']));
foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) {
if ($row2['action'] == 'ad') {
$jobPending = $gsprache->add;
} else if ($row2['action'] == 'dl') {
$jobPending = $gsprache->del;
} else {
$jobPending = $gsprache->mod;
}
$json = @json_decode($row2['extraData']);
$tobeActive = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N';
}
} else {
$jobPending = $gsprache->no;
}
if ($row['active'] == 'N') {
$statusMessage = $gsprache->status_inactive;
} else if ($row['stopped'] == 'Y') {
$statusMessage = $gsprache->status_stop;
} else if ($row['queryName'] == 'OFFLINE' and $row['notified'] >= $rSA['down_checks'] and $row['stopped'] == 'N') {
$statusMessage = $gsprache->status_crashed;
} else if ($row['war'] == 'Y' and $row['queryPassword'] == 'N') {
$statusMessage = $gsprache->status_password;
} else if ($row['brandname'] == 'Y' and $rSA['brandname'] != null and $rSA['brandname'] != '' and strpos(strtolower($row['queryName']), strtolower($rSA['brandname'])) === false) {
$statusMessage = $gsprache->status_server_tag;
}
$array['aaData'][] = array(returnButton($template_to_use, 'ajax_admin_gameserver_icon.tpl', $row['shorten'], '', '', '') . ' ' . $row['address'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $row['status'], (string) $statusMessage), returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userid'], ''), (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_rs.tpl', 'gs', 'rs', $row['id'], $gsprache->start) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_st.tpl', 'gs', 'st', $row['id'], $gsprache->stop), returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'gs', 'ri', $row['id'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'gs', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'gs', 'md', $row['id'], $gsprache->mod));
}

View File

@ -56,7 +56,7 @@ if (!function_exists('gsrestart')) {
$tempCmds = array();
$stopped = 'Y';
$query = $sql->prepare("SELECT g.*,g.`id` AS `switchID`,g.`pallowed` AS `gsPallowed`,g.`protected` AS `gsProtected`,AES_DECRYPT(g.`ppassword`,:aeskey) AS `decryptedppass`,AES_DECRYPT(g.`ftppassword`,:aeskey) AS `decryptedftppass`,s.*,s.`cmd` AS `localCmd`,s.`workShop` AS `sWorkShop`,AES_DECRYPT(s.`uploaddir`,:aeskey) AS `decypteduploaddir`,AES_DECRYPT(s.`webapiAuthkey`,:aeskey) AS `dwebapiAuthkey`,t.`configedit`,t.`modcmds`,t.`modfolder`,t.`gamebinary`,t.`binarydir`,t.`shorten`,t.`appID`,t.`cmd` AS `globalCmd`,t.`workShop` AS `tWorkShop`,t.`protected` AS `tProtected` FROM `gsswitch` g INNER JOIN `serverlist` s ON g.`serverid`=s.`id` INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`active`='Y' AND g.`id`=:serverid AND g.`resellerid`=:reseller_id AND t.`resellerid`=:reseller_id LIMIT 1");
$query = $sql->prepare("SELECT g.*,g.`id` AS `switchID`,g.`pallowed` AS `gsPallowed`,g.`protected` AS `gsProtected`,AES_DECRYPT(g.`ppassword`,:aeskey) AS `decryptedppass`,AES_DECRYPT(g.`ftppassword`,:aeskey) AS `decryptedftppass`,s.*,s.`cmd` AS `localCmd`,s.`workShop` AS `sWorkShop`,AES_DECRYPT(s.`uploaddir`,:aeskey) AS `decypteduploaddir`,AES_DECRYPT(s.`webapiAuthkey`,:aeskey) AS `dwebapiAuthkey`,t.`configedit`,t.`modcmds`,t.`modfolder`,t.`gamebinary`,t.`binarydir`,t.`shorten`,t.`appID`,t.`cmd` AS `globalCmd`,t.`workShop` AS `tWorkShop`,t.`protected` AS `tProtected` FROM `gsswitch` g INNER JOIN `serverlist` s ON g.`serverid`=s.`id` INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`id`=:serverid AND g.`resellerid`=:reseller_id AND t.`resellerid`=:reseller_id LIMIT 1");
$query->execute(array(':aeskey' => $aeskey, ':serverid' => $switchID, ':reseller_id' => $reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {

View File

@ -0,0 +1,306 @@
<section class="content-header">
<h1><?php echo $gsprache->gameserver;?></h1>
<ol class="breadcrumb">
<li><a href="admin.php"><i class="fa fa-home"></i> Home</a></li>
<li><a href="admin.php?w=gs"><?php echo $gsprache->gameserver;?></a></li>
<li class="active"><?php echo $gsprache->add;?></li>
</ol>
</section>
<section class="content">
<?php if (count($errors)>0){ ?>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4><?php echo $gsprache->errors;?></h4>
<?php echo implode(', ',$errors);?>
</div>
</div>
</div>
<?php }?>
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<form role="form" action="admin.php?w=gs&amp;d=ad&amp;r=gs" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="ad">
<div class="box-body">
<div class="form-group">
<label for="inputExternalID">External ID</label>
<div class="controls"><input class="form-control" id="inputExternalID" type="text" name="externalID" value=""></div>
</div>
<div class="form-group">
<label for="inputUser"><?php echo $sprache->user;?></label>
<div class="controls">
<select class="form-control chosen-select" id="inputUser" name="userID" required="required">
<option></option>
<?php foreach ($table as $key=>$val){ ?>
<option value="<?php echo $key;?>"><?php echo $val;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label for="inputRoot"><?php echo $sprache->root;?></label>
<div class="controls">
<select class="form-control chosen-select" id="inputRoot" name="rootID">
<?php foreach ($table2 as $key=>$val){ ?>
<option value="<?php echo $key;?>"><?php echo $val;?></option>
<?php } ?>
</select>
</div>
</div>
<div id="rootWrapper">
</div>
<div class="form-group">
<label for="inputActive"><?php echo $sprache->active;?></label>
<div class="controls">
<select class="form-control" id="inputActive" name="active">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N"><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputAutorestart">Auto Restart</label>
<div class="controls">
<select class="form-control" id="inputAutorestart" name="autoRestart">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N"><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputLend"><?php echo $sprache->lendserver;?></label>
<div class="controls">
<select class="form-control" id="inputLend" name="lendserver">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y"><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputPassFTP">FTP <?php echo $sprache->password;?></label>
<div class="controls"><input class="form-control" id="inputPassFTP" type="text" name="ftpPassword" value="<?php echo passwordgenerate(10);?>"></div>
</div>
<div class="form-group">
<label for="inputEAC">Easy Anti Cheat</label>
<div class="controls">
<select class="form-control" id="inputEAC" name="eacAllowed">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y"><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputSlots"><?php echo $sprache->slots;?></label>
<div class="controls"><input class="form-control" id="inputSlots" type="text" name="slots" value="12"></div>
</div>
<div class="form-group">
<label for="inputPmode"><?php echo $sprache->protect;?></label>
<div class="controls">
<select class="form-control" id="inputPmode" name="protectionAllowed">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y"><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputBrand"><?php echo $sprache->brandname;?></label>
<div class="controls">
<select class="form-control" id="inputBrand" name="brandname">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y"><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputWar"><?php echo $sprache->war;?></label>
<div class="controls">
<select class="form-control" id="inputWar" name="war">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y"><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputTV"><?php echo $sprache->tv;?></label>
<div class="controls">
<select class="form-control" id="inputTV" name="tvEnable">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N"><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputMinRam">Min Ram</label>
<div class="controls"><input class="form-control" id="inputMinRam" type="text" name="minRam" value="512"></div>
</div>
<div class="form-group">
<label for="inputMaxRam">Max Ram</label>
<div class="controls"><input class="form-control" id="inputMaxRam" type="text" name="maxRam" value="1024"></div>
</div>
<?php foreach(customColumns('G') as $row){ ?>
<div class="form-group">
<label for="inputCustom-<?php echo $row['customID'];?>"><?php echo $row['menu'];?></label>
<div class="controls"><input class="form-control" id="inputCustom-<?php echo $row['customID'];?>" type="<?php echo $row['type']=='V' ? 'text' : 'number';?>" name="<?php echo $row['name'];?>" value="" maxlength="<?php echo $row['length'];?>"></div>
</div>
<?php }?>
<div id="gameDetails">
</div>
</div>
<div class="box-footer">
<button class="btn btn-success" id="inputEdit" type="submit"><i class="fa fa-plus-circle">&nbsp;<?php echo $gsprache->add;?></i></button>
</div>
</form>
</div>
</div>
</div>
</section>
<script type="text/javascript">
$("#inputUser,#inputRoot").chosen({
disable_search_threshold: 3,
inherit_select_classes: true,
no_results_text: '<?php echo $gsprache->chosenNoResult;?>',
placeholder_text_single: '<?php echo $gsprache->chosenSelect;?>',
placeholder_text_multiple: '<?php echo $gsprache->chosenSelect;?>',
width: "100%"
});
function loadRootDetails () {
$('#gameDetails').html('');
$.ajax({ url: 'ajax.php?d=appmasterusage&id=' + $("#inputRoot").val(), cache: false } ).done(function(html) {
$('#rootWrapper').html(html);
$("#inputGames").chosen({
disable_search_threshold: 3,
no_results_text: '<?php echo $gsprache->chosenNoResult;?>',
placeholder_text_single: '<?php echo $gsprache->chosenSelect;?>',
placeholder_text_multiple: '<?php echo $gsprache->chosenSelect;?>',
width: "100%"
});
if ($("#inputCoreBind option:selected").val() == 'N') {
toggleID ('#theCores', 'N')
}
});
}
$('#inputRoot').on('change', function() {
loadRootDetails();
});
function toggleID (id, value) {
if (value == 'Y') {
$(id).show();
} else {
$(id).hide();
}
}
function gameDetails () {
var gameID;
var optionString = '';
var idString;
var idsString = '';
var ids = [];
$("#inputGames option:selected").each(function(){
gameID = $(this).val();
if (gameID > 0) {
optionString += '<option value="' + gameID + '">' + $(this).text() + '</option>';
if (typeof idString === 'undefined') {
idString = '&id=' + gameID + '&ip=' + encodeURI($('#inputIP option:selected').val());
}
idsString += '&id[]=' + gameID;
ids.push(gameID);
}
});
if (typeof idString === 'undefined') {
idString = '';
}
$('#inputPrimary').html(optionString);
$('#portWrapper').load('ajax.php?d=appmasterportbest' + idString);
$.ajax({ url: 'ajax.php?d=appmasterappdetails' + idsString, cache: false } ).done(function(html) {
$('#gameDetails').html(html);
ids = $.unique(ids);
var idsLength = ids.length;
var i;
for (i = 0; i < idsLength; i++) {
if (ids[i] > 0) {
toggleGameDetail(ids[i]);
}
}
});
}
function usedPorts (ip) {
$('#portList').load('ajax.php?d=appmasterportusage&ip=' + encodeURI(ip));
bestPorts($('#inputPrimary option:selected').val());
}
function bestPorts (id) {
$('#portWrapper').load('ajax.php?d=appmasterportbest&id=' + id + '&ip=' + encodeURI($('#inputIP option:selected').val()));
}
function toggleGameDetail(id) {
var iconClass = $('#openCloseIcon-' + id);
if (typeof iconClass.attr('class') !== 'undefined') {
if (iconClass.attr('class') == 'fa fa-arrow-circle-o-down') {
iconClass.attr('class','fa fa-arrow-circle-o-up');
$('.gameDetail-' + id).show();
} else {
iconClass.attr('class', 'fa fa-arrow-circle-o-down');
$('.gameDetail-' + id).hide();
}
}
}
$(function(){
loadRootDetails();
});
</script>

View File

@ -0,0 +1,63 @@
<section class="content-header">
<h1><?php echo $gsprache->gameserver;?></h1>
<ol class="breadcrumb">
<li><a href="admin.php"><i class="fa fa-home"></i> Home</a></li>
<li><a href="admin.php?w=gs"><?php echo $gsprache->gameserver;?></a></li>
<li><?php echo $gsprache->del;?></li>
<li class="active"><?php echo $ip.':'.$port;?></li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-md-12">
<div class="box box-danger">
<form role="form" action="admin.php?w=gs&amp;d=dl&amp;id=<?php echo $id;?>&amp;r=gs" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="dl">
<div class="box-body">
<div class="form-group">
<label for="inputUser"><?php echo $sprache->user;?></label>
<div class="controls">
<input class="form-control" id="inputUser" name="user" type="text" value="<?php echo $user;?>" disabled="disabled">
</div>
</div>
<div class="form-group">
<label for="inputIP"><?php echo $sprache->ip;?></label>
<div class="controls">
<input class="form-control" id="inputIP" name="ip" type="text" value="<?php echo $ip;?>" disabled="disabled">
</div>
</div>
<div class="form-group">
<label for="inputPort"><?php echo $sprache->port;?></label>
<div class="controls">
<input class="form-control" id="inputPort" name="port" type="text" value="<?php echo $port;?>" disabled="disabled">
</div>
</div>
<div class="form-group">
<label for="inputSafe"><?php echo $gsprache->del;?></label>
<div class="controls">
<select class="form-control" id="inputSafe" name="safeDelete">
<option value="S"><?php echo $gsprache->delSafe;?></option>
<option value="A"><?php echo $gsprache->delAny;?></option>
<option value="D"><?php echo $gsprache->delDB;?></option>
</select>
</div>
</div>
</div>
<div class="box-footer">
<button class="btn btn-danger" id="inputEdit" type="submit"><i class="fa fa-trash-o">&nbsp;<?php echo $gsprache->del;?></i></button>
</div>
</form>
</div>
</div>
</div>
</section>

View File

@ -0,0 +1,51 @@
<section class="content-header">
<h1><?php echo $sprache->heading_addons;?></h1>
<ol class="breadcrumb">
<li><a href="userpanel.php"><i class="fa fa-home"></i> Home</a></li>
<li><?php echo $gsprache->gameserver;?></li>
<li class="active"><?php echo $gsprache->overview;?></li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-md-12">
<?php echo $gsprache->gameserver;?> <a href="admin.php?w=gs&amp;d=ad"<span class="btn-success btn-sm"><i class="fa fa-plus-circle"></i> <?php echo $gsprache->add;?></span></a>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-body table-responsive">
<table id="dataTable" class="table table-bordered table-hover">
<thead>
<tr>
<th><?php echo $sprache->server;?></a></th>
<th>ID</a></th>
<th><?php echo $gsprache->status;?></a></th>
<th><?php echo $sprache->user;?></a></th>
<th><?php echo $gsprache->jobPending;?></th>
<th><?php echo $gsprache->start.'/'.$gsprache->stop;?></th>
<th><?php echo $gsprache->action;?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo $sprache->server;?></a></th>
<th>ID</a></th>
<th><?php echo $gsprache->status;?></a></th>
<th><?php echo $sprache->user;?></a></th>
<th><?php echo $gsprache->jobPending;?></th>
<th><?php echo $gsprache->start.'/'.$gsprache->stop;?></th>
<th><?php echo $gsprache->action;?></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</section>

View File

@ -0,0 +1,325 @@
<section class="content-header">
<h1><?php echo $gsprache->gameserver;?></h1>
<ol class="breadcrumb">
<li><a href="admin.php"><i class="fa fa-home"></i> Home</a></li>
<li><a href="admin.php?w=gs"><?php echo $gsprache->gameserver;?></a></li>
<li><?php echo $gsprache->mod;?></li>
<li class="active"><?php echo $ip.':'.$port;?></li>
</ol>
</section>
<section class="content">
<?php if (count($errors)>0){ ?>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4><?php echo $gsprache->errors;?></h4>
<?php echo implode(', ',$errors);?>
</div>
</div>
</div>
<?php }?>
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<form role="form" action="admin.php?w=gs&amp;d=md&amp;id=<?php echo $id;?>&amp;r=gs" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="md">
<input type="hidden" id="userID" name="userID" value="<?php echo $userID;?>">
<input type="hidden" id="currentRootID" name="currentRootID" value="<?php echo $rootID;?>">
<input type="hidden" id="currentIP" name="currentIP" value="<?php echo $ip;?>">
<input type="hidden" id="gameServerID" name="gameServerID" value="<?php echo $id;?>">
<input type="hidden" id="currentGameID" name="currentGameID" value="<?php echo $currentGameID;?>">
<input type="hidden" id="currentPort" name="currentPort" value="<?php echo $port;?>">
<input type="hidden" id="currentPort2" name="currentPort2" value="<?php echo $port2;?>">
<input type="hidden" id="currentPort3" name="currentPort3" value="<?php echo $port3;?>">
<input type="hidden" id="currentPort4" name="currentPort4" value="<?php echo $port4;?>">
<input type="hidden" id="currentPort5" name="currentPort5" value="<?php echo $port5;?>">
<div class="box-body">
<div class="form-group">
<label for="inputExternalID">External ID</label>
<div class="controls"><input class="form-control" id="inputExternalID" type="text" name="externalID" value="<?php echo $externalID;?>"></div>
</div>
<div class="form-group">
<label for="inputRoot"><?php echo $sprache->root;?></label>
<div class="controls">
<select class="form-control chosen-select" id="inputRoot" name="rootID">
<?php foreach ($table as $key=>$val){ ?>
<!-- as a first development step will not allow a move from root to root -->
<?php if($key==$rootID){ ?><option value="<?php echo $key;?>" <?php if($key==$rootID) echo 'selected="selected"';?>><?php echo $val;?></option><?php }?>
<?php } ?>
</select>
</div>
</div>
<div id="rootWrapper">
</div>
<div class="form-group">
<label for="inputActive"><?php echo $sprache->active;?></label>
<div class="controls">
<select class="form-control" id="inputActive" name="active">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N" <?php if($active=='N') echo 'selected="selected"';?>><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputAutorestart">Auto Restart</label>
<div class="controls">
<select class="form-control" id="inputAutorestart" name="autoRestart">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N" <?php if($autoRestart=='N') echo 'selected="selected"';?>><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputLend"><?php echo $sprache->lendserver;?></label>
<div class="controls">
<select class="form-control" id="inputLend" name="lendserver">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($lendserver=='N') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputPassFTP">FTP <?php echo $sprache->password;?></label>
<div class="controls"><input class="form-control" id="inputPassFTP" type="text" name="ftpPassword" value="<?php echo $ftpPassword;?>"></div>
</div>
<div class="form-group">
<label for="inputEAC">Easy Anti Cheat</label>
<div class="controls">
<select class="form-control" id="inputEAC" name="eacAllowed">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($eacAllowed=='Y') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputSlots"><?php echo $sprache->slots;?></label>
<div class="controls"><input class="form-control" id="inputSlots" type="text" name="slots" value="<?php echo $slots;?>"></div>
</div>
<div class="form-group">
<label for="inputPmode"><?php echo $sprache->protect;?></label>
<div class="controls">
<select class="form-control" id="inputPmode" name="protectionAllowed">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($protectionAllowed=='Y') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputBrand"><?php echo $sprache->brandname;?></label>
<div class="controls">
<select class="form-control" id="inputBrand" name="brandname">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($brandname=='Y') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputWar"><?php echo $sprache->war;?></label>
<div class="controls">
<select class="form-control" id="inputWar" name="war">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($war=='Y') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputTV"><?php echo $sprache->tv;?></label>
<div class="controls">
<select class="form-control" id="inputTV" name="tvEnable">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N" <?php if($tvEnable=='N') echo 'selected="selected"';?>><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputMinRam">Min Ram</label>
<div class="controls"><input class="form-control" id="inputMinRam" type="text" name="minRam" value="<?php echo $minRam;?>"></div>
</div>
<div class="form-group">
<label for="inputMaxRam">Max Ram</label>
<div class="controls"><input class="form-control" id="inputMaxRam" type="text" name="maxRam" value="<?php echo $maxRam;?>"></div>
</div>
<?php foreach(customColumns('G') as $row){ ?>
<div class="form-group">
<label for="inputCustom-<?php echo $row['customID'];?>"><?php echo $row['menu'];?></label>
<div class="controls"><input class="form-control" id="inputCustom-<?php echo $row['customID'];?>" type="<?php echo $row['type']=='V' ? 'text' : 'number';?>" name="<?php echo $row['name'];?>" value="" maxlength="<?php echo $row['length'];?>"></div>
</div>
<?php }?>
<div id="gameDetails">
</div>
</div>
<div class="box-footer">
<button class="btn btn-primary" id="inputEdit" type="submit"><i class="fa fa-save">&nbsp;<?php echo $gsprache->save;?></i></button>
</div>
</form>
</div>
</div>
</div>
</section>
<script type="text/javascript">
var currentRootID = $("#currentRootID").val();
var currentIP = $("#currentIP").val();
var gameServerID = $("#gameServerID").val();
var currentGameID = $("#currentGameID").val();
$("#inputUser,#inputRoot").chosen({
disable_search_threshold: 3,
inherit_select_classes: true,
no_results_text: '<?php echo $gsprache->chosenNoResult;?>',
placeholder_text_single: '<?php echo $gsprache->chosenSelect;?>',
placeholder_text_multiple: '<?php echo $gsprache->chosenSelect;?>',
width: "100%"
});
function loadRootDetails (modificationInit) {
$('#gameDetails').html('');
$.ajax({ url: 'ajax.php?d=appmasterusage&id=' + $("#inputRoot").val() + '&currentRootID=' + currentRootID + '&currentIP=' + encodeURI(currentIP) + '&gameServerID=' + gameServerID, cache: false } ).done(function(html) {
$('#rootWrapper').html(html);
$("#inputGames").chosen({
disable_search_threshold: 3,
no_results_text: '<?php echo $gsprache->chosenNoResult;?>',
placeholder_text_single: '<?php echo $gsprache->chosenSelect;?>',
placeholder_text_multiple: '<?php echo $gsprache->chosenSelect;?>',
width: "100%"
});
if ($("#inputCoreBind option:selected").val() == 'N') {
toggleID ('#theCores', 'N')
}
gameDetails(true);
});
return true;
}
$('#inputRoot').on('change', function() {
loadRootDetails();
});
function toggleID (id, value) {
if (value == 'Y') {
$(id).show();
} else {
$(id).hide();
}
}
function gameDetails (initLoad) {
var gameID;
var idString;
var idsString = '';
var ids = [];
$("#inputGames option:selected").each(function(){
gameID = $(this).val();
if (typeof gameID !== 'undefined' && gameID > 0) {
if (typeof idString === 'undefined') {
idString = '&id=' + gameID + '&ip=' + encodeURI($('#inputIP option:selected').val());
}
idsString += '&id[]=' + gameID;
ids.push(gameID);
}
});
if (typeof idString === 'undefined') {
idString = '';
}
if (typeof initLoad === 'undefined') {
$('#portWrapper').load('ajax.php?d=appmasterportbest' + idString + '&currentRootID=' + currentRootID + '&currentIP=' + encodeURI(currentIP) + '&gameServerID=' + gameServerID);
}
$.ajax({ url: 'ajax.php?d=appmasterappdetails' + idsString + '&currentRootID=' + currentRootID + '&currentIP=' + encodeURI(currentIP) + '&gameServerID=' + gameServerID, cache: false } ).done(function(html) {
$('#gameDetails').html(html);
ids = $.unique(ids);
var idsLength = ids.length;
var i;
for (i = 0; i < idsLength; i++) {
if (ids[i] > 0) {
toggleGameDetail(ids[i]);
}
}
});
}
function usedPorts (ip) {
$('#portList').load('ajax.php?d=appmasterportusage&ip=' + encodeURI(ip) + '&currentRootID=' + currentRootID + '&currentIP=' + encodeURI(currentIP) + '&gameServerID=' + gameServerID);
bestPorts(currentGameID);
}
function bestPorts (id) {
var ipSelected = $('#inputIP option:selected').val();
if (ipSelected == currentIP) {
$('#inputPortMain').val($('#currentPort').val());
$('#inputPort2').val($('#currentPort2').val());
$('#inputPort3').val($('#currentPort3').val());
$('#inputPort4').val($('#currentPort4').val());
$('#inputPort5').val($('#currentPort5').val());
} else {
$('#portWrapper').load('ajax.php?d=appmasterportbest&id=' + id + '&ip=' + encodeURI(ipSelected));
}
}
function toggleGameDetail(id) {
var iconClass = $('#openCloseIcon-' + id);
if (typeof iconClass.attr('class') !== 'undefined') {
if (iconClass.attr('class') == 'fa fa-arrow-circle-o-down') {
iconClass.attr('class','fa fa-arrow-circle-o-up');
$('.gameDetail-' + id).show();
} else {
iconClass.attr('class', 'fa fa-arrow-circle-o-down');
$('.gameDetail-' + id).hide();
}
}
}
$(function(){
loadRootDetails();
});
</script>

View File

@ -0,0 +1,73 @@
<section class="content-header">
<h1><?php echo $gsprache->gameserver;?></h1>
<ol class="breadcrumb">
<li><a href="admin.php"><i class="fa fa-home"></i> Home</a></li>
<li><a href="admin.php?w=gs"><?php echo $gsprache->gameserver;?></a></li>
<li><?php echo $gsprache->reinstall;?></li>
<li class="active"><?php echo $serverip.':'.$port;?></li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="col-md-12">
<div class="box box-warning">
<form role="form" action="admin.php?w=gs&amp;d=ri&amp;id=<?php echo $id;?>&amp;r=gs" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="ri">
<input type="hidden" id="type" name="type" value="N">
<div class="box-body">
<div class="form-group">
<label for="game"><?php echo $gsprache->game;?></label>
<select class="form-control" id="game" name="game" onchange="toggleTemplates();">
<?php foreach ($table as $table_row){ ?>
<option value="<?php echo $table_row['id'];?>" data-shorten="<?php echo $table_row['shorten'];?>"><?php echo $table_row['description'];?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="template"><?php echo $gsprache->template;?></label>
<select class="form-control" id="template" name="template">
<option id="template1" value="1"><?php echo $shorten;?></option>
<option id="template2" value="2" <?php echo $selected2;?>><?php echo $shorten;?>-2</option>
<option id="template3" value="3" <?php echo $selected3;?>><?php echo $shorten;?>-3</option>
<option value="4"><?php echo $gsprache->all;?></option>
</select>
</div>
<div class="form-group">
<label><?php echo $sprache->type;?></label>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="radio" name="options" value="N" onchange="$('#type').val(this.value);" checked> <?php echo $sprache->resync;?>
</label>
<label class="btn btn-primary">
<input type="radio" name="options" value="Y" onchange="$('#type').val(this.value);"> <?php echo $sprache->reinstall;?>
</label>
</div>
</div>
</div>
<div class="box-footer">
<button class="btn btn-warning" id="inputEdit" type="submit"><i class="fa fa-refresh">&nbsp;<?php echo $gsprache->exec;?></i></button>
</div>
</form>
</div>
</div>
</div>
</section>
<script type="text/javascript">
function toggleTemplates () {
var shorten = $('#game').find(':selected').data('shorten');
$('#template1').text(shorten);
$('#template2').text(shorten + '-2');
$('#template3').text(shorten + '-3');
}
</script>

View File

@ -71,11 +71,6 @@
}
});
/*
$.each(selectedServers, function( index, value ){
alert(value);
});*/
var serverString = '';
var splitted = [];

View File

@ -0,0 +1,89 @@
<?php foreach ($table as $row){ ?>
<h4>
<img src="images/games/icons/<?php echo $row['shorten'];?>.png" alt="<?php echo $row['description'];?>" width="16"> <a href="javascript:void(0)" onclick="toggleGameDetail('<?php echo $row['id'];?>');"><?php echo $row['description'];?> <i id="openCloseIcon-<?php echo $row['id'];?>" class="fa fa-arrow-circle-o-up"></i></a>
</h4>
<?php if ($row['upload']>0) { ?>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-UploadFTP">Upload FTP</label>
<div class="controls"><input class="form-control" id="input-<?php echo $row['id'];?>-UploadFTP" type="text" name="uploadDir[<?php echo $row['id'];?>]" value=""></div>
</div>
<div class="checkbox gameDetail-<?php echo $row['id'];?>">
<label>
<input type="checkbox" name="userUploadDir[<?php echo $row['id'];?>]" value="Y" <?php if($row['userUploadDir']=='Y') echo 'checked="checked"';?>>
Upload FTP <?php echo $sprache->useredit;?>
</label>
</div>
<?php }else{ ?>
<input type="hidden" name="upload[<?php echo $table_row['id'];?>]" value="0">
<?php }?>
<?php if(strlen($row['fps'])>0){ ?>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-FPS"><?php echo $sprache->fps;?></label>
<div class="controls"><input class="form-control" id="input-<?php echo $row['id'];?>-FPS" type="text" name="fps[<?php echo $row['id'];?>]" value="<?php echo $row['fps'];?>"></div>
</div>
<div class="checkbox gameDetail-<?php echo $row['id'];?>">
<label>
<input type="checkbox" name="userFps[<?php echo $row['id'];?>]" value="Y" <?php if($row['userFps']=='Y') echo 'checked="checked"';?>>
<?php echo $sprache->fps.' '.$sprache->useredit;?>
</label>
</div>
<?php } ?>
<?php if(strlen($row['tic'])>0){ ?>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-Tick"><?php echo $sprache->tick;?></label>
<div class="controls"><input class="form-control" id="input-<?php echo $row['id'];?>-Tick" type="text" name="tic[<?php echo $row['id'];?>]" value="<?php echo $row['tic'];?>"></div>
</div>
<div class="checkbox gameDetail-<?php echo $row['id'];?>">
<label>
<input type="checkbox" name="userTick[<?php echo $row['id'];?>]" value="Y" <?php if($row['userTick']=='Y') echo 'checked="checked"';?>>
<?php echo $sprache->tick.' '.$sprache->useredit;?>
</label>
</div>
<?php } ?>
<?php if(strlen($row['map'])>0){ ?>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-Map"><?php echo $sprache->startmap;?></label>
<div class="controls"><input class="form-control" id="input-<?php echo $row['id'];?>-Map" type="text" name="map[<?php echo $row['id'];?>]" value="<?php echo $row['map'];?>"></div>
</div>
<?php } ?>
<?php if(strlen($row['mapGroup'])>0){ ?>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-MapGroup"><?php echo $sprache->startmapgroup;?></label>
<div class="controls"><input class="form-control" id="input-<?php echo $row['id'];?>-MapGroup" type="text" name="mapGroup[<?php echo $row['id'];?>]" value="<?php echo $row['mapGroup'];?>"></div>
</div>
<?php } ?>
<?php if(strlen($row['map'])>0 or strlen($row['mapGroup'])>0){ ?>
<div class="checkbox gameDetail-<?php echo $row['id'];?>">
<label>
<input type="checkbox" name="userMap[<?php echo $row['id'];?>]" value="Y" <?php if($row['userMap']=='Y') echo 'checked="checked"';?>>
<?php echo $sprache->startmap.'/'.$sprache->startmapgroup.' '.$sprache->useredit;?>
</label>
</div>
<?php } ?>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-OwnCMD"><?php echo $sprache->start_own;?></label>
<div class="controls">
<select class="form-control" id="input-<?php echo $row['id'];?>-OwnCMD" name="ownCmd[<?php echo $row['id'];?>]">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($row['ownCmd']=='Y') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div class="form-group gameDetail-<?php echo $row['id'];?>">
<label for="input-<?php echo $row['id'];?>-CMD"><?php echo $sprache->start;?></label>
<div class="controls">
<textarea class="form-control" id="input-<?php echo $row['id'];?>-CMD" rows="5" name="cmd[<?php echo $row['id'];?>]"><?php echo $row['cmd'];?></textarea>
</div>
</div>
<?php } ?>

View File

@ -0,0 +1,26 @@
<div id="portWrapper">
<div class="form-group">
<label for="inputPortMain"><?php echo $sprache->port;?> 1</label>
<div class="controls"><input class="form-control" id="inputPortMain" type="text" name="port" value="<?php echo $port;?>"></div>
</div>
<div class="form-group">
<label for="inputPort2"><?php echo $sprache->port;?> 2</label>
<div class="controls"><input class="form-control" id="inputPort2" type="text" name="port2" value="<?php echo $port2;?>"></div>
</div>
<div class="form-group">
<label for="inputPort3"><?php echo $sprache->port;?> 3</label>
<div class="controls"><input class="form-control" id="inputPort3" type="text" name="port3" value="<?php echo $port3;?>"></div>
</div>
<div class="form-group">
<label for="inputPort4"><?php echo $sprache->port;?> 4</label>
<div class="controls"><input class="form-control" id="inputPort4" type="text" name="port4" value="<?php echo $port4;?>"></div>
</div>
<div class="form-group">
<label for="inputPort5"><?php echo $sprache->port;?> 5</label>
<div class="controls"><input class="form-control" id="inputPort5" type="text" name="port5" value="<?php echo $port5;?>"></div>
</div>
</div>

View File

@ -0,0 +1,114 @@
<div class="form-group">
<label for="inputServerInstalled"><?php echo $sprache->serverinstalled;?></label>
<input class="form-control" id="inputServerInstalled" type="text" name="serverInstalled" value="<?php echo $installedServer.'/'.$maxServer;?>" disabled="disabled">
</div>
<div class="form-group">
<label for="inputSlotsInstalled"><?php echo $sprache->slotsinstalled;?></label>
<input class="form-control" id="inputSlotsInstalled" type="text" name="slotsInstalled" value="<?php echo $installedSlots.'/'.$maxSlots;?>" disabled="disabled">
</div>
<div class="form-group">
<label for="inputRamUsed"><?php echo $sprache->raminstalled;?></label>
<input class="form-control" id="inputRamUsed" type="text" name="ramUsed" value="<?php echo $installedRam.'/'.$maxRam;?>" disabled="disabled">
</div>
<div class="form-group">
<label for="inputGames"><?php echo $sprache->games;?></label>
<div class="controls">
<select class="form-control chosen-select" id="inputGames" name="gameIDs[]" multiple="multiple" onchange="gameDetails(true);">
<option></option>
<?php foreach ($table as $key=>$arr){ ?>
<option value="<?php echo $key;?>" <?php if(in_array($key,$installedGames)) echo 'selected="selected"';?>><?php echo $arr['description'];?></option>
<?php } ?>
</select>
</div>
</div>
<?php if(!$ui->id('gameServerID', 10, 'get')){ ?>
<div class="form-group">
<label for="inputPrimary"><?php echo $sprache->primary;?>:</label>
<div class="controls">
<select class="form-control chosen-select" id="inputPrimary" name="primary" onchange="bestPorts(this.value);" required="required">
<option></option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputGamesInstall"><?php echo $sprache->installGames;?>:</label>
<div class="controls">
<select class="form-control" id="inputGamesInstall" name="installGames">
<option value="2"><?php echo $sprache->primary;?></option>
<option value="1"><?php echo $sprache->installAll;?></option>
<option value="3"><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<?php } ?>
<div class="form-group">
<label for="inputIP"><?php echo $sprache->ip;?></label>
<div class="controls">
<select class="form-control" id="inputIP" name="ip" onchange="usedPorts(this.value);">
<?php foreach ($ips as $v){ ?>
<option <?php if($v==$currentIP) echo 'selected="selected"';?>><?php echo $v;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label><?php echo $sprache->usedports;?></label>
<div class="controls" id="portList">
<?php echo $ports;?>
</div>
</div>
<div id="portWrapper">
<div class="form-group">
<label for="inputPortMain"><?php echo $sprache->port;?> 1</label>
<div class="controls"><input class="form-control" id="inputPortMain" type="text" name="port" value="<?php echo $port;?>"></div>
</div>
<div class="form-group">
<label for="inputPort2"><?php echo $sprache->port;?> 2</label>
<div class="controls"><input class="form-control" id="inputPort2" type="text" name="port2" value="<?php echo $port2;?>"></div>
</div>
<div class="form-group">
<label for="inputPort3"><?php echo $sprache->port;?> 3</label>
<div class="controls"><input class="form-control" id="inputPort3" type="text" name="port3" value="<?php echo $port3;?>"></div>
</div>
<div class="form-group">
<label for="inputPort4"><?php echo $sprache->port;?> 4</label>
<div class="controls"><input class="form-control" id="inputPort4" type="text" name="port4" value="<?php echo $port4;?>"></div>
</div>
<div class="form-group">
<label for="inputPort5"><?php echo $sprache->port;?> 5</label>
<div class="controls"><input class="form-control" id="inputPort5" type="text" name="port5" value="<?php echo $port5;?>"></div>
</div>
</div>
<div class="form-group">
<label for="inputCoreBind">Core Bind</label>
<div class="controls">
<select class="form-control" id="inputCoreBind" name="taskset" onchange="toggleID('#theCores', this.value);">
<option value="N"><?php echo $gsprache->no;?></option>
<option value="Y" <?php if($taskset=='Y') echo 'selected="selected"';?>><?php echo $gsprache->yes;?></option>
</select>
</div>
</div>
<div id="theCores" class="form-group">
<label for="inputCores">Cores <?php echo '0-'.($coreCount-1);?></label>
<div class="controls">
<select class="form-control" id="inputCores" name="cores[]" multiple="multiple">
<?php foreach($cores as $core => $count) { ?>
<option value="<?php echo $core;?>" <?php if(in_array($core,$usedCores)) echo 'selected="selected"';?>><?php echo $core.' ('.$count.') ';?></option>
<?php }?>
</select>
</div>
</div>