Esempio n. 1
0
             echo json_encode(array("Status" => true, "Ram" => number_format((double) get_server_memory_usage(), 2, '.', ''), "Cpu" => number_format((double) get_server_cpu_usage(), 2, '.', ''), "Disco" => number_format((double) get_server_disk_usage(), 2, '.', '')));
             die;
         } else {
             echo json_encode(array("Status" => false, "Mensagem" => $Lang['api_acessoNegado']));
             die;
         }
     }
 }
 if (isset($_GET['Action'])) {
     $Pedido = $_GET['Action'];
     if ($Pedido == "CriarServidor") {
         $User->getInfo();
         if ($User->getNumeroMaxServidores() > $User->getNumeroServidores()) {
             $TipoServer = array();
             if (tipoServidorExisteById($_GET['TipoServidor'])) {
                 $TipoServer = getTipoServidorById($_GET['TipoServidor']);
             } else {
                 echo json_encode(array("Status" => false, "Mensagem" => $Lang['api_tipoServidorNaoEncontrado']));
                 die;
             }
             $FTP_User = "";
             $FTP_Password = "";
             if (isset($_GET['NomeServidor']) && !empty($_GET['NomeServidor']) && isset($_GET['Ip']) && !empty($_GET['Ip']) && isset($_GET['Porta']) && !empty($_GET['Porta']) && is_numeric($_GET['Porta']) && isset($_GET['PortaQuery']) && !empty($_GET['PortaQuery']) && is_numeric($_GET['PortaQuery']) && isset($_GET['TipoServidor']) && !empty($_GET['TipoServidor']) && is_numeric($_GET['TipoServidor']) && isset($_GET['Motd']) && !empty($_GET['Motd']) && isset($_GET['Mapa']) && !empty($_GET['Mapa']) && isset($_GET['OnlineMode']) && is_numeric($_GET['OnlineMode']) && isset($_GET['MaxSlots']) && !empty($_GET['MaxSlots']) && is_numeric($_GET['MaxSlots'])) {
                 addServidor($User->getId(), $_GET['TipoServidor'], $_GET['NomeServidor'], $_GET['Ip'], $_GET['Porta'], $_GET['PortaQuery'], $_GET['MaxSlots'], $_GET['OnlineMode'], $_GET['Mapa'], $_GET['Motd'], $FTP_User, $FTP_Password);
                 header("Location: ../index.php");
                 die;
             } else {
                 // Falta algo para criar o servidor, nao correspondeu a criteria imposta
                 echo json_encode(array("Status" => false, "Mensagem" => $Lang['api_erroCriarServidor']));
                 die;
             }
Esempio n. 2
0
/**
 *	@author João Reis
 *	Adiciona Nome do tipo do servidor a todos os servidores passados no array.
 *	@param $Servidores
 *	@return array
 */
function addInformacaoServidores($Servidores)
{
    $return = array();
    $i = 0;
    foreach ($Servidores as $Servidor) {
        $return[$i] = $Servidor;
        $return[$i]["NomeTipoServidor"] = getTipoServidorById($Servidor['TipoServidor'])['Nome'];
        $i++;
    }
    return $return;
}
Esempio n. 3
0
 /**
  *	@author João Reis
  *	Atualiza a informação do servidor retirando a informação apartir da base de dados.
  *	@return boolean
  */
 function getInfo()
 {
     try {
         // Buscar informação
         $stmt = $this->conexaoBaseDados->prepare(GETSERVIDORBYID);
         // Preparar Statement
         $stmt->execute(array(":Id" => $this->Id));
         // Executar Statement
         $result = $stmt->fetchAll();
         if (count($result)) {
             $this->Id = $result[0]['Id'];
             $this->IdUtilizador = $result[0]['IdUtilizador'];
             $this->User = new Utilizador($this->IdUtilizador, $this->conexaoBaseDados);
             $this->TipoServidor = $result[0]['TipoServidor'];
             $this->NomeServidor = $result[0]['NomeServidor'];
             $this->Ip = $result[0]['Ip'];
             $this->Porta = $result[0]['Porta'];
             $this->PortaQuery = $result[0]['PortaQuery'];
             $this->Status = $result[0]['Status'];
             $this->DataHoraCriado = $result[0]['DataHoraCriado'];
             $this->Instalado = $result[0]['Instalado'];
             $this->MaxSlotsDb = $result[0]['MaxSlots'];
             $this->OnlineMode = $result[0]['OnlineMode'];
             $this->MapaDb = $result[0]['Mapa'];
             $this->Motd = $result[0]['Motd'];
             $this->FTP_User = $result[0]['FTP_User'];
             $this->FTP_Password = $result[0]['FTP_Password'];
             // Tipo Servidor e variaveis do mesmo.
             $this->tipo = getTipoServidorById($this->TipoServidor);
             $this->DownloadUrl = $this->tipo['Url'];
             $this->ComandoInstalar = $this->tipo['ComandoInstalar'];
             $this->ComandoIniciar = $this->tipo['ComandoIniciar'];
         }
         return true;
     } catch (Exception $ex) {
         // Erro ao buscar informação.
         return false;
     }
 }
Esempio n. 4
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_criarServidor'], 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("NumTiposServidores", count(getAllTiposServidores()));
$smarty->assign("Servidores", getServidoresByIdUtilizador($User->getId()));
$smarty->assign("TipoServidor", getTipoServidorById($Tipo)['Nome']);
$smarty->assign("NumServidoresTipo", count($ServidoresTipo));
$smarty->assign("ServidoresTipo", $ServidoresTipo);
$smarty->assign("Lang", $linguagens[$User->getLinguagem()]);
$smarty->assign("LangKey", $User->getLinguagem());
$smarty->assign("Langs", getLangKeys());
$smarty->assign("Temas", getAllTemas());
$smarty->assign("IpServidor", $_SERVER['SERVER_ADDR']);
$smarty->display($User->getPastaTema() . '/tipoServidor.tpl');
#$smarty->display('Metromega/index.tpl');
?>
<script type="text/javascript">
  setInterval(function(){ 
  <?php 
$Servidores = array();
$Servidores = getServidorByTipoServidorAndIdUtilizador($Tipo, $User->getId());