Exemple #1
0
/**
 *	Instalar servidor apagando se existir o servidor atual, e instalar.
 *	@author João Reis
 */
function instalarServidor($Id)
{
    global $conn;
    $server = new Servidor($Id, $conn);
    // cria instancia do servidor
    $server->getFullStatus();
    // Atualiza informaçao do servidor
    $server->instalarServidor();
}
Exemple #2
0
            $_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'];
        }
    }
}
$total = 0;
$Servidores = getServidoresByIdUtilizador($User->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 = new Smarty();
$OldUser = false;
if (isset($_SESSION['Old_Id']) && !empty($_SESSION['Old_Id']) && $_SESSION['Id'] != $_SESSION['Old_Id']) {
    $OldUser = true;
    try {
        $OldUserC = new Utilizador($_SESSION['Old_Id'], $conn);
        $OldUserC->getInfo();
    } catch (Exception $e) {
        $_SESSION['Old_Id'] = "";
        $OldUser = false;
 /**
  *	@author João Reis
  *	@return Int
  */
 function getSlotsUsados()
 {
     $Servidores = $this->getServidoresOnline();
     $total = 0;
     // Total slots usados
     foreach ($Servidores as $Servidor) {
         try {
             $Server = new Servidor($Servidor['Id'], $this->conexaoBaseDados);
             // Criar Instância do Servidor
             $Server->getFullStatus();
             // Atualizar Servidor
             $total += $Server->getSlots();
             // Adicionar slots usados para o total
         } catch (Exception $e) {
             continue;
             // Se ouver algum erro com o servidor e/ou base dados continuar para proximo servidor
         }
     }
     return $total;
 }
Exemple #4
0
/**
 *	@author João Reis
 *	Adiciona Nome do tipo do servidor a todos os servidores passados no array.
 *	@param $Servidores
 *	@return array
 */
function addInformacaoUtilizadores($Utilizadores)
{
    global $conn;
    $return = array();
    $i = 0;
    foreach ($Utilizadores as $Utilizador) {
        $Servidores = getServidoresByIdUtilizador($Utilizador['Id']);
        $return[$i] = $Utilizador;
        #$Sv = new Servidor($, $conn);
        $total = 0;
        foreach ($Servidores as $Servidor) {
            $server = new Servidor($Servidor['Id'], $conn);
            $server->getFullStatus();
            // Fazer update aos Status
            $total += $server->getSlots();
        }
        $slotsOcupados = $total;
        $svOnline = getServidoresByIdUtilizadorAndStatus($Utilizador['Id'], 1);
        $return[$i]['Nome'] = utf8_encode($Utilizador['Nome']);
        $return[$i]['Apelido'] = utf8_encode($Utilizador['Apelido']);
        $return[$i]['Email'] = utf8_encode($Utilizador['Email']);
        $return[$i]["SlotsUsados"] = $slotsOcupados;
        $return[$i]["MaxServidores"] = $Utilizador['NumeroMaxServidores'];
        $return[$i]["NumServidores"] = count($Servidores);
        $return[$i]["ServidoresOnline"] = count($svOnline);
        $i++;
    }
    return $return;
}
Exemple #5
0
 $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>";
         $mail->Body .= "<h6>Mapa: <b>" . $Mapa . "</b></h6>";
         $mail->Body .= "<h6>Slots: <b>" . $Slots . "/" . $MaxSlots . "</b></h6>";
         $mail->Body .= "<h6>Jogadores:</h3>";
         $mail->Body .= "<ul>";
         if (count($JLista)) {
             foreach ($JLista as $lista) {
                 $mail->Body .= "<li>" . $lista . "</li>";
             }