From 24e1fb2190da5f49d5c15c8e941fd916e37058e4 Mon Sep 17 00:00:00 2001 From: tokul Date: Mon, 4 Apr 2005 13:39:26 +0000 Subject: [PATCH] adding function that can be used to display 8bit symbols as hex codes. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9188 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- .../message_details_bottom.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/message_details/message_details_bottom.php b/plugins/message_details/message_details_bottom.php index f5f68db9..6eb88203 100644 --- a/plugins/message_details/message_details_bottom.php +++ b/plugins/message_details/message_details_bottom.php @@ -26,6 +26,13 @@ require_once(SM_PATH . 'functions/mime.php'); sqgetGlobalVar('get_message_details', $md_action, SQ_GET); +/** + * Controls display of 8bit symbols in message source + * @global boolean $msgd_8bit_in_hex; + */ +global $msgd_8bit_in_hex; +$msgd_8bit_in_hex=false; + if (!empty($md_action)) { sqgetGlobalVar('passed_id', $passed_id, SQ_GET); @@ -36,6 +43,19 @@ if (!empty($md_action)) // ---------- 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 string + * @since 1.5.1 + */ +function msgd_convert_to_hex($string) { + global $color; + return preg_replace("/([\200-\377])/e","'{'.dechex(ord('\\1')).'}'",$string); +} /** * Calculates id of MIME entity @@ -103,7 +123,7 @@ function returnTime($start) { */ function get_message_details($mailbox, $passed_id, $stripHTML=FALSE) { -global $imapServerAddress, $imapPort, $color; +global $imapServerAddress, $imapPort, $color,$msgd_8bit_in_hex; $returnValue = ''; @@ -287,9 +307,11 @@ for ($i=1; $i < $count; $i++) { $message_body .= $line . "\r\n"; } else { $line = htmlspecialchars($line); + if ($msgd_8bit_in_hex) $line = msgd_convert_to_hex($line); $message_body .= "$pre"."$line"."$end".'
'."\r\n"; } } + //$returnValue .= returnTime($start).'
'; $xtra = <<