From dfecb88bd32aeaaa0828cc8680fd244b4cd629e4 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 26 Jul 2017 16:14:32 +0200 Subject: [PATCH] skip SFS check for obviously private IP addresses --- html/inc/email.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/html/inc/email.inc b/html/inc/email.inc index cdc5551361..a66425bdcf 100644 --- a/html/inc/email.inc +++ b/html/inc/email.inc @@ -93,8 +93,13 @@ For further information and assistance with ".PROJECT.", visit // function is_valid_email_addr($addr) { if (defined("USE_STOPFORUMSPAM") && USE_STOPFORUMSPAM && array_key_exists('REMOTE_ADDR', $_SERVER)) { - $ip_addr = $_SERVER['REMOTE_ADDR']; - $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip_addr."&email=".$addr); + $ip = $_SERVER['REMOTE_ADDR']; + // For obviously private IPs check just the email against SFS, otherwise check both IP and email + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { + $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr); + } else { + $x = @file_get_contents("https://www.stopforumspam.com/api?email=".$addr); + } if (substr_count($x, 'yes')) { return false; }