2002-11-11 19:40:22 +00:00
|
|
|
<?php
|
|
|
|
|
2007-11-12 22:28:17 +00:00
|
|
|
include_once("../inc/boinc_db.inc");
|
2004-02-02 23:34:39 +00:00
|
|
|
include_once("../inc/util.inc");
|
2004-11-18 20:01:12 +00:00
|
|
|
include_once("../inc/email.inc");
|
2007-07-25 15:11:14 +00:00
|
|
|
include_once("../inc/user.inc");
|
2002-11-11 19:40:22 +00:00
|
|
|
|
|
|
|
function show_error($str) {
|
2005-02-26 09:03:52 +00:00
|
|
|
page_head("Can't create account");
|
2003-02-19 20:34:33 +00:00
|
|
|
echo "$str<br>\n";
|
2007-11-12 22:28:17 +00:00
|
|
|
echo BoincDb::error();
|
2002-11-26 00:39:58 +00:00
|
|
|
echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\n";
|
2002-11-11 19:40:22 +00:00
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2005-02-13 20:57:43 +00:00
|
|
|
$config = get_config();
|
|
|
|
if (parse_bool($config, "disable_account_creation")) {
|
|
|
|
page_head("Account creation is disabled");
|
|
|
|
echo "
|
|
|
|
<h3>Account creation is disabled</h3>
|
|
|
|
Sorry, this project has disabled the creation of new accounts.
|
|
|
|
Please try again later.
|
|
|
|
";
|
|
|
|
exit();
|
|
|
|
}
|
2003-03-26 00:48:56 +00:00
|
|
|
|
2007-11-07 17:23:29 +00:00
|
|
|
// see whether the new account should be pre-enrolled in a team,
|
|
|
|
// and initialized with its founder's project prefs
|
|
|
|
//
|
2005-02-14 18:33:08 +00:00
|
|
|
$teamid = post_int("teamid", true);
|
2005-02-13 20:57:43 +00:00
|
|
|
if ($teamid) {
|
|
|
|
$team = lookup_team($teamid);
|
|
|
|
$clone_user = lookup_user_id($team->userid);
|
|
|
|
if (!$clone_user) {
|
|
|
|
echo "User $userid not found";
|
|
|
|
exit();
|
2003-07-04 00:02:53 +00:00
|
|
|
}
|
2005-02-13 20:57:43 +00:00
|
|
|
$project_prefs = $clone_user->project_prefs;
|
|
|
|
} else {
|
|
|
|
$teamid = 0;
|
|
|
|
$project_prefs = "";
|
|
|
|
}
|
2003-07-04 00:02:53 +00:00
|
|
|
|
2006-05-27 21:41:36 +00:00
|
|
|
if(defined('INVITE_CODES')) {
|
2008-06-11 19:36:10 +00:00
|
|
|
$invite_code = post_str("invite_code");
|
2006-05-27 21:41:36 +00:00
|
|
|
if (strlen($invite_code)==0) {
|
2007-11-02 14:43:02 +00:00
|
|
|
show_error(tra("You must supply an invitation code to create an account."));
|
2006-05-27 21:41:36 +00:00
|
|
|
}
|
|
|
|
if (!preg_match(INVITE_CODES, $invite_code)) {
|
2007-11-02 14:43:02 +00:00
|
|
|
show_error(tra("The invitation code you gave is not valid."));
|
2006-05-27 21:41:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-11 19:36:10 +00:00
|
|
|
$new_name = post_str("new_name");
|
2005-02-13 20:57:43 +00:00
|
|
|
if (strlen($new_name)==0) {
|
|
|
|
show_error("You must supply a name for your account");
|
|
|
|
}
|
2005-02-22 19:37:55 +00:00
|
|
|
if ($new_name != strip_tags($new_name)) {
|
|
|
|
show_error("HTML tags not allowed in name");
|
|
|
|
}
|
|
|
|
|
2008-06-11 19:36:10 +00:00
|
|
|
$new_email_addr = post_str("new_email_addr");
|
2005-02-13 20:57:43 +00:00
|
|
|
$new_email_addr = strtolower($new_email_addr);
|
|
|
|
if (!is_valid_email_addr($new_email_addr)) {
|
|
|
|
show_error("Invalid email address:
|
|
|
|
you must enter a valid address of the form
|
|
|
|
name@domain"
|
|
|
|
);
|
|
|
|
}
|
2005-03-24 19:02:27 +00:00
|
|
|
$user = lookup_user_email_addr($new_email_addr);
|
|
|
|
if ($user) {
|
|
|
|
show_error("There's already an account with that email address.");
|
2005-02-13 20:57:43 +00:00
|
|
|
}
|
2002-11-11 19:40:22 +00:00
|
|
|
|
2008-06-11 19:36:10 +00:00
|
|
|
$passwd = post_str("passwd");
|
|
|
|
$passwd2 = post_str("passwd2");
|
2005-10-12 22:51:55 +00:00
|
|
|
if ($passwd != $passwd2) {
|
|
|
|
show_error("New passwords are different");
|
|
|
|
}
|
|
|
|
|
|
|
|
$min_passwd_length = parse_config($config, "<min_passwd_length>");
|
|
|
|
if (!$min_passwd_length) $min_passwd_length = 6;
|
|
|
|
|
|
|
|
if (!is_ascii($passwd)) {
|
|
|
|
show_error("Passwords may only include ASCII characters.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen($passwd)<$min_passwd_length) {
|
|
|
|
show_error(
|
|
|
|
"New password is too short:
|
|
|
|
minimum password length is $min_passwd_length characters."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$passwd_hash = md5($passwd.$new_email_addr);
|
|
|
|
|
2007-08-26 10:29:08 +00:00
|
|
|
$country = post_str("country");
|
|
|
|
if ($country == "") {
|
|
|
|
$country = "International";
|
|
|
|
}
|
2005-02-13 20:57:43 +00:00
|
|
|
if (!is_valid_country($country)) {
|
|
|
|
echo "bad country";
|
|
|
|
exit();
|
|
|
|
}
|
2004-12-27 03:42:11 +00:00
|
|
|
|
2008-02-13 19:54:54 +00:00
|
|
|
$postal_code = post_str("postal_code", true);
|
2004-12-27 03:42:11 +00:00
|
|
|
|
2007-07-25 15:11:14 +00:00
|
|
|
$user = make_user(
|
|
|
|
$new_email_addr, $new_name, $passwd_hash,
|
|
|
|
$country, $postal_code, $project_prefs, $teamid
|
|
|
|
);
|
|
|
|
if (!$user) {
|
2005-02-13 20:57:43 +00:00
|
|
|
show_error("Couldn't create account");
|
|
|
|
}
|
|
|
|
|
|
|
|
// In success case, redirect to a fixed page so that user can
|
|
|
|
// return to it without getting "Repost form data" stuff
|
2002-11-11 19:40:22 +00:00
|
|
|
|
2005-02-13 20:57:43 +00:00
|
|
|
send_auth_email($user, true, false);
|
2005-10-12 22:51:55 +00:00
|
|
|
|
2006-11-15 20:15:01 +00:00
|
|
|
if(defined('INVITE_CODES')) {
|
2007-07-25 15:11:14 +00:00
|
|
|
error_log("Account '$new_email_addr' created using invitation code '$invite_code'");
|
2006-11-15 20:15:01 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 19:54:54 +00:00
|
|
|
$next_url = post_str('next_url', true);
|
|
|
|
if ($next_url) {
|
|
|
|
Header("Location: $next_url");
|
|
|
|
} else {
|
|
|
|
Header("Location: home.php");
|
|
|
|
send_cookie('init', "1", true);
|
|
|
|
send_cookie('via_web', "1", true);
|
|
|
|
}
|
2008-02-13 19:02:44 +00:00
|
|
|
send_cookie('auth', $user->authenticator, true);
|
2002-12-06 21:37:30 +00:00
|
|
|
|
2005-02-13 20:57:43 +00:00
|
|
|
?>
|