Split out functionality that gathers system specs
[squirrelmail.git] / plugins / filters / filters.php
index b85633a152d111c9206eaed2e23fd91a021e1ed8..34ffd31dd5b355784e5c04ef10200e4f74b0b271 100644 (file)
@@ -1,10 +1,6 @@
 <?php
-
 /**
- * Message and Spam Filter Plugin
- *
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
+ * Message and Spam Filter Plugin - Filtering Functions
  *
  * This plugin filters your inbox into different folders based upon given
  * criteria.  It is most useful for people who are subscibed to mailing lists
  *
  * Also view plugins/README.plugins for more information.
  *
- * $Id$
+ * @version $Id$
+ * @copyright (c) 1999-2004 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @package plugins
  * @subpackage filters
  */
 
 /**
-*
-*/
+ * FIXME: Undocumented function
+ * @access private
+ */
 function filters_SaveCache () {
     global $data_dir, $SpamFilters_DNScache;
 
@@ -57,6 +56,10 @@ function filters_SaveCache () {
     fclose($fp);
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function filters_LoadCache () {
     global $data_dir, $SpamFilters_DNScache;
 
@@ -76,6 +79,10 @@ function filters_LoadCache () {
     }
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function filters_bulkquery($filters, $IPs) {
     global $SpamFilters_YourHop, $attachment_dir, $username,
            $SpamFilters_DNScache, $SpamFilters_BulkQuery,
@@ -113,6 +120,10 @@ function filters_bulkquery($filters, $IPs) {
     }
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function start_filters() {
     global $mailbox, $imapServerAddress, $imapPort, $imap,
            $imap_general, $filters, $imap_stream, $imapConnection,
@@ -153,6 +164,10 @@ function start_filters() {
 #    }
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function user_filters($imap_stream) {
     global $data_dir, $username;
     $filters = load_filters();
@@ -189,10 +204,14 @@ function user_filters($imap_stream) {
     }
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_scan, 
                                   $should_expunge) {
-    global $languages, $squirrelmail_language, $allow_charset_search, 
-           $uid_support, $imap_server_type;
+    global $languages, $squirrelmail_language, $allow_charset_search, $imap_server_type;
+
     if ($user_scan == 'new') {
         $category = 'UNSEEN';
     } else {
@@ -222,7 +241,7 @@ function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_
     }
 
     /* read data back from IMAP */
-    $read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, $uid_support);
+    $read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, TRUE);
 
     // This may have problems with EIMS due to it being goofy
 
@@ -249,9 +268,12 @@ function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_
     return $should_expunge;
 }
 
-// These are the spam filters
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function spam_filters($imap_stream) {
-    global $data_dir, $username, $uid_support;
+    global $data_dir, $username;
     global $SpamFilters_YourHop;
     global $SpamFilters_DNScache;
     global $SpamFilters_SharedCache;
@@ -289,7 +311,7 @@ function spam_filters($imap_stream) {
     if ($filters_spam_scan != 'new') {
         $query = 'FETCH 1:* (BODY.PEEK[HEADER.FIELDS (Received)])';
     } else {
-        $read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, $uid_support);
+        $read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, TRUE);
         if ($response != 'OK' || trim($read[0]) == '* SEARCH') {
            $query = 'FETCH 1:* (BODY.PEEK[HEADER.FIELDS (RECEIVED)])';
         } else {
@@ -372,8 +394,12 @@ function spam_filters($imap_stream) {
     }
 }
 
-// Does the loop through each enabled filter for the specified IP address.
-// IP format:  $a.$b.$c.$d
+/**
+ * FIXME: Undocumented function
+ * Does the loop through each enabled filter for the specified IP address.
+ * IP format:  $a.$b.$c.$d
+ * @access private
+ */
 function filters_spam_check_site($a, $b, $c, $d, &$filters) {
     global $SpamFilters_DNScache, $SpamFilters_CacheTTL;
     foreach ($filters as $key => $value) {
@@ -404,6 +430,10 @@ function filters_spam_check_site($a, $b, $c, $d, &$filters) {
     return 0;
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function load_filters() {
     global $data_dir, $username;
 
@@ -417,6 +447,10 @@ function load_filters() {
     return $filters;
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function load_spam_filters() {
     global $data_dir, $username, $SpamFilters_ShowCommercial;
 
@@ -435,7 +469,7 @@ function load_spam_filters() {
         $filters['MAPS RSS']['dns'] = 'relays.mail-abuse.org';
         $filters['MAPS RSS']['result'] = '127.0.0.2';
         $filters['MAPS RSS']['comment'] =
-            _("COMMERCIAL - Servers that are configured (or misconfigured) to allow spam to be relayed through their system will be banned with this.  Another good one to use.");
+            _("COMMERCIAL - Servers that are configured (or misconfigured) to allow spam to be relayed through their system will be banned with this. Another good one to use.");
 
         $filters['MAPS DUL']['prefname'] = 'filters_spam_maps_dul';
         $filters['MAPS DUL']['name'] = 'MAPS Dial-Up List';
@@ -443,7 +477,7 @@ function load_spam_filters() {
         $filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org';
         $filters['MAPS DUL']['result'] = '127.0.0.3';
         $filters['MAPS DUL']['comment'] =
-            _("COMMERCIAL - Dial-up users are often filtered out since they should use their ISP's mail servers to send mail.  Spammers typically get a dial-up account and send spam directly from there.");
+            _("COMMERCIAL - Dial-up users are often filtered out since they should use their ISP's mail servers to send mail. Spammers typically get a dial-up account and send spam directly from there.");
 
         $filters['MAPS RBLplus-RBL']['prefname'] = 'filters_spam_maps_rblplus_rbl';
         $filters['MAPS RBLplus-RBL']['name'] = 'MAPS RBL+ RBL List';
@@ -694,6 +728,10 @@ function load_spam_filters() {
     return $filters;
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function remove_filter ($id) {
     global $data_dir, $username;
 
@@ -706,6 +744,10 @@ function remove_filter ($id) {
     removePref($data_dir, $username, 'filter' . $id);
 }
 
+/**
+ * FIXME: Undocumented function
+ * @access private
+ */
 function filter_swap($id1, $id2) {
     global $data_dir, $username;
 
@@ -718,8 +760,11 @@ function filter_swap($id1, $id2) {
     }
 }
 
-/* This update the filter rules when
-   renaming or deleting folders */
+/**
+ * This update the filter rules when renaming or deleting folders
+ * @param array $args
+ * @access private
+ */
 function update_for_folder ($args) {
     $old_folder = $args[0];
         $new_folder = $args[2];
@@ -746,15 +791,16 @@ function update_for_folder ($args) {
         }
     }
 }
-/*
+
+/**
  * Function extracted from sqimap_get_small_header_list.
  * The unused FETCH arguments and HEADERS are disabled.
+ * @access private
  */
 function filter_get_headers ($imap_stream, $query) {
-    global $uid_support;
     /* Get the small headers for each message in $msg_list */
 
-    $read_list = sqimap_run_command_list ($imap_stream, $query, false, $response, $message, $uid_support);
+    $read_list = sqimap_run_command_list ($imap_stream, $query, false, $response, $message, TRUE);
 
     if (isset($response) && $response != 'OK') {
         return false;
@@ -867,4 +913,16 @@ function filter_get_headers ($imap_stream, $query) {
     return $msgs;
 }
 
-?>
\ No newline at end of file
+/**
+ * Display formated error message
+ * @param string $string text message
+ * @return string html formated text message
+ * @access private
+ */
+function do_error($string) {
+    global $color;
+    echo "<p align=\"center\"><font color=\"$color[2]\">";
+    echo $string;
+    echo "</font></p>\n";
+}
+?>