From: stekkel Date: Tue, 19 Apr 2005 10:34:50 +0000 (+0000) Subject: Fixed half implemented feature. Now we provide a stream when calling this X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7591f1435e55e514fd8e3d62e0c6bc217ad71337;p=squirrelmail.git Fixed half implemented feature. Now we provide a stream when calling this function. This will save memory usage in case we forward from compose and will stop exhausted memory errors in case of large attachments. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9354 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/mime.php b/functions/mime.php index 09cdec96..fabe0fed 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -159,7 +159,7 @@ function mime_fetch_body($imap_stream, $id, $ent_id=1, $fetch_size=0) { return $ret; } -function mime_print_body_lines ($imap_stream, $id, $ent_id=1, $encoding) { +function mime_print_body_lines ($imap_stream, $id, $ent_id=1, $encoding, $rStream) { /* Don't kill the connection if the browser is over a dialup * and it would take over 30 seconds to download it. @@ -173,14 +173,18 @@ function mime_print_body_lines ($imap_stream, $id, $ent_id=1, $encoding) { Instead, echo the decoded attachment directly to screen */ if (strtolower($encoding) == 'base64') { if (!$ent_id) { - $query = "FETCH $id BODY[]"; + $query = "FETCH $id BODY[]"; } else { - $query = "FETCH $id BODY[$ent_id]"; + $query = "FETCH $id BODY[$ent_id]"; } - sqimap_run_command($imap_stream,$query,true,$response,$message,TRUE,'sqimap_base64_decode','php://stdout',true); + sqimap_run_command($imap_stream,$query,true,$response,$message,TRUE,'sqimap_base64_decode',$rStream,true); } else { - $body = mime_fetch_body ($imap_stream, $id, $ent_id); - echo decodeBody($body, $encoding); + $body = mime_fetch_body ($imap_stream, $id, $ent_id); + if (is_resource($rStream)) { + fputs($rStream,decodeBody($body,$encoding)); + } else { + echo decodeBody($body, $encoding); + } } /* @@ -199,33 +203,6 @@ function mime_print_body_lines ($imap_stream, $id, $ent_id=1, $encoding) { */ return; -/* - fputs ($imap_stream, "$sid FETCH $id BODY[$ent_id]\r\n"); - $cnt = 0; - $continue = true; - $read = fgets ($imap_stream,8192); - - - // This could be bad -- if the section has sqimap_session_id() . ' OK' - // or similar, it will kill the download. - while (!ereg("^".$sid_s." (OK|BAD|NO)(.*)$", $read, $regs)) { - if (trim($read) == ')==') { - $read1 = $read; - $read = fgets ($imap_stream,4096); - if (ereg("^".$sid." (OK|BAD|NO)(.*)$", $read, $regs)) { - return; - } else { - echo decodeBody($read1, $encoding) . - decodeBody($read, $encoding); - } - } else if ($cnt) { - echo decodeBody($read, $encoding); - } - $read = fgets ($imap_stream,4096); - $cnt++; -// break; - } -*/ } /* -[ END MIME DECODING ]----------------------------------------------------------- */