示例#1
0
                 while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                     $query2->execute(array($id, $resellerUpdateId));
                     $query3->execute(array($admin_id, $row['id'], $row['id'], $row['cname'], json_encode(array('newActive' => $useractive)), $id));
                     updateJobs($row['id'], $resellerUpdateId);
                 }
             }
             $query = $sql->prepare("UPDATE `resellerdata` SET `useractive`=?,`maxuser`=?,`maxgserver`=?,`maxvoserver`=?,`maxdedis`=?,`maxvserver`=?,`maxuserram`=?,`maxusermhz`=? WHERE `resellerid`=? LIMIT 1");
             $query->execute(array($useractive, $maxuser, $maxgserver, $maxvoserver, $maxdedis, $maxvserver, $maxuserram, $maxusermhz, $id));
         }
         $loguseraction = '%mod% %user% ' . $cname;
     }
 }
 $query = $sql->prepare("INSERT INTO `easywi_statistics_current` (`userID`) VALUES (?) ON DUPLICATE KEY UPDATE `userID`=VALUES(`userID`)");
 $query->execute(array($accountType == 'a' ? 0 : $id));
 $rowCount += $query->rowCount();
 customColumns('U', $id, 'save');
 $notIn = (is_array($userGroups) and count($userGroups) > 0) ? 'AND `groupID` NOT IN (' . implode(',', $userGroups) . ')' : '';
 $query = $sql->prepare("DELETE FROM `userdata_groups` WHERE `userID`=? AND `resellerID`=? " . $notIn);
 $query->execute(array($id, $resellerLockupID));
 $rowCount += $query->rowCount();
 $query = $sql->prepare("INSERT INTO `userdata_groups` (`userID`,`groupID`,`resellerID`) VALUES (?,?,?) ON DUPLICATE KEY UPDATE `groupID`=VALUES(`groupID`)");
 foreach ($userGroups as $gid) {
     if (isset($groups[$accountType][$gid])) {
         if ($accountType == 'r' and $reseller_id == 0) {
             $query->execute(array($id, $gid, $id));
         } else {
             $query->execute(array($id, $gid, $resellerLockupID));
         }
         $rowCount += $query->rowCount();
     }
 }
示例#2
0
 $query2->execute(array($row['hostID']));
 while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
     $appServer->getAppServerDetails($row2['affectedID']);
     $extraData = @json_decode($row2['extraData']);
     $query3->execute(array($row2['affectedID']));
     while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) {
         $gsIP = $row3['serverip'];
         $port = $row3['port'];
         $protectedAllowed = $row3['pallowed'];
     }
     if ($query3->rowCount() > 0) {
         if ($row2['action'] == 'dl') {
             $appServer->stopAppHard();
             $appServer->userCud('del', 'both');
             $query4->execute(array($row2['affectedID']));
             customColumns('G', $row2['affectedID'], 'del');
             $query5->execute(array($row2['jobID']));
             $command = $gsprache->del . ' gsswitchID: ' . $row2['affectedID'] . ' name:' . $row2['name'] . ' gsswitchID:' . $row2['affectedID'];
         } else {
             if ($row2['action'] == 'ad' or $row2['action'] == 'md' and is_object($extraData)) {
                 $installGames = (is_object($extraData) and property_exists($extraData, 'installGames') and preg_match('/[APN]/', $extraData->installGames)) ? $extraData->installGames : 'N';
                 // userCrud will set the user to inactive
                 $appServer->userCud('add');
                 $appServer->setQuota();
                 if ($row2['action'] == 'ad') {
                     if ($installGames == 'P') {
                         $appServer->addApp(array(), true);
                     } else {
                         if ($installGames == 'A') {
                             $templates = array();
                             $query6->execute(array($row2['affectedID']));
示例#3
0
 private function generateStartCommand()
 {
     $gameType = $this->getGameType();
     // https://github.com/easy-wi/developer/issues/205
     // In case Workshop is on we need to remove mapgroup
     $startCommand = $this->appServerDetails['app']['workShop'] == 'Y' ? str_replace(array('%mapgroup%', ' +mapgroup'), '', $this->appServerDetails['app']['cmd']) : $this->appServerDetails['app']['cmd'];
     // In case of hl2 based servers and no TV allowed, turn off the source tv capabilities
     if ($gameType == 'hl2' and $this->appServerDetails['tvAllowed'] == 'N') {
         $startCommand .= ' -nohltv -tvdisable';
     }
     // If the user decided to use EAC instead of VAC, or turned VAC off on porpuse
     if (($gameType == 'hl1' or $gameType == 'hl2') and ($this->appServerDetails['app']['anticheat'] == 2 or $this->appServerDetails['app']['anticheat'] > 2 and $this->appServerDetails['eacAllowed'] == 'Y')) {
         $startCommand .= ' -insecure';
     }
     // Mod commands are typically used at CS:GO, COD and so and load build in modifications like arms race
     $modCommand = $this->appServerDetails['app']['modcmd'];
     foreach (explode("\r\n", $this->appServerDetails['template']['modcmds']) as $line) {
         if (preg_match('/^(\\[[\\w\\/\\.\\-\\_\\= ]{1,}\\])$/', $line)) {
             $exploded = preg_split("/\\=/", trim($line, '[]'), -1, PREG_SPLIT_NO_EMPTY);
             $name = trim($exploded[0]);
             // This construction appears redundant, but is required as a fallback in case there was an issue in the DB and at least one mod command is required
             if (isset($exploded[1]) and trim($exploded[1]) == 'default' and ($modCommand === null or $modCommand == '')) {
                 $modCommand = trim($exploded[0]);
             }
             if (!isset($modsCmds[$name])) {
                 $modsCmds[$name] = array();
             }
         } else {
             if (isset($name) and isset($modsCmds[$name]) and $line != '') {
                 $modsCmds[$name][] = $line;
             }
         }
     }
     if (isset($modsCmds[$modCommand]) and is_array($modsCmds[$modCommand])) {
         foreach ($modsCmds[$modCommand] as $singleModADD) {
             $startCommand .= ' ' . $singleModADD;
         }
     }
     // Steam Workshop support
     if ($this->appServerDetails['app']['workShop'] == 'Y' and strlen($this->appServerDetails['app']['webApiAuthKey']) > 0 and strlen($this->appServerDetails['app']['workshopCollection']) > 0) {
         if (in_array($this->appServerDetails['template']['shorten'], array('gmod', 'garrysmod'))) {
             $startCommand .= ' -nodefaultmap +host_workshop_collection ' . $this->appServerDetails['app']['workshopCollection'] . ' -authkey ' . $this->appServerDetails['app']['webApiAuthKey'];
         } else {
             $startCommand .= ' -nodefaultmap +host_workshop_collection ' . $this->appServerDetails['app']['workshopCollection'] . ' +workshop_start_map ' . $this->appServerDetails['app']['map'] . ' -authkey ' . $this->appServerDetails['app']['webApiAuthKey'];
             $startCommand = preg_replace('/[\\s\\s+]{1,}\\+map[\\s\\s+]{1,}[\\w-_!%]{1,}/', '', $startCommand);
         }
     }
     if ($this->appServerDetails['lendServer'] == 'Y') {
         $lendDetails = $this->getLendDetails();
         if (!is_array($lendDetails)) {
             $startCommand .= $this->getLendDetails();
         }
     }
     // Add addon commands
     if (isset($this->appServerDetails['extensions']['cmds']) and count($this->appServerDetails['extensions']['cmds']) > 0) {
         $startCommand .= implode('', $this->appServerDetails['extensions']['cmds']);
     }
     // Remove what needs to be removed according to installed addons
     if (isset($this->appServerDetails['extensions']['removeCmds']) and count($this->appServerDetails['extensions']['removeCmds']) > 0) {
         foreach ($this->appServerDetails['extensions']['removeCmds'] as $removeCommand) {
             $startCommand = str_replace($removeCommand, '', $startCommand);
         }
     }
     $replaceSettings = $this->getReplacements();
     $startCommand = str_replace($replaceSettings['placeholder'], $replaceSettings['replacePlaceholderWith'], $startCommand);
     foreach (customColumns('G', $this->appServerDetails['id']) as $customColumn) {
         $startCommand = str_replace("%{$customColumn['name']}%", $customColumn['value'], $startCommand);
     }
     //If a template is set up for both OS, we might need to alter the start of the command
     if ($this->appMasterServerDetails['os'] == 'W') {
         if (substr($startCommand, 0, 2) == './') {
             $startCommand = substr($startCommand, 3);
         }
         if (substr($startCommand, 0, 1) == '.') {
             $startCommand = substr($startCommand, 2);
         }
         $shellCommand = '';
     } else {
         $shellCommand = ($this->appServerDetails['useTaskSet'] == 'Y' and strlen($this->appServerDetails['cores']) > 0) ? 'taskset -c ' . $this->appServerDetails['cores'] : '';
         $shellCommand .= ' screen -A -m -d -L -S ' . $this->appServerDetails['serverIP'] . '_' . $this->appServerDetails['port'] . ' ' . $startCommand;
     }
     return $shellCommand;
 }
示例#4
0
$query = $sql->prepare("INSERT INTO `jobs` (`action`,`date`,`status`,`api`,`type`,`affectedID`,`name`,`hostID`,`userID`,`extraData`,`resellerID`) VALUES ('rp',NOW(),NULL,'J',?,?,?,?,?,?,?)");
$query2 = $sql->prepare("UPDATE `virtualcontainer` SET `imageid`=? WHERE `id`=? LIMIT 1");
$query3 = $sql->prepare("UPDATE `rootsDedicated` SET `imageID`=? WHERE `dedicatedID`=? LIMIT 1");
foreach ($res as $row) {
    if (isset($row['type'])) {
        $query->execute(array($row['type'], $row['affectedID'], $row['name'], $row['hostID'], $row['userID'], json_encode($row['extraData']), $row['resellerID']));
        if ($row['type'] == 'de') {
            $query2->execute(array($row['imageID'], $row['affectedID']));
        } else {
            $query3->execute(array($row['imageID'], $row['affectedID']));
        }
    }
}
print "\r\nApplying DHCPchanges\r\n";
$rootObject->dhcpFiles();
print "\r\n(Re)starting/Stopping dedicated server\r\n";
#$rootObject->startStop();
print "\r\nAdding, Altering, Removing, (Re)starting and Stopping VMWare Virtual Container\r\n";
#$rootObject->VMWare();
print "\r\nRemoving VMWare Virtual Container/Dedicated Server from DB \r\n";
$query = $sql->prepare("DELETE FROM `rootsDedicated` WHERE `dedicatedID`=? LIMIT 1");
foreach ($removeIDs['de'] as $id) {
    customColumns('G', $id, 'del');
    $query->execute(array($id));
}
$query = $sql->prepare("DELETE FROM `virtualcontainer` WHERE `id`=? LIMIT 1");
foreach ($removeIDs['vs'] as $id) {
    customColumns('V', $id, 'del');
    $query->execute(array($id));
}
$rootObject = null;
示例#5
0
    $element->appendChild($key);
    $key = $responsexml->createElement('installGames', $installGames);
    $element->appendChild($key);
    $key = $responsexml->createElement('autoRestart', $autoRestart);
    $element->appendChild($key);
    $key = $responsexml->createElement('ftpUser', $ftpUser);
    $element->appendChild($key);
    $key = $responsexml->createElement('errors', $errors);
    $element->appendChild($key);
    if (isset($shorten) and is_array($shorten)) {
        foreach ($shorten as $short) {
            $key = $responsexml->createElement('shorten', $short);
            $element->appendChild($key);
        }
    }
    foreach (customColumns('G', $customID) as $row) {
        $key = $responsexml->createElement($row['name'], $row['value']);
        $element->appendChild($key);
    }
    $responsexml->appendChild($element);
    $responsexml->formatOutput = true;
    echo $responsexml->saveXML();
} else {
    if ($apiType == 'json' and !isset($list)) {
        header("Content-type: application/json; charset=UTF-8");
        echo json_encode(array('action' => $action, 'private' => $private, 'active' => $active, 'identify_server_by' => $identifyServerBy, 'shorten' => $shorten, 'slots' => $slots, 'server_external_id' => $externalServerID, 'server_local_id' => $localServerID, 'identify_user_by' => $identifyUserBy, 'user_localid' => $localUserID, 'user_externalid' => $externalUserID, 'username' => $username, 'errors' => $errors));
    } else {
        if (!isset($list)) {
            header('HTTP/1.1 403 Forbidden');
            die('403 Forbidden');
        }
示例#6
0
         $query3->execute(array($row['affectedID']));
         if ($row2['accounttype'] == 'r') {
             if ($row2['resellerid'] == $row['affectedID']) {
                 $query3 = $sql->prepare("UPDATE `rootsIP4` SET `ownerID`=0,`resellerID`=0 WHERE `resellerID`=?");
                 $query3->execute(array($row['affectedID']));
             }
             removeUser($row['affectedID'], array('userdata' => 'id', 'userpermissions' => 'userid'));
             $tables = array('addons' => 'resellerid', 'addons_installed' => 'resellerid', 'addons_allowed' => 'reseller_id', 'gsswitch' => 'resellerid', 'rserverdata' => 'resellerid', 'rservermasterg' => 'resellerid', 'serverlist' => 'resellerid', 'servertypes' => 'resellerid', 'settings' => 'resellerid', 'tickets' => 'resellerid', 'ticket_topics' => 'resellerid', 'userdata' => 'resellerid', 'userpermissions' => 'resellerid', 'userlog' => 'resellerid', 'resellerdata' => 'resellerid', 'gserver_restarts' => 'resellerid', 'eac' => 'resellerid', 'imprints' => 'resellerid', 'lendedserver' => 'resellerid', 'lendsettings' => 'resellerid', 'lendstats' => 'resellerID', 'voice_server' => 'resellerid', 'voice_masterserver' => 'resellerid', 'translations' => 'resellerID', 'voice_server_stats' => 'resellerid', 'mysql_external_servers' => 'resellerid', 'mysql_external_dbs' => 'resellerid', 'usergroups' => 'resellerid', 'api_ips' => 'resellerID', 'api_settings' => 'resellerID', 'voice_tsdns' => 'resellerid', 'voice_dns' => 'resellerID');
             removeUser($row['affectedID'], $tables);
             if ($row2['resellerid'] == $row['affectedID']) {
                 removeUser($row['affectedID'], array('traffic_data' => 'userid', 'traffic_data_day' => 'userid'));
                 removeUser($row['affectedID'], array('traffic_data' => 'resellerid', 'traffic_data_day' => 'resellerid'));
             }
         }
     }
     customColumns('U', $row['affectedID'], 'del');
     $query2 = $sql->prepare("DELETE FROM `userdata` WHERE `id`=? LIMIT 1");
     $query2->execute(array($row['affectedID']));
     $command = $gsprache->del . ' userID: ' . $row['affectedID'] . ' name:' . $row['name'];
 } else {
     $extraData = @json_decode($row['extraData']);
     if (is_object($extraData)) {
         $query2 = $sql->prepare("UPDATE `userdata` SET `active`=?,`jobPending`='N' WHERE `id`=? LIMIT 1");
         $query2->execute(array($extraData->newActive, $row['affectedID']));
         $command = $gsprache->mod . ' userID: ' . $row['affectedID'] . ' name:' . $row['name'];
     } else {
         $ok = false;
         $command = 'Error: ' . $gsprache->mod . ' userID: ' . $row['affectedID'] . ' name:' . $row['name'];
     }
 }
 if ($ok == true) {
示例#7
0
     $bitversion = $row2['bitversion'];
 }
 $query3->execute(array($row['hostID']));
 while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) {
     $query4->execute(array($row3['affectedID'], $row3['resellerID']));
     while ($row4 = $query4->fetch(PDO::FETCH_ASSOC)) {
         $active = $row4['active'];
         $ipArray = array($row4['ip']);
         $portArray = array($row4['port']);
         $dnsArray = array($row4['dns']);
         $dnsAction = 'md';
         if ($row3['action'] == 'dl') {
             $dnsAction = 'dl';
             $command = $gsprache->del . ' TS DNS ID: ' . $row3['affectedID'] . ' name:' . $row4['dns'];
             $query5->execute(array($row3['affectedID'], $row['resellerID']));
             customColumns('T', $row3['affectedID'], 'del');
         } else {
             if ($row3['action'] == 'ad') {
                 $command = $gsprache->add . ' TS DNS ID: ' . $row3['affectedID'] . ' name:' . $row4['dns'];
             } else {
                 if ($row3['action'] == 'md') {
                     $extraData = @json_decode($row3['extraData']);
                     if (is_object($extraData) and isset($extraData->newActive)) {
                         $active = $extraData->newActive;
                     }
                     $command = $gsprache->mod . ' TS DNS ID: ' . $row3['affectedID'] . ' name:' . $row4['dns'];
                     if ($active == 'N') {
                         $dnsAction = 'dl';
                     } else {
                         if ($active == 'Y' and isset($oldip) and ($row4['ip'] != $oldip or $row4['port'] != $oldport or $row4['dns'] != $olddns)) {
                             $ipArray = array($row4['ip'], $oldip);