<?php
require_once 'vendor/autoload.php';
include_once 'config.php';
include_once 'redis.php';
include_once 'utils.php';

if (!$DEBUG)    error_reporting(0);
session_start();


use Gregwar\Captcha\PhraseBuilder;


function register_page($error=false){
    include 'config.php';
    if ($error)
        include 'html/error.htm';
    $_SESSION["captcha_token"] = generateRandomString(12);
    include "html/register.htm";
    echo '
    <script>
        const reload_captcha = async (e) => {
            var cont = document.getElementById("reload_captcha");
            cont.innerHTML = "<div class=\'spinner-border text-info\' role=\'status\'><span class=\'sr-only\'>Loading...</span></div>";
            var img = document.getElementById("captcha")
            var url =  "'.$BASE_URL.'/captcha.php?token='.$_SESSION["captcha_token"].'"
            await fetch(url, { cache: "reload", mode: "no-cors" })
             .then(() => {
                img.src = url+"&t=" + new Date().getTime();
                setTimeout( () => {
                    cont.innerHTML = "<button id=\'reload\' class=\'btn btn-outline-info\' type=\'button\'> <span class=\'glyphicon glyphicon-refresh\' aria-hidden=\'true\'></span></button>";
                    bindButton()
                }, 500);
            })
        }
        function bindButton(){
            var button = document.getElementById("reload");
            button.addEventListener("click", reload_captcha)
        }
        bindButton()
    </script>
    ';
}


function verify_request($user){
    unset($_SESSION['captcha_token']);
    include "config.php";
    $error = "";
    if (ldap_user_count($user->user_name)) {
        $error = $error."This username is already in use! Please choose another username<br>";
        unset($_POST["username"]);
    }
    if (preg_match("/\s/", $user->user_name)) {
        $error = $error."Username cannot contain whitespaces<br>";
        unset($_POST["username"]);
    }
    if (strlen($user->user_name) > $VAL_USER->max_username) {
        $error = $error."Username has to be smaller than ".($VAL_USER->max_username+1)." characters<br>";
        unset($_POST["username"]);
    }
    if (strlen($user->user_name) < $VAL_USER->min_username) {
        $error = $error."Username has to be bigger than ".($VAL_USER->min_username-1)." characters<br>";
        unset($_POST["username"]);
    }
    if (preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/',$user->user_name)) {
        $error = $error."The username cannot contain special characters<br>";
        unset($_POST["username"]);
    }
    if (preg_match('/^\d/',$user->user_name)) {
        $error = $error."The username cannot begin with a number<br>";
        unset($_POST["username"]);
    }
    include "blacklists/usernames.php";
    if(in_array($user->user_name, $USERNAME_BLACKLIST)) {
        $error = $error."That Username is not allowed!<br>";
        unset($_POST["username"]);
    }


    if (preg_match("/\s/", $user->name)) {
        $error = $error."First Name cannot contain whitespaces<br>";
        unset($_POST["name"]);
    }
    if (strlen($user->name) > $VAL_USER->max_first_name) {
        $error = $error."First Name has to be smaller than ".($VAL_USER->max_first_name+1)." characters<br>";
        unset($_POST["name"]);
    }
    if (strlen($user->name) < $VAL_USER->min_first_name) {
        $error = $error."First Name has to be bigger than ".($VAL_USER->min_first_name-1)." characters<br>";
        unset($_POST["name"]);
    }
    if (preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\0-9]/',$user->name)) {
        $error = $error."The first name cannot contain special characters or numbers<br>";
        unset($_POST["name"]);
    }


    if (preg_match("/\s/", $user->last_name)) {
        $error = $error."Last Name cannot contain whitespaces<br>";
        unset($_POST["last_name"]);
    }
    if (strlen($user->last_name) > $VAL_USER->max_last_name) {
        $error = $error."Last Name has to be smaller than ".($VAL_USER->max_last_name+1)." characters<br>";
        unset($_POST["last_name"]);
    }
    if (strlen($user->last_name) < $VAL_USER->min_last_name) {
        $error = $error."Last Name has to be bigger than ".($VAL_USER->min_last_name-1)." characters<br>";
        unset($_POST["last_name"]);
    }
    if (preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\ 0-9]/',$user->last_name)) {
        $error = $error."The last name cannot contain special characters or numbers<br>";
        unset($_POST["last_name"]);
    }


    if (ldap_mail_count($user->email)) {
        $error = $error."This email is already has an account. Did you forget your password?<br>";
        unset($_POST["email"]);
    }
    if (!filter_var($user->email, FILTER_VALIDATE_EMAIL)) {
        $error = $error."Invalid email format<br>";
        unset($_POST["email"]);
    }elseif(in_array(explode("@", $user->email)[1], $MAIL_HOST_BLACKLIST )){
        $error = $error."This email service is not allowed<br>";
        unset($_POST["email"]);
    }
    $pending = redis_get("pending");
    if ($pending){
        $maillist = $pending->mails;
        if (in_array($user->email, $maillist)){
            $error = $error."This email is already pending approval, check your mailbox or try to register with a different email<br>";
            unset($_POST["email"]);
        }
    }


    if ($_POST["password"] != $_POST["password_confirm"]) {;
        $error = $error."Passwords do not match!<br>";
        unset($_POST["password_confirm"]);
    }
    $password = $_POST["password"];
    if (strlen($password) < $VAL_USER->min_password) {
        $error = $error."Password should have at least ".$VAL_USER->min_password." characters<br>";
        unset($_POST["password"]);
        unset($_POST["password_confirm"]);
    }
    if (strlen($password) > $VAL_USER->max_password) {
        $error = $error."Your password is too big!<br>";
        unset($_POST["password"]);
        unset($_POST["password_confirm"]);
    }
    include "blacklists/password.php";
    if(in_array($password, $PASSWORD_BLACKLIST)) {
        $error = $error."That password is not allowed!<br>";
        unset($_POST["password"]);
        unset($_POST["password_confirm"]);
    }
    foreach (array("username", "name", "last_name", "email") as &$field) {
        if (!isset($_POST[$field]))
            continue;
        $value = strtoupper($_POST[$field]);
        $PASSWORD = strtoupper($password);
        if(strpos($value, $PASSWORD) !== false || strpos($PASSWORD, $value) !== false){
            $error = $error."Your password cannot contain any of your names or email neither the names can contain the password<br>";
            unset($_POST["password"]);
            unset($_POST["password_confirm"]);
            break;
        }
    }

    if (!(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
        $error = $error."Wrong captcha!<br>";
    }
    unset($_SESSION["captcha"]);
    
    return $error;
}

function approve_request($user){
    include "mail.php";
    echo "<h2>Almost there! Confirm your email</h2>";
    $token = generateRandomString();
    redis_set($token, $user, $MAIL_CONFIRMATION_AWAIT_DELAY);
    $pending = redis_get("pending");
    if ($pending){
        $maillist = $pending->mails;
        array_push($maillist, $user->email);
    }
    else
        $maillist = [$user->email];
    redis_set("pending", (object)["mails"=>$maillist], $MAIL_CONFIRMATION_AWAIT_DELAY);

    $url = $BASE_URL."?type=confirmation&token=".$token;
    if (in_array(explode("@", $user->email)[1], $MAIL_HOST_DIRECT_FALLBACK))
        $smtp = $FALLBACK_SMTP;
    else
        $smtp = $SMTP;
    send_mail($user->email, $smtp, (object) [
        "subject" => $MAIL_TEMPLATE->subject, 
        "text" => str_replace("{{url}}", $url, $MAIL_TEMPLATE->text),
        "html" => str_replace("{{url}}", $url, $MAIL_TEMPLATE->html)
    ]);
    $_SESSION['resend'] = generateRandomString(12);
    $_SESSION['token'] = $token;
    $_SESSION['email'] = $user->email;
    echo "<p>Didn't receive anything yet? <a href='".$BASE_URL."/?type=resend&token=".$_SESSION['resend']."'>Click here</a> to resend the confirmation email.</p>";
}


// PAGE
include "html/header.htm";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    include 'ldap.php';
    if (isset($_POST['type'])) {
        switch ($_POST['type']) {
            case "register":
                $user = new User($_POST["username"], $_POST["name"], $_POST["last_name"], $_POST["email"], $_POST["password"]); 
                if (redis_inc_ipdata(getClientIP(), "register", true) > $HOURLY_REGISTRATIONS){
                    include "html/registration_limit.htm";
                }else{
                    $error = verify_request($user);
                    if ($error)
                        register_page($error);
                    else
                        approve_request($user);
                }
                break;
        }
    }
} elseif (isset($_GET['type'])) {
    switch ($_GET['type']) {
        case "confirmation":
            if (!isset($_GET["token"])){
                echo "INVALID REQUEST!";
            }else{
                include "ldap.php";
                $token = $_GET["token"];
                $user = redis_get($token);
                if ($user){
                    echo "<h1>Email Confirmation</h1>";
                    if (ldap_add_user($user)){
                        if ($REDIRECT_TO)
                            header("Location: ".$REDIRECT_TO);

                        $pending = redis_get("pending");
                        if ($pending){
                            $maillist = $pending->mails;
                            if (in_array($user->email, $maillist)){
                                unset($maillist[array_search($user->email, $maillist)]);
                                redis_set("pending", (object)["mails"=>$maillist], $MAIL_CONFIRMATION_AWAIT_DELAY);
                            }
                        }
                        redis_inc_ipdata(getClientIP(), "register");
                        include "html/mail_confirmed.htm";
                    }else{
                        include "html/registration_error.htm";
                    }
                    redis_delete($token);
                }else{
                    include "html/token_expired.htm";
                }
            }
            break;
        case "resend":
            if (isset($_GET['token']) && isset($_SESSION['resend']) && $_GET['token'] == $_SESSION['resend']){
                include "mail.php";
                include "html/resend_mail.htm";
                $token = $_SESSION['token'];
                $url = $BASE_URL."?type=confirmation&token=".$token;
                $smtp = $FALLBACK_SMTP;
                $mail = $_SESSION["email"];
                send_mail($mail, $smtp, (object) [
                    "subject" => $MAIL_TEMPLATE->subject, 
                    "text" => str_replace("{{url}}", $url, $MAIL_TEMPLATE->text),
                    "html" => str_replace("{{url}}", $url, $MAIL_TEMPLATE->html)
                ]);
                unset($_SESSION['resend']);
                unset($_SESSION['token']);
                unset($_SESSION['email']);
            }
            break;
    }


} else {
    unset($_SESSION['captcha_token']);
    register_page();
}

include "html/bottom.htm";
?>
