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

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

use Gregwar\Captcha\PhraseBuilder;

$URI = array_slice(explode("/", explode('?', $_SERVER['REQUEST_URI'], 2)[0]), -1)[0];
if (strlen($URI) == 2) {
    $GLOBALS["cc"] = $URI;
    $_SESSION["cc"] = $URI;
}

if (isset($_GET["lang"])) {
    $GLOBALS["cc"] = $_GET["lang"];
    $_SESSION["cc"] = $_GET["lang"];
}

$TEMPLATE = template_path();


function send_confirmation_email(string $mail, object $smtp, string $url)
{
    include 'config.php';
    include 'utils.php';
    include "mail.php";
    $TEMPLATE = template_path();
    include $TEMPLATE . "emails.php";

    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)
    ]);
}

function send_recovery_email(string $mail, object $smtp, string $url)
{
    include 'config.php';
    include 'utils.php';
    include "mail.php";
    $TEMPLATE = template_path();
    include $TEMPLATE . "emails.php";

    send_mail($mail, $smtp, (object) [
        "subject" => $RECOVERY_EMAIL_TEMPLATE->subject,
        "text"    => str_replace("{{url}}", $url, $RECOVERY_EMAIL_TEMPLATE->text),
        "html"    => str_replace("{{url}}", $url, $RECOVERY_EMAIL_TEMPLATE->html)
    ]);
}

function reload_captcha_script()
{
    include 'config.php';
    $TEMPLATE = template_path();
    include $TEMPLATE . "strings.php";
    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\'>' . $STRINGS->reloading_captcha . '</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 register_page($error = false)
{
    $TEMPLATE = template_path();
    include 'config.php';
    if ($error)
        include $TEMPLATE . 'error.htm';
    $_SESSION["captcha_token"] = generateRandomString(12);
    include $TEMPLATE . "register.htm";
    reload_captcha_script();
}


function verify_request($user)
{
    $TEMPLATE = template_path();
    unset($_SESSION['captcha_token']);
    include 'validators.php';
    include $TEMPLATE . 'strings.php';
    $password = $_POST["password"];
    $error = "";

    $error .= validate_username($user->user_name);
    $error .= validate_name($user->name, $FIRST_NAME_VALIDATION_ERROR);
    $error .= validate_name($user->last_name, $LAST_NAME_VALIDATION_ERROR);
    $error .= validate_email($user->email);
    $error .= validate_password($password);


    if (!(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
        $error = $error . $STRINGS->wrong_captcha;
    }
    unset($_SESSION["captcha"]);

    return $error;
}

function approve_request($user)
{
    include "mail.php";
    $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_confirmation_email($user->email, $smtp, $url);
    $_SESSION['resend'] = generateRandomString(12);
    $_SESSION['token'] = $token;
    $_SESSION['email'] = $user->email;
    $TEMPLATE = template_path();
    include $TEMPLATE . "confirm_your_email.htm";
}


// PAGE
include $TEMPLATE . "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 $TEMPLATE . "registration_limit.htm";
                } else {
                    $error = verify_request($user);
                    if ($error)
                        register_page($error);
                    else
                        approve_request($user);
                }
                break;
            case "recover":
                $TEMPLATE = template_path();
                unset($_SESSION['captcha_token']);
                include $TEMPLATE . 'strings.php';

                $email = $_POST["email"];
                if (!ldap_mail_count($email)) {
                    $error = $error . $STRINGS->recover_email_not_registered;
                }

                if (!(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
                    $error = $error . $STRINGS->wrong_captcha;
                }

                unset($_SESSION["captcha"]);
                if (redis_inc_ipdata(getClientIP(), "register", true) > $HOURLY_REGISTRATIONS) {
                    include $TEMPLATE . "registration_limit.htm";
                } else {
                    if ($error) {
                        include $TEMPLATE . 'error.htm';
                        include $TEMPLATE . "register.htm";
                        reload_captcha_script();
                    } else {
                        include $TEMPLATE . 'strings.php';
                        $token = generateRandomString();
                        redis_set($token, $email, $MAIL_CONFIRMATION_AWAIT_DELAY);

                        $url = $BASE_URL . "?type=password_change&token=" . $token;
                        if (in_array(explode("@", $email)[1], $MAIL_HOST_DIRECT_FALLBACK))
                            $smtp = $FALLBACK_SMTP;
                        else
                            $smtp = $SMTP;
                        send_confirmation_email($user->email, $smtp, $url);
                        $_SESSION['resend']  = generateRandomString(12);
                        $_SESSION['token']   = $token;
                        $_SESSION['email']   = $email;
                        $_SESSION['recover'] = $email;
                        $TEMPLATE = template_path();
                        include $TEMPLATE . "confirm_your_email.htm";
                        send_recovery_email($email, $smtp, $url);
                    }
                }
                break;

            case "password_change":
                include 'validators.php';
                include 'ldap.php';
                $TEMPLATE = template_path();
                include $TEMPLATE . "register.htm";
                $password = $_POST['password'];
                $error = validate_password($password);
                if ($error) {
                    include $TEMPLATE . 'error.htm';
                    include $TEMPLATE . "recover_new_password_form.htm";
                }else {
                    include $TEMPLATE . "recover_success.htm";
                    include $TEMPLATE . "email.php";
                    include 'mail.php';
                    $email = $_SESSION["email_change"];
                    if (change_password($email, $password)) {
                        if (in_array(explode("@", $email)[1], $MAIL_HOST_DIRECT_FALLBACK))
                            $smtp = $FALLBACK_SMTP;
                        else
                            $smtp = $SMTP;
                        send_mail($email, $smtp, $PASSWORD_CHANGED_EMAIL_TEMPLATE);
                        unset($_SESSION["email_change"]);
                    }
                    else {
                        include $TEMPLATE . "strings.php";
                        echo $STRINGS->change_password_ldap_error;
                    }
                }
                break;
    }
} elseif (isset($_GET['type'])) {
    switch ($_GET['type']) {
        case "confirmation":
            if (!isset($_GET["token"])) {
                echo $RUNTIME_ERROR->user_trying_invalid_get;
            } else {
                include "ldap.php";
                $token = $_GET["token"];
                $user = redis_get($token);
                if ($user && gettype($user) == "object") {
                    if (ldap_add_user($user)) {
                        if ($REDIRECT_TO)
                            header("refresh:5;url=" . $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");
                        echo $STRINGS->email_confirmation;
                        include $TEMPLATE . "mail_confirmed.htm";
                    } else {
                        echo $STRINGS->email_confirmation;
                        include $TEMPLATE . "registration_error.htm";
                    }
                    redis_delete($token);
                } else {
                    include $TEMPLATE . "token_expired.htm";
                }
            }
            break;
        case "resend":
            if (isset($_GET['token']) && isset($_SESSION['resend']) && $_GET['token'] == $_SESSION['resend']) {
                include $TEMPLATE . "resend_mail.htm";
                $token = $_SESSION['token'];
                $url = $BASE_URL . "?type=confirmation&token=" . $token;
                $smtp = $FALLBACK_SMTP;
                $address = $_SESSION["email"];
                if (isset($_SESSION['recover'])){
                    $url = $BASE_URL . "?type=password_change&token=" . $token;
                    send_recovery_email($address, $smtp, $url);
                    unset($_SESSION['recover']);
                }
                else
                    send_confirmation_email($address, $smtp, $url);
                unset($_SESSION['resend']);
                unset($_SESSION['token']);
                unset($_SESSION['email']);
            }
            break;

        case "recover":
            $TEMPLATE = template_path();
            include $TEMPLATE . "register.htm";
            include 'config.php';
            $_SESSION["captcha_token"] = generateRandomString(12);
            reload_captcha_script();
            break;

        case "password_change":
            $TEMPLATE = template_path();
            include $TEMPLATE . "register.htm";
            $token = $_GET["token"];
            $email = redis_get($token);
            $_SESSION["email_change"] = $email;
            if ($email && gettype($email) == "string"){
                include $TEMPLATE . "recover_new_password_form.htm";
            } else {
                include $TEMPLATE . "token_expired.htm";
            }
            break;
    }
} else {
    unset($_SESSION['captcha_token']);
    register_page();
}

include $TEMPLATE . "bottom.htm";
