Introduced new extension ext-blacklist:
authorRoland Häder <roland@mxchange.org>
Mon, 21 Jan 2013 19:25:51 +0000 (19:25 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 21 Jan 2013 19:25:51 +0000 (19:25 +0000)
- Extracted new extension ext-blacklist from aldready existing functions, as
  this should become a more generic black-/white listing feature
- TODOs.txt updated

17 files changed:
.gitattributes
DOCS/TODOs.txt
inc/extensions/ext-blacklist.php [new file with mode: 0644]
inc/extensions/ext-order.php
inc/language/blacklist_de.php [new file with mode: 0644]
inc/language/order_de.php
inc/libs/blacklist_functions.php [new file with mode: 0644]
inc/modules/admin/what-config_blacklist.php [new file with mode: 0644]
inc/modules/admin/what-unlock_emails.php
inc/modules/member/what-order.php
inc/mysql-manager.php
inc/template-functions.php
inc/wrapper-functions.php
install/tables.sql
templates/de/html/admin/admin_config_blacklist.tpl [new file with mode: 0644]
templates/de/html/admin/admin_config_order.tpl
templates/de/html/ext/ext_blacklist.tpl [new file with mode: 0644]

index 3666209..34919c1 100644 (file)
@@ -176,6 +176,7 @@ inc/extensions/ext-bank.php svneol=native#text/plain
 inc/extensions/ext-beg.php svneol=native#text/plain
 inc/extensions/ext-birthday.php svneol=native#text/plain
 inc/extensions/ext-bitcoins.php svneol=native#text/plain
+inc/extensions/ext-blacklist.php svneol=native#text/plain
 inc/extensions/ext-bonus.php svneol=native#text/plain
 inc/extensions/ext-booking.php svneol=native#text/plain
 inc/extensions/ext-cache.php svneol=native#text/plain
@@ -343,6 +344,7 @@ inc/language/autopurge_de.php svneol=native#text/plain
 inc/language/bank_de.php svneol=native#text/plain
 inc/language/beg_de.php svneol=native#text/plain
 inc/language/birthday_de.php svneol=native#text/plain
+inc/language/blacklist_de.php svneol=native#text/plain
 inc/language/bonus_de.php svneol=native#text/plain
 inc/language/booking_de.php svneol=native#text/plain
 inc/language/cache_de.php svneol=native#text/plain
@@ -404,6 +406,7 @@ inc/libs/admins_functions.php svneol=native#text/plain
 inc/libs/autopurge_functions.php svneol=native#text/plain
 inc/libs/beg_functions.php svneol=native#text/plain
 inc/libs/birthday_functions.php svneol=native#text/plain
+inc/libs/blacklist_functions.php svneol=native#text/plain
 inc/libs/bonus_functions.php svneol=native#text/plain
 inc/libs/booking_functions.php svneol=native#text/plain
 inc/libs/cache_functions.php svneol=native#text/plain
@@ -537,6 +540,7 @@ inc/modules/admin/what-config_admin.php svneol=native#text/plain
 inc/modules/admin/what-config_autopurge.php svneol=native#text/plain
 inc/modules/admin/what-config_beg.php svneol=native#text/plain
 inc/modules/admin/what-config_birthday.php svneol=native#text/plain
+inc/modules/admin/what-config_blacklist.php svneol=native#text/plain
 inc/modules/admin/what-config_bonus.php svneol=native#text/plain
 inc/modules/admin/what-config_cache.php svneol=native#text/plain
 inc/modules/admin/what-config_cats.php svneol=native#text/plain
@@ -1250,6 +1254,7 @@ templates/de/html/admin/admin_config_autopurge_pro.tpl svneol=native#text/plain
 templates/de/html/admin/admin_config_beg.tpl svneol=native#text/plain
 templates/de/html/admin/admin_config_beg_pro.tpl svneol=native#text/plain
 templates/de/html/admin/admin_config_birthday.tpl svneol=native#text/plain
+templates/de/html/admin/admin_config_blacklist.tpl svneol=native#text/plain
 templates/de/html/admin/admin_config_bonus.tpl svneol=native#text/plain
 templates/de/html/admin/admin_config_bonus_pro.tpl svneol=native#text/plain
 templates/de/html/admin/admin_config_cache.tpl svneol=native#text/plain
@@ -1762,6 +1767,7 @@ templates/de/html/ext/ext_bank.tpl svneol=native#text/plain
 templates/de/html/ext/ext_beg.tpl svneol=native#text/plain
 templates/de/html/ext/ext_birthday.tpl svneol=native#text/plain
 templates/de/html/ext/ext_bitcoins.tpl svneol=native#text/plain
+templates/de/html/ext/ext_blacklist.tpl svneol=native#text/plain
 templates/de/html/ext/ext_bonus.tpl svneol=native#text/plain
 templates/de/html/ext/ext_booking.tpl svneol=native#text/plain
 templates/de/html/ext/ext_cache.tpl svneol=native#text/plain
index e9e86ea..56d24cb 100644 (file)
@@ -84,7 +84,7 @@
 ./inc/language-functions.php:254:      // @TODO These are all valid languages, again hard-coded
 ./inc/language/install_de.php:142:     // @TODO Move this to e.g. ext-smtp
 ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no       *
-./inc/language/order_de.php:70:        // @TODO Find better text
+./inc/language/order_de.php:69:        // @TODO Find better text
 ./inc/language/rallye_de.php:13: * @TODO Naming convention not applied for language strings             *
 ./inc/language/refback_de.php:51:      // @TODO Rewrite these constants to one
 ./inc/libs/admins_functions.php:537:           // @TODO This can be, somehow, rewritten
 ./inc/template-functions.php:209:       * @TODO On some pages this is buggy
 ./inc/template-functions.php:298:      // @TODO Remove these sanity checks if all is fine
 ./inc/template-functions.php:747:                      // @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates
-./inc/wrapper-functions.php:3209:      // @TODO Find a way to not use direct module comparison
+./inc/wrapper-functions.php:3197:      // @TODO Find a way to not use direct module comparison
 ./inc/wrapper-functions.php:524:// @TODO Do some more sanity check here
 ./inc/xml-functions.php:240:   // @TODO Handle characters
 ./mailid.php:123:              // @TODO Rewrite this to a filter/function
diff --git a/inc/extensions/ext-blacklist.php b/inc/extensions/ext-blacklist.php
new file mode 100644 (file)
index 0000000..50fd459
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 01/21/2013 *
+ * ===================                          Last change: 01/21/2013 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : ext-blacklist.php                                *
+ * -------------------------------------------------------------------- *
+ * Short description : Blacklisting of email/URL addresses              *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  :                                                  *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} // END - if
+
+// Version number
+setThisExtensionVersion('0.0.0');
+
+// Version history array (add more with , '0.0.1' and so on)
+setExtensionVersionHistory(array('0.0.0'));
+
+// This extension is in development (non-productive)
+enableExtensionProductive(FALSE);
+
+switch (getExtensionMode()) {
+       case 'setup': // Do stuff when installation is running
+               // SQL commands to run
+               addDropTableSql('blacklist');
+               addCreateTableSql('blacklist', "
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`data` VARCHAR(255) NOT NULL DEFAULT '',
+`type` VARCHAR(20) NOT NULL DEFAULT 'INVALID',
+`pool_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
+`added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`id`),
+INDEX (`pool_id`)",
+                       'Generic blacklist');
+
+               // Add admin menu
+               addAdminMenuSql('setup','config_blacklist','Sperrlisten','Einstellungen zu den Sperrlisten.',8);
+               addAdminMenuSql('misc','list_blacklist','Sperrlisten...','Zeigt gesperrte Email-Adressen und/oder URLs an.',3);
+
+               // Add configuration
+               addConfigAddSql('url_blacklist', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+               addConfigAddSql('email_blacklist', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+               break;
+
+       case 'remove': // Do stuff when removing extension
+               // SQL commands to run
+               addDropTableSql('blacklist');
+
+               // Remove menu
+               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_blacklist', 'list_blacklist') LIMIT 1");
+               break;
+
+       case 'activate': // Do stuff when admin activates this extension
+               // SQL commands to run
+               break;
+
+       case 'deactivate': // Do stuff when admin deactivates this extension
+               // SQL commands to run
+               break;
+
+       case 'update': // Update an extension
+               switch (getCurrentExtensionVersion()) {
+                       case '0.0.1': // SQL queries for v0.0.1
+                               addExtensionSql('');
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes('');
+                               break;
+               } // END - switch
+               break;
+
+       case 'modify': // When the extension got modified
+               break;
+
+       case 'test': // For testing purposes
+               break;
+
+       case 'init': // Do stuff when extension is initialized
+               break;
+
+       default: // Unknown extension mode
+               reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
+               break;
+} // END - switch
+
+// [EOF]
+?>
index 8d97010..f6ad5bd 100644 (file)
@@ -41,10 +41,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version number
-setThisExtensionVersion('0.5.6');
+setThisExtensionVersion('0.5.7');
 
 // Version history array (add more with , '0.0.1' and so on)
-setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6'));
+setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7'));
 
 switch (getExtensionMode()) {
        case 'setup': // Do stuff when installation is running
@@ -54,7 +54,6 @@ switch (getExtensionMode()) {
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
-               addDropTableSql('url_blacklist');
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_order' LIMIT 1");
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='order'");
 
@@ -305,18 +304,8 @@ nicht die vom Mitglied eingegebene. Resultat: Das Script beschwerte sich, der Us
                                break;
 
                        case '0.5.0': // SQL queries for v0.5.0
-                               addDropTableSql('url_blacklist');
-                               addCreateTableSql('url_blacklist', "
-`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-`url` VARCHAR(255) NOT NULL DEFAULT '',
-`pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-PRIMARY KEY (`id`),
-INDEX (`pool_id`)",
-                                       'URL blacklist');
-
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Tabelle f&uuml;r URL-Sperrliste angelegt.");
+                               setExtensionUpdateNotes("Nicht mehr g&uuml;ltiges Update.");
                                break;
 
                        case '0.5.1': // SQL queries for v0.5.1
@@ -375,6 +364,13 @@ INDEX (`pool_id`)",
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Filter f&uuml;r Spaltenname des gesperrten Werbeguthabens hinzugef&uuml;gt.");
                                break;
+
+                       case '0.5.7': // SQL queries for v0.5.7
+                               addDropTableSql('url_blacklist');
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Tabelle f&uuml;r URL-Sperrliste gel&ouml;scht (nach <strong>ext-blacklist</strong> verschoben).");
+                               break;
                } // END - switch
                break;
 
diff --git a/inc/language/blacklist_de.php b/inc/language/blacklist_de.php
new file mode 100644 (file)
index 0000000..1884f02
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 01/21/2013 *
+ * ===================                          Last change: 01/21/2013 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : blacklist_de.php                                 *
+ * -------------------------------------------------------------------- *
+ * Short description : German langugage support                         *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Deutsche Sprachunterstuetzung                    *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} // END - if
+
+// Language definitions
+addMessages(array(
+       // Admin messages
+       'ADMIN_CONFIG_BLACKLIST_TITLE' => "Konfiguration von Sperrlisten",
+       'ADMIN_CONFIG_BLACKLIST_LEGEND' => "Sperrlisten aktvieren:",
+       'ADMIN_CONFIG_EMAIL_BLACKLIST_ENABLED' => "Sperrliste f&uuml;r Email-Adressen aktivieren?",
+       'ADMIN_CONFIG_URL_BLACKLIST_ENABLED' => "Sperrliste f&uuml;r gebuchte URLs aktivieren?",
+       'ADMIN_CONFIG_BLACKLIST_NOTICE' => "<strong>Hinweise:</strong> Die Sperrliste f&uuml;r Email-Adressen gilt sowohl f&uuml;r die Mitgliedsanmeldung als auch wenn das Mitglied seine Daten &auml;ndert. Ist die vom Mitglied eingegebene Email-Adresse gesperrt, wird diese nicht angenommen. Die URL-Sperrliste gilt f&uuml;r alle Erweiterungen (Besuchertausch, Mailbuchung, Forced-Buchungen usw.).",
+));
+
+// [EOF]
+?>
index ec2c935..04eabde 100644 (file)
@@ -54,7 +54,6 @@ addMessages(array(
        'ADMIN_CONFIG_MAX_UNCONFIRMED_MAILS' => "Maximale erlaubter Anzahl unbest. Mails um eine Mailbuchung durchzuf&uuml;hren",
        'ADMIN_CONFIG_CHECK_EMAIL_TEXT' => "Sind URLs im Werbetext erlaubt?",
        'ADMIN_CONFIG_CHECK_EMAIL_SUBJECT' => "Sind URLs in der Betreffzeile erlaubt?",
-       'ADMIN_CONFIG_URL_BLACKLIST' => "Black-Liste f&uuml;r gebuchte URLs aktivieren?",
        'ADMIN_CONFIG_ORDER_NOTICE' => "Das Auswahlverfahren von Mailempf&auml;ngern wirkt sich nur auf kleinere Buchungen - mit weniger Empf&auml;nger als maximal m&ouml;glich - aus.",
 
        // Admin config - repay options
diff --git a/inc/libs/blacklist_functions.php b/inc/libs/blacklist_functions.php
new file mode 100644 (file)
index 0000000..92e0b2b
--- /dev/null
@@ -0,0 +1,172 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 01/21/2013 *
+ * ===================                          Last change: 01/21/2013 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : blacklist_functions.php                          *
+ * -------------------------------------------------------------------- *
+ * Short description : Functions for ext-                               *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Funktionen fuer ext-                             *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} // END - if
+
+// Inserts a given email (pattern) in blacklist if not found
+function insertEmailInBlacklist ($email, $id) {
+       // Is this feature turned on and is the URL not there?
+       if (!isEmailBlacklistEnabled()) {
+               // Not enabled, then please don't call this function
+               reportBug(__FUNCTION__, __LINE__, 'URL blacklisting is disabled, email=' . $email . ',id=' . $id);
+       } elseif (!isEmailBlacklisted($email)) {
+               // Did not find a record so we can add it... :)
+               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_blacklist` (`data`, `pool_id`, `type`) VALUES ('%s', %s, 'EMAIL')",
+                       array(
+                               $email,
+                               $id
+                       ), __FUNCTION__, __LINE__);
+       } // END - if
+}
+
+// Checks whether given email is blacklisted
+function isEmailBlacklisted ($email) {
+       // Mark it as not listed by default
+       $listed = FALSE;
+
+       // Is black-listing enbaled?
+       if (!isEmailBlacklistEnabled()) {
+               // No, then all emails are not in this list
+               return FALSE;
+       } elseif (!isset($GLOBALS['blacklist_data']['email'][$email])) {
+               // Check black-list for given email
+               $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`added`) AS `added` FROM `{?_MYSQL_PREFIX?}_blacklist` WHERE '%s' REGEXP `data` AND `type`='EMAIL' LIMIT 1",
+                       array($email), __FUNCTION__, __LINE__);
+
+               // Is there an entry?
+               if (SQL_NUMROWS($result) == 1) {
+                       // Jupp, we got one listed
+                       $GLOBALS['blacklist_data']['email'][$email] = SQL_FETCHARRAY($result);
+
+                       // Mark it as listed
+                       $listed = TRUE;
+               } // END - if
+
+               // Free result
+               SQL_FREERESULT($result);
+       } else {
+               // Is found in cache -> black-listed
+               $listed = TRUE;
+       }
+
+       // Return result
+       return $listed;
+}
+
+// Inserts a given URL in blacklist if not found
+function insertUrlInBlacklist ($url, $id) {
+       // Is this feature turned on and is the URL not there?
+       if (!isUrlBlacklistEnabled()) {
+               // Not enabled, then please don't call this function
+               reportBug(__FUNCTION__, __LINE__, 'URL blacklisting is disabled, url=' . $url . ',id=' . $id);
+       } elseif (!isUrlBlacklisted($url)) {
+               // Did not find a record so we can add it... :)
+               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_blacklist` (`data`, `pool_id`, `type`) VALUES ('%s', %s, 'URL')",
+                       array(
+                               $url,
+                               $id
+                       ), __FUNCTION__, __LINE__);
+       } // END - if
+}
+
+// Checks whether given URL is blacklisted
+function isUrlBlacklisted ($url) {
+       // Mark it as not listed by default
+       $listed = FALSE;
+
+       // Is black-listing enbaled?
+       if (!isUrlBlacklistEnabled()) {
+               // No, then all URLs are not in this list
+               return FALSE;
+       } elseif (!isset($GLOBALS['blacklist_data']['url'][$url])) {
+               // Check black-list for given URL
+               $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`added`) AS `added`, `pool_id` FROM `{?_MYSQL_PREFIX?}_blacklist` WHERE `data`='%s' AND `type`='URL' LIMIT 1",
+                       array($url), __FUNCTION__, __LINE__);
+
+               // Is there an entry?
+               if (SQL_NUMROWS($result) == 1) {
+                       // Jupp, we got one listed
+                       $GLOBALS['blacklist_data']['url'][$url] = SQL_FETCHARRAY($result);
+
+                       // Mark it as listed
+                       $listed = TRUE;
+               } // END - if
+
+               // Free result
+               SQL_FREERESULT($result);
+       } else {
+               // Is found in cache -> black-listed
+               $listed = TRUE;
+       }
+
+       // Return result
+       return $listed;
+}
+
+// ----------------------------------------------------------------------------
+//                      Configuration wrapper functions
+// ----------------------------------------------------------------------------
+
+// Wrapper to check if url_blacklist is enabled
+function isUrlBlacklistEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Wrapper to check if email_blacklist is enabled
+function isEmailBlacklistEnabled () {
+       // Is there cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = (getConfig('email_blacklist') == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// [EOF]
+?>
diff --git a/inc/modules/admin/what-config_blacklist.php b/inc/modules/admin/what-config_blacklist.php
new file mode 100644 (file)
index 0000000..11f5b17
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 01/21/2013 *
+ * ===================                          Last change: 01/21/2013 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : what-config_blacklist.php                        *
+ * -------------------------------------------------------------------- *
+ * Short description : Configuration for ext-blacklist                  *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Konfiguration der Sperrlisten                    *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
+} // END - if
+
+// Add description as navigation point
+addYouAreHereLink('admin', __FILE__);
+
+if (isFormSent('save_config')) {
+       // Save data
+       adminSaveSettingsFromPostData();
+} else {
+       // Load template
+       loadTemplate('admin_config_blacklist');
+}
+
+// [EOF]
+?>
index a9145f1..f23946d 100644 (file)
@@ -179,23 +179,14 @@ LIMIT 1',
                        // Nothing selected
                        displayMessage('{--ADMIN_MAILS_NOTHING_CHECKED--}');
                }
-       } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (isUrlBlacklistEnabled())) {
+       } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (isExtensionActive('blacklist')) && (isUrlBlacklistEnabled())) {
                // Lock URLs
                foreach (postRequestElement('sel') as $id => $url) {
                        // Secure id number
                        $id = bigintval($id);
 
                        // Lookup in blacklist
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_url_blacklist` WHERE `url`='%s' LIMIT 1",
-                               array($url), __FILE__, __LINE__);
-                       if (SQL_HASZERONUMS($result)) {
-                               // Did not find a record so we can add it... :)
-                               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_url_blacklist` (`url`, `pool_id`) VALUES ('%s',%s)",
-                                       array($url, $id), __FILE__, __LINE__);
-                       } // END - if
-
-                       // Free memory
-                       SQL_FREERESULT($result);
+                       insertUrlInBlacklist($url);
                } // END - foreach
 
                // Output message
@@ -219,7 +210,7 @@ LIMIT 1',
 
                // Load main template
                loadTemplate('admin_unlock_emails', FALSE, $content);
-       } elseif ((isFormSent('lock')) && (!isUrlBlacklistEnabled())) {
+       } elseif ((isFormSent('lock')) && ((!isExtensionActive('blacklist')) || (!isUrlBlacklistEnabled()))) {
                // URL blacklist not activated
                displayMessage('{--ADMIN_URL_BLACKLIST_DISABLED--}');
        } else {
index 60a07e0..a1f7a2a 100644 (file)
@@ -124,7 +124,7 @@ LIMIT 1",
                } // END - if
 
                // And shall I check that his URL is not in the black list?
-               if (isUrlBlacklisted(postRequestElement('url'))) {
+               if ((isExtensionActive('blacklist')) && (isUrlBlacklisted(postRequestElement('url')))) {
                        // Create redirect-URL
                        $data['url'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('BLIST_URL') . '&amp;blist=' . $GLOBALS['blacklist_data'][postRequestElement('url')]['timestamp'];
                } // END - if
index 6824a16..fd5fa60 100644 (file)
@@ -2451,40 +2451,6 @@ function doGenericListBuilder ($prefix, $listType, $tableName, $columns, $filter
        );
 }
 
-// Checks whether given URL is blacklisted
-function isUrlBlacklisted ($url) {
-       // Mark it as not listed by default
-       $listed = FALSE;
-
-       // Is black-listing enbaled?
-       if (!isUrlBlacklistEnabled()) {
-               // No, then all URLs are not in this list
-               return FALSE;
-       } elseif (!isset($GLOBALS['blacklist_data'][$url])) {
-               // Check black-list for given URL
-               $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`timestamp`) AS `blist_timestamp` FROM `{?_MYSQL_PREFIX?}_url_blacklist` WHERE `url`='%s' LIMIT 1",
-                       array($url), __FILE__, __LINE__);
-
-               // Is there an entry?
-               if (SQL_NUMROWS($result) == 1) {
-                       // Jupp, we got one listed
-                       $GLOBALS['blacklist_data'][$url] = SQL_FETCHARRAY($result);
-
-                       // Mark it as listed
-                       $listed = TRUE;
-               } // END - if
-
-               // Free result
-               SQL_FREERESULT($result);
-       } else {
-               // Is found in cache -> black-listed
-               $listed = TRUE;
-       }
-
-       // Return result
-       return $listed;
-}
-
 // Adds key/value pair to a working SQL string together
 function addKeyValueSql ($key, $value) {
        // Init SQL
index 8c749ab..474a86b 100644 (file)
@@ -2286,7 +2286,7 @@ function anonymizeSensitiveData ($data) {
                if (isAdmin()) {
                        // Is admin, has always priority
                        $data = '[<a href="{%pipe,generateFrametesterUrl=' . $data . '%}" target="_blank">{--ADMIN_TEST_URL--}</a>]';
-               } elseif (isUrlBlacklisted($data)) {
+               } elseif ((isExtensionActive('blacklist')) && (isUrlBlacklisted($data))) {
                        // Yes, so replace it with text
                        $data = '<em>{--URL_IS_BLACKLISTED--}</em>';
                } else {
index 35af66d..ad43853 100644 (file)
@@ -2816,18 +2816,6 @@ function getUserUsedPoints ($userid) {
        return $GLOBALS[__FUNCTION__][$userid];
 }
 
-// Wrapper to check if url_blacklist is enabled
-function isUrlBlacklistEnabled () {
-       // Is there cache?
-       if (!isset($GLOBALS[__FUNCTION__])) {
-               // Determine it
-               $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y');
-       } // END - if
-
-       // Return cache
-       return $GLOBALS[__FUNCTION__];
-}
-
 // Checks whether direct payment is allowed in configuration
 function isDirectPaymentEnabled () {
        // Is there cache?
index 0cc24a4..377eb78 100644 (file)
@@ -41,7 +41,6 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_config` (
   `max_tlength` BIGINT(20) UNSIGNED NOT NULL DEFAULT 1000,
   `autosend_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
   `max_send` TINYINT(3) UNSIGNED NOT NULL DEFAULT 100,
-  `url_blacklist` ENUM('Y','N') NOT NULL DEFAULT 'Y',
   `auto_purge` TINYINT(3) UNSIGNED NOT NULL DEFAULT 14,
   `auto_purge_active` ENUM('Y','N') NOT NULL DEFAULT 'Y',
   `last_update` VARCHAR(10) NOT NULL DEFAULT '0',
diff --git a/templates/de/html/admin/admin_config_blacklist.tpl b/templates/de/html/admin/admin_config_blacklist.tpl
new file mode 100644 (file)
index 0000000..5c21df5
--- /dev/null
@@ -0,0 +1,36 @@
+<div align="center">
+{%form,formMethodPost=modules.php?module=admin&amp;what=config_blacklist%}
+<div class="table dashed">
+       <div class="table_header bottom">
+               <strong>{--ADMIN_CONFIG_BLACKLIST_TITLE--}</strong>
+       </div>
+
+       <fieldset id="config_order_member_fields">
+               <legend>{--ADMIN_CONFIG_BLACKLIST_LEGEND--}</legend>
+
+               <div class="table_row">
+                       <label class="admin_label" for="email_blacklist">{--ADMIN_CONFIG_EMAIL_BLACKLIST_ENABLED--}</label>
+                       <div align="center">
+                               {%template,ConfigurationYesNoSelectionBox=email_blacklist%}
+                       </div>
+               </div>
+
+               <div class="table_row">
+                       <label class="admin_label" for="url_blacklist">{--ADMIN_CONFIG_URL_BLACKLIST_ENABLED--}</label>
+                       <div align="center">
+                               {%template,ConfigurationYesNoSelectionBox=url_blacklist%}
+                       </div>
+               </div>
+       </fieldset>
+
+       <div class="table_footer top">
+               <input type="reset" class="form_reset" value="{--CLEAR_FORM--}" />
+               <input type="submit" class="form_submit" name="save_config" value="{--SAVE_SETTINGS--}" />
+       </div>
+</div>
+{%form_close%}
+</div>
+
+<div class="notice">
+       {--ADMIN_CONFIG_BLACKLIST_NOTICE--}
+</div>
index 8aac624..3157100 100644 (file)
                </div>
 
                <div class="table_row">
-                       <label class="admin_label" for="url_blacklist">{--ADMIN_CONFIG_URL_BLACKLIST--}</label>
-                       <div align="center">
-                               {%template,ConfigurationYesNoSelectionBox=url_blacklist%}
-                       </div>
-               </div>
-
-               <div class="table_row">
                        <label class="admin_label" for="repay_deleted_mails">{--ADMIN_REPAY_ON_DELETE_MODE--}</label>
                        <div align="center">
                                <select name="repay_deleted_mails" class="form_select" size="1">
diff --git a/templates/de/html/ext/ext_blacklist.tpl b/templates/de/html/ext/ext_blacklist.tpl
new file mode 100644 (file)
index 0000000..b9a4327
--- /dev/null
@@ -0,0 +1,4 @@
+<div class="para">
+       Sperren Sie Email-Adressen oder URLs mit dieser Erweiterung. Diese
+       Erweiterung sollte in keinem {?mt_word?} fehlen.
+</div>