+
+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'];
+ 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 */
+