#165: Restart caclendar redirects to dashboard

This commit is contained in:
Ulrich Block 2013-10-28 08:22:25 +01:00
parent c8c876e4a4
commit 5151a4f181

View File

@ -1,4 +1,5 @@
<?php
/**
* File: userpanel_restartcalendar.php.
* Author: Ulrich Block
@ -34,14 +35,20 @@
* 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($user_id) or $main != 1) or (isset($user_id) and !$pa['restart']) or !$ui->id('id',19, 'get')) {
redirect('userpanel.php');
}
$sprache = getlanguagefile('gserver',$user_language,$reseller_id);
if (isset($admin_id) and $reseller_id != 0 and $admin_id != $reseller_id) $reseller_id = $admin_id;
if (!isset($_SESSION['sID']) or in_array($ui->id('id',19, 'get'),$substituteAccess['gs'])) {
$server_id = (int) $ui->id('id',19, 'get');
$sprache = getlanguagefile('gserver', $user_language, $reseller_id);
if (isset($admin_id) and $reseller_id != 0 and $admin_id != $reseller_id) {
$reseller_id = $admin_id;
}
if (!isset($_SESSION['sID']) or in_array($ui->id('id',19, 'get'), $substituteAccess['gs'])) {
$query = $sql->prepare("SELECT g.`serverip`,g.`port`,g.`protected`,s.`anticheat`,g.`pallowed`,g.`eacallowed`,s.`map`,s.`mapGroup`,t.`shorten`,t.`mapGroup` AS `defaultMapGroup` FROM `gsswitch` g LEFT JOIN `serverlist` s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`id`=? AND g.`userid`=? AND g.`resellerid`=? LIMIT 1");
$query->execute(array($ui->id('id',19, 'get'),$user_id,$reseller_id));
$query->execute(array($ui->id('id',19, 'get'), $user_id, $reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$serverip = $row['serverip'];
$port = $row['port'];
@ -58,26 +65,33 @@ if (!isset($_SESSION['sID']) or in_array($ui->id('id',19, 'get'),$substituteAcce
$rowcount = $query->rowcount();
}
if (!isset($rowcount) or $rowcount==0) redirect('userpanel.php');
if (!isset($rowcount) or $rowcount == 0) {
redirect('userpanel.php');
}
if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset($port)) {
$date2 = $ui->gamestring('date', 'post');
$date=explode('_',$date2);
if ($date[0]=="mon") {
$date = explode('_', $date2);
$qstat_array = array();
if ($date[0] == 'mon') {
$day = $sprache->monday;
} else if ($date[0]=="tue") {
} else if ($date[0] == 'tue') {
$day = $sprache->tuesday;
} else if ($date[0]=="wed") {
} else if ($date[0] == 'wed') {
$day = $sprache->wednesday;
} else if ($date[0]=="thu") {
} else if ($date[0] == 'thu') {
$day = $sprache->thursday;
} else if ($date[0]=="fri") {
} else if ($date[0] == 'fri') {
$day = $sprache->friday;
} else if ($date[0]=="sat") {
} else if ($date[0] == 'sat') {
$day = $sprache->saturday;
} else if ($date[0]=="sun") {
} else if ($date[0] == 'sun') {
$day = $sprache->sunday;
}
$hour = $date[1].":00";
$hour = $date[1] . ':00';
$table = array();
$query = $sql->prepare("SELECT `id`,`normal_3`,`normal_4`,`hlds_3`,`hlds_4`,`hlds_5`,`hlds_6` FROM `eac` WHERE `active`='Y' AND `resellerid`=? LIMIT 1");
$query->execute(array($reseller_id));
@ -90,17 +104,21 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$hlds_5 = $row['hlds_5'];
$hlds_6 = $row['hlds_6'];
}
$query = $sql->prepare("SELECT s.`upload`,t.`shorten`,t.`description`,t.`qstat`,t.`mapGroup` FROM `serverlist` s LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`switchID`=? AND s.`resellerid`=? GROUP BY t.`shorten`");
$query->execute(array($ui->id('id',19, 'get'),$reseller_id));
$query->execute(array($ui->id('id',19, 'get'), $reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$shorten = $row['shorten'];
$uploadallowed[] = $row['upload'];
$qstat_array[$shorten] = $row['qstat'];
if (!isset($qstat)) {
$qstat = $row['qstat'];
}
$table[$row['shorten']] = array('shorten' => $shorten,'description' => $row['description'], 'defaultMapGroup' => $row['mapGroup']);
}
$template = '';
$anticheat = '';
$gsswitch = '';
@ -110,7 +128,7 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$worldsafe = 'N';
$upload = '';
$query = $sql->prepare("SELECT * FROM `gserver_restarts` WHERE `restarttime`=? AND `switchID`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($date2,$ui->id('id',19, 'get'),$reseller_id));
$query->execute(array($date2, $ui->id('id',19, 'get'), $reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$template = $row['template'];
$anticheat = $row['anticheat'];
@ -123,7 +141,7 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$backup = $row['backup'];
$worldsafe = $row['worldsafe'];
$qstat = $qstat_array[$gsswitch];
if (in_array('a2s',$qstat_array) and (in_array(2,$uploadallowed) or in_array(3,$uploadallowed))) {
if (in_array('a2s', $qstat_array) and (in_array(2, $uploadallowed) or in_array(3, $uploadallowed))) {
$upload = $row['upload'];
}
}
@ -132,57 +150,66 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
} else {
$style='style="display:none;border-spacing:0px;"';
}
if (!isset($eac) and $eacallowed== 'Y' and $rowcount>0 and ($gsswitch=="css" or $gsswitch=="cod4" or $gsswitch=="cstrike" or $gsswitch=="czero" or $gsswitch=="tf")) {
if ($gsswitch=="cstrike" or $gsswitch=="czero") {
if ($anticheat=="3" and $hlds_3== 'Y') {
if (!isset($eac) and $eacallowed== 'Y' and $rowcount>0 and ($gsswitch == 'css' or $gsswitch == 'cod4' or $gsswitch == 'cstrike' or $gsswitch == 'czero' or $gsswitch == 'tf')) {
if ($gsswitch == 'cstrike' or $gsswitch == 'czero') {
if ($anticheat == 3 and $hlds_3 == 'Y') {
$eac[] = '<option value="3" selected="selected">Easy Anti Cheat</option>';
} else if ($hlds_3== 'Y') {
} else if ($hlds_3 == 'Y') {
$eac[] = '<option value="3">Easy Anti Cheat</option>';
}
if ($anticheat=="4" and $hlds_4== 'Y') {
if ($anticheat == 4 and $hlds_4 == 'Y') {
$eac[] = '<option value="4" selected="selected">Easy Anti Cheat Public</option>';
} else if ($hlds_4== 'Y') {
} else if ($hlds_4 == 'Y') {
$eac[] = '<option value="4">Easy Anti Cheat Public</option>';
}
if ($anticheat=="5" and $hlds_5== 'Y') {
if ($anticheat == 5 and $hlds_5 == 'Y') {
$eac[] = '<option value="5" selected="selected">Easy Anti Cheat 32Bit</option>';
} else if ($hlds_5== 'Y') {
} else if ($hlds_5 == 'Y') {
$eac[] = '<option value="5">Easy Anti Cheat 32Bit</option>';
}
if ($anticheat=="6" and $hlds_6== 'Y') {
if ($anticheat == 6 and $hlds_6 == 'Y') {
$eac[] = '<option value="6" selected="selected">Easy Anti Cheat Public 32Bit</option>';
} else if ($hlds_6== 'Y') {
} else if ($hlds_6 == 'Y') {
$eac[] = '<option value="6">Easy Anti Cheat Public 32Bit</option>';
}
} else {
if ($anticheat=="3" and $normal_3== 'Y') {
if ($anticheat == 3 and $normal_3 == 'Y') {
$eac[] = '<option value="3" selected="selected">Easy Anti Cheat</option>';
} else if ($normal_3== 'Y') {
} else if ($normal_3 == 'Y') {
$eac[] = '<option value="3">Easy Anti Cheat</option>';
}
if ($anticheat=="4" and $normal_4== 'Y') {
if ($anticheat == 4 and $normal_4 == 'Y') {
$eac[] = '<option value="4" selected="selected">Easy Anti Cheat Public</option>';
} else if ($normal_4== 'Y') {
} else if ($normal_4 == 'Y') {
$eac[] = '<option value="4">Easy Anti Cheat Public</option>';
}
}
} else if (!isset($eac)) {
$eac = array();
}
if ($qstat=="a2s" or $qstat=="hla2s") {
$anticheatsoft="Valve Anti Cheat";
} else if ($qstat=="cods") {
$anticheatsoft="Punkbuster";
if ($qstat == 'a2s' or $qstat == 'hla2s') {
$anticheatsoft = 'Valve Anti Cheat';
} else if ($qstat == 'cods') {
$anticheatsoft = 'Punkbuster';
} else {
$anticheatsoft = '';
}
$template_file = "userpanel_gserver_calendar_md.tpl";
$template_file = 'userpanel_gserver_calendar_md.tpl';
} else if ($ui->smallletters('edit2',4, 'post') == 'edit' and $ui->gamestring('date', 'post') and $ui->id('template',1, 'post') and $ui->id('anticheat',1, 'post') and $ui->gamestring('shorten', 'post') and $ui->active('backup', 'post') and $ui->active('restart', 'post') and isset($serverip) and isset($port)) {
$qstat_array = array();
$date = $ui->gamestring('date', 'post');
$template = $ui->id('template',1, 'post');
$anticheat = $ui->id('anticheat',1, 'post');
$gsswitch = $ui->gamestring('shorten', 'post');
$query = $sql->prepare("SELECT `normal_3`,`normal_4`,`hlds_3`,`hlds_4`,`hlds_5`,`hlds_6` FROM `eac` WHERE `active`='Y' AND `resellerid`=? LIMIT 1");
$query->execute(array($reseller_id));
$rowcount = $query->rowCount();
@ -194,26 +221,23 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$hlds_5 = $row['hlds_5'];
$hlds_6 = $row['hlds_6'];
}
if ($ui->active('worldsafe', 'post')) {
$worldsafe = $ui->active('worldsafe', 'post');
} else {
$worldsafe = 'N';
}
if ($ui->active('worldsafe', 'post') and in_array('a2s',$qstat_array) and ($uploadallowed==2 or $uploadallowed==3)) {
$worldsafe = ($ui->active('worldsafe', 'post')) ? $ui->active('worldsafe', 'post') : 'N';
if ($ui->active('worldsafe', 'post') and in_array('a2s', $qstat_array) and ($uploadallowed == 2 or $uploadallowed == 3)) {
$worldsafe = $ui->post['worldsafe'];
} else {
$worldsafe = 'N';
}
if ($anticheat>2) {
if ($gsswitch=="cstrike" or $gsswitch=="czero") {
if ($anticheat==3 and $hlds_3== 'N' and $hlds_5== 'Y') {
if ($gsswitch == 'cstrike' or $gsswitch == 'czero') {
if ($anticheat==3 and $hlds_3== 'N' and $hlds_5 == 'Y') {
$anticheat = 5;
} else if ($anticheat==3 and $hlds_3== 'N' and $hlds_5== 'N') {
$anticheat = 1;
} else {
$anticheat = 1;
}
if ($anticheat==4 and $hlds_4== 'N' and $hlds_6== 'Y') {
if ($anticheat==4 and $hlds_4== 'N' and $hlds_6 == 'Y') {
$anticheat = 6;
} else if ($anticheat==4 and $hlds_4== 'N' and $hlds_6== 'N') {
$anticheat = 1;
@ -249,20 +273,20 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$stvupload = 'N';
}
$query = $sql->prepare("SELECT `id` FROM `gserver_restarts` WHERE `restarttime`=? AND `switchID`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($date,$ui->id('id',19, 'get'),$reseller_id));
$query->execute(array($date, $ui->id('id',19, 'get'), $reseller_id));
$rowcount = $query->rowCount();
if ($rowcount==0) {
$pupdate = $sql->prepare("INSERT INTO `gserver_restarts` (`template`,`anticheat`,`protected`,`restarttime`,`gsswitch`,`map`,`mapGroup`,`restart`,`backup`,`worldsafe`,`upload`,`switchID`,`userid`,`resellerid`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$pupdate->execute(array($template,$anticheat,$protected,$date,$gsswitch,$map,$ui->mapname('mapGroup', 'post'),$restart,$backup,$worldsafe,$stvupload,$ui->id('id',19, 'get'),$user_id,$reseller_id));
$pupdate->execute(array($template, $anticheat, $protected, $date, $gsswitch, $map, $ui->mapname('mapGroup', 'post'), $restart, $backup, $worldsafe, $stvupload, $ui->id('id',19, 'get'), $user_id, $reseller_id));
} else {
$pupdate = $sql->prepare("UPDATE `gserver_restarts` SET `template`=?,`anticheat`=?,`protected`=?,`gsswitch`=?,`map`=?,`mapGroup`=?,`restart`=?,`backup`=?,`worldsafe`=?,`upload`=? WHERE `restarttime`=? AND `switchID`=? AND `userid`=? AND `resellerid`=? LIMIT 1");
$pupdate->execute(array($template,$anticheat,$protected,$gsswitch,$map,$ui->mapname('mapGroup', 'post'),$restart,$backup,$worldsafe,$stvupload,$date,$ui->id('id',19, 'get'),$user_id,$reseller_id));
$pupdate->execute(array($template, $anticheat, $protected, $gsswitch, $map, $ui->mapname('mapGroup', 'post'), $restart, $backup, $worldsafe, $stvupload, $date, $ui->id('id',19, 'get'), $user_id, $reseller_id));
}
$template_file = $spracheResponse->table_add;
} else if ($ui->smallletters('delete',6, 'post') == 'delete' and $ui->gamestring('date', 'post') and isset($serverip) and isset($port)) {
$date = $ui->gamestring('date', 'post');
$pdelete = $sql->prepare("DELETE FROM `gserver_restarts` WHERE `restarttime`=? AND `switchID`=? AND `resellerid`=? LIMIT 1");
$pdelete->execute(array($date,$ui->id('id',19, 'get'),$reseller_id));
$pdelete->execute(array($date, $ui->id('id',19, 'get'), $reseller_id));
$template_file = $spracheResponse->table_del;;
} else if (isset($serverip) and isset($port)){
$i = 0;
@ -271,14 +295,14 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$i++;
}
$query = $sql->prepare("SELECT t.`shorten`,t.`qstat` FROM `serverlist` s LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`switchID`=? AND s.`resellerid`=? GROUP BY t.`shorten`");
$query->execute(array($ui->id('id',19, 'get'),$reseller_id));
$query->execute(array($ui->id('id',19, 'get'), $reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$shorten = $row['shorten'];
$qstat_array[$shorten] = $row['qstat'];
}
$backup = 'N';
$query = $sql->prepare("SELECT `template`,`restarttime`,`gsswitch`,`anticheat`,`map`,`restart`,`backup`,`worldsafe`,`upload` FROM `gserver_restarts` WHERE `switchID`=? AND `resellerid`=?");
$query->execute(array($ui->id('id',19, 'get'),$reseller_id));
$query->execute(array($ui->id('id',19, 'get'), $reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$restarttime=explode("_", $row['restarttime']);
$day = $restarttime[0];
@ -294,9 +318,9 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
} else {
$qstat = '';
}
if (isset($qstat) and $qstat=="a2s" or $qstat=="hla2s") {
if (isset($qstat) and $qstat == 'a2s' or $qstat == 'hla2s') {
$anticheatsoft="VAC";
} else if (isset($qstat) and $qstat=="cods") {
} else if (isset($qstat) and $qstat == 'cods') {
$anticheatsoft="PBuster";
} else {
$anticheatsoft = '';
@ -345,5 +369,5 @@ if ($ui->smallletters('edit',4, 'post') == 'edit' and isset($serverip) and isset
$restarts[$hour][$day] = array('out' => $routput);
}
}
$template_file = "userpanel_gserver_calendar_list.tpl";
$template_file = 'userpanel_gserver_calendar_list.tpl';
}