diff -urN plugins.orig/spam_quarantine/index.php plugins/spam_quarantine/index.php --- plugins.orig/spam_quarantine/index.php Thu Jan 1 03:00:00 1970 +++ plugins/spam_quarantine/index.php Sun Sep 3 19:16:47 2006 @@ -0,0 +1,19 @@ + diff -urN plugins.orig/spam_quarantine/sa-learn.php plugins/spam_quarantine/sa-learn.php --- plugins.orig/spam_quarantine/sa-learn.php Thu Jan 1 03:00:00 1970 +++ plugins/spam_quarantine/sa-learn.php Mon Sep 4 15:07:10 2006 @@ -0,0 +1,150 @@ + + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * $Id: sa-learn.php,v 0.01 2006/09/04 15:07:06 corvax Exp $ + * @package plugins + * @subpackage spam_quarantine + */ + +function sqimap_msgs_list_copy_without_deleting($imap_stream, $id, $mailbox) { + global $uid_support; + $msgs_id = sqimap_message_list_squisher($id); + $read = sqimap_run_command ($imap_stream, "COPY $msgs_id \"$mailbox\"", true, $response, $message, $uid_support); +// $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response, $message, $uid_support); +} + +define('SM_PATH','../../'); + +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/global.php'); +include_once(SM_PATH . 'functions/page_header.php'); +include_once(SM_PATH . 'include/load_prefs.php'); +include_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/identity.php'); +require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/html.php'); + +/* get globals */ +sqgetGlobalVar('key', $key, SQ_COOKIE); +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); +sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); + +//sqgetGlobalVar('mailbox', $mailbox); +sqgetGlobalVar('startMessage', $startMessage); +sqgetGlobalVar('msg', $msg); + +sqgetGlobalVar('msgs', $msgs, SQ_SESSION); +sqgetGlobalVar('composesession', $composesession, SQ_SESSION); +sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION); + +sqgetGlobalVar('moveButton', $moveButton, SQ_POST); +sqgetGlobalVar('expungeButton', $expungeButton, SQ_POST); +sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_POST); +sqgetGlobalVar('expungeButton', $expungeButton, SQ_POST); +sqgetGlobalVar('undeleteButton', $undeleteButton, SQ_POST); +sqgetGlobalVar('markRead', $markRead, SQ_POST); +sqgetGlobalVar('markUnread', $markUnread, SQ_POST); +sqgetGlobalVar('attache', $attache, SQ_POST); +sqgetGlobalVar('location', $location, SQ_POST); + + +sqgetGlobalVar('mailbox', $mailbox, SQ_GET); +sqgetGlobalVar('sort', $sort, SQ_GET); +sqgetGlobalVar('startMessage', $startMessage, SQ_GET); +sqgetGlobalVar('return', $return, SQ_GET); + +sqgetGlobalVar('passed_id', $passed_id, SQ_GET); +sqgetGlobalVar('action1', $action1, SQ_GET); +sqgetGlobalVar('target_mailbox1', $target_mailbox1, SQ_GET); +sqgetGlobalVar('action2', $action2, SQ_GET); +sqgetGlobalVar('target_mailbox2', $target_mailbox2, SQ_GET); + +if (!$mailbox) $mailbox = 'INBOX'; +if (!$sort) $sort = '0'; +if (!$startMessage) $startMessage = 1; +if (!$return) $return = SM_PATH . 'src/right_main.php?sort=' . $sort . '&startMessage=' . $startMessage . '&mailbox=' . $mailbox; + +$error_msg = ''; +$location = $return; + +$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); +$mbx_response=sqimap_mailbox_select($imapConnection, $mailbox); + +/* remember changes to mailbox setting */ +if (!isset($lastTargetMailbox)) { + $lastTargetMailbox = 'INBOX'; +} +if ($targetMailbox != $lastTargetMailbox) { + $lastTargetMailbox = $targetMailbox; + sqsession_register($lastTargetMailbox, 'lastTargetMailbox'); +} +$exception = false; + +$id = array(); +$id[] = $passed_id; + +if (count($id)) { + $targetMailbox = $target_mailbox1; + $action = $action1; + + if ($action == "copy") { + sqimap_msgs_list_copy_without_deleting($imapConnection,$id,$targetMailbox); + + $targetMailbox = $target_mailbox2; + + if ($action2 == "move") { + sqimap_msgs_list_copy($imapConnection,$id,$targetMailbox); + if ($auto_expunge) { + $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true); + } else { + $cnt = 0; + } + + if (($startMessage+$cnt-1) >= $mbx_response['EXISTS']) { + if ($startMessage > $show_num) { + $location = set_url_var($location,'startMessage',$startMessage-$show_num, false); + } else { + $location = set_url_var($location,'startMessage',1, false); + } + } + } + } elseif ($action == "move") { + sqimap_msgs_list_copy($imapConnection,$id,$targetMailbox); + if ($auto_expunge) { + $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true); + } else { + $cnt = 0; + } + + if (($startMessage+$cnt-1) >= $mbx_response['EXISTS']) { + if ($startMessage > $show_num) { + $location = set_url_var($location,'startMessage',$startMessage-$show_num, false); + } else { + $location = set_url_var($location,'startMessage',1, false); + } + } + } +} else { + $exception = true; + $error_msg = "Nothing to learn"; +} + +// Log out this session +sqimap_logout($imapConnection); +if ($exception) { + displayPageHeader($color, $mailbox); + error_message($error_msg, $mailbox, $sort, $startMessage, $color); +} else { + header("Location: $location"); + exit; +} +?> + diff -urN plugins.orig/spam_quarantine/setup.php plugins/spam_quarantine/setup.php --- plugins.orig/spam_quarantine/setup.php Thu Jan 1 03:00:00 1970 +++ plugins/spam_quarantine/setup.php Mon Sep 4 15:07:32 2006 @@ -0,0 +1,92 @@ + + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * Implementation of SA learning. + * + * $Id: sa-learn.php,v 0.01 2006/09/04 14:50:28 corvax Exp $ + * @package plugins + * @subpackage spam_quarantine + */ + +function squirrelmail_plugin_init_spam_quarantine () { + global $squirrelmail_plugin_hooks; + + $squirrelmail_plugin_hooks['read_body_header']['spam_quarantine'] = 'plugin_spam_quarantine_menu'; +} + +function plugin_spam_quarantine_menu() { + global $mailbox, $sort, $startMessage; + + if (strlen(trim($mailbox)) < 1) { + $mailbox = 'INBOX'; + } + + $spam_quarantine_folders = array( + 'probably-spam' => "spam.probably-spam", + 'certainly-spam' => "spam.certainly-spam", + 'certainly-spam-learn' => "spam.certainly-spam-learn", + 'sa-learn-spam' => "spam.sa-learn-spam", + 'sa-learn-ham' => "spam.sa-learn-ham" + ); + + $output = array(); + + /* get globals */ + sqgetGlobalVar('passed_id', $passed_id, SQ_GET); + + $REQUEST_URI = $_SERVER['REQUEST_URI']; + $SCRIPT_NAME = '../plugins/spam_quarantine/sa-learn.php'; + $PARAMS = 'mailbox=' . $mailbox . '&sort=' . $sort . '&startMessage=' . $startMessage; + $return_copy = 'return=' . urlencode($REQUEST_URI); + $return_move = 'return=' . urlencode('../../src/right_main.php?sort=' . $sort . '&startMessage=' . $startMessage . '&mailbox=' . $mailbox); + + if ($mailbox == $spam_quarantine_folders['probably-spam']) { + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=move&target_mailbox1=' . $spam_quarantine_folders['sa-learn-ham'] . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as NOSPAM (move to sa-learn-ham)' . ''; + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=move&target_mailbox1=' . $spam_quarantine_folders['sa-learn-spam'] . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as SPAM (move to sa-learn-spam)' . ''; + } elseif ($mailbox == $spam_quarantine_folders['certainly-spam']) { + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=copy&target_mailbox1=' . $spam_quarantine_folders['sa-learn-ham'] . + '&action2=move&target_mailbox2=INBOX' . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as NOSPAM (copy to sa-learn-ham and move to INBOX)' . ''; + } elseif ($mailbox == $spam_quarantine_folders['certainly-spam-learn']) { + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=move&target_mailbox1=' . $spam_quarantine_folders['sa-learn-spam'] . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as SPAM (move to sa-learn-spam)' . ''; + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=copy&target_mailbox1=' . $spam_quarantine_folders['sa-learn-ham'] . + '&action2=move&target_mailbox2=INBOX' . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as NOSPAM (copy to sa-learn-ham and move to INBOX)' . ''; + } else { + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=move&target_mailbox1=' . $spam_quarantine_folders['sa-learn-spam'] . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as SPAM (move to sa-learn-spam)' . ''; + $act = $SCRIPT_NAME . '?passed_id=' . $passed_id . + '&action1=copy&target_mailbox1=' . $spam_quarantine_folders['sa-learn-ham'] . + '&' . $PARAMS . '&' . $return_move; + $output[] = '' . 'learn as NOSPAM (copy to sa-learn-ham)' . ''; + } + + echo ''; + echo html_tag('td', '' . _("Spam learn subsystem") . ':  ', + 'right', '', 'valign="middle" width="20%"') . "\n"; + echo html_tag('td', '' . implode(' | ', $output) . '', + 'left', $color[0], 'valign="middle" width="80%"') . "\n"; + echo ''; +} + +?>