3
include_once("../inc/db.inc");
3
include_once("../inc/boinc_db.inc");
4
4
include_once("../inc/util.inc");
5
5
include_once("../inc/email.inc");
6
include_once("../inc/user.inc");
7
8
function show_error($str) {
8
9
page_head("Can't create account");
11
echo BoincDb::error();
11
12
echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\n";
44
45
if(defined('INVITE_CODES')) {
45
$invite_code = process_user_text($_POST["invite_code"]);
46
$invite_code = process_user_text(post_str("invite_code"));
46
47
if (strlen($invite_code)==0) {
47
show_error( tr(AC_INVITE_REQUIRED) );
48
show_error(tra("You must supply an invitation code to create an account."));
49
50
if (!preg_match(INVITE_CODES, $invite_code)) {
50
show_error( tr(AC_INVITE_INVALID) );
51
show_error(tra("The invitation code you gave is not valid."));
54
$new_name = process_user_text($_POST["new_name"]);
55
$new_name = process_user_text(post_str("new_name"));
55
56
if (strlen($new_name)==0) {
56
57
show_error("You must supply a name for your account");
96
96
$passwd_hash = md5($passwd.$new_email_addr);
98
$country = $_POST["country"];
98
$country = post_str("country");
100
$country = "International";
99
102
if (!is_valid_country($country)) {
100
103
echo "bad country";
104
$postal_code = strip_tags(process_user_text($_POST["postal_code"]));
107
$postal_code = post_str("postal_code", true);
106
$authenticator = random_string();
107
$cross_project_id = random_string();
108
$country = boinc_real_escape_string($country);
110
$query = "insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$new_email_addr', '$new_name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, 'home', '', 1, 1, '$cross_project_id', '$passwd_hash')";
111
$result = mysql_query($query);
110
$new_email_addr, $new_name, $passwd_hash,
111
$country, $postal_code, $project_prefs, $teamid
113
114
show_error("Couldn't create account");
116
117
// In success case, redirect to a fixed page so that user can
117
118
// return to it without getting "Repost form data" stuff
119
$user->name = $new_name;
120
$user->email_addr = $new_email_addr;
121
$user->authenticator = $authenticator;
122
120
send_auth_email($user, true, false);
124
122
if(defined('INVITE_CODES')) {
125
error_log("New account '$new_name' created using invitation code '$invite_code'");
123
error_log("Account '$new_email_addr' created using invitation code '$invite_code'");
129
$_SESSION["authenticator"] = $authenticator;
130
Header("Location: home.php?new_acct=1&via_web=1");
131
setcookie('auth', $authenticator, time()+3600*24*365);
126
$next_url = post_str('next_url', true);
128
Header("Location: $next_url");
130
Header("Location: home.php");
131
send_cookie('init', "1", true);
132
send_cookie('via_web', "1", true);
134
send_cookie('auth', $user->authenticator, true);