} } $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());
*/ $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;
// Criar instância do Utilizador $UserVer->getInfo(); // Atualizar a informação do utilizador if (!$UserVer->getExiste()) { echo ' <script> window.location.replace("admin.php"); </script> '; 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);
$email = $_POST['email']; $password = $_POST['password']; $email = addslashes($email); // Nunca confiar no que o utilizar introduz. $password = addslashes($password); // Nunca confiar no que o utilizar introduz. $password = md5($password); // Encriptar password com md5 $User = login($email, $password); if (!isset($User)) { header("Location: login.php?erro=2"); die; } $User = new Utilizador($User['Id'], $conn); $User->printInfo(); $_SESSION['Id'] = $User->getId(); } else { header("Location: login.php?erro=1"); die; } } if ($_GET) { if (isset($_GET['erro'])) { $erro = $_GET['erro']; if ($erro == 1) { $err[] = $_SESSION['Lang']['login_emailOuPasswordFalta']; } if ($erro == 2) { $err[] = $_SESSION['Lang']['login_emailOuPasswordErrados']; } }
$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()));
$user = new Utilizador($utilizador['Id'], $conn); if (!$user->hasCron()) { continue; } $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = $email_host; $mail->SMTPAuth = true; $mail->Username = $email_user; $mail->Password = $email_pass; $mail->SMTPSecure = $email_sec; $mail->Port = $email_port; $mail->setFrom('*****@*****.**', 'CyberPanel - Servers Info'); $mail->isHTML(true); $stmt = $conn->prepare(GETSERVIDORBYIDUTILIZADOR); $stmt->execute(array(":IdUtilizador" => $user->getId())); $servidoresV = $stmt->fetchAll(); $mail->addAddress($user->getEmail(), $user->getNome() . " " . $user->getApelido()); $mail->Subject = 'Cyber-Panel Servers Info'; foreach ($servidoresV as $servidor) { $sv = new Servidor($servidor['Id'], $conn); $mail->Body .= "<h2>" . $sv->getNomeServidor() . "</h2>"; $mail->Body .= "<p><b>" . $sv->getIp() . ":" . $sv->getPorta() . "</b></p>"; $Res = $sv->getFullStatus(); if ($Res) { $Mapa = $Res['Map']; $Slots = $Res['Players']; $MaxSlots = $Res['MaxPlayers']; $JLista = $Res['Playerlist']; $Plugins = $Res['Plugins']; $mail->Body .= "<h5><font color='green'>Online</font></h5>";