Fixed blacklist code
authorLisa Marie Maginnis <lisam@fsf.org>
Mon, 24 Nov 2014 19:38:04 +0000 (14:38 -0500)
committerLisa Marie Maginnis <lisam@fsf.org>
Mon, 24 Nov 2014 19:38:04 +0000 (14:38 -0500)
trustcommerce.php

index 45d2ab4124d9b935787d9f3c13e539090f7c33dc..afa2b0d07eddaf13097be70d83786a61d3f5c954 100644 (file)
@@ -151,11 +151,13 @@ class org_fsf_payment_trustcommerce extends CRM_Core_Payment {
     }
   }
 
-  /* Return TRUE when client is either IP or agent blacklisted, or
-   * FALSE otherwise.
-   */
   function _isBlacklisted() {
-    return $this->_isIPBlacklisted() || $this->_IsAgentBlacklisted();
+    if($this->_isIPBlacklisted()) {
+      return TRUE;
+    } else if($this->_IsAgentBlacklisted()) {
+      return TRUE;
+    } 
+    return FALSE;
   }
 
   function _isAgentBlacklisted() {
@@ -164,8 +166,8 @@ class org_fsf_payment_trustcommerce extends CRM_Core_Payment {
     $dao = CRM_Core_DAO::executeQuery('SELECT * FROM `trustcommerce_useragent_blacklist`');
     while($dao->fetch()) {
       if(preg_match('/'.$dao->name.'/', $agent) === 1) {
-        error_log(' [client '.$ip.'] [agent '.$agent.'] - Blacklisted by USER_AGENT rule #'.$dao->id);
-        return TRUE;
+       error_log(' [client '.$ip.'] [agent '.$agent.'] - Blacklisted by USER_AGENT rule #'.$dao->id);
+       return TRUE;
       }
     }
     return FALSE;
@@ -179,8 +181,8 @@ class org_fsf_payment_trustcommerce extends CRM_Core_Payment {
     $dao = CRM_Core_DAO::executeQuery('SELECT * FROM `trustcommerce_blacklist`');
     while($dao->fetch()) {
       if($ip >= $dao->start && $ip <= $dao->end) {
-        error_log('[client '.$ip.'] [agent '.$agent.'] Blacklisted by IP rule #'.$dao->id);
-        return TRUE;
+       error_log('[client '.long2ip($ip).'] [agent '.$agent.'] Blacklisted by IP rule #'.$dao->id);
+       return TRUE;
       }
     }
     return FALSE;