Exemple #1
0
/**
 *	Retorna Logs de um servidor.
 *	@author João Reis
 *	@return Array
 */
function getServerLogsById($Id)
{
    global $conn;
    $Server = new Servidor($Id, $conn);
    $Server->getInfo();
    if ($Server->getStatus() == 0) {
        return array();
    }
    $output = shell_exec("sudo tmux capture-pane -t {$Id}");
    $output = shell_exec("sudo tmux show-buffer");
    $Linhas = explode("\n", $output);
    $Logs = array();
    foreach ($Linhas as $Linha) {
        $Logs[] = htmlentities($Linha);
    }
    return $Logs;
}
Exemple #2
0
    $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);

	    // Internet Explorer 8 and lower
	    if (isIE && version < 9) {
	        var link = document.createElement('a');
	        link.href = url;
	        document.body.appendChild(link);
Exemple #3
0
/**
 *	@author João Reis
 *	Caso o serviço Tmux seja desligado e/ou a sessão estiver desligada passar para false e/ou true para a base de dados aos respetivos servidores
 *	@param $IdUtilizador
 */
function updateRunningServers($IdUtilizador)
{
    global $conn;
    $Servidores = array();
    $Servidores = getServidoresByIdUtilizador($IdUtilizador);
    $ServersOn = array();
    $ServersOn = getRunningServers();
    foreach ($Servidores as $Servidor) {
        // Atualizar base de dados consuante sessoes do Tmux estiverem ativas ou nao
        $server = new Servidor($Servidor['Id'], $conn);
        $server->getInfo();
        #$server->getFullStatus();
        #$serverUpdate = new Servidor($ServersOn[$]);
        if ($server->getStatus() == true) {
            $Ligado = false;
            if (count($ServersOn)) {
                foreach ($ServersOn as $ServerOn) {
                    if ($ServerOn == $server->getId()) {
                        $Ligado = true;
                        break;
                        // Dar Break ao foreach ServersOn e continuar o Foreach Servidores. o Servidor continua online
                    }
                }
            }
            // Se nao estiver ligado passar para desligado na base de dados
            if (!$Ligado) {
                $server->setStatus(0);
                $server->atualizaInfo();
            }
        } else {
            $Ligado = false;
            if (count($ServersOn)) {
                foreach ($ServersOn as $ServerOn) {
                    if ($ServerOn == $server->getId()) {
                        // Se o servidor esta aqui significa que esta online mas esta offline na base de dados. Passar servidor para online na base de dados
                        $Ligado = true;
                        break;
                    }
                }
            }
            // Se estiver Ligado entao passar para ligado na base de dados
            if ($Ligado) {
                $server->setStatus(1);
                $server->atualizaInfo();
            }
        }
    }
}