X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=plugins%2Fspamcop%2Fspamcop.php;h=6139a097982b803749fcae55c37b12d3d0d126e1;hb=b587ac51cdb214754146d61829ba87bf4341f949;hp=511ca33e856dbd09ea51954d18b9e68564ba4f9b;hpb=04f6008a45f667d2ce38925f5b2dc4b56076d28e;p=squirrelmail.git diff --git a/plugins/spamcop/spamcop.php b/plugins/spamcop/spamcop.php index 511ca33e..6139a097 100644 --- a/plugins/spamcop/spamcop.php +++ b/plugins/spamcop/spamcop.php @@ -2,7 +2,7 @@ /** ** spamcop.php -- SpamCop plugin ** - ** Copyright (c) 1999-2002 The SquirrelMail development team + ** Copyright (c) 1999-2003 The SquirrelMail development team ** Licensed under the GNU GPL. For full terms see the file COPYING. ** ** $Id$ @@ -14,74 +14,117 @@ define('SM_PATH','../../'); require_once(SM_PATH . 'include/validate.php'); require_once(SM_PATH . 'functions/imap.php'); - /* GLOBALS */ +function getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, + $passed_ent_id='', $imapConnection) { + global $attachments, $attachment_dir, $username, $data_dir, $uid_support; + + $hashed_attachment_dir = getHashedDir($username, $attachment_dir); + if (!$passed_ent_id) { + $body_a = sqimap_run_command($imapConnection, + 'FETCH '.$passed_id.' RFC822', + TRUE, $response, $readmessage, + $uid_support); + } else { + $body_a = sqimap_run_command($imapConnection, + 'FETCH '.$passed_id.' BODY['.$passed_ent_id.']', + TRUE, $response, $readmessage, $uid_support); + $message = $message->parent; + } + if ($response = 'OK') { + $subject = encodeHeader($message->rfc822_header->subject); + array_shift($body_a); + $body = implode('', $body_a) . "\r\n"; + + $localfilename = GenerateRandomString(32, 'FILE', 7); + $full_localfilename = "$hashed_attachment_dir/$localfilename"; + $fp = fopen( $full_localfilename, 'w'); + fwrite ($fp, $body); + fclose($fp); + + /* dirty relative dir fix */ + if (substr($attachment_dir,0,3) == '../') { + $attachment_dir = substr($attachment_dir,3); + $hashed_attachment_dir = getHashedDir($username, $attachment_dir); + } + $full_localfilename = "$hashed_attachment_dir/$localfilename"; + + $composeMessage->initAttachment('message/rfc822','email.txt', + $full_localfilename); + } + return $composeMessage; +} + + /* GLOBALS */ $username = $_SESSION['username']; $key = $_COOKIE['key']; $onetimepad = $_SESSION['onetimepad']; - $mailbox = $_GET['mailbox']; $passed_id = $_GET['passed_id']; - $startMessage = $_GET['startMessage']; + if (isset($_GET['startMessage'])) { + $startMessage = $_GET['startMessage']; + } else { + $startMessage = 1; + } + if (isset($_GET['passed_ent_id'])) { + $passed_ent_id = $_GET['passed_ent_id']; + } else { + $passed_ent_id = ''; + } + if ( isset($_SESSION['compose_messages']) ) { + $compose_messages = &$_SESSION['compose_messages']; + } + if ( isset($_SESSION['composesession']) ) { + $composesession = $_SESSION['composesession']; + } else { + $composesession = 0; + sqsession_register($composesession, 'composesession'); + } /* END GLOBALS */ + displayPageHeader($color, $mailbox); $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqimap_mailbox_select($imap_stream, $mailbox); - $sid = sqimap_session_id($uid_support) - fputs($imap_stream, $sid.' FETCH ' . $passed_id . ' RFC822' . "\r\n"); - - $read = sqimap_read_data($imap_stream, $sid, true, $response, $message); - array_shift($read); if ($spamcop_method == 'quick_email' || $spamcop_method == 'thorough_email') { // Use email-based reporting -- save as an attachment - if(!isset($composesession)) { - $composesession = 0; - sqsession_register($composesession, 'composesession'); + $session = "$composesession"+1; + $composesession = $session; + sqsession_register($composesession,'composesession'); + if (!isset($compose_messages)) { + $compose_messages = array(); } - if (!isset($session)) { - $session = "$composesession" +1; - $composesession = $session; + if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) { + $composeMessage = new Message(); + $rfc822_header = new Rfc822Header(); + $composeMessage->rfc822_header = $rfc822_header; + $composeMessage->reply_rfc822_header = ''; + $compose_messages[$session] = $composeMessage; + sqsession_register($compose_messages,'compose_messages'); + } else { + $composeMessage=$compose_messages[$session]; } - if (!isset($attachments)) { - $attachments = array(); - sqsession_register($attachments, 'attachments'); - } - - foreach ($attachments as $info) { - if (file_exists($attachment_dir . $info['localfilename'])) - unlink($attachment_dir . $info['localfilename']); - } - $attachments = array(); - - $file = GenerateRandomString(32, '', 7); - while (file_exists($attachment_dir . $file)) - $file = GenerateRandomString(32, '', 7); - $newAttachment['localfilename'] = $file; - $newAttachment['remotefilename'] = 'email.txt'; - $newAttachment['type'] = 'message/rfc822'; - $newAttachment['session'] = $session; - $fp = fopen($attachment_dir . $file, 'w'); - foreach ($read as $line) { - fputs($fp, $line); - } - sqsession_unregister('attachments'); - $attachments[] = $newAttachment; - sqsession_register($attachments , 'attachments'); - $fn = getPref($data_dir, $username, 'full_name'); - $em = getPref($data_dir, $username, 'email_address'); - - $HowItLooks = $fn . ' '; - if ($em != '') + $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); + $composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, + $passed_ent_id='', $imap_stream); + + $compose_messages[$session] = $composeMessage; + sqsession_register($compose_messages, 'compose_messages'); + + $fn = getPref($data_dir, $username, 'full_name'); + $em = getPref($data_dir, $username, 'email_address'); + + $HowItLooks = $fn . ' '; + if ($em != '') $HowItLooks .= '<' . $em . '>'; - } + } ?> @@ -116,12 +159,13 @@ agree to follow SpamCop's rules/terms of service/etc.

$report_email = 'submit.' . $spamcop_id . '@spam.spamcop.net'; else $report_email = 'quick.' . $spamcop_id . '@spam.spamcop.net'; -?>
+ $form_action = SM_PATH . 'src/compose.php'; +?> - + @@ -129,6 +173,12 @@ agree to follow SpamCop's rules/terms of service/etc.

50000) { $Warning = "\n[truncated by SpamCop]\n";