Continued with ext-blacklist:
[mailer.git] / inc / libs / blacklist_functions.php
index 05803c8c2793cb4aef11661d9e3bac2f14b96c44..70f45e96e967ae9603bd237fe6c78457c465bc68 100644 (file)
@@ -40,6 +40,24 @@ if (!defined('__SECURITY')) {
        die();
 } // END - if
 
+// Checks whether given email is blacklisted
+function isEmailBlacklisted ($email) {
+       // Call inner function
+       return isGenericBlacklisted('email', $email);
+}
+
+// Checks whether given IP is blacklisted
+function isIpBlacklisted ($ip) {
+       // Call inner function
+       return isGenericBlacklisted('ip', $ip);
+}
+
+// Checks whether given URL is blacklisted
+function isUrlBlacklisted ($url) {
+       // Call inner function
+       return isGenericBlacklisted('url', $email);
+}
+
 // Checks whether given data is blacklisted
 function isGenericBlacklisted ($type, $data) {
        // Mark it as not listed by default
@@ -92,13 +110,19 @@ LIMIT 1",
 // Inserts a given email (pattern) in blacklist if not found
 function insertEmailInBlacklist ($email, $provider = 'BLACKLIST') {
        // Call inner function
-       insertGenericInBlacklist ('email', $email, NULL, $provider);
+       return insertGenericInBlacklist ('email', $email, NULL, $provider);
 }
 
-// Inserts a given URL in blacklist if not found
+// Inserts a given IP (pattern) in blacklist if not found
+function insertIpInBlacklist ($ip, $provider = 'BLACKLIST') {
+       // Call inner function
+       return insertGenericInBlacklist ('ip', $ip, NULL, $provider);
+}
+
+// Inserts a given URL (pattern) in blacklist if not found
 function insertUrlInBlacklist ($url, $poolId, $provider = 'BLACKLIST') {
        // Call inner function
-       insertGenericInBlacklist ('url', $url, $poolId, $provider);
+       return insertGenericInBlacklist ('url', $url, $poolId, $provider);
 }
 
 // Inserts a given URL in blacklist if not found
@@ -129,18 +153,9 @@ function insertGenericInBlacklist ($type, $data, $poolId = NULL, $provider = 'BL
                        strtoupper($type)
                ), __FUNCTION__, __LINE__);
        } // END - if
-}
 
-// Checks whether given email is blacklisted
-function isEmailBlacklisted ($email) {
-       // Call inner function
-       return isGenericBlacklisted('email', $email);
-}
-
-// Checks whether given URL is blacklisted
-function isUrlBlacklisted ($url) {
-       // Call inner function
-       return isGenericBlacklisted('url', $email);
+       // Return insert id for debugging/reporting pursposes
+       return SQL_INSERT_ID();
 }
 
 // ----------------------------------------------------------------------------
@@ -183,5 +198,17 @@ function isEmailBlacklistEnabled () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// Wrapper to check if ip_blacklist is enabled
+function isIpBlacklistEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getConfig('ip_blacklist') == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // [EOF]
 ?>