svn: /web/php/trunk/ include/email-validation.inc submit-event.php

From: Date: Mon, 22 Aug 2011 13:33:56 +0000
Subject: svn: /web/php/trunk/ include/email-validation.inc submit-event.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-11986@lists.php.net to get a copy of this message
danbrown Mon, 22 Aug 2011 13:33:56 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=315294 Log: Slightly improved address and domain-matching SPAM prevention mechanism. Changed paths: U web/php/trunk/include/email-validation.inc U web/php/trunk/submit-event.php Modified: web/php/trunk/include/email-validation.inc =================================================================== --- web/php/trunk/include/email-validation.inc 2011-08-22 13:30:01 UTC (rev 315293) +++ web/php/trunk/include/email-validation.inc 2011-08-22 13:33:56 UTC (rev 315294) @@ -30,3 +30,24 @@ } } +/** + * 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; + } +} Modified: web/php/trunk/submit-event.php =================================================================== --- web/php/trunk/submit-event.php 2011-08-22 13:30:01 UTC (rev 315293) +++ web/php/trunk/submit-event.php 2011-08-22 13:33:56 UTC (rev 315294) @@ -44,11 +44,14 @@ $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']);

« previous php.webmaster (#11986) next »