} } $smarty->debugging = false; $smarty->caching = false; $smarty->cache_lifetime = 10; $smarty->assign("NomeTema", $User->getNomeTema(), true); // Nome do Tema $smarty->assign("PastaTema", $User->getPastaTema(), true); // Pasta do Tema $smarty->assign("Titulo", "Cyber-Panel", true); // Titulo do HTML $smarty->assign("Zona", $linguagens[$User->getLinguagem()]['zona_perfil'], true); // Zona em que se encontra $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(), "IsAdmin" => $User->isAdmin(), "NumServidores" => count(getServidoresByIdUtilizador($User->getId())), "MaxServidores" => $User->getNumeroMaxServidores(), "PercentUsado" => round($PercentagemServidores), "Cron" => $User->hasCron(), "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), "Cron" => $User->hasCron(), "OldUser" => $OldUser); } // Passar Dados para Sistema Smarty. $smarty->assign("Utilizador", $Uti); // Informação sobre o utilizador $smarty->assign("Infos", array("NumServidores" => count(getServidoresByIdUtilizador($User->getId())), "NumServidoresOnline" => count(getServidoresByIdUtilizadorAndStatus($User->getId(), 1)), "NumServidoresOffline" => count(getServidoresByIdUtilizadorAndStatus($User->getId(), 0)), "NumSlotsOcupados" => $slotsOcupados)); // Informação adicional $smarty->assign("TiposServidores", getAllTiposServidores()); // Todos os tipos de servidores disponiveis $smarty->assign("Servidores", getServidoresByIdUtilizador($User->getId())); // Todos os servidores do utilizador $smarty->assign("Lang", $linguagens[$User->getLinguagem()]); // Todas as palavras da lingua dele. $smarty->assign("LangKey", $User->getLinguagem());
die; } if ($UserVer == $User) { $UserVerIgual = true; } $total = 0; $Servidores = getServidoresByIdUtilizador($UserVer->getId()); foreach ($Servidores as $Servidor) { $server = new Servidor($Servidor['Id'], $conn); $server->getFullStatus(); // Fazer update aos Status $total += $server->getSlots(); } addInformacaoServidores($Servidores); $slotsOcupados = $total; $smarty->assign("UserVer", array("Nome" => utf8_encode($UserVer->getNome()), "Apelido" => utf8_encode($UserVer->getApelido()), "Email" => utf8_encode($UserVer->getEmail()), "Id" => $UserVer->getId(), "IdTema" => $UserVer->getIdTema(), "NomeTema" => $UserVer->getNomeTema(), "NumServidores" => count(getServidoresByIdUtilizador($UserVer->getId())), "MaxServidores" => $UserVer->getNumeroMaxServidores(), "IsAdmin" => $UserVer->isAdmin(), "SlotsUsados" => $slotsOcupados, "PercentUsado" => round(getPercentagem($UserVer->getNumeroServidores(), $UserVer->getNumeroMaxServidores())))); } } } $smarty->assign("passo1", $passo1); $smarty->assign("passo2", $passo2); $smarty->assign("passo3", $passo3); $smarty->assign("passo4", $passo4); $smarty->assign("Opcao", $opcao); $smarty->assign("UserVerIgual", $UserVerIgual); $smarty->display($User->getPastaTema() . '/admin.tpl'); ?> <style type="text/css"> #FullWidth { width: calc(100% - 12px); /* IE 9,10 , Chrome, Firefox */ width: -webkit-calc(100% - 12px); /*For safari 6.0*/
*/ $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;
$total = 0; $Servidores = getServidoresByIdUtilizador($User->getId()); if (count($Servidores)) { foreach ($Servidores as $Servidors) { $server = new Servidor($Servidors['Id'], $conn); $server->getFullStatus(); // Fazer update aos Status $total += $server->getSlots(); } $slotsOcupados = $total; } 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()));