public static function checkStartStopServerState()
 {
     $con = Database::getCon();
     $res = $con->query("SELECT * FROM gameserver " . "WHERE status = " . GAMESERVER_STATUS_CHECK_START . " " . "OR status = " . GAMESERVER_STATUS_CHECK_STOP);
     if ($res->num_rows) {
         $d = array();
         while ($row = $res->fetch_assoc()) {
             $gs = new Gameserver($row["id"], $row);
             if ($gs->statusWaitedFree()) {
                 $time = time();
                 $lastUpdate = strtotime($gs->GetData('lastStatusUpdate'));
                 if ($gs->isRunningOnServer()) {
                     echo $gs->getTemplate()->getData("gameName");
                     echo "-Server started stop..";
                     $gs->updateStatus(GAMESERVER_STATUS_RUNNING);
                 } else {
                     echo $gs->getTemplate()->getData("gameName");
                     echo "-Server wasnt started.";
                     $gs->updateStatus(GAMESERVER_STATUS_IDLE);
                 }
             }
         }
         return $d;
     } else {
         return false;
     }
 }
 public function index()
 {
     $options = array("address" => "gameservers.address ASC, gameservers.port ASC", "name" => "gameservers.name ASC", "game" => "games.name ASC", "map" => "gameservers.map ASC", "players" => "gameservers.numplayers DESC, gameservers.maxplayers DESC", "ping" => "gameservers.ping ASC");
     if (isset($_GET['sort']) && array_key_exists($_GET['sort'], $options)) {
         $sortkey = $_GET['sort'];
         $sort = $options[$_GET['sort']];
     } else {
         $sort = $options['name'];
         $sortkey = "name";
     }
     $content = Content::find_by_permalink("servers", false);
     $servers = Gameserver::find_all("gametypes.deleted = false AND gameservers.online = 1", $sort);
     $this->assign("servers", $servers);
     $this->assign("content", $content);
     $this->assign("sort", $sortkey);
     $this->title = "Servers";
     $this->render("gameserver/index.tpl");
 }
Ejemplo n.º 3
0
         Core::addToAdminLog("Admin {$localUsername} ({$localID}) has disabled a gameserver ({$gameName} [{$ip}:{$serverPort}]) (Owner: {$username} #{$userID})");
     } else {
         $page->assign("t_Report", Reporting::error(Utils::buildErrorString($error)));
     }
 } else {
     if ("EnableGameserver" == $do) {
         $error = array();
         // Serverid
         $err = @Utils::checkInput($_POST['gameserverid'], "Gameserver ID", 1, 64, INPUT_TYPE_NUMERIC);
         if (strlen($err) != 0) {
             $error[] = $err;
         } else {
             if (!GameserverManager::existsById($_POST['gameserverid'])) {
                 $error[] = "The given gameserver id doesn't exists.";
             } else {
                 $gameserver = new Gameserver($_POST['gameserverid']);
                 if ($gameserver->getData("status") != GAMESERVER_STATUS_DISABLED) {
                     $error[] = "The given gameserver isn't disabled.";
                 }
             }
         }
         if (count($error) == 0) {
             $page->assign("t_Report", Reporting::success("The gameserver will be enabled soon."));
             $gameserver->enable();
             // Log
             $local = UserManager::getLocalUser();
             $localUsername = $local->getData("username");
             $localID = $local->getData("id");
             $gameName = $gameserver->getTemplate()->getData("gameName");
             $ip = $gameserver->getServer()->getData("ip");
             $user = $gameserver->getUser();
Ejemplo n.º 4
0
<?php

/*
 * WolfPanel (c) 2015 by Fursystems.de (Marcel Kallen)
 * 
 * WolfPanel is licensed under a
 * Creative Commons Attribution-NonCommercial 4.0 International License.
 * 
 * You should have received a copy of the license along with this
 * work. If not, see <http://creativecommons.org/licenses/by-nc/4.0/>. 
 */
include "../core.php";
if (isset($_POST["id"])) {
    // Gameserver ID
    $err = @Utils::checkInput($_POST['id'], "Gameserver ID", 1, 64, INPUT_TYPE_NUMERIC);
    if (strlen($err) != 0) {
        $error[] = $err;
    } else {
        if (!GameserverManager::existsById($_POST['id'])) {
            $error[] = "The given Gameserver doesnt exist.";
        } else {
            $gameserver = new Gameserver($_POST['id']);
            if ($gameserver->getOwnerId() != UserManager::GetLocalUser()->getData("id")) {
                $error[] = "You dont have permission to perform this command";
            } else {
                $smarty->assign("log", "<pre>" . $gameserver->getLatestLog() . "</pre>");
            }
        }
    }
    $smarty->display("ajax/getGameserverLog.tpl");
}
Ejemplo n.º 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     GameserverIp::destroy(Gameserver::findOrFail($id));
     Gameserver::destroy($id);
 }
Ejemplo n.º 6
0
$smarty->assign("page", "Dashboard");
$smarty->assign("pageActive", "userdashboard");
$page = new Page($smarty, "pages/userDashboard.tpl");
if (isset($_GET['do']) || isset($_POST['do'])) {
    $do = isset($_GET['do']) ? $_GET['do'] : $_POST['do'];
    if ("select" == $do) {
        $error = array();
        // Gameserver ID
        $err = @Utils::checkInput($_REQUEST['id'], "Gameserver ID", 1, 64, INPUT_TYPE_NUMERIC);
        if (strlen($err) != 0) {
            $error[] = $err;
        } else {
            if (!GameserverManager::existsById($_REQUEST['id'])) {
                $error[] = "The given Gameserver doesnt exist.";
            } else {
                $gameserver = new Gameserver($_REQUEST['id']);
                if ($gameserver->getOwnerId() != UserManager::GetLocalUser()->getData("id")) {
                    $error[] = "You dont have permission to perform this command";
                } else {
                    UserManager::GetLocalUser()->setSelectedGameserver($gameserver);
                }
            }
        }
        if (count($error) == 0) {
            $page->assign("t_Report", Reporting::Success("The server has been selected."));
            UserManager::GetLocalUser()->setSelectedGameserver($gameserver);
        } else {
            $page->assign("t_Report", Reporting::error(Utils::buildErrorString($error)));
        }
    }
}
Ejemplo n.º 7
0
 * WolfPanel (c) 2015 by Fursystems.de (Marcel Kallen)
 * 
 * WolfPanel is licensed under a
 * Creative Commons Attribution-NonCommercial 4.0 International License.
 * 
 * You should have received a copy of the license along with this
 * work. If not, see <http://creativecommons.org/licenses/by-nc/4.0/>. 
 */
include "../core.php";
if (isset($_GET["id"])) {
    // Gameserver ID
    $err = @Utils::checkInput($_GET['id'], "Gameserver ID", 1, 64, INPUT_TYPE_NUMERIC);
    if (strlen($err) != 0) {
        $error[] = $err;
    } else {
        if (!GameserverManager::existsById($_GET['id'])) {
            $error[] = "The given Gameserver doesnt exist.";
        } else {
            $gameserver = new Gameserver($_GET['id']);
            if ($gameserver->getOwnerId() != UserManager::GetLocalUser()->getData("id")) {
                $error[] = "You dont have permission to perform this command";
            } else {
                $smarty->assign("ip", $gameserver->getPrintIP());
                $smarty->assign("status", $gameserver->getStatusString());
                $smarty->assign("iconFile", $gameserver->getTemplate()->getIconFileURI());
                $smarty->assign("gameName", $gameserver->getTemplate()->getData("gameName"));
            }
        }
    }
    $smarty->display("ajax/getGameserverStatus.tpl");
}
Ejemplo n.º 8
0
 public function postStartAction($gsId)
 {
     $action = Input::get('action');
     $gs = Gameserver::find($gsId);
     $scripts = $gs->game->scripts;
     $host = $gs->ipport->ip->ip . ':8080';
     /** @var Script $script_f */
     $script_f = null;
     foreach ($scripts as $script) {
         if ($script->type == $action) {
             $script_f = $script;
         }
     }
     return Redirect::action('ActionController@getPush')->with('action_data', [$script_f, $host]);
 }
Ejemplo n.º 9
0
 public function execute()
 {
     $done = true;
     if (!$this->_validate()) {
         return $this->delete();
     }
     try {
         switch ($this->getData("type")) {
             case TASK_SERVER_INIT:
                 $err = $this->server->initializeForUse();
                 if (strlen($err) == 0) {
                     Core::addToTaskLog("Server " . $this->getData("serverID") . " has been initialized.");
                 } else {
                     Core::addToTaskLog("Server " . $this->getData("serverID") . " could not be initialized. Reason: {$err}.");
                 }
                 break;
             case TASK_SERVER_UPDATE:
                 $server = new PhysicalServer($this->getData('serverID'));
                 $server->updateServer();
                 Core::addToTaskLog("Server " . $this->getData("serverID") . " has been updated");
                 break;
             case TASK_SERVER_INSTALL_TEMPLATE:
                 if (!PhysicalServerManager::existsById($this->getData("serverID"))) {
                     $this->delete();
                 }
                 if (!TemplateManager::existsById($this->getData("addInfo"))) {
                     $this->delete();
                 }
                 $server = new PhysicalServer($this->getData("serverID"));
                 $template = new Template($this->getData("addInfo"));
                 $template->installOnServer($server);
                 Core::addToTaskLog("Template (" . $template->getData("id") . ", " . $template->getData("gameName") . ") installed on server " . $server->getData("id") . " (" . $server->getData("name") . ")");
                 break;
             case TASK_TEMPLATES_INSTALL_FROM_REMOTE:
                 $template = TemplateManager::loadTemplateByRemote($this->getData("addInfo"));
                 Core::addToTaskLog("Gameserver templated downloaded. (" . $template->getData("gameName") . ")");
                 break;
             case TASK_GAMESERVER_UPDATESETTINGS:
                 if (GameserverManager::existsById($this->getData("addInfo"))) {
                     echo "Updating Config.";
                     $gameserver = new Gameserver($this->getData("addInfo"));
                     $gameserver->settingsUpdateOnServer();
                     $id = $gameserver->getData("id");
                     Core::addToTaskLog("Gameserver settings saved. (ID: {$id})");
                 } else {
                     $id = $this->getData("addInfo");
                     Core::addToTaskLog("Gameserver Install Task couldnt be executed. Gameserver doesnt exist (ID: {$id})", LOGLEVEL_WARNING);
                 }
                 break;
             case TASK_GAMESERVER_INSTALL:
                 if (GameserverManager::existsById($this->getData("addInfo"))) {
                     $gameserver = new Gameserver($this->getData("addInfo"));
                     $gameserver->install();
                     $id = $gameserver->getData("id");
                     Core::addToTaskLog("Gameserver installed. (ID: {$id})");
                 } else {
                     $id = $this->getData("addInfo");
                     Core::addToTaskLog("Gameserver Install Task couldnt be executed. Gameserver doesnt exist (ID: {$id})", LOGLEVEL_WARNING);
                 }
                 break;
             case TASK_GAMESERVER_UNINSTALL:
                 if (GameserverManager::existsById($this->getData("addInfo"))) {
                     $gameserver = new Gameserver($this->getData("addInfo"));
                     $done = $gameserver->delete();
                     $id = $gameserver->getData("id");
                     if ($done) {
                         Core::addToTaskLog("Gameserver deleted. (ID: {$id})");
                     }
                 } else {
                     $id = $this->getData("addInfo");
                     Core::addToTaskLog("Gameserver Install Task couldnt be executed. Gameserver doesnt exist (ID: {$id})", LOGLEVEL_WARNING);
                 }
                 break;
             case TASK_GAMESERVER_START:
                 if (GameserverManager::existsById($this->getData("addInfo"))) {
                     $gameserver = new Gameserver($this->getData("addInfo"));
                     $gameserver->start();
                     $id = $gameserver->getData("id");
                     Core::addToTaskLog("Gameserver started. (ID: {$id})");
                 } else {
                     $id = $this->getData("addInfo");
                     Core::addToTaskLog("Gameserver Install Task couldnt be executed. Gameserver doesnt exist (ID: {$id})", LOGLEVEL_WARNING);
                 }
                 break;
             case TASK_GAMESERVER_STOP:
                 if (GameserverManager::existsById($this->getData("addInfo"))) {
                     $gameserver = new Gameserver($this->getData("addInfo"));
                     $gameserver->stop();
                     $id = $gameserver->getData("id");
                     Core::addToTaskLog("Gameserver stopped. (ID: {$id})");
                 } else {
                     $id = $this->getData("addInfo");
                     Core::addToTaskLog("Gameserver Install Task couldnt be executed. Gameserver doesnt exist (ID: {$id})", LOGLEVEL_WARNING);
                 }
                 break;
             case TASK_GAMESERVER_DISABLE:
                 if (GameserverManager::existsById($this->getData("addInfo"))) {
                     $gameserver = new Gameserver($this->getData("addInfo"));
                     $gameserver->disable();
                     $id = $gameserver->getData("id");
                     Core::addToTaskLog("Gameserver disabled. (ID: {$id})");
                 } else {
                     $id = $this->getData("addInfo");
                     Core::addToTaskLog("Gameserver Install Task couldnt be executed. Gameserver doesnt exist (ID: {$id})", LOGLEVEL_WARNING);
                 }
                 break;
             default:
                 $id = $this->getData("id");
                 Core::addToTaskLog("Task couldnt be executed. Unknown Job. (ID: {$id})", LOGLEVEL_WARNING);
                 $this->delete();
                 return;
         }
         if ($done) {
             $con = Database::getCon();
             $con->query("UPDATE tasks SET done = 1 WHERE id = " . $this->getData("id"));
         }
     } catch (Exception $e) {
         echo "Task couldnt be executed. (ID: " . $this->getData("id") . ") Message: " . $e->getMessage();
         Core::addToTaskLog("Task couldnt be executed. (ID: " . $this->getData("id") . ") Message: " . $e->getMessage(), LOGLEVEL_ERROR);
     }
 }
Ejemplo n.º 10
0
 /**
  * 
  * Returns the current selected gameserver object
  * 
  * @return \Gameserver|null
  */
 public function getSelectedGameserver()
 {
     if (isset($_SESSION["gameserver"]) && $_SESSION["gameserver"] != INVALID_ID) {
         if (GameserverManager::ExistsById($_SESSION["gameserver"])) {
             $gameserver = new Gameserver($_SESSION["gameserver"]);
             if ($gameserver->getOwnerId() == $this->getData("id")) {
                 return $gameserver;
             } else {
                 $_SESSION["gameserver"] = INVALID_ID;
                 return null;
             }
         } else {
             $_SESSION["gameserver"] = INVALID_ID;
             return null;
         }
     } else {
         $_SESSION["gameserver"] = INVALID_ID;
         return null;
     }
 }
Ejemplo n.º 11
0
 /**
  * Get object containing the output data for a single server
  * 
  * @param \SQ\Gameserver $gs 
  * @return \SQ\TemplateHolder Object containing template values
  */
 private static function getServerTemplateData(Gameserver $gs)
 {
     $server = new TemplateHolder();
     $server->online = $gs->isOnline();
     $server->error = $gs->getError();
     $gameId = $gs->getGameId();
     $server->gameId = $gameId;
     $server->gameName = self::cleanOutput(Config::$games[$gameId]['name']);
     $server->gameIcon = self::getGameImageURL($gameId);
     $server->addr = $gs->getAddress();
     $server->link = $gs->getConnectLink();
     $server->name = self::cleanOutput($gs->getName());
     $server->map = self::cleanOutput($gs->getMapName());
     $server->playerCount = $gs->getPlayerCount();
     $server->maxPlayers = $gs->getMaxPlayers();
     $server->players = $gs->getPlayerList();
     if ($server->players !== null) {
         $server->players = array_map(array('self', 'cleanOutput'), $server->players);
     }
     return $server;
 }
Ejemplo n.º 12
0
 /**
  * Get the cache key based on a Gameserver object
  *
  * @param \SQ\Gameserver $server
  * @return string
  */
 private static function getKey(Gameserver $server)
 {
     return 'sq_' . $server->getGameId() . '_' . str_replace(':', '_', $server->getAddress());
 }