<?php
// VERIFICAÇÕES DA PÁGINA DE LOGIN
include_once "./system/functions.php";
$server_name = getServerProperty("server_name");
if (isset($_GET["l"])) {
$key = $_GET["l"];
}
if (isset($_GET["web"])) {
$Key = $_GET["web"];
}
$result = getUserPropertyByValue("test_key", $key);
$idUsuario = getUserByID($result["userid"]);
$resselerID = !empty($idUsuario) ? $idUsuario : "";
// var_dump($idUsuario['id']); die();
$logotipo = getUserProperty($idUsuario['id'], "logotipo");
$titulo = getUserProperty($idUsuario['id'], "nomePainel");
$copyright = getUserProperty($idUsuario['id'], "copyright");
//var_dump($titulo); die();

startSession();
if (isset($_SESSION["__l0gg3d_us3r__"])) {
    header("Location: ./dash.php");
    exit;
}
if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST['idrevenda'])) {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $ID = $_POST['idrevenda'];
    $result = loginUser($username, $password, $ID);
    switch ($result) {
        case 1:
        header("location: ./dash.php");
        exit;
        case 2:
        header("location: ?result=cant_connect");
        exit;
        case 3:
        header("location: ?result=invalid_user_or_pass");
        exit;
        case 4:
        header("location: ?result=blocked");
        exit;
        case 5:
        header("location: ?result=insufficient_permission");
        exit;
        case 6:
        header("location: ./tv/dashboard.php");
        exit;
        case 7:
        header("location: ?result=conta_expirada");
        exit;
        case 8:
        header("location: ?result=detalhes_invalidos");
        exit;
        case 9:
        header("location: ?result=detalhes_invalidos");
        exit;
    }
}

// VERIFICAÇÕES DA PÁGINA DE RECUPERAR SENHA
include_once "./system/functions.php";
startSession();


// VERIFICAÇÕES DA PÁGINA DE LISTAR TODOS CLIENTES
?>