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/user.inc");
21require_once("../inc/util.inc");
22require_once("../inc/countries.inc");
23
24check_get_args(array("tnow", "ttok"));
25
26$user = get_logged_in_user();
27check_tokens($user->authenticator);
28
29$name = trim(post_str("user_name"));
30if ($name != sanitize_tags($name)) {
31    error_page(tra("HTML tags are not allowed in your name."));
32}
33if (strlen($name) == 0) {
34    error_page(tra("You must supply a name for your account."));
35}
36$url = post_str("url", true);
37$url = sanitize_tags($url);
38$country = post_str("country");
39if ($country == "") {
40    $country = "International";
41}
42if (!is_valid_country($country)) {
43    error_page("bad country");
44}
45$country = BoincDb::escape_string($country);
46if (POSTAL_CODE) {
47    $postal_code = BoincDb::escape_string(sanitize_tags(post_str("postal_code", true)));
48} else {
49    $postal_code = '';
50}
51
52$name = BoincDb::escape_string($name);
53$url = BoincDb::escape_string($url);
54
55$result = $user->update(
56    "name='$name', url='$url', country='$country', postal_code='$postal_code'"
57);
58if ($result) {
59    Header("Location: home.php");
60} else {
61    error_page(tra("Couldn't update user info."));
62}
63
64?>
65