<?php
if(filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL) && $_POST['pass'] && $_SERVER['SERVER_NAME'] == 'host.ciberweb.com' && $_SERVER['HTTPS'] == 'on' && is_file('../../../usuarios/'.base64_encode($_POST['mail']).'.txt') == true){
    $usuario = json_decode(file_get_contents('../../../usuarios/'.base64_encode($_POST['mail']).'.txt'), true);
    if($usuario['pass'] == $_POST['pass']){
        setcookie('usuario', base64_encode($_POST['mail']), time() + 2500 * 24 * 60 * 60, '/');
        header("Location: ../");
    } else {
        header("Location: ../index.php?error=true");
    }
    
} else {
    header("Location: ../index.php?error=true");
}
exit();
?>