57fc68413fb9c1c95200ccd6d9c72a0f9a0e23d4
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Submits a message which Squirrelmail couldn't handle
10 * because of malformedness of the message
11 * sends it to retrievalerror@squirrelmail.org
12 * Of course, this only happens when the end user has chosen to do so
17 /* Path for SquirrelMail required files. */
18 define('SM_PATH','../');
20 /* SquirrelMail required files. */
21 require_once(SM_PATH
. 'include/validate.php');
22 require_once(SM_PATH
. 'functions/imap.php');
23 require_once(SM_PATH
. 'functions/smtp.php');
24 require_once(SM_PATH
. 'functions/page_header.php');
25 require_once(SM_PATH
. 'include/load_prefs.php');
27 $destination = 'retrievalerror@squirrelmail.org';
28 $attachments = array();
32 $key = $_COOKIE['key'];
33 $username = $_SESSION['username'];
34 $onetimepad = $_SESSION['onetimepad'];
36 $mailbox = $_GET['mailbox'];
37 $passed_id = $_GET['passed_id'];
38 $startMessage = $_GET['startMessage'];
39 $show_more = $_GET['show_more'];
40 $response = $_GET['response'];
41 $message = $_GET['message'];
42 $topline = $_GET['topline'];
44 if(isset($_GET['where'])) {
45 $where = $_GET['where'];
47 if(isset($_GET['what'])) {
48 $what = $_GET['what'];
53 function ClearAttachments() {
54 global $attachments, $attachment_dir, $username;
56 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
57 foreach ($attachments as $info) {
58 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
59 if (file_exists($attached_file)) {
60 unlink($attached_file);
64 $attachments = array();
67 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
68 sqimap_mailbox_select($imap_stream, $mailbox);
69 $sid = sqimap_session_id();
70 fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
71 $data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
72 sqimap_logout($imap_stream);
73 $topline2 = array_shift($data);
74 $thebastard = implode('', $data);
76 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
77 $localfilename = GenerateRandomString(32, '', 7);
78 $full_localfilename = "$hashed_attachment_dir/$localfilename";
79 while (file_exists($full_localfilename)) {
80 $localfilename = GenerateRandomString(32, '', 7);
81 $full_localfilename = "$hashed_attachment_dir/$localfilename";
84 /* Write Attachment to file */
85 $fp = fopen ($full_localfilename, 'wb');
86 fputs ($fp, $thebastard);
89 $newAttachment = array();
90 $newAttachment['localfilename'] = $localfilename;
91 $newAttachment['remotefilename'] = 'message.duh';
92 $newAttachment['type'] = 'application/octet-stream';
93 $attachments[] = $newAttachment;
95 $body = "Response: $response\n" .
96 "Message: $message\n" .
97 "FETCH line: $topline\n" .
98 "Server Type: $imap_server_type\n";
100 $imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
101 $server_info = fgets ($imap_stream, 1024);
103 $body .= " Server info: $server_info";
104 fputs ($imap_stream, "a001 CAPABILITY\r\n");
105 $read = fgets($imap_stream, 1024);
106 $list = explode(' ', $read);
109 $read = implode(' ', $list);
110 $body .= " Capabilities: $read";
111 fputs ($imap_stream, "a002 LOGOUT\r\n");
112 fclose($imap_stream);
115 $body .= "\nFETCH line for gathering the whole message: $topline2\n";
117 sendMessage($destination, '', '', 'submitted message', $body, False, 0);
119 displayPageHeader($color, $mailbox);
121 $par = 'mailbox='.urlencode($mailbox)."&passed_id=$passed_id";
122 if (isset($where) && isset($what)) {
123 $par .= '&where='.urlencode($where).'&what='.urlencode($what);
125 $par .= "&startMessage=$startMessage&show_more=0";
128 echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
129 'Thank you very much<BR>' .
130 'Please submit every message only once<BR>' .
131 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";