[back to main page]");
define('STR_ERR_VERIFY_USER_NOT_FOUND', "User '%USER%' not found in the database. Please make sure you pasted the link correctly or return to the main page.");
$index = "index.php";
$sendConfirm = getVal($_GET, 'sendConfirm');
if($sendConfirm != ''){
$email = simpleQuery("SELECT emailAddr FROM users WHERE username='$sendConfirm'");
if($email != ''){
$confirmError = sendConfirm($sendConfirm);
if($confirmError != ''){
ob_start();
dispError($confirmError);
$content = ob_get_contents();
ob_end_clean();
simplePage($content);
exit;
} else {
ob_start();
dispMsg(str_replace("%LINK%", $index, STR_WIN_VERIFICATION_SENT), 'success');
$content = ob_get_contents();
ob_end_clean();
simplePage($content);
exit;
}
} else {
ob_start();
$err = str_replace("%USER%", $sendConfirm, STR_ERR_VERIFY_USER_NOT_FOUND);
$err = str_replace("%LINK%", $index, $err);
dispError($err);
$content = ob_get_contents();
ob_end_clean();
simplePage($content);
exit;
}
}
$username = getVal($_GET, 'u');
$code = getVal($_GET, 'c');
if(($username!='') & ($code!='')){
$_GET['index'] = "index.php"; // makes the post go to index.php instead of verify.php
requireLogin(false, '', '', $username, $code);
ob_start();
// If the user was already logged in when they clicked the link, they're not getting verified by the login() function... do it here.
$user = getUser();
if($user->isLoggedIn() && ($user->getUsername() == $username) && (!$user->isVerified())){
if($code != ''){
$isMatch = simpleQuery("SELECT COUNT(*) FROM users WHERE username='$username' AND isVerified=0 AND emailHash='$code'");
if($isMatch){
sendQuery("UPDATE users SET isVerified=1 WHERE username='$username' AND emailHash='$code'");
$user->reload();
saveUser();
}
}
}
if(!$user->isVerified()){
logEvent("There was an error trying to verify the email address for \"$username\" with code \"$code\".");
}
dispSuccess("Your email address has been confirmed."); // STRINGTABLES
$content = ob_get_clean();
$page = home_getHomePage();
$page->addMessage($content);
$page->display();
}
?>