diff --git a/web/ajax.php b/web/ajax.php index c7934b9d..e54a0f3f 100644 --- a/web/ajax.php +++ b/web/ajax.php @@ -98,6 +98,72 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { 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']) { + + include(EASYWIDIR . '/stuff/methods/functions_ssh_exec.php'); + include(EASYWIDIR . '/stuff/methods/class_masterserver.php'); + include(EASYWIDIR . '/stuff/keyphrasefile.php'); + + $sprache = getlanguagefile('roots', $user_language, $resellerLockupID); + + $rootServer = new masterServer($ui->id('serverID', 10, 'get'), $aeskey); + + /* + $i = 1; + $gamelist = array(); + $games = explode('_', $ui->username('gamestring', 50, 'get')); + $count = count($games); + $query = $sql->prepare("SELECT `id` FROM `servertypes` WHERE `shorten`=? AND `resellerid`=? LIMIT 1"); + + while ($i < $count) { + + if ($games[$i] != '' and !in_array($games[$i], $gamelist)) { + $gamelist[] = $games[$i]; + $query->execute(array($games[$i], $resellerLockupID)); + $typeID = $query->fetchColumn(); + $rootServer->collectData($typeID, true); + } + + $i++; + }*/ + + $gamelist = array(); + + $query = $sql->prepare("SELECT `shorten` FROM `servertypes` WHERE `id`=? AND `resellerid`=? LIMIT 1"); + foreach($ui->id('masterIDs', 10, 'get') as $masterID) { + + $query->execute(array($masterID, $resellerLockupID)); + + $gameShorten = $query->fetchColumn(); + + if (strlen($gameShorten) > 0) { + + $gamelist[] = $gameShorten; + + $rootServer->collectData($masterID, true); + } + } + + $sshcmd = $rootServer->returnCmds('install', 'all'); + + if ($rootServer->sshcmd === null) { + echo 'Nothing to update/sync!'; + } else { + + if (ssh2_execute('gs', $ui->id('serverID', 10, 'get'), $rootServer->sshcmd) === false) { + echo $sprache->error_root_updatemaster . ' ( ' . implode(', ', $gamelist) . ' )'; + } else { + $rootServer->setUpdating(); + echo $sprache->root_updatemaster . ' ( ' . implode(', ', $gamelist) . ' )'; + } + + if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) { + echo '
' . implode('
', $rootServer->sshcmd); + } + } + 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')) { diff --git a/web/serverallocation.php b/web/serverallocation.php index cd77bec2..02ee2816 100644 --- a/web/serverallocation.php +++ b/web/serverallocation.php @@ -58,16 +58,8 @@ if (!isset($pa) or count($pa)==0 or ((!isset($admin_id) and !isset($user_id)) or $die = true; } -if ($ui->smallletters('w',5, 'get') == 'check') { - $return='bad'; - if ($ui->w('method',40, 'get')) { - $method = $ui->w('method',40, 'get'); - if ($ui->id('length',255, 'get') and $ui->$method('check', $ui->id('length',255, 'get'), 'get')) $return='ok'; - else if ($ui->$method('check', 'get')) $return='ok'; - } - echo $return; +if ($die == true) { -} else if ($die == true) { redirect('login.php'); } else if ($ui->id('id',19, 'get') and $ui->st('d', 'get')=="vs" and ($pa['addvserver'] or $pa['root'])) { @@ -320,56 +312,6 @@ if ($ui->smallletters('w',5, 'get') == 'check') { username('gamestring', 50, 'get') and $ui->id('id',19, 'get') and ($pa['roots'] or $pa['root'])) { - - include(EASYWIDIR . '/stuff/methods/functions_ssh_exec.php'); - include(EASYWIDIR . '/stuff/methods/class_masterserver.php'); - include(EASYWIDIR . '/stuff/keyphrasefile.php'); - - $sprache = getlanguagefile('roots', $user_language, $reseller_id); - - if ($reseller_id != 0 and $admin_id != $reseller_id) { - $reseller_id = $admin_id; - } - - $rootServer = new masterServer($ui->id('id', 10, 'get'), $aeskey); - - $i = 1; - $gamelist = array(); - $games = explode('_', $ui->username('gamestring', 50, 'get')); - $count = count($games); - $query = $sql->prepare("SELECT `id` FROM `servertypes` WHERE `shorten`=? AND `resellerid`=? LIMIT 1"); - - while ($i < $count) { - - if ($games[$i] != '' and !in_array($games[$i], $gamelist)) { - $gamelist[] = $games[$i]; - $query->execute(array($games[$i], $reseller_id)); - $typeID = $query->fetchColumn(); - $rootServer->collectData($typeID, true); - } - - $i++; - } - - $sshcmd = $rootServer->returnCmds('install', 'all'); - - if ($rootServer->sshcmd === null) { - echo 'Nothing to update/sync!'; - } else { - - if (ssh2_execute('gs', $ui->id('id', 10, 'get'), $rootServer->sshcmd) === false) { - echo $sprache->error_root_updatemaster . ' ( ' . implode(', ', $gamelist) . ' )'; - } else { - $rootServer->setUpdating(); - echo $sprache->root_updatemaster . ' ( ' . implode(', ', $gamelist) . ' )'; - } - - if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) { - echo '
' . implode('
', $rootServer->sshcmd); - } - } - } else if (($pa['voiceserver'] or $pa['voiceserver']) and $ui->st('d', 'get')=="vo" and $ui->id('id',19, 'get')) { $sprache = getlanguagefile('voice', $user_language, $reseller_id); diff --git a/web/stuff/admin/masterserver.php b/web/stuff/admin/masterserver.php index 28c6dd70..1df9d754 100644 --- a/web/stuff/admin/masterserver.php +++ b/web/stuff/admin/masterserver.php @@ -208,10 +208,13 @@ if ($ui->w('action', 4, 'post') and !token(true)) { $template_file = 'admin_master_list.tpl'; -} else if ($ui->st('d', 'get') == 'ud' and $ui->smallletters('action', 2, 'post') == 'ud') { +} else if ($ui->st('d', 'get') == 'ud' and $ui->st('action', 'post') == 'ud') { - if (is_object($ui->id('id', 10, 'post')) or is_array($ui->id('id', 10, 'post'))) { - foreach($ui->id('id',19, 'post') as $id) { + $ips = array(); + $ajaxStrings = array(); + + if (is_object($ui->id('serverID', 10, 'post')) or is_array($ui->id('serverID', 10, 'post'))) { + foreach($ui->id('serverID', 10, 'post') as $id) { $query = $sql->prepare("SELECT `ip` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1"); $query->execute(array($id, $resellerLockupID)); foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { @@ -220,70 +223,59 @@ if ($ui->w('action', 4, 'post') and !token(true)) { } } - if ((isset($ips))) { + if (count($ips) > 0) { - $query = $sql->prepare("SELECT s.`shorten` FROM `rservermasterg` r LEFT JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE s.`description`=? AND r.`serverid`=? AND r.`installing`='N' AND r.`resellerid`=?"); - $ajax = ''; - - $htmlExtraInformation['js'][] = $ajax; - $template_file = 'admin_master_ud2.tpl'; } else { - $template_file ='Error: No server selected or the server(s) are already updating'; + $template_file = 'admin_404.tpl'; } - } else { - $table = array(); - $table3 = array(); + $appServer = array(); + $masterList = array(); - $i = 0; - - $query = $sql->prepare("SELECT s.`description`,s.`shorten` FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` " . $where . " GROUP BY s.`description` ORDER BY s.`description` ASC"); - $query->execute(array(':reseller_id' => $resellerLockupID)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - $table[$i]['game'] = array('shorten' => $row['shorten'], 'description' => $row['description']); - $i++; - } - - $i2 = 0; - - $query = $sql->prepare("SELECT d.`id`,d.`ip` FROM `rservermasterg` r INNER JOIN `rserverdata` d ON r.`serverid`=d.`id` INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` " . $where . " GROUP BY d.`id` ASC"); - $query->execute(array(':reseller_id' => $resellerLockupID)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - $table[$i2]['server'] = array('id' => $row['id'], 'ip' => $row['ip']); - $i2++; - } - - $query = $sql->prepare("SELECT s.`shorten` FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE r.`resellerid`=? GROUP BY s.`shorten` ORDER BY s.`shorten` ASC"); + $query = $sql->prepare("SELECT `id`,`ip`,`description` FROM `rserverdata` WHERE `active`='Y' AND `resellerid`=?"); $query->execute(array($resellerLockupID)); foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - $shorten = $row['shorten']; - $table3[] = '' . $shorten . ''; + $appServer[$row['id']] = array('ip' => $row['ip'], 'description' => $row['description']); + } + + $query = $sql->prepare("SELECT `id`,`shorten`,`description` FROM `servertypes` s WHERE `resellerid`=? ORDER BY `description` ASC"); + $query2 = $sql->prepare("SELECT r.`id` FROM `rservermasterg` AS m INNER JOIN `rserverdata` AS r ON r.`id`=m.`serverid` WHERE m.`servertypeid`=?"); + + $query->execute(array($resellerLockupID)); + foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { + + $serverIDs = array(); + + $query2->execute(array($row['id'])); + while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { + $serverIDs[] = $row2['id']; + } + + if (count($serverIDs) > 0) { + $masterList[$row['id']] = array('description' => $row['description'], 'shorten' => $row['shorten'], 'serverIDs' => implode(',', $serverIDs)); + } } $template_file = 'admin_master_ud.tpl'; - } \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_master_ud.tpl b/web/template/adminlte/admin/admin_master_ud.tpl new file mode 100644 index 00000000..0ceecf84 --- /dev/null +++ b/web/template/adminlte/admin/admin_master_ud.tpl @@ -0,0 +1,107 @@ +
+

header_update;?>

+ +
+ +
+
+
+ + + + +
+
+ +
+

appRoot;?>

+
+ +
+ $server){ ?> +
+ + +
+ +
+
+
+ +
+
+ +
+

master;?>

+
+ +
+ $master){ ?> +
+ + +
+ +
+ + +
+
+
+
+
+ \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_master_ud2.tpl b/web/template/adminlte/admin/admin_master_ud2.tpl new file mode 100644 index 00000000..b17cd09b --- /dev/null +++ b/web/template/adminlte/admin/admin_master_ud2.tpl @@ -0,0 +1,47 @@ +
+

header_update;?>

+ +
+ +
+
+ +
+
+ +
+

appRoot;?>

+
+ +
+
+ $ip) { ?> +
+
+
+
+
+
+ +
+
+
+
+
+
+ +