]> git.mxchange.org Git - mailer.git/blobdiff - inc/filter/blacklist_filter.php
Added update_year.sh (still not fully flexible) and updated all years with it.
[mailer.git] / inc / filter / blacklist_filter.php
index 289d27105f374098726d317093d1a37861679fdb..4ef45336e5b4b4997799213ea18dfbefbf880f31 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -45,7 +45,9 @@ function FILTER_CHECK_EMAIL_BLACKLISTED ($filterData) {
        // Is the email address blacklisted?
        if (($filterData['init_done'] === TRUE) && (isEmailBlacklistEnabled()) && (isEmailBlacklisted($filterData['post_data']['email']))) {
                // Then abort here
-               $filterData['init_done'] = FALSE;
+               $filterData['init_done']   = FALSE;
+               $filterData['blacklisted'] = 'email';
+               $filterData['message']     = '{--EMAIL_IS_BLACKLISTED--}';
 
                // Run filter chain for successful detection (don't rely on other fields than 'email') here
                runFilterChain('post_email_blacklisted', $filterData);
@@ -55,10 +57,72 @@ function FILTER_CHECK_EMAIL_BLACKLISTED ($filterData) {
        return $filterData;
 }
 
+// Filter to check if IP address is blacklisted
+function FILTER_CHECK_IP_BLACKLISTED ($filterData) {
+       // Is the IP address blacklisted?
+       if (($filterData['init_done'] === TRUE) && (isEmailBlacklistEnabled()) && (isIpBlacklisted(determineRealRemoteAddress()))) {
+               // Then abort here
+               $filterData['init_done']   = FALSE;
+               $filterData['blacklisted'] = 'ip';
+               $filterData['message']     = '{--IP_IS_BLACKLISTED--}';
+
+               // Run filter chain for successful detection (don't rely on other fields than 'IP') here
+               runFilterChain('post_ip_blacklisted', $filterData);
+       } // END - if
+
+       // Return filtered data
+       return $filterData;
+}
+
+// Filter to check URL against blacklist
+function FILTER_CHECK_URL_BLACKLISTED ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+       // And shall I check that his URL is not in the black list?
+       if ((isUrlBlacklistEnabled()) && (isUrlBlacklisted($filterData['url']))) {
+               // Create redirect-URL
+               $filterData['redirect'] = 'modules.php?module=login&what=order&code=' . getCode('BLIST_URL') . '&blist=' . $GLOBALS['blacklist_data'][$filterData['url']]['timestamp'];
+               interruptFilterChain();
+
+               // Set data for next filter chain
+               $filterData['init_done']   = FALSE;
+               $filterData['blacklisted'] = 'url';
+               $filterData['message']     = '{--URL_IS_BLACKLISTED--}';
+
+               // Run filter chain for successful detection (don't rely on other fields than 'IP') here
+               runFilterChain('post_url_blacklisted', $filterData);
+       } // END - if
+
+       // Return the data for next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       return $filterData;
+}
+
 // Filter for logging blacklisted email addresses, is being called from above filter
 function FILTER_LOG_EMAIL_BLACKLISTED ($filerData) {
        // Make sure, that required data is there
-       assert((isset($filterData['init_done'])) && (isset($filterData['post_data']['email'])));
+       assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'email'));
+
+       // @TODO Insert log entry
+
+       // Return filtered data
+       return $filterData;
+}
+
+// Filter for logging blacklisted IP addresses, is being called from above filter
+function FILTER_LOG_IP_BLACKLISTED ($filerData) {
+       // Make sure, that required data is there
+       assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'ip'));
+
+       // @TODO Insert log entry
+
+       // Return filtered data
+       return $filterData;
+}
+
+// Filter for logging blacklisted URLs, is being called from above filter
+function FILTER_LOG_URL_BLACKLISTED ($filerData) {
+       // Make sure, that required data is there
+       assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'url'));
 
        // @TODO Insert log entry