]> git.datanom.net - qtadmin.git/blame - message_view.php
First upload of wblist page
[qtadmin.git] / message_view.php
CommitLineData
6df4b805 1<?php
6b3d5ba9 2/* vim: set ts=4 tw=0 sw=4 noet: */
b95d1cdb
MR
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';
6df4b805 7
3056d117 8 $util = new Utils;
b95d1cdb
MR
9 $loggedIn = $util->isLoggedIn();
10 if ($loggedIn && isset($_GET['id'])) {
6df4b805
MR
11 $id = $_GET['id'];
12 $id = urldecode($id);
13
af31b70b
MR
14 $mail = unserialize($_SESSION['mailInfo'][$id]);
15
2b099ad2 16 if (! is_object($mail) || false == $util->authorized($mail->recipient)) {
7047d03c 17 header('Location: qtadmin.php');
af31b70b
MR
18 exit;
19 }
20
b95d1cdb
MR
21 $util->setHeading("Message ID : $id");
22 echo $util->getHeader();
23 echo $util->getHeading();
6df4b805 24
b95d1cdb
MR
25 $row = $DB->getMail($id);
26 $string = $row->mail_text;
27 $sa_tests = null;
28 $params['include_bodies'] = true;
29 $params['decode_bodies'] = true;
30 $params['decode_headers'] = true;
31 $params['input'] = $string;
32 $params['crlf'] = "\r\n";
6df4b805 33
b95d1cdb
MR
34 $structure = Mail_mimeDecode::decode($params);
35 $headers = $structure->headers;
6df4b805 36
b95d1cdb
MR
37 echo '<table class="button-menu">';
38 echo '<tr class="button-row">';
39 echo '<td class="button"><input class="btn-input" type="button" value="Return"
40 onclick="javascript: history.back();"/></td>';
41 echo '</tr></table>';
6df4b805 42
8335f35a 43 echo '<table>';
b95d1cdb
MR
44 $from = $headers['from'];
45 $from = str_replace("<", "&lt;", $from);
46 $from = str_replace(">", "&gt;", $from);
47 echo "<tr><td class=\"label\">From</td><td class=\"value\">$from</td></tr>";
48 $to = $headers['to'];
49 $to = str_replace("<", "&lt;", $to);
50 $to = str_replace(">", "&gt;", $to);
51 echo "<tr><td class=\"label\">To</td><td class=\"value\">$to</td></tr>";
52 $date = $headers['date'];
53 $date = str_replace("<", "&lt;", $date);
54 $date = str_replace(">", "&gt;", $date);
55 echo "<tr><td class=\"label\">Date</td><td class=\"value\">$date</td></tr>";
56 echo "<tr><td class=\"label\">Subject</td><td class=\"value\">".$headers['subject']."</td></tr>";
57 echo '<tr><td class="label">Body</td><td class="value">';
58 if (isset($structure->parts)) {
59 foreach ($structure->parts as $part) {
60 if ($_GET['format'] == 'html') {
61 if ($part->ctype_primary=="text" and $part->ctype_secondary=="html") {
62 $bodytext = str_replace("\n", " ",$part->body);
63 $bodytext = str_replace("<body>", "", $bodytext);
64 $bodytext = str_replace("</body>", "", $bodytext);
65 $bodytext = str_replace("<head>", "", $bodytext);
66 $bodytext = str_replace("</head>", "", $bodytext);
67 $bodytext = str_replace("<html>", "", $bodytext);
68 $bodytext = str_replace("</html>", "", $bodytext);
69 echo $bodytext;
70 }
71 } else {
72 if ($part->ctype_primary=="text" and $part->ctype_secondary=="plain") {
73 $bodytext = str_replace("\n", "<br />",$part->body);
74 echo $bodytext;
75 }
76 }
77 }
78 } else {
79 if ($_GET['format'] == 'html') {
80 $bodytext = str_replace("\n", " ",$structure->body);
81 $bodytext = str_replace("<body>", "", $bodytext);
82 $bodytext = str_replace("</body>", "", $bodytext);
83 $bodytext = str_replace("<head>", "", $bodytext);
84 $bodytext = str_replace("</head>", "", $bodytext);
85
86 $bodytext = str_replace("<html>", "", $bodytext);
87 $bodytext = str_replace("</html>", "", $bodytext);
88 echo $bodytext;
89 } else {
90 $bodytext = $structure->body;
91 $bodytext = wordwrap($bodytext, 90, "<br/>");
92 echo $bodytext;
93 }
94 }
95 echo '</td></tr></table>';
96 echo $util->getFooter();
6df4b805 97 } else if ($loggedIn) {
7047d03c 98 header('Location: qtadmin.php');
6df4b805
MR
99 } else {
100 header('Location: auth.php');
101 }
102
103?>
104
This page took 0.108186 seconds and 5 git commands to generate.