Reseller Leihserver Modul #677

This commit is contained in:
Ulrich Block 2016-03-20 12:09:30 +01:00
parent 8aff0d523b
commit d40ef9131f

View File

@ -46,8 +46,8 @@ include(EASYWIDIR . '/stuff/methods/functions_ssh_exec.php');
include(EASYWIDIR . '/stuff/methods/class_ts3.php');
include(EASYWIDIR . '/stuff/methods/class_app.php');
$sprache = getlanguagefile('lendserver', $user_language, $reseller_id);
$gssprache = getlanguagefile('gserver', $user_language, $reseller_id);
$sprache = getlanguagefile('lendserver', $user_language, $resellerLockupID);
$gssprache = getlanguagefile('gserver', $user_language, $resellerLockupID);
$loguserid = $admin_id;
$logusername = getusername($admin_id);
$logusertype = 'admin';
@ -67,13 +67,14 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
if ($ui->w('activeGS', 1, 'post') or $ui->w('activeVS', 1, 'post')) {
$query = $sql->prepare("UPDATE `lendsettings` SET `activeGS`=?,`activeVS`=?,`mintime`=?,`maxtime`=?,`timesteps`=?,`minplayer`=?,`maxplayer`=?,`playersteps`=?,`mintimeRegistered`=?,`maxtimeRegistered`=?,`timestepsRegistered`=?,`minplayerRegistered`=?,`maxplayerRegistered`=?,`playerstepsRegistered`=?,`vomintime`=?,`vomaxtime`=?,`votimesteps`=?,`vominplayer`=?,`vomaxplayer`=?,`voplayersteps`=?,`vomintimeRegistered`=?,`vomaxtimeRegistered`=?,`votimestepsRegistered`=?,`vominplayerRegistered`=?,`vomaxplayerRegistered`=?,`voplayerstepsRegistered`=?,`shutdownempty`=?,`shutdownemptytime`=?,`ftpupload`=?,`ftpuploadpath`=AES_ENCRYPT(?,?),`lendaccess`=? WHERE `resellerid`=? LIMIT 1");
$query->execute(array($ui->w('activeGS', 1, 'post'), $ui->w('activeVS', 1, 'post'), $ui->id('mintime',3, 'post'), $ui->id('maxtime',4, 'post'), $ui->id('timesteps',3, 'post'), $ui->id('minplayer',3, 'post'), $maxplayer = $ui->id('maxplayer',3, 'post'), $ui->id('playersteps',3, 'post'), $ui->id('mintimeRegistered',3, 'post'), $ui->id('maxtimeRegistered',4, 'post'), $ui->id('timestepsRegistered',3, 'post'), $ui->id('minplayerRegistered',3, 'post'), $ui->id('maxplayerRegistered',3, 'post'), $ui->id('playerstepsRegistered',3, 'post'), $vomintime = $ui->id('vomintime',3, 'post'), $ui->id('vomaxtime',4, 'post'), $ui->id('votimesteps',3, 'post'), $ui->id('vominplayer',3, 'post'), $ui->id('vomaxplayer',3, 'post'), $ui->id('voplayersteps',3, 'post'), $ui->id('vomintimeRegistered',3, 'post'), $ui->id('vomaxtimeRegistered',4, 'post'), $ui->id('votimestepsRegistered',3, 'post'), $ui->id('vominplayerRegistered',3, 'post'), $ui->id('vomaxplayerRegistered',3, 'post'), $ui->id('voplayerstepsRegistered',3, 'post'), $ui->active('shutdownempty', 'post'), $ui->id('shutdownemptytime',4, 'post'), $ui->w('ftpupload',1, 'post'), $ui->url('ftpuploadpath', 'post'), $aeskey, $ui->id('lendaccess',1, 'post'), $reseller_id));
$query->execute(array($ui->w('activeGS', 1, 'post'), $ui->w('activeVS', 1, 'post'), $ui->id('mintime',3, 'post'), $ui->id('maxtime',4, 'post'), $ui->id('timesteps',3, 'post'), $ui->id('minplayer',3, 'post'), $maxplayer = $ui->id('maxplayer',3, 'post'), $ui->id('playersteps',3, 'post'), $ui->id('mintimeRegistered',3, 'post'), $ui->id('maxtimeRegistered',4, 'post'), $ui->id('timestepsRegistered',3, 'post'), $ui->id('minplayerRegistered',3, 'post'), $ui->id('maxplayerRegistered',3, 'post'), $ui->id('playerstepsRegistered',3, 'post'), $vomintime = $ui->id('vomintime',3, 'post'), $ui->id('vomaxtime',4, 'post'), $ui->id('votimesteps',3, 'post'), $ui->id('vominplayer',3, 'post'), $ui->id('vomaxplayer',3, 'post'), $ui->id('voplayersteps',3, 'post'), $ui->id('vomintimeRegistered',3, 'post'), $ui->id('vomaxtimeRegistered',4, 'post'), $ui->id('votimestepsRegistered',3, 'post'), $ui->id('vominplayerRegistered',3, 'post'), $ui->id('vomaxplayerRegistered',3, 'post'), $ui->id('voplayerstepsRegistered',3, 'post'), $ui->active('shutdownempty', 'post'), $ui->id('shutdownemptytime',4, 'post'), $ui->w('ftpupload',1, 'post'), $ui->url('ftpuploadpath', 'post'), $aeskey, $ui->id('lendaccess',1, 'post'), $resellerLockupID));
$template_file = ($query->rowCount() > 0) ? $spracheResponse->table_add : $spracheResponse->error_table;;
} else {
$query = $sql->prepare("SELECT *,AES_DECRYPT(`ftpuploadpath`,?) AS `decyptedftpuploadpath` FROM `lendsettings` WHERE `resellerid`=? LIMIT 1");
$query->execute(array($aeskey, $reseller_id));
$query->execute(array($aeskey, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$activeGS = $row['activeGS'];
$activeVS = $row['activeVS'];
@ -117,7 +118,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$stats = '';
$query = $sql->prepare("SELECT * FROM `lendstats` WHERE `resellerID`=?");
$query->execute(array($reseller_id));
$query->execute(array($resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$servertype = $row['servertype'];
@ -144,7 +145,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
if ($ui->id('id', 19, 'post')) {
$query = $sql->prepare("SELECT `serverid`,`servertype` FROM `lendedserver` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($ui->id('id',19, 'post'), $reseller_id));
$query->execute(array($ui->id('id',19, 'post'), $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$id = $row['serverid'];
$servertype = $row['servertype'];
@ -153,7 +154,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
if (isset($servertype) and $servertype == 'g') {
$query = $sql->prepare("SELECT s.`switchID`,g.`rootID` FROM `serverlist` s INNER JOIN `gsswitch` g ON s.`switchID`=g.`id` WHERE s.`id`=? AND s.`resellerid`=? LIMIT 1");
$query->execute(array($id, $reseller_id));
$query->execute(array($id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$appServer = new AppServer($row['rootID']);
$appServer->getAppServerDetails($row['switchID']);
@ -164,7 +165,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
} else if (isset($servertype) and $servertype == 'v') {
$query = $sql->prepare("SELECT v.`localserverid`,m.`ssh2ip`,m.`rootid`,m.`addedby`,m.`queryport`,AES_DECRYPT(m.`querypassword`,?) AS `decryptedquerypassword` FROM `voice_server` v LEFT JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`id`=? AND v.`resellerid`=? LIMIT 1");
$query->execute(array($aeskey, $id, $reseller_id));
$query->execute(array($aeskey, $id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$queryport = $row['queryport'];
@ -176,7 +177,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$queryip = $row['ssh2ip'];
} else if ($addedby == 1) {
$query2 = $sql->prepare("SELECT `ip`,`altips` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query2->execute(array($row['rootid'], $reseller_id));
$query2->execute(array($row['rootid'], $resellerLockupID));
$queryip = $query2->fetchColumn();
}
@ -190,7 +191,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
}
}
$query = $sql->prepare("DELETE FROM `lendedserver` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($ui->id('id',19, 'post'), $reseller_id));
$query->execute(array($ui->id('id',19, 'post'), $resellerLockupID));
$template_file = ($query->rowCount() > 0) ? $spracheResponse->table_del : $spracheResponse->error_table;
@ -206,7 +207,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$shutDownEmptyTime = 5;
$query = $sql->prepare("SELECT `shutdownempty`,`shutdownemptytime` FROM `lendsettings` WHERE `resellerid`=? LIMIT 1");
$query->execute(array($reseller_id));
$query->execute(array($resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$shutDownEmpty = $row['shutdownempty'];
$shutDownEmptyTime = $row['shutdownemptytime'];
@ -214,11 +215,11 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$deleteQuery = $sql->prepare("DELETE FROM `lendedserver` WHERE `id`=? LIMIT 1");
$query = $sql->prepare("SELECT `id`,`queryMap`,`queryNumplayers`,`queryName`,`serverip`,`port`,`slots`,`serverid`,`rootID` FROM `gsswitch` WHERE `lendserver`='Y' AND `active`='Y' AND `resellerid`=0");
$query2 = $sql->prepare("SELECT s.`id`,t.`shorten`,t.`description` FROM `serverlist` s INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`switchID`=? AND s.`resellerid`=0");
$query = $sql->prepare("SELECT `id`,`queryMap`,`queryNumplayers`,`queryName`,`serverip`,`port`,`slots`,`serverid`,`rootID` FROM `gsswitch` WHERE `lendserver`='Y' AND `active`='Y' AND `resellerid`=?");
$query2 = $sql->prepare("SELECT s.`id`,t.`shorten`,t.`description` FROM `serverlist` s INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`switchID`=? AND s.`resellerid`=?");
$query3 = $sql->prepare("SELECT `id`,`slots`,`started`,`lendtime`,`password`,`rcon`,CURRENT_TIMESTAMP AS `now` FROM `lendedserver` WHERE `serverid`=? AND `servertype`='g' LIMIT 1");
$query->execute(array($reseller_id));
$query->execute(array($resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$installedShorten = array();
@ -229,7 +230,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$password = null;
$rcon = null;
$query2->execute(array($row['id']));
$query2->execute(array($row['id'], $resellerLockupID));
while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
$installedShorten[$row2['shorten']] = $row2['description'];
@ -276,7 +277,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$query = $sql->prepare("SELECT v.`id`,v.`ip`,v.`port`,v.`queryName`,v.`dns`,v.`usedslots`,v.`slots` AS `availableSlots`,l.`password`,l.`slots`,l.`started`,l.`lendtime`,CURRENT_TIMESTAMP AS `now`,l.`id` AS `lend_id` FROM `voice_server` v LEFT JOIN `lendedserver` l ON v.`id`=l.`serverid` AND l.`servertype`='v' WHERE v.`lendserver`='Y' AND v.`active`='Y' AND v.`resellerid`=0");
$query2 = $sql->prepare("SELECT v.`localserverid`,m.`ssh2ip`,m.`rootid`,m.`addedby`,m.`queryport`,AES_DECRYPT(m.`querypassword`,?) AS `decryptedquerypassword` FROM `voice_server` v LEFT JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`id`=? AND v.`resellerid`=? LIMIT 1");
$query->execute(array($reseller_id));
$query->execute(array($resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$time = 0;
@ -294,7 +295,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
if ($time == 0 or ($shutDownEmpty == 'Y' and ($row['lendtime'] - $timeleft) > $shutDownEmptyTime and $row['usedslots'] < 1)) {
$query2->execute(array($aeskey, $row['id'], $reseller_id));
$query2->execute(array($aeskey, $row['id'], $resellerLockupID));
while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
$queryport = $row2['queryport'];
@ -305,7 +306,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
if ($addedby == 2) {
$queryip = $row2['ssh2ip'];
} else if ($addedby == 1) {
$query4->execute(array($row2['rootid'], $reseller_id));
$query4->execute(array($row2['rootid'], $resellerLockupID));
$queryip = $query4->fetchColumn();
}
@ -338,7 +339,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
}
$query = $sql->prepare("SELECT ((UNIX_TIMESTAMP(`lastcheck`)-UNIX_TIMESTAMP(`oldcheck`))/60)-((UNIX_TIMESTAMP()-UNIX_TIMESTAMP(`lastcheck`))/60) AS `nextRunInMinutes` FROM `lendsettings` WHERE `resellerid`=? LIMIT 1");
$query->execute(array($reseller_id));
$query->execute(array($resellerLockupID));
$nextcheck = $query->fetchColumn();
$nextcheck = ($nextcheck > 0) ? ceil($nextcheck) : ceil($nextcheck) * -1;