mirror of https://github.com/BOINC/boinc.git
125 lines
3.6 KiB
PHP
125 lines
3.6 KiB
PHP
<?php
|
|
|
|
require_once("../inc/util.inc");
|
|
require_once("../project/project.inc");
|
|
|
|
// Send an email describing an account to the user.
|
|
// There are a few scenarios:
|
|
//
|
|
// 1) the account was created by user via web.
|
|
// In this case they're currently looking at the "validate account" page
|
|
// (account_created.php), although they might have strayed
|
|
// so we need to give them a link.
|
|
// 2) the account was created administratively and is not validated.
|
|
// 3) the account was created administratively and is validated.
|
|
// 4) the user requested account key for existing account
|
|
//
|
|
function send_auth_email($user, $is_new, $is_validated) {
|
|
$body = "";
|
|
|
|
if (defined('EMAIL_FROM')) {
|
|
$headers = "From: ". EMAIL_FROM;
|
|
} else {
|
|
$headers ="";
|
|
}
|
|
|
|
if ($is_new) {
|
|
$subject = PROJECT." account confirmation for $user->name";
|
|
$body = "Welcome to ".PROJECT.".
|
|
|
|
This email confirms your account with ".PROJECT.":
|
|
Project URL: ".MASTER_URL."
|
|
Account Key: $user->authenticator
|
|
|
|
User name: $user->name
|
|
E-mail: $user->email_addr
|
|
";
|
|
if (!$is_validated) {
|
|
$body .= "
|
|
To activate your account, copy and paste your Account Key
|
|
in the 'Activate account' page at ".URL_BASE."account_created.php
|
|
";
|
|
}
|
|
} else {
|
|
$subject = PROJECT." information for $user->name";
|
|
$body = "Your ".PROJECT." account information is:
|
|
Project URL: ".MASTER_URL."
|
|
Account Key: $auth
|
|
|
|
User name: $user->name
|
|
E-mail: $user->email_addr
|
|
";
|
|
}
|
|
|
|
$body .= "
|
|
|
|
Save this email.
|
|
You'll need the Project URL and Account Key when you run the client software
|
|
and to log in to the ".PROJECT." web site.
|
|
|
|
For further information and assistance with ".PROJECT." go to ".MASTER_URL."
|
|
";
|
|
return mail($user->email_addr, $subject, $body, $headers);
|
|
}
|
|
|
|
function email_sent_message($email_addr) {
|
|
if (defined('EMAIL_FROM')) {
|
|
$email_from = EMAIL_FROM;
|
|
} else {
|
|
$email_from = URL_BASE;
|
|
}
|
|
|
|
echo "
|
|
Your Account Key has been emailed to $email_addr.
|
|
<p>
|
|
If the email doesn't arrive in a few minutes,
|
|
your ISP may be blocking it as spam.
|
|
In this case please contact your ISP and
|
|
ask them to not block email from $email_from.
|
|
";
|
|
}
|
|
|
|
// a valid email address is of the form A@B.C
|
|
// where A, B, C are nonempty,
|
|
// A and B don't contain @ or .,
|
|
// and C doesn't contain @
|
|
//
|
|
function is_valid_email_addr($addr) {
|
|
$x = strstr($addr, "@");
|
|
if (!$x) return false;
|
|
if (strlen($x) == strlen($addr)) return false;
|
|
$x = substr($x, 1);
|
|
if (strstr($x, "@")) return false;
|
|
$y = strstr($x, ".");
|
|
if (!$y) return false;
|
|
if (strlen($y) == strlen($x)) return false;
|
|
if (strlen($y) == 1) return false;
|
|
return true;
|
|
}
|
|
|
|
// A few functions relating to email-address munging
|
|
// A "munged" email address is of the form @X_Y,
|
|
// where X is a valid email address
|
|
// and Y is a random string not containing _.
|
|
// When an email address hasn't been validated yet, it's munged.
|
|
// (Used during account creation and email address changes)
|
|
|
|
function munge_email_addr($email, $string) {
|
|
return "@".$email."_".$string;
|
|
}
|
|
|
|
// if email_addr is of the form @X_Y, split out the X and return true.
|
|
// otherwise return false
|
|
//
|
|
function split_munged_email_addr($addr, $auth, &$email) {
|
|
if (substr($addr, 0, 1) != "@") return false;
|
|
$x = strrchr($addr, "_");
|
|
if (!$x) return false;
|
|
$y = substr($x, 1);
|
|
if ($auth && $y != $auth) return false;
|
|
$email = substr($addr, 1, strlen($addr)-strlen($x)-1);
|
|
return true;
|
|
}
|
|
|
|
?>
|