/**
  *	@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;
 }
Beispiel #2
0
            $_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;
    }
} else {
Beispiel #3
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;
}