|
|
|
@ -388,6 +388,24 @@ function generateRegistrationCode() {
|
|
|
|
return str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
|
|
|
|
return str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendRegistrationVerificationEmail($email, $code) {
|
|
|
|
|
|
|
|
$email = trim((string) $email);
|
|
|
|
|
|
|
|
if ($email === '') {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$subject = 'Your KaI registration verification code';
|
|
|
|
|
|
|
|
$message = "Hello,\n\n"
|
|
|
|
|
|
|
|
. "You requested to create a KaI account.\n"
|
|
|
|
|
|
|
|
. "Your verification code is: {$code}\n\n"
|
|
|
|
|
|
|
|
. "Please enter this code on the registration page to complete your account setup.";
|
|
|
|
|
|
|
|
$headers = "From: " . MAIL_FROM_NAME . " <" . MAIL_FROM . ">\r\n"
|
|
|
|
|
|
|
|
. "Reply-To: " . MAIL_FROM . "\r\n"
|
|
|
|
|
|
|
|
. "X-Mailer: PHP/" . phpversion();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mail($email, $subject, $message, $headers);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function savePendingRegistration($username, $email, $password, $code) {
|
|
|
|
function savePendingRegistration($username, $email, $password, $code) {
|
|
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
|
|
session_start();
|
|
|
|
session_start();
|
|
|
|
|