*/ $User = null; // Inicialização. if (!isset($_SESSION['Id'])) { die; } else { $User = new Utilizador($_SESSION['Id'], $conn); // Depois de estar logado receber toda a informação do utilizador } $Lang = $linguagens[$User->getLinguagem()]; if ($_GET) { if (isset($_GET['Id'])) { /** * Se o servidor não pertencer ao utilizador e o utilizador não for admin então negar acesso a API. */ if (!isServerOwnedById($_GET['Id'], $User->getId()) && !$User->isAdmin()) { die(json_encode(array("Status" => false, "Mensagem" => "Acesso NEGADO!"))); } updateRunningServers($User->getId()); // Update de todos os servidores para com a base de dados antes de fazer alguma ação. # Pedidos de Ação if (isset($_GET['Action']) && isset($_GET['Id'])) { if ($_GET['Action'] == "Start") { iniciarServidor($_GET['Id']); // Iniciar servidor if (isset($_GET['Return'])) { header("Location: ../servidor.php?Id=" . $_GET['Id']); die; } echo json_encode(array("Status" => true, "Id" => $_GET['Id'], "Mensagem" => $Lang['api_servidorIniciado'])); die;
require_once "includes/querys/SourceQuery.class.php"; require_once "lang.php"; if (!isset($_SESSION['Id'])) { header("Location: login.php"); } $User = new Utilizador($_SESSION['Id'], $conn); if ($_GET) { if (!isset($_GET['Id'])) { header("Location: index.php"); die; } $Id = addslashes($_GET['Id']); /** * Verificar se o utilizador e dono do servidor. */ if (!isServerOwnedById($Id, $User->getId())) { // Redirect de pagina caso não seja dono do servidor. header("Location: index.php"); die; } $Servidor = new Servidor($Id, $conn); $Servidor->getInfo(); $Servidor->getFullStatus(); updateRunningServers($User->getId()); } else { header("Location: index.php"); die; } $OldUser = false; if (isset($_SESSION['Old_Id']) && !empty($_SESSION['Old_Id']) && $_SESSION['Id'] != $_SESSION['Old_Id']) { $OldUser = true;