300 lines
12 KiB
PHP
300 lines
12 KiB
PHP
<?php
|
||
session_start();
|
||
require_once 'db/config.php';
|
||
require_once 'mail/MailService.php';
|
||
require_once 'includes/webinar_schedule.php';
|
||
|
||
header('Content-Type: application/json');
|
||
|
||
function normalize_email_address($email) {
|
||
return strtolower(trim((string) $email));
|
||
}
|
||
|
||
function has_valid_email_dns($domain) {
|
||
if ($domain === '') {
|
||
return false;
|
||
}
|
||
|
||
return checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A') || checkdnsrr($domain, 'AAAA');
|
||
}
|
||
|
||
function is_disposable_email_domain($domain) {
|
||
static $blocked_domains = [
|
||
'10minutemail.com',
|
||
'dispostable.com',
|
||
'emailondeck.com',
|
||
'fakeinbox.com',
|
||
'guerrillamail.com',
|
||
'maildrop.cc',
|
||
'mailinator.com',
|
||
'mailnesia.com',
|
||
'mintemail.com',
|
||
'sharklasers.com',
|
||
'tempmail.com',
|
||
'temp-mail.org',
|
||
'trashmail.com',
|
||
'yopmail.com',
|
||
'example.com',
|
||
'example.net',
|
||
'example.org',
|
||
];
|
||
|
||
return in_array($domain, $blocked_domains, true);
|
||
}
|
||
|
||
function validate_registration_email($email) {
|
||
$email = normalize_email_address($email);
|
||
|
||
if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||
return 'Please enter a valid email address.';
|
||
}
|
||
|
||
if (strlen($email) > 190) {
|
||
return 'Please enter a shorter email address.';
|
||
}
|
||
|
||
$parts = explode('@', $email);
|
||
if (count($parts) !== 2) {
|
||
return 'Please enter a valid email address.';
|
||
}
|
||
|
||
[$local, $domain] = $parts;
|
||
|
||
if ($local === '' || $domain === '') {
|
||
return 'Please enter a valid email address.';
|
||
}
|
||
|
||
if (is_disposable_email_domain($domain)) {
|
||
return 'Please use your real email address. Temporary or disposable inboxes are not allowed.';
|
||
}
|
||
|
||
if (!has_valid_email_dns($domain)) {
|
||
return 'Please use an email with a real mail domain.';
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
function clean_text_input($value, int $max_length = 255): string {
|
||
$value = trim((string) $value);
|
||
$value = strip_tags($value);
|
||
$value = preg_replace('/[ |