1<?php
2// This file is part of BOINC.
3// http://boinc.berkeley.edu
4// Copyright (C) 2008 University of California
5//
6// BOINC is free software; you can redistribute it and/or modify it
7// under the terms of the GNU Lesser General Public License
8// as published by the Free Software Foundation,
9// either version 3 of the License, or (at your option) any later version.
10//
11// BOINC is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14// See the GNU Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public License
17// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19require_once("../inc/boinc_db.inc");
20require_once("../inc/util.inc");
21require_once("../inc/email.inc");
22
23$auth = post_str("auth");
24$name = post_str("name");
25
26if (strlen($name)==0) {
27    error_page(tra("You must supply a name for your account"));
28}
29if ($name != sanitize_tags($name)) {
30    error_page(tra("HTML tags not allowed in name"));
31}
32
33$country = post_str("country");
34if (!is_valid_country($country)) {
35    error_page("invalid country");
36}
37$country = BoincDb::escape_string($country);
38if (POSTAL_CODE) {
39    $postal_code = BoincDb::escape_string(sanitize_tags(post_str("postal_code", true)));
40} else {
41    $postal_code = '';
42}
43
44$auth = BoincDb::escape_string($auth);
45
46$name = BoincDb::escape_string($name);
47
48$user = BoincUser::lookup("authenticator='$auth'");
49if (!$user) {
50    error_page("no such user");
51}
52$retval = $user->update("name='$name', country='$country', postal_code='$postal_code'");
53if (!$retval) {
54    error_page("database error");
55}
56
57// team may have already been joined in create_account RPC.
58// if so, skip team-finder
59//
60if ($user->teamid) {
61    Header("Location: home.php");
62} else {
63    Header("Location: team_search.php");
64}
65send_cookie('auth', $auth, true);
66send_cookie('init', "1", true);
67?>
68