2005-08-09 18:46:53 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
// RPC handler for account creation
|
|
|
|
|
|
|
|
require_once("../inc/db.inc");
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/email.inc");
|
|
|
|
require_once("../inc/xml.inc");
|
2007-07-25 15:11:14 +00:00
|
|
|
require_once("../inc/user.inc");
|
2010-03-30 17:46:09 +00:00
|
|
|
require_once("../inc/team.inc");
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
xml_header();
|
|
|
|
|
2006-09-06 20:56:55 +00:00
|
|
|
$retval = db_init_xml();
|
|
|
|
if ($retval) xml_error($retval);
|
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
$config = get_config();
|
2006-10-19 18:09:02 +00:00
|
|
|
if (parse_bool($config, "disable_account_creation")) {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-208);
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
|
|
|
|
2006-10-19 18:09:02 +00:00
|
|
|
if(defined('INVITE_CODES')) {
|
2008-06-11 19:36:10 +00:00
|
|
|
$invite_code = get_str("invite_code");
|
2006-10-19 18:09:02 +00:00
|
|
|
if (!preg_match(INVITE_CODES, $invite_code)) {
|
2007-08-26 10:29:08 +00:00
|
|
|
xml_error(-209);
|
2006-10-19 18:09:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
$email_addr = get_str("email_addr");
|
2008-06-11 19:36:10 +00:00
|
|
|
$email_addr = strtolower($email_addr);
|
|
|
|
$passwd_hash = get_str("passwd_hash");
|
|
|
|
$user_name = get_str("user_name");
|
2010-03-30 20:58:39 +00:00
|
|
|
$team_name = get_str("team_name", true);
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
if (!is_valid_email_addr($email_addr)) {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-205);
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
2009-06-10 18:42:15 +00:00
|
|
|
if (is_banned_email_addr($email_addr)) {
|
|
|
|
xml_error(-205);
|
|
|
|
}
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
if (strlen($passwd_hash) != 32) {
|
2006-09-08 19:51:33 +00:00
|
|
|
xml_error(-1, "password hash length not 32");
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
|
|
|
|
2005-08-16 20:48:21 +00:00
|
|
|
$user = lookup_user_email_addr($email_addr);
|
|
|
|
if ($user) {
|
|
|
|
if ($user->passwd_hash != $passwd_hash) {
|
2007-01-15 22:53:41 +00:00
|
|
|
xml_error(-137);
|
2005-08-16 20:48:21 +00:00
|
|
|
} else {
|
|
|
|
$authenticator = $user->authenticator;
|
|
|
|
}
|
|
|
|
} else {
|
2007-08-26 10:29:08 +00:00
|
|
|
$user = make_user($email_addr, $user_name, $passwd_hash, 'International');
|
2007-07-25 15:11:14 +00:00
|
|
|
if (!$user) {
|
2006-09-08 19:51:33 +00:00
|
|
|
xml_error(-137);
|
2005-08-16 20:48:21 +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 for '$email_addr' created using invitation code '$invite_code'");
|
2006-11-15 20:15:01 +00:00
|
|
|
}
|
2005-08-16 20:48:21 +00:00
|
|
|
}
|
|
|
|
|
2010-03-30 17:46:09 +00:00
|
|
|
if ($team_name) {
|
|
|
|
$team_name = BoincDb::escape_string($team_name);
|
2010-03-30 20:58:39 +00:00
|
|
|
$team = BoincTeam::lookup("name='$team_name'");
|
2010-03-30 17:46:09 +00:00
|
|
|
if ($team && $team->joinable) {
|
|
|
|
user_join_team($team, $user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-08 19:51:33 +00:00
|
|
|
echo " <account_out>\n";
|
2007-07-25 15:11:14 +00:00
|
|
|
echo " <authenticator>$user->authenticator</authenticator>\n";
|
2006-09-08 19:51:33 +00:00
|
|
|
echo "</account_out>\n";
|
2005-08-10 08:55:57 +00:00
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
?>
|