2002-11-11 19:40:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once("util.inc");
|
|
|
|
|
|
|
|
function show_error($str) {
|
|
|
|
page_head("Create account: error");
|
|
|
|
echo $str;
|
|
|
|
echo mysql_error();
|
2002-11-26 00:39:58 +00:00
|
|
|
echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\n";
|
2002-11-11 19:40:22 +00:00
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2002-12-04 19:14:00 +00:00
|
|
|
$authenticator = init_session();
|
2002-11-11 19:40:22 +00:00
|
|
|
db_init();
|
|
|
|
|
|
|
|
$new_email_addr = $HTTP_POST_VARS["new_email_addr"];
|
|
|
|
if (strlen($new_email_addr) == 0) {
|
|
|
|
show_error("Email address missing");
|
|
|
|
}
|
|
|
|
$query = "select * from user where email_addr='$new_email_addr'";
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if ($result) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
if ($user) {
|
|
|
|
show_error("There's already an account with that email address");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// web passwords disabled by default
|
|
|
|
if (0) {
|
|
|
|
if (strlen($HTTP_POST_VARS["new_password"]) == 0) {
|
|
|
|
show_error("Password missing");
|
|
|
|
}
|
|
|
|
if ($HTTP_POST_VARS["new_password"] != $HTTP_POST_VARS["new_password2"]) {
|
|
|
|
show_error("Different passwords entered");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$authenticator = random_string();
|
|
|
|
$query = sprintf(
|
2003-02-18 23:07:48 +00:00
|
|
|
"insert into user (create_time, email_addr, name, web_password, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, teamid, venue) values(%d, '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 0, 0, 'home')",
|
2002-11-11 19:40:22 +00:00
|
|
|
time(),
|
2002-11-23 09:23:02 +00:00
|
|
|
$new_email_addr,
|
2002-11-11 19:40:22 +00:00
|
|
|
$HTTP_POST_VARS["new_name"],
|
|
|
|
$HTTP_POST_VARS["new_password"],
|
|
|
|
$authenticator,
|
|
|
|
$HTTP_POST_VARS["country"],
|
|
|
|
$HTTP_POST_VARS["postal_code"]
|
|
|
|
);
|
|
|
|
$result = mysql_query($query);
|
|
|
|
if (!$result) {
|
|
|
|
show_error("Couldn't create account");
|
|
|
|
}
|
|
|
|
|
2002-12-19 05:11:25 +00:00
|
|
|
// In success case, redirect to a fixed page so that user can
|
|
|
|
// return to it without getting "Repost form data" stuff
|
2002-12-06 21:37:30 +00:00
|
|
|
|
2002-12-19 18:08:43 +00:00
|
|
|
send_auth_email($new_email_addr, $authenticator);
|
2003-02-07 09:00:35 +00:00
|
|
|
Header("Location: account_created.php?email_addr=$new_email_addr");
|