X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fmessage_details%2Fmessage_details_bottom.php;h=955ea6d174c9862963774262c877d1aa10d433c3;hp=08a8b0e43116474c91a29d0b805c5b892bfc6800;hb=768c6816fba75ca42198049e0de77522912f8d00;hpb=ea5f4b8eaf805c4cc4e9533e87d057300a7fe666
diff --git a/plugins/message_details/message_details_bottom.php b/plugins/message_details/message_details_bottom.php
index 08a8b0e4..955ea6d1 100644
--- a/plugins/message_details/message_details_bottom.php
+++ b/plugins/message_details/message_details_bottom.php
@@ -1,36 +1,74 @@
{'.dechex(ord('\\1')).'}'",$string);
+}
+
+/**
+ * Calculates id of MIME entity
+ * @param string $entString
+ * @param integer $direction
+ * @return string
+ * @access private
+ */
function CalcEntity($entString, $direction) {
$result = $entString;
if ($direction == -1) {
@@ -39,217 +77,224 @@ function CalcEntity($entString, $direction) {
}
switch ($direction) {
- case 0:
- $pos = strrpos($entString,'.');
- if ($pos === false) {
- $entString++;
- $result= $entString;
- }
- else {
- $level = substr($entString,0,$pos);
- $sublevel = substr($entString,$pos+1);
- $sublevel++;
- $result = "$level".'.'."$sublevel";
- }
- break;
- case 1:
- $result = "$entString".".0";
- break;
- default:
- break;
+ case 0:
+ $pos = strrpos($entString,'.');
+ if ($pos === false) {
+ $entString++;
+ $result= $entString;
+ }
+ else {
+ $level = substr($entString,0,$pos);
+ $sublevel = substr($entString,$pos+1);
+ $sublevel++;
+ $result = "$level".'.'."$sublevel";
+ }
+ break;
+ case 1:
+ $result = "$entString".".0";
+ break;
+ default:
+ break;
}
return ($result);
}
-function returnTime($start) {
- $stop = gettimeofday();
- $timepassed = 1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec'];
- return $timepassed;
-}
-function GetMimeProperties($header) {
-}
+/**
+ * Returns actual message details
+ * @param string $mailbox
+ * @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
+ * @access public
+ */
+function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=FALSE) {
+ global $imapServerAddress, $imapPort, $color,$msgd_8bit_in_hex, $username;
-$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
-$read = sqimap_mailbox_select($imapConnection, $mailbox);
-$start = gettimeofday();
-$body = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, $uid_support);
-$message_body = '';
-$header = false;
-$mimepart = false;
-$bnd_end = false;
-$messageheader = true;
-$messageheaderstart=false;
-$boundaries = array();
-$entities = array();
-session_unregister("entities");
-$pre = '';
-$end = '';
-$entStr = '';
-$bla ='';
-$content = array ();
-$content_indx = -1;
-$contentset = false;
+ $returnValue = '';
-$count=count($body);
-$body[$count-1] = substr($body[$count-1], -1);
-for ($i=1; $i < $count; $i++) {
- $line = trim($body[$i]);
- if ($line == '') {
- $pre = '';
- $end = '';
- if ($bnd_end) {
- $header = true;
- $mimepart = false;
- } else if ($messageheader) {
- if ($header) {
- $header=false;
- $end = "\n \n".''."\n \n".'
'."\n \n";
- }
- $mimepart = -$header;
- $bnd_end = false;
- if ($messageheaderstart) {
- $messageheaderstart=false;
- }
- } else if ($messageheaderstart) {
- $messageheader= false;
- } else {
- if ($header) {
- $pre = '';
- $end = "\n \n".'
'."\n \n".''."\n \n";
- }
- $header = false;
- $mimepart=true;
- }
- $contentset = false;
- $nameset = false;
- } else {
- if (!$header && $messageheader) {
- $messageheaderstart=true;
- if ($pre != '
') {
- $pre = '';
- }
- }
- if (!$messageheader && !$header ) {
- $mimepart=true;
- } else {
- $mimepart=false;
- }
- $pre = '';
- $end = '';
- }
- if ( ( $header || $messageheader) && (preg_match("/^.*boundary=\"?(.+(?=\")|.+).*/i",$line,$reg)) ) {
- $bnd = $reg[1];
- $bndreg = $bnd;
- $bndreg = str_replace("\\","\\\\",$bndreg);
- $bndreg = str_replace("?","\\?",$bndreg);
- $bndreg = str_replace("+","\\+",$bndreg);
- $bndreg = str_replace(".","\\.",$bndreg);
- $bndreg = str_replace("/","\\/",$bndreg);
- $bndreg = str_replace("-","\\-",$bndreg);
- $bndreg = str_replace("(","\\(",$bndreg);
- $bndreg = str_replace(")","\\)",$bndreg);
+ $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
+ $read = sqimap_mailbox_select($imapConnection, $mailbox);
+ if (!empty($passed_ent_id))
+ $body = sqimap_run_command($imapConnection, "FETCH $passed_id BODY[$passed_ent_id]",true, $response, $readmessage, TRUE);
+ else
+ $body = sqimap_run_command($imapConnection, "FETCH $passed_id RFC822",true, $response, $readmessage, TRUE);
+ $message_body = '';
+ $header = false;
+ $mimepart = false;
+ $bnd_end = false;
+ $messageheader = true;
+ $messageheaderstart=false;
+ $boundaries = array();
+ $entities = array();
+ session_unregister("entities");
+ $pre = '';
+ $end = '';
+ $entStr = '';
+ $bla ='';
+ $content = array ();
+ $content_indx = -1;
+ $contentset = false;
- $boundaries[] = array( 'bnd' => $bnd, 'bndreg' => $bndreg);
- $messageheader = false;
- $messageheaderstart=false;
- $mimepart=false;
- if ($entStr=='') {
- $entStr='0';
- } else {
- $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 (preg_match($regstr,$line,$reg) ) {
- $bndlen = strlen($reg[1]);
- $bndend = false;
- if (strlen($line) > ($bndlen + 3)) {
- if ($line{$bndlen+2} == '-' && $line{$bndlen+3} == '-')
- $bndend = true;
- }
- if ($bndend) {
- $entStr = CalcEntity("$entStr",-1);
- array_pop($boundaries);
- $pre .= '';
- $header = true;
- $mimepart = false;
- $bnd_end = true;
- $encoding = '';
- } else {
- $header = true;
- $bnd_end = false;
- $entStr = CalcEntity("$entStr",0);
- $content_indx++;
- $content[$content_indx]=array();
- $content[$content_indx]['ent'] = '$entStr".'';
- $pre .= "\n \n".' '."\n \n".'';
+ }
+ $mimepart = -$header;
+ $bnd_end = false;
+ if ($messageheaderstart) {
+ $messageheaderstart=false;
+ }
+ } else if ($messageheaderstart) {
+ $messageheader= false;
+ } else {
+ if ($header) {
+ $pre = '';
+ $end = '
';
+ }
+ $header = false;
+ $mimepart=true;
+ }
+ $contentset = false;
+ $nameset = false;
+ } else {
+ if (!$header && $messageheader) {
+ $messageheaderstart=true;
+ if ($pre != '
') {
+ $pre = '';
+ $end = '';
+ }
+ }
+ if (!$messageheader && !$header ) {
+ $mimepart=true;
+ } else {
+ $mimepart=false;
+ }
+ $pre = '';
+ $end = '';
+ }
+ if ( ( $header || $messageheader) && (preg_match("/^.*boundary=\"?(.+(?=\")|.+).*/i",$line,$reg)) ) {
+ $bnd = $reg[1];
+ $bndreg = $bnd;
+ $bndreg = str_replace("\\","\\\\",$bndreg);
+ $bndreg = str_replace("?","\\?",$bndreg);
+ $bndreg = str_replace("+","\\+",$bndreg);
+ $bndreg = str_replace(".","\\.",$bndreg);
+ $bndreg = str_replace("/","\\/",$bndreg);
+ $bndreg = str_replace("-","\\-",$bndreg);
+ $bndreg = str_replace("(","\\(",$bndreg);
+ $bndreg = str_replace(")","\\)",$bndreg);
+
+ $boundaries[] = array( 'bnd' => $bnd, 'bndreg' => $bndreg);
+ $messageheader = false;
+ $messageheaderstart=false;
+ $mimepart=false;
+ if ($entStr=='') {
+ $entStr='0';
+ } else {
+ $entStr = CalcEntity("$entStr",1);
+ }
+ }
- $pre .= '';
- //$mimepart=false;
- }
- }
- }
-/*
- if ($mimepart) {
- if (isset($entities["$entStr"])) {
- if (isset($encoding) && $encoding == 'base64') {
- if (!isset( $entities["$entStr"]['content'])) $entities[$entStr]['content'] = '';
- $entities["$entStr"]['content'] .= $line;
- }
+ if (($line != '' && $line{0} == '-' || $header) && isset($boundaries[0])) {
+ $cnt=count($boundaries)-1;
+ $bnd = $boundaries[$cnt]['bnd'];
+ $bndreg = $boundaries[$cnt]['bndreg'];
+
+ $regstr = '/^--'."($bndreg)".".*".'/';
+ if (preg_match($regstr,$line,$reg) ) {
+ $bndlen = strlen($reg[1]);
+ $bndend = false;
+ if (strlen($line) > ($bndlen + 3)) {
+ if ($line{$bndlen+2} == '-' && $line{$bndlen+3} == '-')
+ $bndend = true;
+ }
+ if ($bndend) {
+ $entStr = CalcEntity("$entStr",-1);
+ array_pop($boundaries);
+ $pre .= '';
+ $end .= '';
+ $header = true;
+ $mimepart = false;
+ $bnd_end = true;
+ $encoding = '';
+ } else {
+ $header = true;
+ $bnd_end = false;
+ $entStr = CalcEntity("$entStr",0);
+ $content_indx++;
+ $content[$content_indx]=array();
+ $content[$content_indx]['ent'] = '$entStr".'';
+ $pre .= '