3
* Message Details plugin - bottom frame with message structure and rfc822 body
5
5
* Plugin to view the RFC822 raw message output and the bodystructure of a message
7
* Copyright (c) 2002 Marc Groot Koerkamp, The Netherlands
8
7
* Licensed under the GNU GPL. For full terms see the file COPYING.
10
* $Id: message_details_bottom.php,v 1.12 2003/10/27 22:24:40 tassium Exp $
9
* @author Marc Groot Koerkamp
10
* @copyright Copyright © 2002 Marc Groot Koerkamp, The Netherlands
11
* @copyright Copyright © 2004-2005 The SquirrelMail Project Team
12
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
13
* @version $Id: message_details_bottom.php,v 1.10.2.3 2004/12/27 15:03:58 kink Exp $
12
15
* @subpackage message_details
19
22
require_once(SM_PATH . 'include/validate.php');
20
23
require_once(SM_PATH . 'functions/imap.php');
21
24
require_once(SM_PATH . 'functions/mime.php');
22
require_once(SM_PATH . 'config/config.php');
23
require_once(SM_PATH . 'functions/prefs.php');
25
26
global $color, $uid_support;
31
32
sqgetGlobalVar('key', $key, SQ_COOKIE);
32
33
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
36
* Calculates id of MIME entity
37
* @param string $entString
38
* @param integer $direction
34
42
function CalcEntity($entString, $direction) {
35
43
$result = $entString;
36
44
if ($direction == -1) {
64
function returnTime($start) {
65
$stop = gettimeofday();
66
$timepassed = 1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec'];
70
function GetMimeProperties($header) {
73
72
$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
74
73
$read = sqimap_mailbox_select($imapConnection, $mailbox);
75
$start = gettimeofday();
76
74
$body = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, $uid_support);
77
75
$message_body = '';
142
140
if ( ( $header || $messageheader) && (preg_match("/^.*boundary=\"?(.+(?=\")|.+).*/i",$line,$reg)) ) {
145
$bndreg = str_replace("\\","\\\\",$bndreg);
146
$bndreg = str_replace("?","\\?",$bndreg);
147
$bndreg = str_replace("+","\\+",$bndreg);
148
$bndreg = str_replace(".","\\.",$bndreg);
149
$bndreg = str_replace("/","\\/",$bndreg);
150
$bndreg = str_replace("-","\\-",$bndreg);
151
$bndreg = str_replace("(","\\(",$bndreg);
152
$bndreg = str_replace(")","\\)",$bndreg);
143
$bndreg = str_replace("\\","\\\\",$bndreg);
144
$bndreg = str_replace("?","\\?",$bndreg);
145
$bndreg = str_replace("+","\\+",$bndreg);
146
$bndreg = str_replace(".","\\.",$bndreg);
147
$bndreg = str_replace("/","\\/",$bndreg);
148
$bndreg = str_replace("-","\\-",$bndreg);
149
$bndreg = str_replace("(","\\(",$bndreg);
150
$bndreg = str_replace(")","\\)",$bndreg);
154
$boundaries[] = array( 'bnd' => $bnd, 'bndreg' => $bndreg);
155
$messageheader = false;
156
$messageheaderstart=false;
161
$entStr = CalcEntity("$entStr",1);
152
$boundaries[] = array( 'bnd' => $bnd, 'bndreg' => $bndreg);
153
$messageheader = false;
154
$messageheaderstart=false;
159
$entStr = CalcEntity("$entStr",1);
165
163
if (($line != '' && $line{0} == '-' || $header) && isset($boundaries[0])) {
179
$entStr = CalcEntity("$entStr",-1);
180
array_pop($boundaries);
181
$pre .= '<b><font color ='."$color[2]>";
182
$end .= '</font></b>';
177
$entStr = CalcEntity("$entStr",-1);
178
array_pop($boundaries);
179
$pre .= '<b><font color ='."$color[2]>";
180
$end .= '</font></b>';
190
$entStr = CalcEntity("$entStr",0);
192
$content[$content_indx]=array();
193
$content[$content_indx]['ent'] = '<A HREF="#'."$entStr \">$entStr".'</a>';
194
$pre .= "\n \n".'</div>'."\n \n".'<div class="entheader" ID="'.$entStr.'H"><a name="'."$entStr".'"><b><font color ='."$color[2]>";
195
$end .= '</font></b>'."\n";
188
$entStr = CalcEntity("$entStr",0);
190
$content[$content_indx]=array();
191
$content[$content_indx]['ent'] = '<a href="#'."$entStr \">$entStr".'</a>';
192
$pre .= "\n \n".'</div>'."\n \n".'<div class="entheader" id="'.
193
$entStr.'H"><a name="'."$entStr".'"><b><font color ='."$color[2]>";
194
$end .= '</font></b>'."\n";
274
273
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
275
274
echo '<code>'."\n";
276
275
echo '<font face = "monospace">'."\n";
280
//session_register("entities");
281
//$keys = array_keys($entities);
282
//$start = gettimeofday();
283
//foreach ($keys as $key) {
284
// if (isset($entities[$key])) {
285
// if ($entities[$key]['encoding'] == 'base64') {
286
// echo '<img src="message_viewentity.php?ent='.$entities[$key]['entity'].'&name='.$entities[$key]['name'].'"><br>';
290
//session_unregister("entities");
292
278
if (count($content) > 0) {
293
echo '<h2> Bodystructure </h2>'."\n\n";
279
echo '<h2>' . _("Bodystructure") . "</h2>\n\n";
294
280
echo '<table border=1 width="98%"><thead>'.
295
281
'<tr bgcolor="'."$color[7]".'">'.
296
'<td><b><font color="'."$color[5]".'">Entity</font></b></td>'.
297
'<td><b><font color="'."$color[5]".'">Content-Type</font></b></td>'.
298
'<td><b><font color="'."$color[5]".'">Name</font></b></td>'.
299
'<td><b><font color="'."$color[5]".'">Encoding</font></b></td>'.
282
'<td><b><font color="'."$color[5]".'">' . _("Entity") . '</font></b></td>'.
283
'<td><b><font color="'."$color[5]".'">' . _("Content-Type") . '</font></b></td>'.
284
'<td><b><font color="'."$color[5]".'">' . _("Name") . '</font></b></td>'.
285
'<td><b><font color="'."$color[5]".'">' . _("Encoding") . '</font></b></td>'.
302
288
'</thead><tbody>';
319
305
echo '</tbody></table><br>'."\n";
321
echo '<h2> RFC822 Message body </h2>'."\n\n";
307
echo '<h2>' . _("RFC822 Message body") . "</h2>\n\n";
322
308
echo '<div><div class="header">'."\n\n";
323
309
echo $message_body;
324
310
echo '</div></div></font></code></body></html>';