Add RFC 2231 support. Thanks to Piotr Pawlow. (#2501379)
[squirrelmail.git] / plugins / spamcop / functions.php
index e21fbfecf8f2b27bdc90261d0f9a8f13f8fae76a..1a5ed9d5523241203313cc50091d275620cb6746 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * SpamCop plugin - functions
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
@@ -66,7 +66,7 @@ function spamcop_show_link_function(&$links) {
         return;
 
     /* GLOBALS */
-    sqgetGlobalVar('passed_id',    $passed_id,    SQ_FORM);
+    sqgetGlobalVar('passed_id',    $passed_id,    SQ_FORM, NULL, SQ_TYPE_BIGINT);
     sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_FORM);
     sqgetGlobalVar('mailbox',      $mailbox,      SQ_FORM);
     if ( sqgetGlobalVar('startMessage', $startMessage, SQ_FORM) ) {
@@ -180,9 +180,7 @@ function spamcop_enable_disable($option,$disable_action,$enable_action) {
  */
 function spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed_id,
                                       $passed_ent_id='', $imapConnection) {
-    global $attachment_dir, $username;
 
-    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
     if (!$passed_ent_id) {
         $body_a = sqimap_run_command($imapConnection,
                                     'FETCH '.$passed_id.' RFC822',
@@ -198,21 +196,12 @@ function spamcop_getMessage_RFC822_Attachment($message, $composeMessage, $passed
         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');
+        $filename = sq_get_attach_tempfile();
+        $fp = fopen($filename, 'wb');
         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);
+                         $filename);
     }
     return $composeMessage;
 }