mirror of
https://github.com/php/web-php.git
synced 2026-04-30 02:13:21 +02:00
Slightly improved address and domain-matching SPAM prevention mechanism.
This commit is contained in:
@@ -30,3 +30,24 @@ function is_emailable_address($email)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic blacklisting.
|
||||
* Add email addresses, domains, or partial-match patterns
|
||||
* to $mosquitoes array to blacklist.
|
||||
* CAUTION: Be sure anything you add here won't partially
|
||||
* match legitimate email addresses! For example:
|
||||
* spamsend
|
||||
* .... will match:
|
||||
* real_person@thisispamsendoftheweb.example.com
|
||||
*/
|
||||
function blacklisted($email) {
|
||||
$mosquitoes = array(
|
||||
'saradhaaa@gmail.com',
|
||||
'mg-tuzi@yahoo.com.cn',
|
||||
'bitlifesciences',
|
||||
'bitconferences',
|
||||
);
|
||||
foreach ($mosquitoes as $m) {
|
||||
if (preg_match('/'.$m.'/i',$email)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -44,11 +44,14 @@ if ($process) {
|
||||
$errors[] = 'You must supply a valid email address.';
|
||||
}
|
||||
|
||||
// Temporary lockout of annoying users (better solution is needed)
|
||||
/**
|
||||
* Lockout of addresses and domains known to SPAM us.
|
||||
* Add, edit, or remove blacklisted users or domains
|
||||
* in include/email-validation.inc :: blacklisted().
|
||||
*/
|
||||
$uemail = isset($_POST['email']) ? strtolower($_POST['email']) : '';
|
||||
$mosquitoes = array('saradhaaa@gmail.com', 'mg-tuzi@yahoo.com.cn', 'ruby@bitlifesciences.com');
|
||||
if (in_array($uemail, $mosquitoes)) {
|
||||
$errors[] = 'Sorry an error has occurred, please try again later.';
|
||||
if (blacklisted($uemail)) {
|
||||
$errors[] = 'An expected error has been encountered. Please don\'t try again later.';
|
||||
}
|
||||
|
||||
$_POST['sdesc'] = trim($_POST['sdesc']);
|
||||
|
||||
Reference in New Issue
Block a user