making sure that plugin works without configuration file. Most of plugin
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 29 Apr 2005 08:46:42 +0000 (08:46 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 29 Apr 2005 08:46:42 +0000 (08:46 +0000)
configuration options are about tuning plugin and not about required site
specific changes.

optimized sqgetGlobalVar and include calls.

updated some docs.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9400 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/filters/README
plugins/filters/config_default.php [moved from plugins/filters/config.sample.php with 92% similarity]
plugins/filters/filters.php
plugins/filters/options.php
plugins/filters/spamoptions.php

index cf30ffba86314d48e7bda83eaf0bfb5ea67bde09..967f12c1ba172325cc182c544f62ba3538d80383 100644 (file)
@@ -1,50 +1,52 @@
 Filters Plugin
 
 Filters Plugin
 
-This plugin filters your inbox into different folders based upon given criteria.
-It is most useful for people who are subscibed to mailing lists to help organize
-their messages. The argument stands that filtering is not the place of the
-client, which is why this has been made a plugin for SquirrelMail. You may be
-better off using products such as Sieve or Procmail to do your filtering so it
-happens even when SquirrelMail isn't running.
+ABOUT PLUGIN
+------------
+This plugin sorts messages in your inbox into different folders based upon 
+given criteria. It is most useful for people who are subscribed to mailing 
+lists to help organize their messages. The argument stands that filtering is 
+not the place of the client, which is why this has been made a plugin for 
+SquirrelMail. You may be better off using products such as Sieve, Maildrop or 
+Procmail to do your filtering so it happens even when SquirrelMail isn't 
+running.
 
 IMPORTANT: At least one version of PHP has bugs in the checkdnsrr() function
 that the SPAM filtering code RELIES ON. The PHP server that comes with Mandrake
 8.1 has this problem -- checkdnsrr() NEVER finds the inaddr records, even the
 ones that really exist.
 
 
 IMPORTANT: At least one version of PHP has bugs in the checkdnsrr() function
 that the SPAM filtering code RELIES ON. The PHP server that comes with Mandrake
 8.1 has this problem -- checkdnsrr() NEVER finds the inaddr records, even the
 ones that really exist.
 
-NOTE!!! As of the time of this writing, there is a bug in sqimap_read_data() in
-functions/imap_general.php. I rewrote it (see sqimap_read_data.php) so if the
-SPAM filters aren't filtering, make a backup copy of functions/imap_general.php,
-remove the sqimap_read_data() function in there and replace it with the contents
-of sqimap_read_data.php. Hopefully, either my replacement will be blessed by
-squirrelmail-devel or some other version will come out soon. Now back to your
-regularly scheduled README... (grin)
-
 This is a poor alternative to procmail or Elm's filter programs. This is a
 pathetic replacement for good RBL mail scanning when you get the mail. This is
 This is a poor alternative to procmail or Elm's filter programs. This is a
 pathetic replacement for good RBL mail scanning when you get the mail. This is
-more for systems that can't/won't offer that kind of functionality and you still
-require it.
+more for systems that can't/won't offer that kind of functionality and you 
+still require it.
 
 This is slow. Yep. Slow.
 
 
 This is slow. Yep. Slow.
 
-To configure, first you need to rename config.sample.php to config.php. You
-should then just take a peek at config.php and set $SpamFilters_YourHop to some
-string if you want to avoid tons of false hits on the RSS and DUL and ORBS
-databases. It should also speed up the scan somewhat.
-
-If you do not want to enable spam filters for all users, edit config.php and set
-the $AllowSpamFilters to false. Spam filters can take TONS of time, so if you
-don't want your users to complain and ask you tons of questions, this is a quick
-and easy method.
+INSTALLATION
+------------
+Plugin is installed by enabling it in SquirrelMail configuration script. 
+Plugin configuration can be changed with configuration files stored in 
+config/filters_config.php or plugins/filters/config.php. Default configuration
+values can be found in plugins/filters/config_default.php. If both 
+configuration files are present, plugin uses file from config directory.
+
+Main configuration option that must be changed is $SpamFilters_YourHop setting.
+See comments about it in config_default.php. If $SpamFilters_YourHop uses 
+default value, plugin will be unable to use RBL filtering correctly and 
+warning message will is displayed to end user. If you don't want to use RBL 
+filtering, you can disable it by setting $AllowSpamFilters option to false. If 
+you can control your incoming SMTP server, it is recommended to turn RBL 
+filtering on server.
 
 If you use UW and if you encounter strange errors while using this plugin on
 
 If you use UW and if you encounter strange errors while using this plugin on
-your system, edit config.php and set $UseSeparateImapConnection to true. This
-may not solve the problem. One problem it might fix is if you run UW 2001 and if
-you don't see the number of unread messages in your left-hand folder pane, or if
-you see timeouts or IMAP server error messages. Turning on this feature may slow
-down the filters a bit more since it has to open a new connection.
-
-Lastly, if there are some IPs that you want to refuse email from or some IPs you
-want to accept email from REGARDLESS of what the DNS databases say, you can put
-in overrides in the SpamFilters_DNScache[] array. See the comments in config.php
-for more info on this.
+your system, edit configuration file and set $UseSeparateImapConnection to 
+true. This may not solve the problem. One problem it might fix is if you run UW
+2001 and if you don't see the number of unread messages in your left-hand 
+folder pane, or if you see timeouts or IMAP server error messages. Turning on 
+this feature may slow down the filters a bit more since it has to open a new 
+connection.
+
+Lastly, if there are some IPs that you want to refuse email from or some IPs 
+you want to accept email from REGARDLESS of what the DNS databases say, you can
+put in overrides in the SpamFilters_DNScache[] array. See the comments in 
+config_default.php for more info on this.
similarity index 92%
rename from plugins/filters/config.sample.php
rename to plugins/filters/config_default.php
index 0764dc67d03ba94e69892dc48496661142a73db9..28d95f4831d9f2ed0eddf4286008b79b6d568b85 100644 (file)
@@ -17,8 +17,6 @@
  *        Seems to be related to UW
  * @global bool $UseSeparateImapConnection
  */
  *        Seems to be related to UW
  * @global bool $UseSeparateImapConnection
  */
-
-global $UseSeparateImapConnection;
 $UseSeparateImapConnection = false;
 
 /**
 $UseSeparateImapConnection = false;
 
 /**
@@ -28,8 +26,6 @@ $UseSeparateImapConnection = false;
  * spam filters
  * @global bool $AllowSpamFilters
  */
  * spam filters
  * @global bool $AllowSpamFilters
  */
-
-global $AllowSpamFilters;
 $AllowSpamFilters = true;
 
 /**
 $AllowSpamFilters = true;
 
 /**
@@ -49,8 +45,6 @@ $AllowSpamFilters = true;
  * the header (lots of false alarms here tho).
  * @global string $SpamFilters_YourHop
  */
  * the header (lots of false alarms here tho).
  * @global string $SpamFilters_YourHop
  */
-
-global $SpamFilters_YourHop;
 $SpamFilters_YourHop = ' ';
 
 /**
 $SpamFilters_YourHop = ' ';
 
 /**
@@ -62,12 +56,10 @@ $SpamFilters_YourHop = ' ';
  * should set SpamFilters_ShowCommercial to false.
  * @global bool $SpamFilters_ShowCommercial
  */
  * should set SpamFilters_ShowCommercial to false.
  * @global bool $SpamFilters_ShowCommercial
  */
-
-global $SpamFilters_ShowCommercial;
 $SpamFilters_ShowCommercial = false;
 
 /**
 $SpamFilters_ShowCommercial = false;
 
 /**
- * SpamFiltring Cache
+ * SpamFiltering Cache
  *
  * A cache of IPs we've already checked or are known bad boys or good boys
  * ie. $SpamFilters_DNScache["210.54.220.18"] = true;
  *
  * A cache of IPs we've already checked or are known bad boys or good boys
  * ie. $SpamFilters_DNScache["210.54.220.18"] = true;
@@ -76,8 +68,7 @@ $SpamFilters_ShowCommercial = false;
  * email coming from it would NOT be SPAM
  * @global array $SpamFilters_DNScache
  */
  * email coming from it would NOT be SPAM
  * @global array $SpamFilters_DNScache
  */
-
-global $SpamFilters_DNScache;
+$SpamFilters_DNScache=array();
 
 /**
  * Path to bulkquery program
 
 /**
  * Path to bulkquery program
@@ -87,8 +78,6 @@ global $SpamFilters_DNScache;
  * in the bulkquery directory for more information on using bulkquery.
  * @global string $SpamFilters_BulkQuery
  */
  * in the bulkquery directory for more information on using bulkquery.
  * @global string $SpamFilters_BulkQuery
  */
-
-global $SpamFilters_BulkQuery;
 $SpamFilters_BulkQuery = '';
 
 /**
 $SpamFilters_BulkQuery = '';
 
 /**
@@ -100,8 +89,6 @@ $SpamFilters_BulkQuery = '';
  * data directory.
  * @global bool $SpamFilters_SharedCache
  */
  * data directory.
  * @global bool $SpamFilters_SharedCache
  */
-
-global $SpamFilters_SharedCache;
 $SpamFilters_SharedCache = true;
 
 /**
 $SpamFilters_SharedCache = true;
 
 /**
@@ -110,8 +97,6 @@ $SpamFilters_SharedCache = true;
  * How long should DNS query results be cached for by default (in seconds)?
  * @global integer $SpamFilters_CacheTTL
  */
  * How long should DNS query results be cached for by default (in seconds)?
  * @global integer $SpamFilters_CacheTTL
  */
-
-global $SpamFilters_CacheTTL;
 $SpamFilters_CacheTTL = 7200;
 
 ?>
\ No newline at end of file
 $SpamFilters_CacheTTL = 7200;
 
 ?>
\ No newline at end of file
index c326a1f5a7942b1f2cc85f5e044b507455c21d9e..2e405bbc4acdc9e1d39485d4d60600b732a8ce19 100644 (file)
@@ -9,9 +9,35 @@
  * @subpackage filters
  */
 
  * @subpackage filters
  */
 
-/** load config */
-if (file_exists(SM_PATH . 'plugins/filters/config.php'))
+/** @ignore */
+if (! defined('SM_PATH')) define('SM_PATH','../../');
+
+/** load globals */
+global $UseSeparateImapConnection, 
+    $AllowSpamFilters, $SpamFilters_YourHop, $SpamFilters_ShowCommercial, 
+    $SpamFilters_DNScache, $SpamFilters_BulkQuery, $SpamFilters_SharedCache, 
+    $SpamFilters_CacheTTL;
+
+/** load default config */
+if (file_exists(SM_PATH . 'plugins/filters/config_default.php')) {
+    include_once (SM_PATH . 'plugins/filters/config_default.php');
+} else {
+    // default config was removed.
+    $UseSeparateImapConnection = false;
+    $AllowSpamFilters = true;
+    $SpamFilters_YourHop = ' ';
+    $SpamFilters_ShowCommercial = false;
+    $SpamFilters_DNScache = array();
+    $SpamFilters_BulkQuery = '';
+    $SpamFilters_SharedCache = true;
+    $SpamFilters_CacheTTL = 7200;
+}
+
+if (file_exists(SM_PATH . 'config/filters_config.php')) {
+    include_once (SM_PATH . 'config/filters_config.php');
+} elseif (file_exists(SM_PATH . 'plugins/filters/config.php')) {
     include_once (SM_PATH . 'plugins/filters/config.php');
     include_once (SM_PATH . 'plugins/filters/config.php');
+}
 
 /**
  * Init Hooks
 
 /**
  * Init Hooks
@@ -19,10 +45,8 @@ if (file_exists(SM_PATH . 'plugins/filters/config.php'))
  */
 function filters_init_hooks () {
     global $squirrelmail_plugin_hooks;
  */
 function filters_init_hooks () {
     global $squirrelmail_plugin_hooks;
-    if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-    if (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) {
-        sqgetGlobalVar('mailbox',$mailbox,SQ_FORM);
-    } else {
+
+    if (! sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) {
         $mailbox = 'INBOX';
     }
 
         $mailbox = 'INBOX';
     }
 
@@ -42,7 +66,6 @@ function filters_init_hooks () {
  */
 function filters_optpage_register_block() {
     global $optpage_blocks, $AllowSpamFilters;
  */
 function filters_optpage_register_block() {
     global $optpage_blocks, $AllowSpamFilters;
-    if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
 
     $optpage_blocks[] = array(
         'name' => _("Message Filters"),
 
     $optpage_blocks[] = array(
         'name' => _("Message Filters"),
@@ -165,8 +188,6 @@ function start_filters() {
     global $imapServerAddress, $imapPort, $imap_stream, $imapConnection,
            $UseSeparateImapConnection, $AllowSpamFilters;
 
     global $imapServerAddress, $imapPort, $imap_stream, $imapConnection,
            $UseSeparateImapConnection, $AllowSpamFilters;
 
-    if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-
     sqgetGlobalVar('username', $username, SQ_SESSION);
     sqgetGlobalVar('key',      $key,      SQ_COOKIE);
 
     sqgetGlobalVar('username', $username, SQ_SESSION);
     sqgetGlobalVar('key',      $key,      SQ_COOKIE);
 
@@ -822,8 +843,6 @@ function filter_swap($id1, $id2) {
  */
 function update_for_folder ($args) {
 
  */
 function update_for_folder ($args) {
 
-    if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-
     $old_folder = $args[0];
     $new_folder = $args[2];
     $action = $args[1];
     $old_folder = $args[0];
     $new_folder = $args[2];
     $action = $args[1];
index 58147c5e672d6d92e7d10c0d82fd2a9d40214f33..c4e974511d02e9c64b40c66eb7b98a96b6ca44db 100644 (file)
@@ -17,13 +17,8 @@ define('SM_PATH','../../');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'plugins/filters/filters.php');
-
-if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-include_once (SM_PATH . 'plugins/filters/config.php');
-
-global $AllowSpamFilters;
+include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'plugins/filters/filters.php');
 
 displayPageHeader($color, 'None');
 
 
 displayPageHeader($color, 'None');
 
index 26bb53c207227987357280122ed0c2e29aaac5a3..c2ab0b0ca18a7863e996ef9240545d51ad73b051 100644 (file)
@@ -17,12 +17,8 @@ define('SM_PATH','../../');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'include/load_prefs.php');
-require_once(SM_PATH . 'functions/html.php');
-require_once(SM_PATH . 'plugins/filters/filters.php');
-global $AllowSpamFilters;
+include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'plugins/filters/filters.php');
 
 /* get globals */
 sqgetGlobalVar('username', $username, SQ_SESSION);
 
 /* get globals */
 sqgetGlobalVar('username', $username, SQ_SESSION);