]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | /* vim: set ts=4 tw=0 sw=4 noet: */ | |
3 | require_once 'Mail/mimeDecode.php'; | |
4 | require_once 'config.php'; | |
5 | require_once $CFG->root . 'lib/db_factory.php'; | |
6 | require_once $CFG->root . 'lib/utils.inc.php'; | |
7 | ||
8 | $util = new Utils; | |
9 | $loggedIn = $util->isLoggedIn(); | |
10 | if ($loggedIn && isset($_GET['id'])) { | |
11 | $id = $_GET['id']; | |
12 | $id = urldecode($id); | |
13 | ||
14 | $util->setHeading("Message ID : $id"); | |
15 | echo $util->getHeader(); | |
16 | echo $util->getHeading(); | |
17 | ||
18 | $mail = unserialize($_SESSION['mailInfo'][$id]); | |
19 | ||
20 | $row = $DB->getMail($id); | |
21 | $string = $row->mail_text; | |
22 | $sa_tests = null; | |
23 | $params['include_bodies'] = true; | |
24 | $params['decode_bodies'] = true; | |
25 | $params['decode_headers'] = true; | |
26 | $params['input'] = $string; | |
27 | $params['crlf'] = "\r\n"; | |
28 | ||
29 | $structure = Mail_mimeDecode::decode($params); | |
30 | $headers = $structure->headers; | |
31 | ||
32 | echo '<table class="button-menu">'; | |
33 | echo '<tr class="button-row">'; | |
34 | echo '<td class="button"><input class="btn-input" type="button" value="Return" | |
35 | onclick="javascript: history.back();"/></td>'; | |
36 | echo '</tr></table>'; | |
37 | ||
38 | echo '<table><tr>'; | |
39 | $from = $headers['from']; | |
40 | $from = str_replace("<", "<", $from); | |
41 | $from = str_replace(">", ">", $from); | |
42 | echo "<tr><td class=\"label\">From</td><td class=\"value\">$from</td></tr>"; | |
43 | $to = $headers['to']; | |
44 | $to = str_replace("<", "<", $to); | |
45 | $to = str_replace(">", ">", $to); | |
46 | echo "<tr><td class=\"label\">To</td><td class=\"value\">$to</td></tr>"; | |
47 | $date = $headers['date']; | |
48 | $date = str_replace("<", "<", $date); | |
49 | $date = str_replace(">", ">", $date); | |
50 | echo "<tr><td class=\"label\">Date</td><td class=\"value\">$date</td></tr>"; | |
51 | echo "<tr><td class=\"label\">Subject</td><td class=\"value\">".$headers['subject']."</td></tr>"; | |
52 | echo '<tr><td class="label">Body</td><td class="value">'; | |
53 | if (isset($structure->parts)) { | |
54 | foreach ($structure->parts as $part) { | |
55 | if ($_GET['format'] == 'html') { | |
56 | if ($part->ctype_primary=="text" and $part->ctype_secondary=="html") { | |
57 | $bodytext = str_replace("\n", " ",$part->body); | |
58 | $bodytext = str_replace("<body>", "", $bodytext); | |
59 | $bodytext = str_replace("</body>", "", $bodytext); | |
60 | $bodytext = str_replace("<head>", "", $bodytext); | |
61 | $bodytext = str_replace("</head>", "", $bodytext); | |
62 | $bodytext = str_replace("<html>", "", $bodytext); | |
63 | $bodytext = str_replace("</html>", "", $bodytext); | |
64 | echo $bodytext; | |
65 | } | |
66 | } else { | |
67 | if ($part->ctype_primary=="text" and $part->ctype_secondary=="plain") { | |
68 | $bodytext = str_replace("\n", "<br />",$part->body); | |
69 | echo $bodytext; | |
70 | } | |
71 | } | |
72 | } | |
73 | } else { | |
74 | if ($_GET['format'] == 'html') { | |
75 | $bodytext = str_replace("\n", " ",$structure->body); | |
76 | $bodytext = str_replace("<body>", "", $bodytext); | |
77 | $bodytext = str_replace("</body>", "", $bodytext); | |
78 | $bodytext = str_replace("<head>", "", $bodytext); | |
79 | $bodytext = str_replace("</head>", "", $bodytext); | |
80 | ||
81 | $bodytext = str_replace("<html>", "", $bodytext); | |
82 | $bodytext = str_replace("</html>", "", $bodytext); | |
83 | echo $bodytext; | |
84 | } else { | |
85 | $bodytext = $structure->body; | |
86 | $bodytext = wordwrap($bodytext, 90, "<br/>"); | |
87 | echo $bodytext; | |
88 | } | |
89 | } | |
90 | echo '</td></tr></table>'; | |
91 | echo $util->getFooter(); | |
92 | } else if ($loggedIn) { | |
93 | header('Location: index.php'); | |
94 | } else { | |
95 | header('Location: auth.php'); | |
96 | } | |
97 | ||
98 | ?> | |
99 |