コード例 #1
0
ファイル: utility.php プロジェクト: robinmin/swale
/**
 * log_message : log message
 * @param  string $level   log level
 * @param  string $message message
 * @return None
 */
function log_message($level, $message = '')
{
    $level = strtoupper($level);
    $begin = '';
    $end = '';
    $log = AppServer::get_instance()->get_log_file();
    if (empty($log)) {
        switch ($level) {
            case 'ERROR':
                $begin = "";
                $end = "";
                break;
            case 'INFO':
                $begin = "";
                $end = "";
                break;
            default:
                break;
        }
    }
    $output = $begin . date('m-d H:i:s') . ' @' . getmypid() . ' : [' . $level . '] ' . $message . $end . PHP_EOL;
    if (empty($log)) {
        fwrite(STDERR, $output);
    } else {
        $lock = new swoole_lock(SWOOLE_MUTEX);
        $lock->lock();
        $fp = fopen($log, 'a+');
        fwrite($fp, $output);
        fclose($fp);
        $lock->unlock();
    }
}
コード例 #2
0
ファイル: server.php プロジェクト: robinmin/swale
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
define('SYS_ENV', 'development');
/**
 * SYS_PATH : Path name of the system
 */
if (file_exists(__DIR__ . '/sys')) {
    define('SYS_PATH', __DIR__ . '/sys');
} else {
    define('SYS_PATH', __DIR__ . '/vendor/robinmin/swale/sys');
}
/**
 * APP_PATH : Path name of the current application
 */
define('APP_PATH', __DIR__ . '/apps');
/**
 * Load necessary class definition to start the server
 */
require SYS_PATH . '/core/bootstrap.php';
/**
 * Start the Application server
 */
AppServer::get_instance([])->start();
コード例 #3
0
ファイル: swale_tests.php プロジェクト: robinmin/swale
 public function test_session()
 {
     $app = super_app::get_app();
     $new_val = rand(1, 9999);
     $app->session->set('once', $new_val);
     $domain = AppServer::get_instance()->config->get('session_domain', __METHOD__);
     $test = $app->session->get('once');
     $this->_assert_true($new_val === $test && $new_val === $_SESSION[$domain]['once'], 'Run task');
 }
コード例 #4
0
ファイル: lend.php プロジェクト: nightcore125/developer
 $query = $sql->prepare("INSERT INTO `lendedserver` (`serverid`,`servertype`,`rcon`,`password`,`slots`,`started`,`lendtime`,`lenderip`,`ftpuploadpath`,`resellerid`) VALUES (?,?,?,?,?,NOW(),?,?,AES_ENCRYPT(?,?),?)");
 $query->execute(array($serverid, 'g', $rcon, $password, $slots, $lendtime, $loguserip, $ftpuploadpath, $aeskey, $reseller_id));
 $query = $sql->prepare("INSERT INTO `lendstats` (`lendDate`,`serverID`,`serverType`,`lendtime`,`slots`,`resellerID`) VALUES (NOW(),?,?,?,?,?) ON DUPLICATE KEY UPDATE `resellerID`=`resellerID`");
 $query->execute(array($serverid, 'g', $lendtime, $slots, $reseller_id));
 $query = $sql->prepare("SELECT g.`id`,g.`serverip`,g.`port`,g.`rootID`,t.`description` FROM `gsswitch` g  LEFT JOIN `serverlist` s ON s.`switchID`=g.`id` LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`id`=? AND s.`resellerid`=? LIMIT 1");
 $query->execute(array($serverid, $reseller_id));
 while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
     $serverip = $row['serverip'];
     $port = $row['port'];
     $description = $row['description'];
     $updateID = $row['id'];
     $rootID = $row['rootID'];
 }
 $query = $insert = $sql->prepare("UPDATE `gsswitch` SET `serverid`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
 $query->execute(array($serverid, $updateID, $reseller_id));
 $appServer = new AppServer($rootID);
 $appServer->getAppServerDetails($updateID);
 $appServer->startApp();
 $appServer->execute();
 if (!isset($page_include) and $ui->id('xml', 1, 'post') == 1) {
     $xml = new DOMDocument('1.0', 'utf-8');
     $element = $xml->createElement('startserver');
     $key = $xml->createElement('status', 'started');
     $element->appendChild($key);
     $key = $xml->createElement('ip', $serverip);
     $element->appendChild($key);
     $key = $xml->createElement('port', $port);
     $element->appendChild($key);
     $key = $xml->createElement('slots', $slots);
     $element->appendChild($key);
     $key = $xml->createElement('lendtime', $lendtime);
コード例 #5
0
ファイル: gameserver.php プロジェクト: nightcore125/developer
         } else {
             $template_file = 'admin_404.tpl';
         }
     }
     // Gameserver Restart
 } else {
     if (in_array($ui->st('d', 'get'), array('rs', 'st', 'du')) and $ui->id('id', 10, 'get')) {
         $query = $sql->prepare("SELECT `serverip`,`port`,`rootID` FROM `gsswitch` WHERE `id`=? AND `resellerid`=? LIMIT 1");
         $query->execute(array($id, $resellerLockupID));
         while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
             $gsip = $row['serverip'];
             $port = $row['port'];
             $rootID = $row['rootID'];
         }
         if ($query->rowCount() > 0) {
             $appServer = new AppServer($rootID);
             $appServer->getAppServerDetails($id);
             if ($ui->st('d', 'get') == 'rs') {
                 $appServer->startApp();
                 $template_file = $sprache->serverrestart;
                 $loguseraction = '%start% %gserver% ' . $gsip . ':' . $port;
             } else {
                 if ($ui->st('d', 'get') == 'st') {
                     $appServer->stopApp();
                     $template_file = $sprache->serverstop;
                     $loguseraction = '%stop% %gserver% ' . $gsip . ':' . $port;
                 }
             }
             $return = $appServer->execute();
             if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
                 $template_file .= '<br><pre>' . implode("\r\n", $appServer->debug()) . '</pre>';
コード例 #6
0
ファイル: server_log.php プロジェクト: nightcore125/developer
 *
 * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
 * Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
 */
if (!defined('AJAXINCLUDED')) {
    die('Do not access directly!');
}
if (!isset($resellerLockupID)) {
    $resellerLockupID = $reseller_id;
}
$array = array('lastLog' => 0, 'log' => '');
$query = $sql->prepare("SELECT r.`ip` AS `ftp_ip`,r.`ftpport`,u.`cname`,g.`id`,g.`newlayout`,g.`rootID`,g.`serverip`,g.`port`,g.`protected`,AES_DECRYPT(g.`ftppassword`,?) AS `dftppass`,AES_DECRYPT(g.`ppassword`,?) AS `decryptedftppass`,s.`servertemplate`,t.`binarydir`,t.`shorten` FROM `gsswitch` AS g INNER JOIN `userdata` AS u ON u.`id`=g.`userid` INNER JOIN `rserverdata` AS r ON r.`id`=g.`rootID` INNER JOIN `serverlist` AS s ON g.`serverid`=s.`id` INNER JOIN `servertypes` AS t ON s.`servertype`=t.`id` WHERE g.`id`=? AND g.`userid`=? AND g.`resellerid`=? LIMIT 1");
$query->execute(array($aeskey, $aeskey, $ui->id('id', 10, 'get'), $user_id, $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    if ($ui->escaped('cmd', 'post')) {
        $appServer = new AppServer($row['rootID']);
        $appServer->getAppServerDetails($ui->id('id', 10, 'get'));
        $appServer->shellCommand($ui->escaped('cmd', 'post'));
        $appServer->execute();
    } else {
        $shorten = $row['shorten'];
        $ftppass = $row['dftppass'];
        $username = $row['newlayout'] == 'Y' ? $row['cname'] . '-' . $row['id'] : $row['cname'];
        if ($row['protected'] == 'N' and $row['servertemplate'] > 1) {
            $shorten .= '-' . $row['servertemplate'];
            $pserver = 'server/';
        } else {
            if ($row['protected'] == 'Y') {
                $username .= '-p';
                $ftppass = $row['decryptedftppass'];
                $pserver = '';
コード例 #7
0
ファイル: userpanel_gserver.php プロジェクト: Eun/developer
 } else {
     $updated = false;
 }
 $ftppass = $ui->password('ftppass', 100, 'post');
 if ($ftpAccess == 'Y') {
     $query = $sql->prepare("UPDATE `gsswitch` SET `serverid`=?,`ftppassword`=AES_ENCRYPT(?,?) WHERE `id`=? AND `resellerid`=? LIMIT 1");
     $query->execute(array($switchID, $ftppass, $aeskey, $id, $resellerLockupID));
     $updated = $query->rowCount() > 0 ? true : $updated;
     if (isset($oldID, $switchID, $oldProtected) and $oldID != $switchID and $oldProtected == 'Y') {
         $query = $sql->prepare("UPDATE `gsswitch` SET `protected`='N' WHERE `id`=? AND `resellerid`=? LIMIT 1");
         $query->execute(array($id, $resellerLockupID));
         $updated = $query->rowCount() > 0 ? true : $updated;
     }
 }
 if ($updated) {
     $appServer = new AppServer($rootID);
     $appServer->getAppServerDetails($id);
     if (isset($oldPass, $ftppass) and $ftppass != $oldPass) {
         $appServer->userCud('add');
     }
     if (isset($oldID, $switchID, $oldServerTemplate, $serverTemplate) and ($oldID != $switchID or $oldServerTemplate != $serverTemplate)) {
         $appServer->startApp();
     }
     $loguseraction = '%mod% %gserver% ' . $server;
     $insertlog->execute();
     $template_file = $spracheResponse->table_add;
     $appServer->execute();
     if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
         $template_file .= '<br><pre>' . implode("\r\n", $appServer->debug()) . '</pre>';
     }
 } else {
コード例 #8
0
ファイル: userpanel_fdl.php プロジェクト: Eun/developer
$logreseller = 0;
if (isset($admin_id)) {
    $logsubuser = $admin_id;
} else {
    if (isset($subuser_id)) {
        $logsubuser = $subuser_id;
    } else {
        $logsubuser = 0;
    }
}
if ($ui->st('d', 'get') == 'ud' and $ui->id('id', 10, 'get') and (!isset($_SESSION['sID']) or in_array($ui->id('id', 10, 'get'), $substituteAccess['gs']))) {
    $id = (int) $ui->id('id', 10, 'get');
    $query = $sql->prepare("SELECT g.`rootID`,g.`masterfdl`,g.`mfdldata`,g.`serverip`,g.`port`,u.`fdlpath` FROM `gsswitch` AS g INNER JOIN `userdata` AS u ON g.`userid`=u.`id` WHERE g.`active`='Y' AND g.`id`=? AND g.`resellerid`=? LIMIT 1");
    $query->execute(array($id, $resellerLockupID));
    while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
        $appServer = new AppServer($row['rootID']);
        $appServer->getAppServerDetails($id);
        $appServer->fastDLSync($row['masterfdl'] == 'Y' ? $row['fdlpath'] : $row['mfdldata']);
        $appServer->execute();
        $template_file = $sprache->fdlstarted;
        if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
            $template_file .= '<br><pre>' . implode("\r\n", $appServer->debug()) . '</pre>';
        }
        $loguseraction = '%start% %fastdl% ' . $row['serverip'] . ':' . $row['port'];
        $insertlog->execute();
    }
} else {
    if ($ui->st('d', 'get') == 'es' and $ui->id('id', 10, 'get') and (!isset($_SESSION['sID']) or in_array($ui->id('id', 10, 'get'), $substituteAccess['gs']))) {
        $errors = array();
        $id = (int) $ui->id('id', 10, 'get');
        $masterfdl = $ui->active('masterfdl', 'post');
コード例 #9
0
ファイル: lendserver.php プロジェクト: nightcore125/developer
     while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
         $installedShorten[$row2['shorten']] = $row2['description'];
         if ($row2['id'] == $row['serverid']) {
             $runningGame = $row2['shorten'];
         }
     }
     $query3->execute(array($row['serverid']));
     while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) {
         $lendID = $row3['id'];
         $password = $row3['password'];
         $rcon = $row3['rcon'];
         $slots = $row3['slots'];
         $timeleft = round($row3['lendtime'] - (strtotime($row3['now']) - strtotime($row3['started'])) / 60);
         $time = $timeleft <= 0 ? 0 : $timeleft . '/' . $row3['lendtime'];
         if ($time == 0 or $shutDownEmpty == 'Y' and $row3['lendtime'] - $timeleft > $shutDownEmptyTime and $row['queryNumplayers'] < 1) {
             $appServer = new AppServer($row['rootID']);
             $appServer->getAppServerDetails($row['id']);
             $appServer->stopApp();
             $appServer->execute();
             $deleteQuery->execute(array($row3['id']));
             $lendID = null;
             $time = 0;
         }
         if (!isset($nextfree) or $nextfree > $timeleft) {
             $nextfree = $timeleft;
         }
     }
     $lendGameServers[] = array('id' => $lendID, 'password' => $password, 'rcon' => $rcon, 'ip' => $row['serverip'], 'port' => (int) $row['port'], 'queryName' => htmlentities($row['queryName'], ENT_QUOTES, 'UTF-8'), 'queryMap' => htmlentities($row['queryMap'], ENT_QUOTES, 'UTF-8'), 'runningGame' => $runningGame, 'games' => $installedShorten, 'slots' => (int) $slots, 'usedslots' => (int) $row['queryNumplayers'], 'timeleft' => $time);
 }
 if (!isset($nextfree)) {
     $nextfree = 0;
コード例 #10
0
ファイル: mvc.php プロジェクト: robinmin/swale
 /**
  * __get : get plugin by name for current working process
  * @param  string  $plugin  plugin name
  * @return mixed       plugin instance or false if none can be found
  */
 public function __get($plugin)
 {
     // if can find the plugin in sys_plugin list
     $plgn = AppServer::get_instance()->get_plugin($plugin);
     if ($plgn === false) {
         // if can find the plugin in http_plugin list
         return parent::__get($plugin);
     }
     return $plgn;
 }
コード例 #11
0
ファイル: main.php プロジェクト: dreamsxin/Kellner
        $parts = parse_url($_SERVER["REQUEST_URI"]);
        $_SERVER['QUERY_STRING'] = $parts['query'];
        parse_str($_SERVER['QUERY_STRING'], $_GET);
        $headers = evhttp_request_headers($r);
        // normalize to php way
        foreach ($headers as $name => $value) {
            $_SERVER["HTTP_" . str_replace("-", "_", strtoupper($name))] = $value;
        }
        echo "script-land memory: " . memory_get_usage() . "\n";
    }
    public function processRequest($r)
    {
        try {
            $this->_initRequest($r);
            $response = $this->controller->dispatch();
        } catch (Exception $e) {
            return $e->__toString();
        }
        return evhttp_response_set($response->getBody(), $response->getHttpResponseCode(), "OK");
    }
    public function run()
    {
        event_init();
        $this->httpd = evhttp_start($this->addr, $this->port);
        evhttp_set_gencb($this->httpd, array($this, 'processRequest'));
        echo "Application listening at {$this->addr}:{$this->port}...\n";
        event_dispatch();
    }
}
$app = new AppServer("0.0.0.0", 8080);
$app->run();
コード例 #12
0
ファイル: plugin.php プロジェクト: robinmin/swale
 /**
  * init : init function
  * @return boolean    operation result
  */
 public function init()
 {
     $svr = AppServer::get_instance();
     $option = isset($svr->config['cache']) ? $svr->config['cache'] : array();
     $ssdb = new SSDB\Client(isset($option['ip']) ? $option['ip'] : '127.0.0.1', isset($option['port']) ? $option['port'] : 8888);
     $handler = new SSDBSession\SessionHandler($ssdb);
     session_set_save_handler($handler, true);
     session_start();
 }
コード例 #13
0
             $shortens[] = $row['shorten'] . '-2';
             $shortens[] = $row['shorten'] . '-3';
         }
         $template_file = 'userpanel_gserver_backup_rb.tpl';
     } else {
         if ($ui->w('action', 3, 'post') == 'rb2' and $ui->gamestring('template', 'post') and isset($rootID)) {
             $shortens = array();
             $query = $sql->prepare("SELECT DISTINCT(t.`shorten`) FROM `serverlist` s LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE s.`switchID`=?");
             $query->execute(array($id));
             while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                 $shortens[] = $row['shorten'];
                 $shortens[] = $row['shorten'] . '-2';
                 $shortens[] = $row['shorten'] . '-3';
             }
             if (in_array($ui->gamestring('template', 'post'), $shortens)) {
                 $appServer = new AppServer($rootID);
                 $appServer->getAppServerDetails($id);
                 $appServer->backupDeploy($ui->gamestring('template', 'post'), $ftpUploadString);
                 $appServer->execute();
                 $template_file = $sprache->backup_recover;
                 if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
                     $template_file .= '<br><pre>' . implode("\r\n", $appServer->debug()) . '</pre>';
                 }
             } else {
                 $template_file = 'userpanel_404.tpl';
             }
         } else {
             $template_file = 'userpanel_404.tpl';
         }
     }
 }
コード例 #14
0
ファイル: roots.php プロジェクト: xanzion/developer
     $table = array();
     if ($reseller_id == 0) {
         $query = $sql->prepare("SELECT `id`,`serverip`,`port` FROM `gsswitch` WHERE `rootID`=?");
         $query->execute(array($id));
     } else {
         $query = $sql->prepare("SELECT `id`,`serverip`,`port` FROM `gsswitch` WHERE `rootID`=? AND `resellerid`=?");
         $query->execute(array($id, $resellerLockupID));
     }
     while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
         $table[$row['id']] = array('ip' => $row['serverip'], 'port' => $row['port']);
     }
     $template_file = 'admin_roots_ri.tpl';
 } else {
     if ($ui->st('action', 'post') == 'ri' and $ui->id('serverID', 10, 'post')) {
         include EASYWIDIR . '/stuff/methods/class_app.php';
         $appServer = new AppServer($id);
         $query = $sql->prepare("SELECT t.`shorten` FROM `serverlist` AS s INNER JOIN `servertypes` AS t  ON t.`id`=s.`servertype` WHERE s.`switchID`=?");
         $query2 = $sql->prepare("SELECT g.`serverip`,g.`port`,t.`shorten` FROM `gsswitch` AS g INNER JOIN `serverlist` AS s ON s.`id`=g.`serverid` INNER JOIN `servertypes` AS t ON t.`id`=s.`servertype` WHERE g.`id`=? LIMIT 1");
         foreach ((array) $ui->id('serverID', 10, 'post') as $serverID) {
             $removeTemplates = array();
             $appServer->getAppServerDetails($serverID);
             $appServer->userCud('add');
             $appServer->stopAppHard();
             $query->execute(array($serverID));
             while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                 $removeTemplates[] = $row['shorten'];
                 $removeTemplates[] = $row['shorten'] . '-2';
                 $removeTemplates[] = $row['shorten'] . '-3';
             }
             if (count($removeTemplates) > 0) {
                 $appServer->removeApp($removeTemplates);
コード例 #15
0
ファイル: cloud.php プロジェクト: nightcore125/developer
                 unset($internalUserID, $customer);
                 $query4->execute(array(json_encode(array('I' => $row['importID'])), getParam('belongsToID'), $resellerID));
                 foreach ($query4->fetchAll(PDO::FETCH_ASSOC) as $row2) {
                     $internalUserID = $row2['id'];
                     $customer = $row2['cname'];
                 }
                 if (isset($internalUserID) and isset($customer) and isid($internalUserID, 11)) {
                     $passwordGenerate = passwordgenerate(10);
                     $query5->execute(array($passwordGenerate, $aeskey, $internalUserID, $gameRootIPs[$arrayIP]['id'], getParam('ip'), getParam('port'), getParam('port2'), getParam('slots'), $taskset, $core, getParam('protectionMode'), json_encode(array('I' => $row['importID'])), getParam('externalID'), $resellerID));
                     $switchID = $sql->lastInsertId();
                     $tickrate = getParam('tickrate') > 0 ? getParam('tickrate') : 66;
                     $startMap = strlen(getParam('startMap')) > 0 ? getParam('startMap') : $defaultMap;
                     $query6->execute(array($tickrate, $startMap, $switchID, $servertypeID, $resellerID));
                     $query7->execute(array($sql->lastInsertId(), $switchID));
                     $ftpConnectString = 'ftp://' . str_replace('//', '/', getParam('ip') . ':' . $gameRootIPs[$arrayIP]['ftpPort'] . '/' . getParam('path') . '/' . $servertypeModFolder);
                     $appServer = new AppServer($gameRootIPs[$arrayIP]['id']);
                     $appServer->getAppServerDetails($switchID);
                     $appServer->migrateToEasyWi(array('user' => getParam('ftpUser'), 'password' => getParam('ftpPass'), 'path' => '/' . getParam('path') . '/' . $servertypeModFolder, 'connectString' => $ftpConnectString), getParam('shorten'), $servertypeModFolder);
                     $appServer->execute();
                     printText('Import Gameserver. Address: ' . getParam('ip') . ':' . getParam('port') . '. And shorten:' . getParam('shorten'));
                 } else {
                     printText('Error: Import skipped since no user with external userID ' . getParam('belongsToID') . ' for gameserver with address: ' . getParam('ip') . ':' . getParam('port') . ' and shorten:' . getParam('shorten'));
                 }
             }
         } else {
             printText('Error: No masterserver with the shorten ' . getParam('shorten') . ' found. Gameserver update skipped for address: ' . getParam('ip') . ':' . getParam('port'));
         }
     } else {
         printText('Error: No game rootserver found with the IP ' . getParam('ip') . '. Gameserver not imported: ' . getParam('ip') . ':' . getParam('port') . ' (' . getParam('shorten') . ')');
     }
 }
コード例 #16
0
ファイル: userpanel_ao.php プロジェクト: Eun/developer
}
if (isset($admin_id)) {
    $logsubuser = $admin_id;
} else {
    if (isset($subuser_id)) {
        $logsubuser = $subuser_id;
    } else {
        $logsubuser = 0;
    }
}
if ($ui->id('id', 10, 'get') and $ui->id('adid', 10, 'get') and in_array($ui->st('action', 'get'), array('ad', 'dl')) and (!isset($_SESSION['sID']) or in_array($ui->id('id', 10, 'get'), $substituteAccess['gs']))) {
    $id = (int) $ui->id('id', 10, 'get');
    $addonID = (int) $ui->id('adid', 10, 'get');
    $query = $sql->prepare("SELECT `rootID` FROM `gsswitch` WHERE `id`=? AND `userid`=? AND `resellerid`=? LIMIT 1");
    $query->execute(array($id, $user_id, $resellerLockupID));
    $appServer = new AppServer($query->fetchColumn());
    $appServer->getAppServerDetails($id);
    // Will be false in case no fitting data could be fetched before
    if ($appServer->appServerDetails) {
        $query2 = $sql->prepare("INSERT INTO `addons_installed` (`userid`,`addonid`,`serverid`,`servertemplate`,`paddon`,`resellerid`) VALUES (?,?,?,?,?,?)");
        $query = $sql->prepare("SELECT `addon`,`paddon` FROM `addons` WHERE `id`=? AND `resellerid`=? AND `active`='Y' LIMIT 1");
        $query->execute(array($addonID, $resellerLockupID));
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            $protectedAllowed = $row['paddon'];
            $addonName = $row['addon'];
            if ($ui->st('action', 'get') == 'ad') {
                // Check if the addon is allowed for installing
                if ($appServer->appServerDetails['protectionModeStarted'] == 'N' or $appServer->appServerDetails['protectionModeStarted'] == 'Y' and $protectedAllowed == 'Y') {
                    $query2->execute(array($user_id, $addonID, $appServer->appServerDetails['app']['id'], $appServer->appServerDetails['app']['servertemplate'], $appServer->appServerDetails['protectionModeStarted'], $resellerLockupID));
                    $template_file = $sprache->addon_inst;
                    $actionstatus = 'ok';
コード例 #17
0
ファイル: bootstrap.php プロジェクト: robinmin/swale
 /**
  * get_instance : Get unique object of server
  * @param  array  $config config object
  * @return object   object of server
  */
 public static function get_instance($config = array())
 {
     if (empty(self::$_self)) {
         self::$_self = new AppServer($config);
     }
     return self::$_self;
 }
コード例 #18
0
ファイル: reboot.php プロジェクト: nightcore125/developer
             $connection->CloseConnection();
         }
         usleep(500000);
     }
 }
 $currenttime = strtolower(date('D', strtotime("{$resellerstimezone} hour"))) . '_' . date('G', strtotime("{$resellerstimezone} hour"));
 $query2 = $sql->prepare("SELECT g.`id`,CONCAT(g.`serverip`,':',g.`port`) AS `server`,g.`protected`,AES_DECRYPT(`ftpbackup`,?) AS `backup` FROM `gsswitch` AS g INNER JOIN `userdata` AS u ON u.`id`=g.`userid` WHERE g.`rootID`=? AND g.`active`='Y' AND g.`lendserver`='N' AND g.`stopped`='N' AND u.`active`='Y'");
 $query3 = $sql->prepare("SELECT r.*,s.`id` AS `server_id` FROM `gserver_restarts` AS r INNER JOIN `servertypes` AS t ON t.`shorten`=r.`gsswitch` AND t.`resellerid`=r.`resellerid` INNER JOIN `serverlist` AS s ON s.`servertype`=t.`id` AND s.`switchID`=r.`switchID` WHERE r.`switchID`=? AND r.`restarttime`=? LIMIT 1");
 $query4 = $sql->prepare("UPDATE `gsswitch` SET `serverid`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
 $query5 = $sql->prepare("UPDATE `serverlist` SET `anticheat`=?,`map`=?,`mapGroup`=?,`servertemplate`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
 $query6 = $sql->prepare("UPDATE `gsswitch` SET `ppassword`=AES_ENCRYPT(?,?) WHERE `id`=? LIMIT 1");
 $query = $sql->prepare("SELECT `id`,`resellerid` FROM `rserverdata` WHERE `active`='Y'");
 $query->execute();
 while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
     $resellerLockupID = $row['resellerid'];
     $appServer = new AppServer($row['id']);
     $query2->execute(array($aeskey, $row['id']));
     while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
         $query3->execute(array($row2['id'], $currenttime));
         while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) {
             $query4->execute(array($row3['server_id'], $row3['switchID'], $resellerLockupID));
             $query5->execute(array($row3['anticheat'], $row3['map'], $row3['mapGroup'], $row3['template'], $row3['server_id'], $resellerLockupID));
             $appServer->getAppServerDetails($row3['switchID']);
             if ($row3['restart'] == 'N' and $row3['worldsafe'] == 'Y') {
                 $appServer->mcWorldSave();
                 echo 'MC worldsave: ' . $row2['server'] . "\r\n";
             }
             if ($row3['restart'] == 'N' and $row3['upload'] == 'Y') {
                 $appServer->demoUpload();
                 echo 'Demo upload for: ' . $row2['server'] . "\r\n";
             }
コード例 #19
0
ファイル: statuscheck.php プロジェクト: Eun/developer
                             }
                         }
                     }
                 } else {
                     print "Not Stopping as database leftover: {$address}\r\n";
                 }
             }
         }
         $query = $sql->prepare("UPDATE `gsswitch` SET `queryName`=?,`queryNumplayers`=?,`queryMaxplayers`=?,`queryMap`=?,`queryPassword`=?,`queryUpdatetime`=?,`notified`=? WHERE `id`=? LIMIT 1");
         $query->execute(array($name, $numplayers, $maxplayers, $map, $password, $logdate, $notified, $switchID));
     }
 }
 unset($gq);
 foreach ($startStopList as $resellerLockupID => $rootServer) {
     foreach ($rootServer as $rootID => $actionList) {
         $appServer = new AppServer($rootID);
         foreach ($actionList as $action => $switchIDs) {
             foreach ($switchIDs as $switchID) {
                 $appServer->getAppServerDetails($switchID);
                 if ($action == 'start') {
                     $appServer->startApp();
                 } else {
                     $appServer->stopApp();
                 }
             }
         }
         $appServer->execute();
         if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
             print implode("\r\n", $appServer->debug()) . "\r\n";
         }
     }
コード例 #20
0
ファイル: client.php プロジェクト: robinmin/swale
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
define('SYS_ENV', 'development');
/**
 * SYS_PATH : Path name of the system
 */
if (file_exists(__DIR__ . '/sys')) {
    define('SYS_PATH', __DIR__ . '/sys');
} else {
    define('SYS_PATH', __DIR__ . '/vendor/robinmin/swale/sys');
}
/**
 * APP_PATH : Path name of the current application
 */
define('APP_PATH', __DIR__ . '/apps');
/**
 * Load necessary class definition to start the server
 */
require SYS_PATH . '/core/bootstrap.php';
/**
 * Start the Application server
 */
AppServer::get_instance([])->request($argv);
コード例 #21
0
            if ($ftp->ftpConnection and !$ftp->loggedIn) {
                $error[] = $sprache->ftp_user;
                $error[] = $sprache->ftp_password;
            } else {
                if (!in_array($sprache->ftp_adresse, $error)) {
                    $error[] = $sprache->ftp_adresse;
                }
                if (!in_array($sprache->ftp_port, $error)) {
                    $error[] = $sprache->ftp_port;
                }
            }
        }
        if (count($error) == 0 and isset($rootID)) {
            $ftpConnectString = $ssl == 'N' ? 'ftp://' : 'ftps://';
            $ftpConnectString .= $ftpAddress . ':' . $ftpPort . str_replace(array('//', '///'), '/', '/' . $ftpPath);
            $appServer = new AppServer($rootID);
            $appServer->getAppServerDetails($thisID);
            $appServer->migrateToEasyWi(array('user' => $ftpUser, 'password' => $ftpPassword, 'path' => $ftpPath, 'connectString' => $ftpConnectString), $gameSwitchTemplate, $modFolder);
            $appServer->execute();
            $template_file = $sprache->import_start;
            if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) {
                $template_file .= '<br><pre>' . implode("\r\n", $appServer->debug()) . '</pre>';
            }
            $loguseraction = '%import% %gserver% ' . $address;
            $insertlog->execute();
        }
    }
}
if (!isset($template_file) and isset($customer)) {
    $template_file = 'userpanel_gserver_migration.tpl';
}
コード例 #22
0
 * Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
 */
$query = $sql->prepare("SELECT `hostID`,`resellerID` FROM `jobs` WHERE (`status` IS NULL OR `status`='1') AND `type`='gs' GROUP BY `hostID`");
$query2 = $sql->prepare("SELECT * FROM `jobs` WHERE (`status` IS NULL OR `status`='1') AND `type`='gs' AND `hostID`=?");
$query3 = $sql->prepare("SELECT `serverip`,`port`,`pallowed` FROM `gsswitch` WHERE `id`=? LIMIT 1");
$query4 = $sql->prepare("DELETE FROM `gsswitch` WHERE `id`=? LIMIT 1");
$query5 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? LIMIT 1");
$query6 = $sql->prepare("SELECT t.`shorten` FROM `serverlist` AS s INNER JOIN `servertypes` AS t ON t.`id`=s.`servertype` WHERE s.`switchID`=?");
$query7 = $sql->prepare("UPDATE `gsswitch` SET `serverip`=?,`port`=? WHERE `id`=? LIMIT 1");
$query8 = $sql->prepare("UPDATE `gsswitch` SET `jobPending`='N' WHERE `id`=? LIMIT 1");
$query9 = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `jobID`=? LIMIT 1");
$query->execute();
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    // at web part set within settings.php; here in the job needs to be set on a root by root case
    $resellerLockupID = $row['resellerID'];
    $appServer = new AppServer($row['hostID']);
    $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']));
コード例 #23
0
$logusertype = 'user';
$logreseller = 0;
if (isset($admin_id)) {
    $logsubuser = $admin_id;
} else {
    if (isset($subuser_id)) {
        $logsubuser = $subuser_id;
    } else {
        $logsubuser = 0;
    }
}
$id = $ui->id('id', 10, 'get');
$query = $sql->prepare("SELECT `rootID` FROM `gsswitch` WHERE `id`=? AND `userid`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($id, $user_id, $resellerLockupID));
$rootID = $query->fetchColumn();
$appServer = new AppServer($rootID);
$appServer->getAppServerDetails($id);
if ($query->rowCount() == 0 or !$appServer->appServerDetails or $appServer->appServerDetails['protectionModeAllowed'] == 'N' or isset($_SESSION['sID']) and !in_array($id, $substituteAccess['gs'])) {
    redirect('userpanel.php');
} else {
    if ($rootID > 0) {
        $files = array();
        foreach (explode("\r\n", $appServer->appServerDetails['template']['protectedSaveCFGs']) as $cfg) {
            if ($cfg != '') {
                $files[] = $cfg;
            }
        }
        if ($appServer->appServerDetails['protectionModeStarted'] == 'Y') {
            $protected = 'N';
            $template_file = $sprache->protect . ' ' . $sprache->off2;
            $loguseraction = '%stop% %pmode% ' . $appServer->appServerDetails['serverIP'] . ':' . $appServer->appServerDetails['port'];