";
$user_created_ok = false;
AddToLog("User registration requested for: ".$user_name, 'auth');
if (get_user_id($user_name)) {
echo "
".WT_I18N::translate('Duplicate user name. A user with that user name already exists. Please choose another user name.')."";
echo "
".WT_I18N::translate('Back')."";
} elseif (get_user_by_email($user_email)) {
echo "
".WT_I18N::translate('Duplicate email address. A user with that email already exists.')."";
echo "
".WT_I18N::translate('Back')."";
} elseif ($user_password01 == $user_password02) {
if ($user_id=create_user($user_name, $user_realname, $user_email, $user_password01)) {
set_user_setting($user_id, 'language', $user_language);
set_user_setting($user_id, 'verified', 0);
set_user_setting($user_id, 'verified_by_admin', !$REQUIRE_ADMIN_AUTH_REGISTRATION);
set_user_setting($user_id, 'reg_timestamp', date('U'));
set_user_setting($user_id, 'reg_hashcode', md5(uniqid(rand(), true)));
set_user_setting($user_id, 'contactmethod', "messaging2");
set_user_setting($user_id, 'defaulttab', get_gedcom_setting(WT_GED_ID, 'GEDCOM_DEFAULT_TAB'));
set_user_setting($user_id, 'visibleonline', 1);
set_user_setting($user_id, 'editaccount', 1);
set_user_setting($user_id, 'auto_accept', 0);
set_user_setting($user_id, 'canadmin', 0);
set_user_setting($user_id, 'sessiontime', 0);
if (!empty($user_gedcomid)) {
set_user_gedcom_setting($user_id, $GEDCOM, 'gedcomid', $user_gedcomid);
set_user_gedcom_setting($user_id, $GEDCOM, 'rootid', $user_gedcomid);
}
$user_created_ok = true;
} else {
echo "
".WT_I18N::translate('Unable to add user. Please try again.')."
";
echo "
".WT_I18N::translate('Back')."";
}
} else {
echo "
".WT_I18N::translate('Passwords do not match.')."";
echo "
".WT_I18N::translate('Back')."";
}
if ($user_created_ok) {
// switch to the user's language
WT_I18N::init($user_language);
$mail_body = "";
$mail_body .= WT_I18N::translate('Hello %s ...', $user_realname) . "\r\n\r\n";
$mail_body .= /* I18N: %s placeholders are the site URL and an email address */ WT_I18N::translate('A request was received at %s to create a webtrees account with your email address %s.', WT_SERVER_NAME.WT_SCRIPT_PATH, $user_email) . " ";
$mail_body .= WT_I18N::translate('Information about the request is shown under the link below.') . "\r\n\r\n";
$mail_body .= WT_I18N::translate('Please click on the following link and fill in the requested data to confirm your request and email address.') . "\r\n\r\n";
if ($TEXT_DIRECTION=="rtl") {
$mail_body .= "
";
}
$mail_body .= WT_SERVER_NAME.WT_SCRIPT_PATH . "login_register.php?user_name=".urlencode($user_name)."&user_hashcode=".urlencode(get_user_setting($user_id, 'reg_hashcode'))."&action=userverify";
if ($TEXT_DIRECTION=="rtl") $mail_body .= "";
$mail_body .= "\r\n";
$mail_body .= WT_I18N::translate('User name') . " " . $user_name . "\r\n";
$mail_body .= WT_I18N::translate('Verification code:') . " " . get_user_setting($user_id, 'reg_hashcode') . "\r\n\r\n";
$mail_body .= WT_I18N::translate('Comments').": " . $user_comments . "\r\n\r\n";
$mail_body .= WT_I18N::translate('If you didn\'t request an account, you can just delete this message.') . " ";
$mail_body .= WT_I18N::translate('You won\'t get any more email from this site, because the account request will be deleted automatically after seven days.') . "\r\n";
require_once WT_ROOT.'includes/functions/functions_mail.php';
webtreesMail($user_email, $WEBTREES_EMAIL, WT_I18N::translate('Your registration at %s', WT_SERVER_NAME.WT_SCRIPT_PATH), $mail_body);
// switch language to webmaster settings
$webmaster_user_id=get_gedcom_setting(WT_GED_ID, 'WEBMASTER_USER_ID');
WT_I18N::init(get_user_setting($webmaster_user_id, 'language'));
$mail_body = "";
$mail_body .= WT_I18N::translate('Hello Administrator ...') . "\r\n\r\n";
$mail_body .= WT_I18N::translate('A prospective user has registered with webtrees at %s.', WT_SERVER_NAME.WT_SCRIPT_PATH) . "\r\n\r\n";
$mail_body .= WT_I18N::translate('User name') . " " . $user_name . "\r\n";
$mail_body .= WT_I18N::translate('Real name') . " " . $user_realname . "\r\n";
$mail_body .= WT_I18N::translate('Email Address:') . " " . $user_email . "\r\n\r\n";
$mail_body .= WT_I18N::translate('Comments').": " . $user_comments . "\r\n\r\n";
$mail_body .= WT_I18N::translate('The user has been sent an e-mail with the information necessary to confirm the access request') . "\r\n\r\n";
if ($REQUIRE_ADMIN_AUTH_REGISTRATION) $mail_body .= WT_I18N::translate('You will be informed by e-mail when this prospective user has confirmed the request. You can then complete the process by activating the user name. The new user will not be able to login until you activate the account.') . "\r\n";
else $mail_body .= WT_I18N::translate('You will be informed by e-mail when this prospective user has confirmed the request. After this, the user will be able to login without any action on your part.') . "\r\n";
$message = array();
$message["to"]=get_user_name($webmaster_user_id);
$message["from"]=$user_name;
$message["subject"] = WT_I18N::translate('New registration at %s', WT_SERVER_NAME.WT_SCRIPT_PATH);
$message["body"] = $mail_body;
$message["created"] = $time;
$message["method"] = get_user_setting($webmaster_user_id, 'contact_method');
addMessage($message);
// switch language to user's settings
WT_I18N::init($user_language);
?>
Thank you for your registration.', $user_realname); ?>
%s. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.
After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.
To login to this site, you will need to know your user name and password.', $user_email);
else echo WT_I18N::translate('We will now send a confirmation email to the address %s. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.
After you have followed the instructions in the confirmation email, you can login. To login to this site, you will need to know your user name and password.', $user_email);
?>
|
";
} else {
header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.'login.php');
exit;
}
break;
case "userverify" :
if (!get_site_setting('USE_REGISTRATION_MODULE')) {
header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH);
exit;
}
// Change to the new user's language
$user_id=get_user_id($user_name);
WT_I18N::init(get_user_setting($user_id, 'language'));
print_header(WT_I18N::translate('User verification'));
echo "
";
echo "
";
echo "| ".WT_I18N::translate('User verification')." |
";
echo "";
echo WT_I18N::translate('The data for the user %s was checked.', $user_name);
if ($user_id) {
$pw_ok = check_user_password($user_id, $user_password);
$hc_ok = (get_user_setting($user_id, 'reg_hashcode') == $user_hashcode);
if (($pw_ok) && ($hc_ok)) {
set_user_setting($user_id, 'verified', 1);
set_user_setting($user_id, 'pwrequested', null);
set_user_setting($user_id, 'reg_timestamp', date("U"));
set_user_setting($user_id, 'reg_hashcode', null);
if (!$REQUIRE_ADMIN_AUTH_REGISTRATION) {
set_user_setting($user_id, 'verified_by_admin', 1);
}
AddToLog("User verified: ".$user_name, 'auth');
// switch language to webmaster settings
$webmaster_user_id=get_gedcom_setting(WT_GED_ID, 'WEBMASTER_USER_ID');
WT_I18N::init(get_user_setting($webmaster_user_id, 'language'));
$mail_body = "";
$mail_body .= WT_I18N::translate('Hello Administrator ...') . "\r\n\r\n";
$mail_body .= /* I18N: User () has ... */ WT_I18N::translate('User %s (%s) has confirmed their request for an account.', $user_name, getUserFullName($user_id)) . "\r\n\r\n";
if ($REQUIRE_ADMIN_AUTH_REGISTRATION) $mail_body .= WT_I18N::translate('Please click on the link below to login to your site. You must Edit the user to activate the account so that he can login to your site.') . "\r\n";
else $mail_body .= WT_I18N::translate('You do not have to take any action; the user can now login.') . "\r\n";
if ($TEXT_DIRECTION=="rtl") {
$mail_body .= "";
}
$mail_body .= WT_SERVER_NAME.WT_SCRIPT_PATH."admin_users.php?action=edituser&username=" . urlencode($user_name);
if ($TEXT_DIRECTION=="rtl") $mail_body .= "";
$mail_body .= "\r\n";
$message = array();
$message["to"]=get_user_name($webmaster_user_id);
$message["from"]=$user_name;
$message["subject"] = WT_I18N::translate('New user at %s', WT_SERVER_NAME.WT_SCRIPT_PATH);
$message["body"] = $mail_body;
$message["created"] = $time;
$message["method"] = get_user_setting($webmaster_user_id, 'CONTACT_METHOD');
addMessage($message);
WT_I18N::init(WT_LOCALE); // Reset language
echo "
".WT_I18N::translate('You have confirmed your request to become a registered user.')."
";
if ($REQUIRE_ADMIN_AUTH_REGISTRATION) echo WT_I18N::translate('The Administrator has been informed. As soon as he gives you permission to login, you can login with your user name and password.');
else echo WT_I18N::translate('You can now login with your user name and password.');
echo "
|
";
} else {
echo "
";
echo "";
echo WT_I18N::translate('Data was not correct, please try again');
echo "
";
}
} else {
echo "
";
echo "";
echo WT_I18N::translate('Could not verify the information you entered. Please try again or contact the site administrator for more information.');
echo "
";
}
echo "
";
echo "
";
break;
default :
header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.$url);
break;
}
print_footer();