Source for file printer_friendly_bottom.php
Documentation is available at printer_friendly_bottom.php
* printer_friendly_bottom.php
* with javascript on, it is the bottom frame of printer_friendly_main.php
* else, it is alone in a new window
* - this is the page that does all the work, really.
* @copyright 1999-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: printer_friendly_bottom.php 14840 2020-01-07 07:42:38Z pdontthink $
/** This is the printer_friendly_bottom page */
define('PAGE_NAME', 'printer_friendly_bottom');
* Path for SquirrelMail required files.
/* SquirrelMail required files. */
require_once(SM_PATH .
'include/validate.php');
require_once(SM_PATH .
'functions/imap.php');
/* get some of these globals */
! preg_match('/^\d+(\.\d+)*$/', $passed_ent_id) ) {
$pf_cleandisplay =
getPref($data_dir, $username, 'pf_cleandisplay', false);
global $imap_stream_options; // in case not defined in config
$imapConnection =
sqimap_login($username, $key, $imapServerAddress, $imapPort, 0, $imap_stream_options);
if (isset
($messages[$mbx_response['UIDVALIDITY']][$passed_id])) {
$message =
$messages[$mbx_response['UIDVALIDITY']][$passed_id];
$message =
$message->getEntity($passed_ent_id);
/* --start display setup-- */
$rfc822_header =
$message->rfc822_header;
/* From and Date are usually fine as they are... */
$from =
$rfc822_header->getAddr_s('from');
$subject =
trim($rfc822_header->subject);
/* we can clean these up if the list is too long... */
$cc =
$rfc822_header->getAddr_s('cc');
$to =
$rfc822_header->getAddr_s('to');
if ($show_html_default ==
1) {
$ent_ar =
$message->findDisplayEntity(array());
$ent_ar =
$message->findDisplayEntity(array(), array('text/plain'));
for ($i =
0; $i <
count($ent_ar); $i++
) {
$body .=
formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox, true);
$body .=
'<hr noshade size="1" />';
$hookResults =
do_hook('message_body', $body);
$body =
_("Message not printable");
/* now, if they choose to, we clean up the display a bit... */
$num_leading_spaces =
9; // nine leading spaces for indentation
// sometimes I see ',,' instead of ',' seperating addresses *shrug*
$cc =
pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces);
$to =
pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces);
// the body should have no leading zeros
// disabled because it destroys html mail
// $body = pf_clean_string($body, 0);
// clean up everything else...
$subject =
pf_clean_string($subject, $num_leading_spaces);
$from =
pf_clean_string($from, $num_leading_spaces);
$date =
pf_clean_string($date, $num_leading_spaces);
/* --start browser output-- */
echo
'<body text="#000000" bgcolor="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">'.
"\n" .
/* headers (we use table because translations are not all the same width) */
html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"' ) .
html_tag( 'td', _("From").
': ', 'left' ,'','valign="top"') .
html_tag( 'td', _("Subject").
': ', 'left','','valign="top"' ) .
html_tag( 'td', _("Date").
': ', 'left' ) .
html_tag( 'td', _("To").
': ', 'left','','valign="top"' ) .
if ( strlen($cc) >
0 ) { /* only show Cc: if it's there... */
html_tag( 'td', _("Cc").
': ', 'left','','valign="top"' ) .
html_tag( 'td', '<hr noshade size="1" /><br />' .
"\n" .
$body, 'left', '', 'colspan="2"' )
if (! empty($attachments)) {
html_tag( 'td','<b>'.
_("Attachments:").
'</b>', 'left', '', 'colspan="2"' )
html_tag( 'td',$attachments, 'left', '', 'colspan="2"' )
html_tag( 'td', '<hr style="height: 1px;" />', 'left', '', 'colspan="2"' )
/* --end browser output-- */
/* --start pf-specific functions-- */
* Function should clean layout of printed messages when user
* enables "Printer Friendly Clean Display" option.
* @param string unclean_string
* @param integer num_leading_spaces
* @example $string = pf_clean_string($string, 9);
function pf_clean_string ( $unclean_string, $num_leading_spaces ) {
$unclean_string =
str_replace(' ',' ',$unclean_string);
$wrap_at =
getPref($data_dir, $username, 'wrap_at', 86);
$wrap_at =
$wrap_at -
$num_leading_spaces; /* header stuff */
while ( strlen($leading_spaces) <
$num_leading_spaces )
while ( strlen($unclean_string) >
$wrap_at )
$this_line =
substr($unclean_string, 0, $wrap_at);
if ( strrpos( $this_line, "\n" ) ) /* this should NEVER happen with anything but the $body */
$clean_string .=
substr( $this_line, 0, strrpos( $this_line, "\n" ));
$clean_string .=
$leading_spaces;
$unclean_string =
substr($unclean_string, strrpos( $this_line, "\n" ));
$clean_string .=
substr( $this_line, 0, $i);
$clean_string .=
"\n" .
$leading_spaces;
$unclean_string =
substr($unclean_string, 1+
$i);
$clean_string .=
$unclean_string;
} /* end pf_clean_string() function */
* Displays attachment information
* Stripped version of formatAttachments() function from functions/mime.php.
* @param object $message SquirrelMail message object
* @param array $exclude_id message parts that are not attachments.
* @param string $mailbox mailbox name
* @param integer $id message id
* @return string html formated attachment information.
global $where, $what, $startMessage, $color, $passed_ent_id;
if (!count($att_ar)) return '';
foreach ($att_ar as $att) {
if ($type0 ==
'message' &&
$type1 ==
'rfc822') {
$rfc822_header =
$att->rfc822_header;
$filename =
$rfc822_header->subject;
if (trim( $filename ) ==
'') {
$filename =
'untitled-[' .
$ent .
']' ;
$from_o =
$rfc822_header->from;
$from_name =
_("Unknown sender");
$filename =
$att->getFilename();
if ($header->description) {
$display_filename =
$filename;
// TODO: maybe make it nicer?
$attachments .=
'<table cellpadding="0" cellspacing="0" border="1"><tr><th colspan="2">'.
decodeHeader($display_filename).
'</th></tr>' .
if (! empty($description)) {
$attachments .=
$description;
$attachments .=
"</table>\n";
/* --end pf-specific functions */
Documentation generated on Mon, 13 Jan 2020 04:25:11 +0100 by phpDocumentor 1.4.3