} catch (Exception $e) { return false; } } /** * Verificar se tem sessão iniciada */ $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
require_once "__classes/Servidor.class.php"; // Classe Utilizador 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); // Depois de estar logado receber toda a informação do utilizador $User->getInfo(); updateRunningServers($User->getId()); if ($_GET) { if (isset($_GET['Logged'])) { $Logged = $_GET['Logged']; if ($Logged == 1) { $Sucessos[] = $linguagens[$User->getLinguagem()]['sucesso_realizarLoginOutroUser']; } } if (isset($_GET['Option']) && $_GET['Option'] == "Login") { try { $_SESSION['Id'] = $_SESSION['Old_Id']; // Meter Id do utilizar anterior $_SESSION['Old_Id'] = ""; unset($_SESSION['Old_Id']); header("Location: admin.php?Logged=0"); die; } catch (Exception $e) { $Erros[] = $linguagens[$User->getLinguagem()]['erro_realizarLoginOutroUser']; } } }
if ($Acao == "Downgrade") { $UserVer->setTipoUtilizador(0); $UserVer->atualizaInfo(); } } } } } $smarty = new Smarty(); $smarty->debugging = false; $smarty->caching = false; $smarty->cache_lifetime = 0; $smarty->assign("NomeTema", $User->getNomeTema(), true); $smarty->assign("PastaTema", $User->getPastaTema(), true); $smarty->assign("Titulo", "Cyber-Panel", true); $smarty->assign("Zona", $linguagens[$User->getLinguagem()]['zona_administracao'], true); $PercentagemServidores = round(getPercentagem($User->getNumeroServidores(), $User->getNumeroMaxServidores())); if ($OldUser) { $Uti = array("Nome" => utf8_encode($User->getNome()), "Apelido" => utf8_encode($User->getApelido()), "Email" => utf8_encode($User->getEmail()), "Id" => $User->getId(), "IdTema" => $User->getIdTema(), "NomeTema" => $User->getNomeTema(), "NumServidores" => count(getServidoresByIdUtilizador($User->getId())), "MaxServidores" => $User->getNumeroMaxServidores(), "IsAdmin" => $User->isAdmin(), "PercentUsado" => round($PercentagemServidores), "OldUser" => $OldUser, "OldId" => $OldUserC->getId(), "OldNome" => utf8_encode($OldUserC->getNome()), "OldApelido" => utf8_encode($OldUserC->getApelido()), "OldEmail" => utf8_encode($OldUserC->getEmail())); } else { $Uti = array("Nome" => utf8_encode($User->getNome()), "Apelido" => utf8_encode($User->getApelido()), "Email" => utf8_encode($User->getEmail()), "Id" => $User->getId(), "IdTema" => $User->getIdTema(), "NomeTema" => $User->getNomeTema(), "NumServidores" => count(getServidoresByIdUtilizador($User->getId())), "MaxServidores" => $User->getNumeroMaxServidores(), "IsAdmin" => $User->isAdmin(), "PercentUsado" => round($PercentagemServidores), "OldUser" => $OldUser); } $smarty->assign("Utilizador", $Uti); $smarty->assign("Infos", array("NumServidores" => count(getServidoresByIdUtilizador($User->getId())), "NumServidoresOnline" => count(getServidoresByIdUtilizadorAndStatus($User->getId(), 1)), "NumServidoresOffline" => count(getServidoresByIdUtilizadorAndStatus($User->getId(), 0)), "NumSlotsOcupados" => $slotsOcupados)); $smarty->assign("TiposServidores", getAllTiposServidores()); $smarty->assign("Servidores", getServidoresByIdUtilizador($User->getId())); $smarty->assign("Lang", $linguagens[$User->getLinguagem()]); $smarty->assign("LangKey", $User->getLinguagem()); $smarty->assign("Langs", getLangKeys()); $smarty->assign("hasErros", $hasErros); $smarty->assign("hasSucessos", $hasSucessos);
require_once "__classes/Servidor.class.php"; // Classe Utilizador 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); // Depois de estar logado receber toda a informação do utilizador $User->getInfo(); updateRunningServers($User->getId()); if ($_GET) { if (isset($_GET['Logged'])) { $Logged = $_GET['Logged']; if ($Logged == 1) { $Sucessos[] = $linguagens[$User->getLinguagem()]['alerta_loginRealizado']; } } if (isset($_GET['Option']) && $_GET['Option'] == "Login") { try { $_SESSION['Id'] = $_SESSION['Old_Id']; // Meter Id do utilizar anterior $_SESSION['Old_Id'] = ""; unset($_SESSION['Old_Id']); header("Location: admin.php?Logged=0"); die; } catch (Exception $e) { $Erros[] = $linguagens[$User->getLinguagem()]['alerta_erroAoFazerLogin']; } } }
} else { $slotsOcupados = 0; } $smarty = new Smarty(); if ($OldUser) { $Uti = array("Nome" => utf8_encode($User->getNome()), "Apelido" => utf8_encode($User->getApelido()), "Email" => utf8_encode($User->getEmail()), "Id" => $User->getId(), "IdTema" => $User->getIdTema(), "NomeTema" => $User->getNomeTema(), "IsAdmin" => $User->isAdmin(), "OldUser" => $OldUser, "OldId" => $OldUserC->getId(), "OldNome" => utf8_encode($OldUserC->getNome()), "OldApelido" => utf8_encode($OldUserC->getApelido()), "OldEmail" => utf8_encode($OldUserC->getEmail())); } else { $Uti = array("Nome" => utf8_encode($User->getNome()), "Apelido" => utf8_encode($User->getApelido()), "Email" => utf8_encode($User->getEmail()), "Id" => $User->getId(), "IdTema" => $User->getIdTema(), "NomeTema" => $User->getNomeTema(), "IsAdmin" => $User->isAdmin(), "OldUser" => $OldUser); } $smarty->debugging = false; $smarty->caching = false; $smarty->cache_lifetime = 10; $smarty->assign("NomeTema", utf8_encode($User->getPastaTema()), true); $smarty->assign("PastaTema", utf8_encode($User->getPastaTema()), true); $smarty->assign("Titulo", "Cyber-Panel", true); $smarty->assign("Zona", utf8_encode($linguagens[$User->getLinguagem()]['zona_servidor'] . " :: " . $Servidor->getNomeServidor()), true); $smarty->assign("Utilizador", $Uti); $smarty->assign("Infos", array("NumServidores" => count(getServidoresByIdUtilizador($User->getId())), "NumServidoresOnline" => count(getServidoresByIdUtilizadorAndStatus($User->getId(), 1)), "NumServidoresOffline" => count(getServidoresByIdUtilizadorAndStatus($User->getId(), 0)), "NumSlotsOcupados" => $slotsOcupados)); $smarty->assign("TiposServidores", getAllTiposServidores()); $smarty->assign("Servidores", getServidoresByIdUtilizador($User->getId())); $smarty->assign("Servidor", array("Id" => $Servidor->getId(), "IdUtilizador" => $Servidor->getIdUtilizador(), "TipoServidor" => $Servidor->getTipoServidor(), "NomeTipoServidor" => $Servidor->getNomeTipoServidor(), "NomeServidor" => $Servidor->getNomeServidor(), "Ip" => $Servidor->getIp(), "Porta" => $Servidor->getPorta(), "PortaQuery" => $Servidor->getPortaQuery(), "Mapa" => $Servidor->getMapaAtual(), "MapaDb" => $Servidor->getMapaInicial(), "Motd" => $Servidor->getMotd(), "MaxSlots" => $Servidor->getMaxSlots(), "MaxSlotsDb" => $Servidor->getMaxSlotsDb(), "Slots" => $Servidor->getSlots(), "Jogadores" => $Servidor->getJogadores(), "Instalado" => $Servidor->isInstalado(), "OnlineMode" => $Servidor->getOnlineMode(), "FTP_User" => $Servidor->getFTPUser(), "FTP_Password" => $Servidor->getFTPPassword(), "Status" => $Servidor->getStatus())); $smarty->assign("Lang", $linguagens[$User->getLinguagem()]); $smarty->display($User->getPastaTema() . '/servidor.tpl'); #$smarty->display('Metromega/index.tpl'); ?> <script type="text/javascript"> function Redirect (url) { var ua = navigator.userAgent.toLowerCase(), isIE = ua.indexOf('msie') !== -1, version = parseInt(ua.substr(4, 2), 10);
$User->setIdTema($_POST['ID']); $User->atualizaInfo(); $User->getInfo(); echo json_encode(array("Status" => true, "Result" => "Tema alterado com sucesso!")); die; } else { echo json_encode(array("Status" => false, "Result" => "Erro ao alterar tema!")); die; } } if (isset($_POST['MudarLang']) && isset($_POST['ID'])) { if (getLangById($_POST['ID']) != false) { $User->setLinguagem($_POST['ID']); $User->atualizaInfo(); $User->getInfo(); echo json_encode(array("Status" => true, "ID" => $User->getLinguagem(), "Result" => "Linguagem alterada com sucesso!")); die; } else { echo json_encode(array("Status" => false, "Result" => "Erro ao alterar linguagem!")); die; } echo json_encode(array("Status" => false, "Result" => "Erro ao alterar linguagem!")); die; } } if ($_GET) { if (!isset($_GET['Tipo']) && empty($_GET['Tipo'])) { header("Location: index.php"); die; } $Tipo = addslashes($_GET['Tipo']);
$User->setIdTema($_POST['ID']); $User->atualizaInfo(); $User->getInfo(); echo json_encode(array("Status" => true, "Result" => "Tema alterado com sucesso!")); die; } else { echo json_encode(array("Status" => false, "Result" => "Erro ao alterar tema!")); die; } } if (isset($_POST['MudarLang']) && isset($_POST['ID'])) { if (getLangById($_POST['ID']) != false) { $User->setLinguagem($_POST['ID']); $User->atualizaInfo(); $User->getInfo(); echo json_encode(array("Status" => true, "ID" => $User->getLinguagem(), "Result" => "Linguagem alterada com sucesso!")); die; } else { echo json_encode(array("Status" => false, "Result" => "Erro ao alterar linguagem!")); die; } echo json_encode(array("Status" => false, "Result" => "Erro ao alterar linguagem!")); die; } } if ($_GET) { if (isset($_GET['query'])) { $Resultados = getServidoresByIdUtilizadorAndQuery($User->getId(), $_GET['query']); } else { header("Location: index.php"); die;