Forráskód Böngészése

Keep on going... filters plugin rg=0 compat.

Thijs Kinkhorst 23 éve
szülő
commit
72897c50b4

+ 6 - 3
plugins/filters/filters.php

@@ -162,9 +162,12 @@ function filters_bulkquery($filters_spam_scan, $filters, $read) {
 }
 }
 
 
 function start_filters() {
 function start_filters() {
-    global $mailbox, $username, $key, $imapServerAddress, $imapPort, $imap,
+    global $mailbox, $imapServerAddress, $imapPort, $imap,
            $imap_general, $filters, $imap_stream, $imapConnection,
            $imap_general, $filters, $imap_stream, $imapConnection,
-           $UseSeparateImapConnection, $AllowSpamFilters;
+           $UseSeparateImapConnection, $AllowSpamFilters, $_SESSION, $_COOKIE;
+
+    $username = $_SESSION['username'];
+    $key = $_COOKIE['key'];
 
 
 #    if ($mailbox == 'INBOX') {
 #    if ($mailbox == 'INBOX') {
         // Detect if we have already connected to IMAP or not.
         // Detect if we have already connected to IMAP or not.
@@ -411,7 +414,7 @@ function spam_filters($imap_stream) {
     if ($SpamFilters_SharedCache) {
     if ($SpamFilters_SharedCache) {
        filters_SaveCache();
        filters_SaveCache();
     } else {
     } else {
-       session_register('SpamFilters_DNScache');
+       sqsession_register($SpamFilters_DNScache, 'SpamFilters_DNScache');
     }
     }
 
 
 }
 }

+ 32 - 5
plugins/filters/options.php

@@ -39,8 +39,32 @@ require_once(SM_PATH . 'plugins/filters/filters.php');
 
 
    displayPageHeader($color, 'None');
    displayPageHeader($color, 'None');
 
 
-   if (isset($filter_submit)) {
-      if (!isset($theid)) $theid = 0;
+   $username = $_SESSION['username'];
+   $key = $_COOKIE['key'];
+   $onetimepad = $_SESSION['onetimepad'];
+   $delimiter = $_SESSION['delimiter'];
+   if(isset($_GET['theid'])) {
+       $theid = $_GET['theid'];
+   }
+   if(isset($_POST['theid'])) {
+       $theid = $_POST['theid'];
+   }
+   if(isset($_GET['action'])) {
+       $action = $_GET['action'];
+   }
+
+   if (isset($_POST['filter_submit'])) {
+      if(isset($_GET['theid'])) {
+          $theid = $_GET['theid'];
+      } elseif (isset($_POST['theid'])) {
+          $theid = $_POST['theid'];
+      } else {
+          $theid = 0;
+      }
+      $filter_what   = $_POST['filter_what'];
+      $filter_where  = $_POST['filter_where'];
+      $filter_folder = $_POST['filter_folder'];
+
       $filter_what = ereg_replace(",", " ", $filter_what);
       $filter_what = ereg_replace(",", " ", $filter_what);
       $filter_what = str_replace("\\\\", "\\", $filter_what);
       $filter_what = str_replace("\\\\", "\\", $filter_what);
       $filter_what = str_replace("\\\"", "\"", $filter_what);
       $filter_what = str_replace("\\\"", "\"", $filter_what);
@@ -60,9 +84,9 @@ require_once(SM_PATH . 'plugins/filters/filters.php');
       filter_swap($theid, $theid - 1);
       filter_swap($theid, $theid - 1);
    } elseif (isset($action) && $action == 'move_down') {
    } elseif (isset($action) && $action == 'move_down') {
       filter_swap($theid, $theid + 1);
       filter_swap($theid, $theid + 1);
-   } elseif (isset($user_submit)) {
-       echo "<br><center><b>"._("Saved Scan type")."</b></center>\n";
-       setPref($data_dir, $username, 'filters_user_scan', $filters_user_scan_set);
+   } elseif (isset($_POST['user_submit'])) {
+       setPref($data_dir, $username, 'filters_user_scan', $_POST['filters_user_scan_set']);
+       echo '<br><center><b>'._("Saved Scan type")."</b></center>\n";
    }
    }
 
 
    $filters = load_filters();
    $filters = load_filters();
@@ -105,6 +129,9 @@ require_once(SM_PATH . 'plugins/filters/filters.php');
         'center' ) . '<br>';
         'center' ) . '<br>';
 
 
     if (isset($action) && ($action == 'add' || $action == 'edit')) {
     if (isset($action) && ($action == 'add' || $action == 'edit')) {
+        $username = $_SESSION['username'];
+        $key = $_COOKIE['key'];
+
         $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
         $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
         $boxes = sqimap_mailbox_list($imapConnection);
         $boxes = sqimap_mailbox_list($imapConnection);
         sqimap_logout($imapConnection);
         sqimap_logout($imapConnection);

+ 11 - 2
plugins/filters/setup.php

@@ -105,10 +105,19 @@ $SpamFilters_CacheTTL = 7200;
 
 
 function squirrelmail_plugin_init_filters() {
 function squirrelmail_plugin_init_filters() {
     global $squirrelmail_plugin_hooks;
     global $squirrelmail_plugin_hooks;
-    global $mailbox, $imap_stream, $imapConnection;
+
+    if (isset($_GET['mailbox'])) {
+        $mailbox = $_GET['mailbox'];
+    }
+    elseif (isset($_POST['mailbox'])) {
+        $mailbox = $_POST['mailbox'];
+    }
+    else {
+        $mailbox = 'INBOX';
+    }
 
 
     $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
     $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
-    if ($mailbox == 'INBOX') {
+    if (isset($mailbox) && $mailbox == 'INBOX') {
         $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters';
         $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters';
     }
     }
     $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block';
     $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block';

+ 18 - 10
plugins/filters/spamoptions.php

@@ -36,17 +36,26 @@ require_once(SM_PATH . 'functions/html.php');
 require_once(SM_PATH . 'plugins/filters/filters.php');
 require_once(SM_PATH . 'plugins/filters/filters.php');
 global $AllowSpamFilters;
 global $AllowSpamFilters;
 
 
+$username = $_SESSION['username'];
+$key = $_COOKIE['key'];
+$onetimepad = $_SESSION['onetimepad'];
+$delimiter = $_SESSION['delimiter'];
+
+if (isset($_GET['action'])) {
+    $action = $_GET['action'];
+}
+
 displayPageHeader($color, 'None');
 displayPageHeader($color, 'None');
 
 
-if (isset($spam_submit)) {
+if (isset($_POST['spam_submit'])) {
     $spam_filters = load_spam_filters();
     $spam_filters = load_spam_filters();
-    setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
-    setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
+    setPref($data_dir, $username, 'filters_spam_folder', $_POST['filters_spam_folder_set']);
+    setPref($data_dir, $username, 'filters_spam_scan', $_POST['filters_spam_scan_set']);
     foreach ($spam_filters as $Key => $Value) {
     foreach ($spam_filters as $Key => $Value) {
         $input = $spam_filters[$Key]['prefname'] . '_set';
         $input = $spam_filters[$Key]['prefname'] . '_set';
-        if ( isset( $$input ) ) {
+        if ( isset( $_POST[$input] ) ) {
             setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],
             setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],
-                     $$input);
+                     $_POST[$input]);
         } else {
         } else {
             removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
             removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
         }
         }
@@ -78,10 +87,9 @@ if (isset($action) && $action == 'spam') {
     $boxes = sqimap_mailbox_list($imapConnection);
     $boxes = sqimap_mailbox_list($imapConnection);
     sqimap_logout($imapConnection);
     sqimap_logout($imapConnection);
     for ($i = 0; $i < count($boxes) && $filters_spam_folder == ''; $i++) {
     for ($i = 0; $i < count($boxes) && $filters_spam_folder == ''; $i++) {
-
-        if ($boxes[$i]['flags'][0] != 'noselect' &&
-            $boxes[$i]['flags'][1] != 'noselect' &&
-            $boxes[$i]['flags'][2] != 'noselect') {
+        if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
+            (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
+            (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
             $filters_spam_folder = $boxes[$i]['unformatted'];
             $filters_spam_folder = $boxes[$i]['unformatted'];
         }
         }
     }
     }
@@ -176,7 +184,7 @@ if (isset($action) && $action == 'spam') {
 
 
 }
 }
 
 
-if (! isset($action) || $action != 'spam') {
+if (! isset($_GET['action']) || $_GET['action'] != 'spam') {
 
 
     echo html_tag( 'p', '', 'center' ) .
     echo html_tag( 'p', '', 'center' ) .
          '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
          '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .