/**
* Message and Spam Filter Plugin
*
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This plugin filters your inbox into different folders based upon given
* Also view plugins/README.plugins for more information.
*
* $Id$
+ * @package plugins
+ * @subpackage filters
*/
-chdir ('..');
-require_once('../src/validate.php');
-require_once('../functions/page_header.php');
-require_once('../functions/imap.php');
-require_once('../src/load_prefs.php');
-require_once('../functions/html.php');
+/** Path for SquirrelMail required files. */
+define('SM_PATH','../../');
+/* 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;
+/* get globals */
+sqgetGlobalVar('username', $username, SQ_SESSION);
+sqgetGlobalVar('key', $key, SQ_COOKIE);
+sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
+sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
+
+sqgetGlobalVar('action', $action, SQ_GET);
+/* end globals */
+
displayPageHeader($color, 'None');
-if (isset($spam_submit)) {
+if (isset($_POST['spam_submit'])) {
$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) {
$input = $spam_filters[$Key]['prefname'] . '_set';
- if ( isset( $$input ) ) {
+ if ( isset( $_POST[$input] ) ) {
setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],
- $$input);
+ $_POST[$input]);
} else {
removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
}
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
$boxes = sqimap_mailbox_list($imapConnection);
sqimap_logout($imapConnection);
- for ($i = 0; $i < count($boxes) && $filters_spam_folder == ''; $i++) {
+ $numboxes = count($boxes);
- if ($boxes[$i]['flags'][0] != 'noselect' &&
- $boxes[$i]['flags'][1] != 'noselect' &&
- $boxes[$i]['flags'][2] != 'noselect') {
+ for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++) {
+ 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'];
}
}
html_tag( 'td', '', 'left' ) .
'<select name="filters_spam_folder_set">';
- for ($i = 0; $i < count($boxes); $i++) {
- if (! in_array('noselect', $boxes[$i]['flags'])) {
- $box = $boxes[$i]['unformatted'];
- $box2 = str_replace(' ', ' ', $boxes[$i]['formatted']);
- if ($filters_spam_folder == $box) {
- echo "<OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
- } else {
- echo "<OPTION VALUE=\"$box\">$box2</OPTION>\n";
- }
- }
- }
+ $selected = 0;
+ if ( isset($filters_spam_folder) )
+ $selected = array(strtolower($filters_spam_folder));
+ echo sqimap_mailbox_option_list(0, $selected, 0, $boxes);
echo '</select>'.
'</td>'.
'</tr>'.
}
-if (! isset($action) || $action != 'spam') {
+if (! isset($_GET['action']) || $_GET['action'] != 'spam') {
echo html_tag( 'p', '', 'center' ) .
'[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .