Exemple #1
0
if (isset($_POST['register-captcha'])) {
    $inputValue[4] = "";
    /* we need to always clear the captcha field, because it will regenerate after a reresh*/
    if ($Error->captcha($_POST['register-captcha'])) {
        $errorClass[4] = 'success';
    } else {
        $errorClass[4] = 'error';
    }
} else {
    if (isset($_POST['action'])) {
        $Error->add('error', 'Captcha cannot be left empty');
        $errorClass[4] = 'error';
    }
}
// Instantiontiate the erroring before we need to refresh the page
$msg = $Error->alert();
// Check if the form was submitted without any errors.
if (isset($_POST['register-username']) && isset($_POST['register-password']) && isset($_POST['register-confirm']) && isset($_POST['register-email']) && isset($_POST['register-captcha']) && !$Error->ok()) {
    $complete = true;
    // Create the actual user
    Auth::createNewUser($_POST['register-username'], $_POST['register-password'], $_POST['register-email']);
    $userId = Auth::userId($_POST['register-username']);
    $link = full_url_to_script('activate.php') . "?action=activate&code=" . Activation::get($userId) . "&id=" . $userId;
    //echo $link;
    Emailtemplate::setBaseDir('./assets/email_templates');
    $html = Emailtemplate::loadTemplate('activation', array('title' => 'Activation Email', 'prettyName' => Options::get('prettyName'), 'name' => $_POST['register-username'], 'siteName' => Options::get('emailName'), 'activationLink' => $link, 'footerLink' => Options::get('siteName'), 'footerEmail' => Options::get('emailInfo')));
    send_html_mail(array($_POST['register-username'] => $_POST['register-email']), 'Activation Email', $html, array(Options::get('siteName') => Options::get('emailAdmin')));
}
Template::setBaseDir('./assets/tmpl');
$html = Template::loadTemplate('layout', array('header' => Template::loadTemplate('header', array('title' => $title, 'user' => $user, 'admin' => $isadmin, 'msg' => $msg, 'meta' => $meta, 'selected' => 'register')), 'content' => Template::loadTemplate('register', array('errorClass' => $errorClass, 'inputValue' => $inputValue, 'complete' => $complete, 'callback' => $callback)), 'footer' => Template::loadTemplate('footer', array('time_start' => $time_start))));
echo $html;
Exemple #2
0
        $Error->add('error', 'You will need to provide us with either a username or email address to reset your password');
    }
    // Check if the details provided exists and whether they would be allowed to reset their password.
    if (isset($detail) && Auth::resetPasswordCheck($detail) == false) {
        $Error->add('error', 'No account found with the username or email address specified!');
    }
}
// Instantiontiate the erroring before we need to refresh the page
$msg = $Error->alert();
// Check if the form was submitted without any errors.
if (isset($detail) && Auth::resetPasswordCheck($detail) !== false) {
    $userId = Auth::resetPasswordCheck($detail);
    $activationCode = Activation::get($userId);
    $complete = true;
    $u = new User($userId);
    $link = full_url_to_script('forgot.php') . "?action=resetpassword&code=" . Activation::get($userId) . "&uid=" . $userId;
    // Select the Email tempalte and replace the relevant values
    Emailtemplate::setBaseDir('./assets/email_templates');
    $html = Emailtemplate::loadTemplate('forgot', array('title' => 'Reset Password Email', 'prettyName' => Options::get('prettyName'), 'name' => $u->username, 'siteName' => Options::get('emailName'), 'link' => $link, 'footerLink' => Options::get('siteName'), 'footerEmail' => Options::get('emailInfo')));
    // Replace the relevant values and send the HTML email
    send_html_mail(array($u->username => $u->email), 'Reset Password Email', $html, array(Options::get('siteName') => Options::get('emailAdmin')));
}
// Otherwise if the email link is followed lets reset the password and email it to the user.
if (isset($_GET['action']) && $_GET['action'] == 'resetpassword' && isset($_GET['uid']) && isset($_GET['code']) and Activation::get($_GET['uid']) == $_GET['code']) {
    $u = new User($_GET['uid']);
    $userId = $u->id;
    $newPassword = Auth::generateStrongPassword(6, false, 'ld');
    Auth::changePassword($userId, $newPassword);
    $reset = true;
    // Select the Email tempalte and replace the relevant values
    Emailtemplate::setBaseDir('./assets/email_templates');