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
* @author Marc Groot Koerkamp
* @copyright 2002 Marc Groot Koerkamp, The Netherlands
* @copyright 2002-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: message_details_bottom.php 14845 2020-01-07 08:09:34Z pdontthink $
* @subpackage message_details
//FIXME: this file uses HTML extensively and eventually needs to be "templatized" (don't echo HTML directly)
* Include the SquirrelMail initialization file.
require
('../../include/init.php');
require
(SM_PATH .
'functions/imap_general.php');
require
(SM_PATH .
'functions/imap_messages.php');
require
(SM_PATH .
'functions/mime.php');
* Controls display of 8bit symbols in message source
* @global boolean $msgd_8bit_in_hex;
global $msgd_8bit_in_hex;
if (!empty($md_action)) {
* change $unformatted to TRUE if you want to see
* message source without formating
// ---------- function definitions ----------
* Converts 8bit string to hex
* Replaces 8bit symbols with their hex strings,
* encloses them in curly brackets and uses different color.
* @param string $string text
return preg_replace("/([\200-\377])/e","'<font color=\"$color[2]\">{'.dechex(ord('\\1')).'}</font>'",$string);
* 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";
* Returns actual message details
* @param string $passed_id
* @param string $passed_ent_id
* @param boolean $stripHTML If TRUE, only plain text is returned,
* default is FALSE, wherein output contains
* pretty-HTMLification of message body
* @return string The formatted message details
global $imapServerAddress, $imapPort, $imap_stream_options,
$color,$msgd_8bit_in_hex, $username;
$imapConnection =
sqimap_login($username, false, $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, TRUE);
$body =
sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, TRUE);
$messageheaderstart=
false;
$body[$count-
1] =
substr($body[$count-
1], -
1);
for ($i=
1; $i <
$count; $i++
) {
$line =
rtrim($body[$i]);
} else if ($messageheader) {
$end =
'</div><div class="ent_body" id="'.
$entStr.
'B">';
if ($messageheaderstart) {
$messageheaderstart=
false;
} else if ($messageheaderstart) {
$end =
'</div><div class="ent_body" id="'.
$entStr.
'B">';
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 .=
'</div><div class="entheader" id="'.
$entStr.
'H"><a name="'.
"$entStr".
'"></a><b><font color="'.
$color[2].
'">';
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].
'">';
$message_body .=
$line .
"\r\n";
$message_body .=
"$pre".
"$line".
"$end".
"\r\n";
//$returnValue .= returnTime($start).'<br />';
$returnValue .=
"<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n";
$returnValue .=
'<font face="monospace">'.
"\n";
$returnValue .=
'<br />'.
"\n";
if (count($content) >
0 &&
!$stripHTML) {
$returnValue .=
'<h2>'.
_("Bodystructure").
"</h2>\n\n";
$returnValue .=
'<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++
) {
$returnValue .=
'<tr><td>';
$returnValue .=
$content[$i]['ent'].
'</td><td>';
if (isset
($content[$i]['type'])) {
$returnValue .=
$content[$i]['type'];
} else $returnValue .=
'TEXT/PLAIN';
$returnValue .=
'</td><td>';
if (isset
($content[$i]['name'])) {
$returnValue .=
$content[$i]['name'];
} else $returnValue .=
' ';
$returnValue .=
'</td><td>';
if (isset
($content[$i]['encoding'])) {
$returnValue .=
$content[$i]['encoding'];
} else $returnValue .=
' ';
$returnValue .=
'</td></tr>'.
"\n";
$returnValue .=
'</tbody></table><br />'.
"\n";
$returnValue .=
'<h2>'.
_("RFC822 Message body").
"</h2>\n\n";
$returnValue .=
'<pre><div><div class="header">';
$returnValue .=
$message_body;
$returnValue .=
'</div></div></pre></font></body></html>';
$returnValue .=
'</pre>';
Documentation generated on Mon, 13 Jan 2020 04:23:05 +0100 by phpDocumentor 1.4.3