* 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");
}