Wrong include path
[squirrelmail.git] / src / retrievalerror.php
CommitLineData
a019eeb8 1<?php
895905c0 2
35586184 3/**
4 * retrievalerror.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
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
13 *
14 * $Id$
15 */
16
86725763 17/* Path for SquirrelMail required files. */
18define('SM_PATH','../');
19
20/* SquirrelMail required files. */
08185f2a 21require_once(SM_PATH . 'include/validate.php');
86725763 22require_once(SM_PATH . 'functions/imap.php');
23require_once(SM_PATH . 'functions/smtp.php');
24require_once(SM_PATH . 'functions/page_header.php');
08185f2a 25require_once(SM_PATH . 'include/load_prefs.php');
32f4e318 26
feb8ce79 27$destination = 'retrievalerror@squirrelmail.org';
32f4e318 28$attachments = array();
29
30function ClearAttachments() {
31 global $attachments, $attachment_dir, $username;
32
33 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
34 foreach ($attachments as $info) {
35 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
36 if (file_exists($attached_file)) {
37 unlink($attached_file);
38 }
39 }
40
41 $attachments = array();
42}
43
44$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
45sqimap_mailbox_select($imap_stream, $mailbox);
46$sid = sqimap_session_id();
47fputs ($imap_stream, "$sid FETCH $passed_id BODY[]\r\n");
48$data = sqimap_read_data ($imap_stream, $sid, true, $response, $message);
49sqimap_logout($imap_stream);
50$topline2 = array_shift($data);
51$thebastard = implode('', $data);
52
53$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
54$localfilename = GenerateRandomString(32, '', 7);
55$full_localfilename = "$hashed_attachment_dir/$localfilename";
56while (file_exists($full_localfilename)) {
57 $localfilename = GenerateRandomString(32, '', 7);
58 $full_localfilename = "$hashed_attachment_dir/$localfilename";
59}
60
61/* Write Attachment to file */
81d79073 62$fp = fopen ($full_localfilename, 'wb');
32f4e318 63fputs ($fp, $thebastard);
64fclose ($fp);
65
66$newAttachment = array();
67$newAttachment['localfilename'] = $localfilename;
68$newAttachment['remotefilename'] = 'message.duh';
69$newAttachment['type'] = 'application/octet-stream';
70$attachments[] = $newAttachment;
71
72$body = "Response: $response\n" .
73 "Message: $message\n" .
74 "FETCH line: $topline\n" .
75 "Server Type: $imap_server_type\n";
76
77$imap_stream = fsockopen ($imapServerAddress, $imapPort, &$error_number, &$error_string);
78$server_info = fgets ($imap_stream, 1024);
79if ($imap_stream) {
80 $body .= " Server info: $server_info";
81 fputs ($imap_stream, "a001 CAPABILITY\r\n");
82 $read = fgets($imap_stream, 1024);
83 $list = explode(' ', $read);
84 array_shift($list);
85 array_shift($list);
86 $read = implode(' ', $list);
87 $body .= " Capabilities: $read";
88 fputs ($imap_stream, "a002 LOGOUT\r\n");
89 fclose($imap_stream);
90}
91
92$body .= "\nFETCH line for gathering the whole message: $topline2\n";
93
4041157c 94sendMessage($destination, '', '', 'submitted message', $body, False, 0);
32f4e318 95
96displayPageHeader($color, $mailbox);
97
5e9e90fd 98$par = 'mailbox='.urlencode($mailbox)."&amp;passed_id=$passed_id";
32f4e318 99if (isset($where) && isset($what)) {
5e9e90fd 100 $par .= '&amp;where='.urlencode($where).'&amp;what='.urlencode($what);
32f4e318 101} else {
5e9e90fd 102 $par .= "&amp;startMessage=$startMessage&amp;show_more=0";
32f4e318 103}
104
105echo '<BR>The message has been submitted to the developers knowledgebase!<BR>' .
106 'Thank you very much<BR>' .
107 'Please submit every message only once<BR>' .
108 "<A HREF=\"../src/read_body.php?$par\">View the message</A><BR>";
109
5e9e90fd 110?>