#493 Add option to specify query port (1-5)

This commit is contained in:
Ulrich Block 2014-09-20 11:57:42 +02:00
parent 06c030508c
commit 2d7f03a113
7 changed files with 62 additions and 13 deletions

View File

@ -69,4 +69,5 @@
<tvport>SourceTV Port</tvport>
<type2>Addon für</type2>
<type>Map, oder Servertool</type>
<useQueryPort>Query Port</useQueryPort>
</sprache>

View File

@ -68,4 +68,5 @@
<tvport>SourceTV Port</tvport>
<type2>Addon for</type2>
<type>Kort eller Serverværktøj</type>
<useQueryPort></useQueryPort>
</sprache>

View File

@ -69,4 +69,5 @@
<tvport>SourceTV port</tvport>
<type2>Addon for</type2>
<type>Map, or server tool</type>
<useQueryPort>Query port</useQueryPort>
</sprache>

View File

@ -210,14 +210,26 @@ if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip,
$shellCmds = array();
// Get the list of servers which are active and are not stopped. The array to be created will support batch mode.
$query = $sql->prepare("SELECT g.`id`,g.`rootID`,g.`serverid`,g.`serverip`,g.`port`,g.`port2`,t.`gameq` FROM `gsswitch` g INNER JOIN `serverlist` s ON g.`serverid`=s.`id` INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`stopped`='N' AND g.`active`='Y'");
$query = $sql->prepare("SELECT g.`id`,g.`rootID`,g.`serverid`,g.`serverip`,g.`port`,g.`port2`,g.`port3`,g.`port4`,g.`port5`,t.`gameq`,t.`shorten`,t.`useQueryPort` FROM `gsswitch` g INNER JOIN `serverlist` s ON g.`serverid`=s.`id` INNER JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`stopped`='N' AND g.`active`='Y'");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
// without the gameq value we cannot query. So this results need to be sorted out.
if (!in_array($row['gameq'], array('', null, false))) {
$checkAtIPPort = (in_array($row['gameq'], array('cube2', 'ut', 'ut2004', 'ut3', 'mta'))) ? $row['serverip'] . ':' . $row['port2'] : $row['serverip'] . ':' . $row['port'];
$checkAtIPPort = $row['serverip'] . ':';
if ($row['useQueryPort'] == 5) {
$checkAtIPPort .= $row['port5'];
} else if ($row['useQueryPort'] == 4) {
$checkAtIPPort .= $row['port4'];
} else if ($row['useQueryPort'] == 3) {
$checkAtIPPort .= $row['port3'];
} else if ($row['useQueryPort'] == 2) {
$checkAtIPPort .= $row['port2'];
} else {
$checkAtIPPort .= $row['port'];
}
$serverBatchArray[] = array('id' => $row['id'], 'type' => $row['gameq'], 'host' => $checkAtIPPort);
$i++;
@ -229,6 +241,9 @@ if (!isset($ip) or $ui->escaped('SERVER_ADDR', 'server') == $ip or in_array($ip,
}
$totalCount++;
} else {
print "No GameQ found for {$row['shorten']}\r\n";
}
}

View File

@ -123,12 +123,13 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$gamemod2 = $ui->w('gamemod2', 10, 'post');
$gamemod = ($ui->active('gamemod', 'post')) ? $ui->active('gamemod', 'post') : 'N';
$portMax = ($ui->id('portMax', 1, 'post')) ? $ui->id('portMax', 1, 'post') : 1;
$portStep = ($ui->id('portStep',4, 'post')) ? $ui->id('portStep',4, 'post') : 100;
$portOne = ($ui->id('portOne',5, 'post')) ? $ui->id('portOne',5, 'post') : 27015;
$portTwo = ($ui->id('portTwo',5, 'post')) ? $ui->id('portTwo',5, 'post') : null;
$portThree = ($ui->id('portThree',5, 'post')) ? $ui->id('portThree',5, 'post') : null;
$portFour = ($ui->id('portFour',5, 'post')) ? $ui->id('portFour',5, 'post') : null;
$portFive = ($ui->id('portFive',5, 'post')) ? $ui->id('portFive',5, 'post') : null;
$portStep = ($ui->id('portStep', 4, 'post')) ? $ui->id('portStep',4, 'post') : 100;
$portOne = ($ui->id('portOne', 5, 'post')) ? $ui->id('portOne', 5, 'post') : 27015;
$portTwo = ($ui->id('portTwo', 5, 'post')) ? $ui->id('portTwo', 5, 'post') : null;
$portThree = ($ui->id('portThree', 5, 'post')) ? $ui->id('portThree', 5, 'post') : null;
$portFour = ($ui->id('portFour', 5, 'post')) ? $ui->id('portFour', 5, 'post') : null;
$portFive = ($ui->id('portFive', 5, 'post')) ? $ui->id('portFive', 5, 'post') : null;
$useQueryPort = ($ui->id('useQueryPort', 1, 'post')) ? $ui->id('useQueryPort', 1, 'post') : 1;
$appID = ($ui->id('appID', 19, 'post')) ? $ui->id('appID', 19, 'post') : null;
$protected = ($ui->active('protected', 'post')) ? $ui->active('protected', 'post') : 'N';
$ramLimited = ($ui->active('ramLimited', 'post')) ? $ui->active('ramLimited', 'post') : 'N';
@ -310,6 +311,9 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
if ($node->nodeName == 'os') {
$os = $node->nodeValue;
}
if ($node->nodeName == 'useQueryPort') {
$useQueryPort = $node->nodeValue;
}
}
}
} catch(Exception $error) {
@ -350,6 +354,7 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
$portThree = $row['portThree'];
$portFour = $row['portFour'];
$portFive = $row['portFive'];
$useQueryPort = $row['useQueryPort'];
$protected = $row['protected'];
$iptables = $row['iptables'];
$protectedSaveCFGs = $row['protectedSaveCFGs'];
@ -446,14 +451,14 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
}
$query = $sql->prepare("SELECT `id` FROM `servertypes` WHERE `shorten`=? AND `resellerid`=? LIMIT 1");
$query2 = $sql->prepare("INSERT INTO `servertypes` (`iptables`,`protectedSaveCFGs`,`steamgame`,`updates`,`shorten`,`description`,`type`,`gamebinary`,`gamebinaryWin`,`binarydir`,`modfolder`,`map`,`mapGroup`,`workShop`,`cmd`,`modcmds`,`gameq`,`gamemod`,`gamemod2`,`configs`,`configedit`,`appID`,`portMax`,`portStep`,`portOne`,`portTwo`,`portThree`,`portFour`,`portFive`,`protected`,`ramLimited`,`ftpAccess`,`os`,`resellerid`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$query2 = $sql->prepare("INSERT INTO `servertypes` (`iptables`,`protectedSaveCFGs`,`steamgame`,`updates`,`shorten`,`description`,`type`,`gamebinary`,`gamebinaryWin`,`binarydir`,`modfolder`,`map`,`mapGroup`,`workShop`,`cmd`,`modcmds`,`gameq`,`gamemod`,`gamemod2`,`configs`,`configedit`,`appID`,`portMax`,`portStep`,`portOne`,`portTwo`,`portThree`,`portFour`,`portFive`,`useQueryPort`,`protected`,`ramLimited`,`ftpAccess`,`os`,`resellerid`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
foreach ($resellerInsertIDs as $rID) {
$query->execute(array($shorten, $rID));
if ($query->rowCount() == 0) {
$query2->execute(array($iptables, $protectedSaveCFGs, $steamgame, $updates, $shorten, $description, 'gserver', $gamebinary, $gamebinaryWin,$binarydir, $modfolder, $map, $mapGroup, $workShop, $cmd, $modcmds, $gameq, $gamemod, $gamemod2, $configs, $configedit, $appID, $portMax, $portStep, $portOne, $portTwo, $portThree, $portFour, $portFive, $protected, $ramLimited, $ftpAccess, $os, $rID));
$query2->execute(array($iptables, $protectedSaveCFGs, $steamgame, $updates, $shorten, $description, 'gserver', $gamebinary, $gamebinaryWin, $binarydir, $modfolder, $map, $mapGroup, $workShop, $cmd, $modcmds, $gameq, $gamemod, $gamemod2, $configs, $configedit, $appID, $portMax, $portStep, $portOne, $portTwo, $portThree, $portFour, $portFive, $useQueryPort, $protected, $ramLimited, $ftpAccess, $os, $rID));
$rowCount += $query2->rowCount();
}
@ -464,8 +469,8 @@ if ($ui->w('action', 4, 'post') and !token(true)) {
} else if ($ui->st('action', 'post') == 'md') {
$query = $sql->prepare("UPDATE `servertypes` SET `iptables`=?,`protectedSaveCFGs`=?,`steamgame`=?,`updates`=?,`shorten`=?,`description`=?,`gamebinary`=?,`gamebinaryWin`=?,`binarydir`=?,`modfolder`=?,`map`=?,`mapGroup`=?,`workShop`=?,`cmd`=?,`modcmds`=?,`gameq`=?,`gamemod`=?,`gamemod2`=?,`configs`=?,`configedit`=?,`appID`=?,`portMax`=?,`portStep`=?,`portOne`=?,`portTwo`=?,`portThree`=?,`portFour`=?,`portFive`=?,`protected`=?,`ramLimited`=?,`ftpAccess`=?,`os`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($iptables, $protectedSaveCFGs, $steamgame, $updates, $shorten, $description, $gamebinary, $gamebinaryWin, $binarydir, $modfolder, $map, $mapGroup, $workShop, $cmd, $modcmds, $gameq, $gamemod, $gamemod2, $configs, $configedit, $appID, $portMax, $portStep, $portOne, $portTwo, $portThree, $portFour, $portFive, $protected, $ramLimited, $ftpAccess, $os, $ui->id('id', 10, 'get'), $resellerLockupID));
$query = $sql->prepare("UPDATE `servertypes` SET `iptables`=?,`protectedSaveCFGs`=?,`steamgame`=?,`updates`=?,`shorten`=?,`description`=?,`gamebinary`=?,`gamebinaryWin`=?,`binarydir`=?,`modfolder`=?,`map`=?,`mapGroup`=?,`workShop`=?,`cmd`=?,`modcmds`=?,`gameq`=?,`gamemod`=?,`gamemod2`=?,`configs`=?,`configedit`=?,`appID`=?,`portMax`=?,`portStep`=?,`portOne`=?,`portTwo`=?,`portThree`=?,`portFour`=?,`portFive`=?,`useQueryPort`=?,`protected`=?,`ramLimited`=?,`ftpAccess`=?,`os`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($iptables, $protectedSaveCFGs, $steamgame, $updates, $shorten, $description, $gamebinary, $gamebinaryWin, $binarydir, $modfolder, $map, $mapGroup, $workShop, $cmd, $modcmds, $gameq, $gamemod, $gamemod2, $configs, $configedit, $appID, $portMax, $portStep, $portOne, $portTwo, $portThree, $portFour, $portFive, $useQueryPort, $protected, $ramLimited, $ftpAccess, $os, $ui->id('id', 10, 'get'), $resellerLockupID));
$rowCount = $query->rowCount();
$loguseraction = '%mod% %template% ' . $shorten;

View File

@ -214,6 +214,19 @@
</div>
</div>
<div class="form-group">
<label class="control-label" for="inputUseQueryPort"><?php echo $sprache->useQueryPort;?></label>
<div class="controls">
<select class="form-control" id="inputUseQueryPort" name="useQueryPort">
<option>1</option>
<option <?php if($useQueryPort==2) echo 'selected="selected"'; ?>>2</option>
<option <?php if($useQueryPort==3) echo 'selected="selected"'; ?>>3</option>
<option <?php if($useQueryPort==4) echo 'selected="selected"'; ?>>4</option>
<option <?php if($useQueryPort==5) echo 'selected="selected"'; ?>>5</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label" for="inputPortStep"><?php echo $sprache->portStep;?></label>
<div class="controls"><input class="form-control" id="inputPortStep" type="text" name="portStep" value="<?php echo $portStep;?>"></div>

View File

@ -13,7 +13,7 @@
<div class="col-md-11">
<div class="box box-info">
<form role="form" action="admin.php?w=gs&amp;d=md&amp;id=<?php echo $id;?>&amp;r=im" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post" >
<form role="form" action="admin.php?w=im&amp;d=md&amp;id=<?php echo $id;?>&amp;r=im" 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">
@ -185,6 +185,19 @@
</div>
</div>
<div class="form-group">
<label class="control-label" for="inputUseQueryPort"><?php echo $sprache->useQueryPort;?></label>
<div class="controls">
<select class="form-control" id="inputUseQueryPort" name="useQueryPort">
<option>1</option>
<option <?php if($useQueryPort==2) echo 'selected="selected"'; ?>>2</option>
<option <?php if($useQueryPort==3) echo 'selected="selected"'; ?>>3</option>
<option <?php if($useQueryPort==4) echo 'selected="selected"'; ?>>4</option>
<option <?php if($useQueryPort==5) echo 'selected="selected"'; ?>>5</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label" for="inputPortStep"><?php echo $sprache->portStep;?></label>
<div class="controls"><input class="form-control" id="inputPortStep" type="text" name="portStep" value="<?php echo $portStep;?>"></div>