<?php

session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/src/configfiles/config.php';
$login = new Crecket\AdvancedLogin\Login();
// set the template to be used as a string. {url} will be replaced automatically with the required url
$login->ResetPasswordFunc = "Please click the following link to set a new password. <a href='{url}'>{url}</a>";
// OR a function with the first parameter being the url
$login->ResetPasswordFunc = function ($url) {
    // use a template engine or do some action to generate the template (twig for example)
    $template = file_get_contents(__DIR__ . '/email_templates/password_reset.html');
    return str_replace("{url}", $url, $template);
};
// test your function like this: first parameter will be the reset url
//echo call_user_func($login->ResetPasswordFunc, 'http://some_url');
$login->checkLoggedIn();
if (Crecket\AdvancedLogin\Core::$loggedIn !== false) {
    header('Location: index.php');
}
$show_request_form = true;
// default is yes whether to show the request email form is shown
$show_password_form = false;
// check if code isset
if (!empty($_GET['code'])) {
    $show_request_form = false;
    $show_password_form = $login->checkForgotPasswordCode($_GET['code']);
    // the code is valid and returned user data
    if ($show_password_form !== false) {
        // create new link from user data to stop users from editing the link
        $link = Crecket\AdvancedLogin\Login::ForgotpasswordLinkCreator($show_password_form['forgotpassword_code']);
<?php

session_start();
// Run composer install before trying these!
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/src/configfiles/config.php';
$login = new Crecket\AdvancedLogin\Login();
if ($login->verifyQrCode(@$_GET['code'])) {
    echo "Activated!";
} else {
    echo "Not Activated!";
}
<?php

session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/src/configfiles/config.php';
$login = new Crecket\AdvancedLogin\Login();
$login->checkLoggedIn();
if ($login->checkLoggedIn()) {
    header('Location: index.php');
}
if (!empty($_GET['code'])) {
    $login->checkActivationCode($_GET['code']);
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>advanced-login-script | Activate</title>
</head>
<body>
<div class="header">
    <pre>
<?php 
print_r($_SESSION[ADVANCEDLOGINSCRIPT_MESSAGE_KEY]);
unset($_SESSION[ADVANCEDLOGINSCRIPT_MESSAGE_KEY]);
?>
    </pre>
</div>
<div class="body">
    <a href="index.php">Return home</a><br>
    <a href="login.php">Or click here to log in</a><br>
<?php

session_start();
// Run composer install before trying these!
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/src/configfiles/config.php';
$login = new Crecket\AdvancedLogin\Login();
$login->createQrCode(true);
<?php

session_start();
// Run composer install before trying these!
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/src/configfiles/config.php';
$login = new Crecket\AdvancedLogin\Login();
$login->logout();
?>

<!DOCTYPE html>
<html>
<head>
    <title>LoginScript - Logout</title>
</head>
<body>
<div class="header">
    <pre>
<?php 
print_r($_SESSION[ADVANCEDLOGINSCRIPT_MESSAGE_KEY]);
unset($_SESSION[ADVANCEDLOGINSCRIPT_MESSAGE_KEY]);
?>
    </pre>
</div>
<div class="body">
    <a href="index.php">Return home</a>
</div>
</body>
</html>
<?php

session_start();
// Run composer install before trying these!
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/src/configfiles/config.php';
$login = new Crecket\AdvancedLogin\Login();
// set the template to be used as a string. {url} will be replaced automatically with the required url
$login->ActivationFunc = "Please click the following link to activate your account. <a href='{url}'>{url}</a>";
// OR a function with the first parameter being the url
$login->ActivationFunc = function ($url) {
    // use a template engine or do some action to generate the template (twig for example)
    $template = file_get_contents(__DIR__ . '/email_templates/activation.html');
    return str_replace("{url}", $url, $template);
};
// test your function like this: first parameter will be the activation url
//echo call_user_func($login->ActivationFunc, 'http://some_url');exit;
if (Crecket\AdvancedLogin\Core::$loggedIn !== false) {
    // check if use is logged in
    header('Location: index.php');
}
if (!empty($_POST['username']) && \SecureFuncs\SecureFuncs::getFormToken('register', $_POST['form_token']) !== false) {
    if ($login->register($_POST['username'], $_POST['email'], $_POST['password'], $_POST['repeat_password'])) {
        header('Location: index.php');
    }
}
$formToken = \SecureFuncs\SecureFuncs::setFormtoken('register');
?>
<!DOCTYPE html>
<html>
<head>