From f44504177fba4a9bc389c4f1569ffdfa363be5c1 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 6 Mar 2005 03:11:40 +0000 Subject: [PATCH] Placing main message details code inside of a function where it is immensely more useful to others; also adding ability to return details without HTML formatting git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@8956 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- .../message_details_bottom.php | 125 +++++++++++++----- .../message_details/message_details_main.php | 4 +- 2 files changed, 91 insertions(+), 38 deletions(-) diff --git a/plugins/message_details/message_details_bottom.php b/plugins/message_details/message_details_bottom.php index b8976779..f5f68db9 100644 --- a/plugins/message_details/message_details_bottom.php +++ b/plugins/message_details/message_details_bottom.php @@ -16,21 +16,26 @@ */ /** @ignore */ -define('SM_PATH','../../'); +if (!defined('SM_PATH')) + define('SM_PATH','../../'); /* 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; +sqgetGlobalVar('get_message_details', $md_action, SQ_GET); -sqgetGlobalVar('passed_id', $passed_id, SQ_GET); -sqgetGlobalVar('mailbox', $mailbox, SQ_GET); +if (!empty($md_action)) +{ + sqgetGlobalVar('passed_id', $passed_id, SQ_GET); + sqgetGlobalVar('mailbox', $mailbox, SQ_GET); + echo get_message_details($mailbox, $passed_id); +} + + +// ---------- function definitions ---------- -sqgetGlobalVar('username', $username, SQ_SESSION); -sqgetGlobalVar('key', $key, SQ_COOKIE); -sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); /** * Calculates id of MIME entity @@ -69,6 +74,8 @@ function CalcEntity($entString, $direction) { return ($result); } + + /** * Returns time in microseconds between selected and current timestamp * @@ -82,6 +89,27 @@ function returnTime($start) { return $timepassed; } + + +/** + * Returns actual message details + * @param string $mailbox + * @param string $passed_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, $stripHTML=FALSE) { + +global $imapServerAddress, $imapPort, $color; + +$returnValue = ''; + +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('key', $key, SQ_COOKIE); + $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $read = sqimap_mailbox_select($imapConnection, $mailbox); $start = gettimeofday(); @@ -255,10 +283,14 @@ for ($i=1; $i < $count; $i++) { } } */ - $line = htmlspecialchars($line); - $message_body .= "$pre"."$line"."$end".'
'."\r\n"; + if ($stripHTML) { + $message_body .= $line . "\r\n"; + } else { + $line = htmlspecialchars($line); + $message_body .= "$pre"."$line"."$end".'
'."\r\n"; + } } -//echo returnTime($start).'
'; +//$returnValue .= returnTime($start).'
'; $xtra = << @@ -282,12 +314,20 @@ $xtra = <<\n"; -echo ''."\n"; -echo ''."\n"; -echo '
'."\n"; +if (!$stripHTML) { + $returnValue .= "\n"; + $returnValue .= ''."\n"; + $returnValue .= ''."\n"; + $returnValue .= '
'."\n"; +} //session_register("entities"); @@ -296,15 +336,17 @@ echo '
'."\n"; //foreach ($keys as $key) { // if (isset($entities[$key])) { // if ($entities[$key]['encoding'] == 'base64') { -// echo '
'; +// if (!$stripHTML) { +// $returnValue .= 'img src="message_viewentity.php?ent='.$entities[$key]['entity'].'&name='.$entities[$key]['name'].'">
'; +// } // } // } //} //session_unregister("entities"); -if (count($content) > 0) { - echo '

'._("Bodystructure")."

\n\n"; - echo ''. +if (count($content) > 0 && !$stripHTML) { + $returnValue .= '

'._("Bodystructure")."

\n\n"; + $returnValue .= '
'. ''. ''. ''. @@ -313,25 +355,36 @@ if (count($content) > 0) { ''. ''; for ($i = 0; $i < count($content);$i++) { - echo ''."\n"; + $returnValue .= $content[$i]['encoding']; + } else $returnValue .= ' '; + $returnValue .= ''."\n"; } - echo '
'._("Entity").''._("Content-Type").'
'; - echo $content[$i]['ent'].''; + $returnValue .= '
'; + $returnValue .= $content[$i]['ent'].''; if (isset($content[$i]['type'])) { - echo $content[$i]['type']; - } else echo 'TEXT/PLAIN'; - echo ''; + $returnValue .= $content[$i]['type']; + } else $returnValue .= 'TEXT/PLAIN'; + $returnValue .= ''; if (isset($content[$i]['name'])) { - echo $content[$i]['name']; - } else echo ' '; - echo ''; + $returnValue .= $content[$i]['name']; + } else $returnValue .= ' '; + $returnValue .= ''; if (isset($content[$i]['encoding'])) { - echo $content[$i]['encoding']; - } else echo ' '; - echo '

'."\n"; + $returnValue .= '
'."\n"; } -echo '

'._("RFC822 Message body")."

\n\n"; -echo '
'."\n\n"; -echo $message_body; -echo '
'; -?> \ No newline at end of file + +if (!$stripHTML) { + $returnValue .= '

'._("RFC822 Message body")."

\n\n"; + $returnValue .= '
'."\n\n"; +} + +$returnValue .= $message_body; + +if (!$stripHTML) + $returnValue .= '
'; + +return $returnValue; + +} + +?> diff --git a/plugins/message_details/message_details_main.php b/plugins/message_details/message_details_main.php index 13b6a0cf..09d873e4 100644 --- a/plugins/message_details/message_details_main.php +++ b/plugins/message_details/message_details_main.php @@ -29,6 +29,6 @@ sqgetGlobalVar('passed_id', $passed_id, SQ_GET); echo "\n"; echo ''; -echo ''; +echo ''; echo ''."\n"."\n"; -?> \ No newline at end of file +?> -- 2.25.1