Source for file message_details_bottom.php
Documentation is available at message_details_bottom.php
* Message Details plugin - bottom frame with message structure and rfc822 body
* Plugin to view the RFC822 raw message output and the bodystructure of a message
* Licensed under the GNU GPL. For full terms see the file COPYING.
* @author Marc Groot Koerkamp
* @copyright 2002 Marc Groot Koerkamp, The Netherlands
* @copyright 2004-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: message_details_bottom.php 14840 2020-01-07 07:42:38Z pdontthink $
* @subpackage message_details
/* SquirrelMail required files. */
require_once(SM_PATH .
'include/validate.php');
require_once(SM_PATH .
'functions/imap.php');
require_once(SM_PATH .
'functions/mime.php');
global $color, $uid_support;
if (!sqGetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM))
global $imap_stream_options; // in case not defined in config
* Calculates id of MIME entity
* @param string $entString
* @param integer $direction
function CalcEntity($entString, $direction) {
$result =
substr($entString,0,$pos);
$level =
substr($entString,0,$pos);
$sublevel =
substr($entString,$pos+
1);
$result =
"$level".
'.'.
"$sublevel";
$result =
"$entString".
".0";
$imapConnection =
sqimap_login($username, $key, $imapServerAddress, $imapPort, 0, $imap_stream_options);
if (!empty($passed_ent_id))
$body =
sqimap_run_command($imapConnection, "FETCH $passed_id BODY[$passed_ent_id]",true, $response, $readmessage, $uid_support);
$body =
sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, $uid_support);
$messageheaderstart=
false;
$body[$count-
1] =
substr($body[$count-
1], -
1);
for ($i=
1; $i <
$count; $i++
) {
} else if ($messageheader) {
$end =
"\n \n".
'</div>'.
"\n \n".
'<div class="ent_body" id="'.
$entStr.
'B">'.
"\n \n";
if ($messageheaderstart) {
$messageheaderstart=
false;
} else if ($messageheaderstart) {
$end =
"\n \n".
'</div>'.
"\n \n".
'<div class="ent_body" id="'.
$entStr.
'B">'.
"\n \n";
if (!$header &&
$messageheader) {
$messageheaderstart=
true;
$pre =
'<i><font color ='.
"$color[1]>";
if (!$messageheader &&
!$header ) {
if ( ( $header ||
$messageheader) &&
(preg_match("/^.*boundary=\"?(.+(?=\")|.+).*/i",$line,$reg)) ) {
$boundaries[] =
array( 'bnd' =>
$bnd, 'bndreg' =>
$bndreg);
$messageheaderstart=
false;
$entStr =
CalcEntity("$entStr",1);
if (($line !=
'' &&
$line{0} ==
'-' ||
$header) && isset
($boundaries[0])) {
$cnt=
count($boundaries)-
1;
$bnd =
$boundaries[$cnt]['bnd'];
$bndreg =
$boundaries[$cnt]['bndreg'];
$regstr =
'/^--'.
"($bndreg)".
".*".
'/';
if (strlen($line) >
($bndlen +
3)) {
if ($line{$bndlen+
2} ==
'-' &&
$line{$bndlen+
3} ==
'-')
$entStr =
CalcEntity("$entStr",-
1);
$pre .=
'<b><font color ='.
"$color[2]>";
$entStr =
CalcEntity("$entStr",0);
$content[$content_indx]=
array();
$content[$content_indx]['ent'] =
'<a href="#' .
$entStr .
'">' .
$entStr .
'</a>';
$pre .=
"\n \n".
'</div>'.
"\n \n".
'<div class="entheader" id="'.
$entStr.
'H"><a name="'.
"$entStr".
'"></a><b><font color ='.
"$color[2]>";
$end .=
'</font></b>'.
"\n";
if (!$contentset &&
preg_match("/^.*(content-type:)\s*(\w+)\/(\w+).*/i",$line,$reg)) {
$content[$content_indx]['type'] =
"$reg[2]/$reg[3]";
if ($reg[2] ==
'image') {
$entities["$entStr"] =
array();
$entities["$entStr"]['entity'] =
$entStr;
$entities["$entStr"]['contenttype']=
$reg[2].
'/'.
$reg[3];
} else if (!$nameset &&
preg_match("/^.*(name=\s*)\"(.*)\".*/i",$line,$reg)) {
if (isset
($entities["$entStr"])) {
$entities["$entStr"]['name'] =
urlEncode($reg[2]);
} else if (preg_match("/^.*(content-transfer-encoding:)\s*(\w+-?(\w+)?).*/i",$line,$reg) ) {
if (isset
($entities["$entStr"])) {
$entities["$entStr"]['encoding']=
$reg[2];
$content[$content_indx]['encoding'] =
$encoding;
$pre .=
'<b><font color ='.
"$color[7]>";
if (isset($entities["$entStr"])) {
if (isset($encoding) && $encoding == 'base64') {
if (!isset( $entities["$entStr"]['content'])) $entities[$entStr]['content'] = '';
$entities["$entStr"]['content'] .= $line;
$message_body .=
"$pre".
"$line".
"$end".
'<br />'.
"\r\n";
echo
"<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
echo
'<font face = "monospace">'.
"\n";
if (count($content) >
0) {
echo
'<h2>' .
_("Bodystructure") .
"</h2>\n\n";
echo
'<table border=1 width="98%"><thead>'.
'<tr bgcolor="'.
"$color[7]".
'">'.
'<td><b><font color="'.
"$color[5]".
'">' .
_("Entity") .
'</font></b></td>'.
'<td><b><font color="'.
"$color[5]".
'">' .
_("Content-Type") .
'</font></b></td>'.
'<td><b><font color="'.
"$color[5]".
'">' .
_("Name") .
'</font></b></td>'.
'<td><b><font color="'.
"$color[5]".
'">' .
_("Encoding") .
'</font></b></td>'.
for ($i =
0; $i <
count($content);$i++
) {
echo
$content[$i]['ent'].
'</td><td>';
if (isset
($content[$i]['type'])) {
echo
$content[$i]['type'];
} else echo
'TEXT/PLAIN';
if (isset
($content[$i]['name'])) {
echo
$content[$i]['name'];
if (isset
($content[$i]['encoding'])) {
echo
$content[$i]['encoding'];
echo
'</tbody></table><br>'.
"\n";
echo
'<h2>' .
_("RFC822 Message body") .
"</h2>\n\n";
echo
'<div><div class="header">'.
"\n\n";
echo
'</div></div></font></code></body></html>';
Documentation generated on Mon, 13 Jan 2020 04:24:57 +0100 by phpDocumentor 1.4.3