2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 01/21/2013 *
4 * =================== Last change: 01/21/2013 *
6 * -------------------------------------------------------------------- *
7 * File : blacklist_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for ext- *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer ext- *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Checks whether given data is blacklisted
44 function isGenericBlacklisted ($type, $data) {
45 // Mark it as not listed by default
48 // Is black-listing enbaled?
49 if (!isGenericBlacklistEnabled($type)) {
50 // No, then all emails are not in this list
52 } elseif (!isset($GLOBALS['blacklist_data'][$type][$data])) {
53 // Check black-list for given email
54 $result = SQL_QUERY_ESC("SELECT
60 UNIX_TIMESTAMP(`added`) AS `added`
62 `{?_MYSQL_PREFIX?}_blacklist`
64 '%s' REGEXP `data` AND
70 ), __FUNCTION__, __LINE__);
73 if (SQL_NUMROWS($result) == 1) {
74 // Jupp, we got one listed
75 $GLOBALS['blacklist_data'][$type][$data] = SQL_FETCHARRAY($result);
82 SQL_FREERESULT($result);
84 // Is found in cache -> black-listed
92 // Inserts a given email (pattern) in blacklist if not found
93 function insertEmailInBlacklist ($email, $provider = 'BLACKLIST') {
94 // Call inner function
95 insertGenericInBlacklist ('email', $email, NULL, $provider);
98 // Inserts a given URL in blacklist if not found
99 function insertUrlInBlacklist ($url, $poolId, $provider = 'BLACKLIST') {
100 // Call inner function
101 insertGenericInBlacklist ('url', $url, $poolId, $provider);
104 // Inserts a given URL in blacklist if not found
105 function insertGenericInBlacklist ($type, $data, $poolId = NULL, $provider = 'BLACKLIST') {
106 // Is this feature turned on and is the URL not there?
107 if (!isGenericBlacklistEnabled($type)) {
108 // Not enabled, then please don't call this function
109 reportBug(__FUNCTION__, __LINE__, 'Blacklisting of type ' . $type . ' is disabled, data=' . $data . ',poolId=' . convertZeroToNull($poolId));
110 } elseif (!isUrlBlacklisted($data)) {
111 // Did not find a record so we can add it... :)
112 SQL_QUERY_ESC("INSERT INTO
113 `{?_MYSQL_PREFIX?}_blacklist`
127 convertZeroToNull($poolId),
130 ), __FUNCTION__, __LINE__);
134 // Checks whether given email is blacklisted
135 function isEmailBlacklisted ($email) {
136 // Call inner function
137 return isGenericBlacklisted('email', $email);
140 // Checks whether given URL is blacklisted
141 function isUrlBlacklisted ($url) {
142 // Call inner function
143 return isGenericBlacklisted('url', $email);
146 // ----------------------------------------------------------------------------
147 // Configuration wrapper functions
148 // ----------------------------------------------------------------------------
151 function isGenericBlacklistEnabled ($type) {
153 if (!isset($GLOBALS[__FUNCTION__])) {
155 $GLOBALS[__FUNCTION__] = (getConfig($type . '_blacklist') == 'Y');
159 return $GLOBALS[__FUNCTION__];
162 // Wrapper to check if url_blacklist is enabled
163 function isUrlBlacklistEnabled () {
165 if (!isset($GLOBALS[__FUNCTION__])) {
167 $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
171 return $GLOBALS[__FUNCTION__];
174 // Wrapper to check if email_blacklist is enabled
175 function isEmailBlacklistEnabled () {
177 if (!isset($GLOBALS[__FUNCTION__])) {
179 $GLOBALS[__FUNCTION__] = (getConfig('email_blacklist') == 'Y');
183 return $GLOBALS[__FUNCTION__];