/**
* Get the MIME structure
- *
+ *
* This function gets the structure of a message and stores it in the "message" class.
* It will return this object for use with all relevant header information and
* fully parsed into the standard "message" object format.
/* Don't kill the connection if the browser is over a dialup
* and it would take over 30 seconds to download it.
- * Donยดt call set_time_limit in safe mode.
+ * Dont call set_time_limit in safe mode.
*/
if (!ini_get('safe_mode')) {
translateText($body, $wrap_at,
$body_message->header->getParameter('charset'));
}
- $link = 'read_body.php?passed_id=' . $id . '&ent_id='.$ent_num.
+ $link = 'passed_id=' . $id . '&ent_id='.$ent_num.
'&mailbox=' . $urlmailbox .'&sort=' . $sort .
'&startMessage=' . $startMessage . '&show_more=0';
if (isset($passed_ent_id)) {
$link .= '&passed_ent_id='.$passed_ent_id;
}
+ $body .= '<center><small><a href="download.php?absolute_dl=true&' .
+ $link . '">' . _("Download this as a file") . '</a>';
if ($view_unsafe_images) {
$text = _("Hide Unsafe Images");
} else {
$text = '';
}
}
- $body .= '<center><small><a href="'.$link.'">'.$text.
- '</a></small></center><br>' . "\n";
+ if($text != '') {
+ $body .= ' | <a href="read_body.php?' . $link . '">' . $text . '</a>';
+ }
+ $body .= '</small></center><br>' . "\n";
}
return $body;
}
$encoded = false;
/* if encoded words are not separated by a linear-space-white we still catch them */
$j = $i-1;
-// if ($chunk{0} === '=') { /* performance, saves an unnessecarry preg call */
+
while ($match = preg_match('/^(.*)=\?([^?]*)\?(Q|B)\?([^?]*)\?=(.*)$/Ui',$chunk,$res)) {
/* if the last chunk isn't an encoded string then put back the space, otherwise don't */
if ($iLastMatch !== $j) {
$chunk = $res[5];
$encoded = true;
}
-// }
if (!$encoded) {
if ($htmlsave) {
$ret .= ' ';
/**
* Remove any backslashes. See if there are any first.
*/
+
if (strstr($attvalue, '\\') !== false){
$attvalue = stripslashes($attvalue);
}
* @param $attvalue A string to run entity check against.
* @return Translated value.
*/
+
function sq_deent($attvalue){
$me = 'sq_deent';
/**
* See if we have to run the checks first. All entities must start
* with "&".
*/
- if (strpos($attvalue, "&") === false){
+ if (strpos($attvalue, '&') === false){
return $attvalue;
}
/**
* Leave " in, as it can mess us up.
*/
$trans = array_flip($trans);
- unset($trans{"""});
+ unset($trans{'"'});
while (list($ent, $val) = each($trans)){
- $attvalue = preg_replace("/$ent*(\W)/si", "$val\\1", $attvalue);
+ $attvalue = preg_replace('/' . $ent . '*/si', $val, $attvalue);
}
/**
* Now translate numbered entities from 1 to 255 if needed.
*/
- if (strpos($attvalue, "#") !== false){
+ if (strpos($attvalue, '#') !== false){
$omit = Array(34, 39);
- for ($asc=1; $asc<256; $asc++){
+ for ($asc = 256; $asc >= 0; $asc--){
if (!in_array($asc, $omit)){
$chr = chr($asc);
- $attvalue = preg_replace("/\�*$asc;*(\D)/si", "$chr\\1",
- $attvalue);
- $attvalue = preg_replace("/\�*".dechex($asc).";*(\W)/si",
- "$chr\\1", $attvalue);
+ $octrule = '/\�*' . $asc . ';*/si';
+ $hexrule = '/\�*' . dechex($asc) . ';*/si';
+ $attvalue = preg_replace($octrule, $chr, $attvalue);
+ $attvalue = preg_replace($hexrule, $chr, $attvalue);
}
}
}
* @param $message the message object
* @param $id the message id
* @param $content a string with whatever is between <style> and </style>
+ * @param $mailbox the message mailbox
* @return a string with edited content.
*/
-function sq_fixstyle($body, $pos, $message, $id){
+function sq_fixstyle($body, $pos, $message, $id, $mailbox){
global $view_unsafe_images;
$me = 'sq_fixstyle';
$ret = sq_findnxreg($body, $pos, '</\s*style\s*>');
while (preg_match("|url\s*\(\s*([\'\"]\s*cid:.*?[\'\"])\s*\)|si",
$content, $matches)){
$cidurl = $matches{1};
- $httpurl = sq_cid2http($message, $id, $cidurl);
+ $httpurl = sq_cid2http($message, $id, $cidurl, $mailbox);
$content = preg_replace("|url\s*\(\s*$cidurl\s*\)|si",
"url($httpurl)", $content);
}
* @param $message the message object
* @param $id the message id
* @param $cidurl the cid: url.
+ * @param $mailbox the message mailbox
* @return a string with a http-friendly url
*/
function sq_cid2http($message, $id, $cidurl, $mailbox){
*/
if ($tagname == "style" && $tagtype == 1){
list($free_content, $curpos) =
- sq_fixstyle($body, $gt+1, $message, $id);
+ sq_fixstyle($body, $gt+1, $message, $id, $mailbox);
if ($free_content != FALSE){
$trusted .= sq_tagprint($tagname, $attary, $tagtype);
$trusted .= $free_content;
* @param string $type1 second half of mime type
* @param string $filename filename to tell the browser for downloaded file
* @param boolean $force whether to force the download dialog to pop
+ * @param integer $filesize optional, send the Content-Header and length to the browser
* @return void
*/
- function SendDownloadHeaders($type0, $type1, $filename, $force) {
+ function SendDownloadHeaders($type0, $type1, $filename, $force, $filesize=0) {
global $languages, $squirrelmail_language;
$isIE = $isIE6 = 0;
header("Content-Type: application/octet-stream; name=\"$filename\"");
}
}
- }
+
+ //send the content-length header if the calling function provides it
+ if ($filesize > 0) {
+ header("Content-Length: $filesize");
+ }
+
+ } // end fn SendDownlaodHeaders
?>