2003-02-19 20:34:33 +00:00
|
|
|
<?php
|
|
|
|
|
2003-08-22 05:36:25 +00:00
|
|
|
require_once("db.inc");
|
2003-02-19 20:34:33 +00:00
|
|
|
require_once("util.inc");
|
|
|
|
require_once("user.inc");
|
|
|
|
|
|
|
|
function send_verify_email($user, $email_addr, $key) {
|
|
|
|
mail(
|
|
|
|
$email_addr,
|
|
|
|
PROJECT." account email change",
|
2003-07-25 00:45:08 +00:00
|
|
|
"You have asked that the email address of your " . PROJECT . " account be changed to $email_addr.
|
2003-02-19 20:34:33 +00:00
|
|
|
To confirm this change, please visit the following URL:
|
2003-07-25 00:45:08 +00:00
|
|
|
". URL_BASE ."confirm_email_change.php?id=$user->id&str=$key"
|
|
|
|
); // Changed from (URL_BASE || MASTER_URL)
|
2003-02-19 20:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
db_init();
|
2003-03-19 21:01:32 +00:00
|
|
|
$user = get_logged_in_user();
|
2003-02-19 20:34:33 +00:00
|
|
|
|
|
|
|
$email_addr = $HTTP_POST_VARS["email_addr"];
|
|
|
|
|
|
|
|
page_head("Edit email address");
|
|
|
|
if ($email_addr == "Verification pending") {
|
|
|
|
echo "You previously requested an email address change.
|
|
|
|
An email was sent to the new address,
|
|
|
|
containing a URL that you must visit to verify the new address.
|
|
|
|
";
|
|
|
|
} else if (!is_valid_email_addr($email_addr)) {
|
|
|
|
echo "Invalid email address requested";
|
|
|
|
} else if ($email_addr == $user->email_addr) {
|
|
|
|
echo "No change requested";
|
|
|
|
} else {
|
|
|
|
$existing = null;
|
|
|
|
$result = mysql_query("select * from user where email_addr='$email_addr'");
|
|
|
|
if ($result) {
|
|
|
|
$existing = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
}
|
|
|
|
if ($existing) {
|
|
|
|
echo "There's already an account with that email address";
|
|
|
|
} else {
|
|
|
|
$x = random_string();
|
|
|
|
$y = munge_email_addr($email_addr, $x);
|
|
|
|
$result = mysql_query("update user set email_addr='$y' where id=$user->id");
|
|
|
|
if ($result) {
|
|
|
|
send_verify_email($user, $email_addr, $x);
|
|
|
|
echo "
|
|
|
|
An email has been sent to $email_addr,
|
|
|
|
containing a URL that you must visit to verify the address.
|
|
|
|
";
|
|
|
|
} else {
|
|
|
|
echo "
|
|
|
|
We can't update your email address
|
|
|
|
due to a database problem. Please try again later.
|
|
|
|
";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
page_tail();
|
|
|
|
|
|
|
|
?>
|