2005-08-09 18:46:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
|
|
|
|
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')) {
|
|
|
|
$invite_code = process_user_text(get_str("invite_code"));
|
|
|
|
if (!preg_match(INVITE_CODES, $invite_code)) {
|
|
|
|
xml_error(-209);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
$email_addr = get_str("email_addr");
|
|
|
|
$email_addr = process_user_text(strtolower($email_addr));
|
|
|
|
$passwd_hash = process_user_text(get_str("passwd_hash"));
|
|
|
|
$user_name = process_user_text(get_str("user_name"));
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
$authenticator = random_string();
|
|
|
|
$cross_project_id = random_string();
|
|
|
|
$now = time();
|
2006-01-13 01:07:05 +00:00
|
|
|
$query = "insert into user (create_time, email_addr, name, authenticator, expavg_time, send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$email_addr', '$user_name', '$authenticator', unix_timestamp(), 1, 1, '$cross_project_id', '$passwd_hash')";
|
2005-08-16 20:48:21 +00:00
|
|
|
$result = mysql_query($query);
|
|
|
|
if (!$result) {
|
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')) {
|
|
|
|
error_log("New account '$new_name' created using invitation code '$invite_code'");
|
|
|
|
}
|
2005-08-16 20:48:21 +00:00
|
|
|
}
|
|
|
|
|
2006-09-08 19:51:33 +00:00
|
|
|
echo " <account_out>\n";
|
|
|
|
echo " <authenticator>$authenticator</authenticator>\n";
|
|
|
|
echo "</account_out>\n";
|
2005-08-10 08:55:57 +00:00
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
?>
|
|
|
|
|