Change is_int to is_numeric, solves [ 655060 ] Image size for login.php and
[squirrelmail.git] / src / printer_friendly_bottom.php
CommitLineData
f226cba7 1<?php
2
35586184 3/**
4 * printer_friendly_bottom.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * with javascript on, it is the bottom frame of printer_friendly_main.php
10 * else, it is alone in a new window
11 *
12 * - this is the page that does all the work, really.
13 *
14 * $Id$
15 */
16
86725763 17/* Path for SquirrelMail required files. */
18define('SM_PATH','../');
19
20/* SquirrelMail required files. */
08185f2a 21require_once(SM_PATH . 'include/validate.php');
86725763 22require_once(SM_PATH . 'functions/strings.php');
23require_once(SM_PATH . 'config/config.php');
08185f2a 24require_once(SM_PATH . 'include/load_prefs.php');
86725763 25require_once(SM_PATH . 'functions/imap.php');
26require_once(SM_PATH . 'functions/page_header.php');
27require_once(SM_PATH . 'functions/html.php');
f226cba7 28
0b97a708 29/* get some of these globals */
30$key = $_COOKIE['key'];
31$username = $_SESSION['username'];
32$onetimepad = $_SESSION['onetimepad'];
33
9b761dbd 34$passed_id = (int) $_GET['passed_id'];
0b97a708 35$mailbox = $_GET['mailbox'];
36/* end globals */
37
32f4e318 38$pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay');
18680db6 39$mailbox = urldecode($mailbox);
40$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
41sqimap_mailbox_select($imapConnection, $mailbox);
42$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
5caf2d0c 43$id = $passed_id;
44if (isset($passed_ent_id)) {
45 $message = $message->getEntity($passed_ent_id);
46}
47
32f4e318 48
49/* --start display setup-- */
50
7e1c2d41 51$rfc822_header = $message->rfc822_header;
32f4e318 52/* From and Date are usually fine as they are... */
7e1c2d41 53$from = decodeHeader($rfc822_header->getAddr_s('from'));
54$date = getLongDateString($rfc822_header->date);
55$subject = trim(decodeHeader($rfc822_header->subject));
32f4e318 56
57/* we can clean these up if the list is too long... */
7e1c2d41 58$cc = decodeHeader($rfc822_header->getAddr_s('cc'));
59$to = decodeHeader($rfc822_header->getAddr_s('to'));
32f4e318 60
c8d6aef3 61if ($show_html_default == 1) {
62 $ent_ar = $message->findDisplayEntity(array());
63} else {
64 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
65}
18680db6 66$body = '';
67if ($ent_ar[0] != '') {
68 for ($i = 0; $i < count($ent_ar); $i++) {
69 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
5caf2d0c 70 $body .= '<hr noshade size=1>';
18680db6 71 }
72 $hookResults = do_hook('message_body', $body);
73 $body = $hookResults[1];
32f4e318 74} else {
18680db6 75 $body = _("Message not printable");
32f4e318 76}
3bbf5974 77
32f4e318 78 /* now, if they choose to, we clean up the display a bit... */
18680db6 79
32f4e318 80if ( empty($pf_cleandisplay) || $pf_cleandisplay != 'no' ) {
f226cba7 81
32f4e318 82 $num_leading_spaces = 9; // nine leading spaces for indentation
f226cba7 83
32f4e318 84 // sometimes I see ',,' instead of ',' seperating addresses *shrug*
85 $cc = pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces);
86 $to = pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces);
f226cba7 87
32f4e318 88 // the body should have no leading zeros
5caf2d0c 89 // disabled because it destroys html mail
90
91// $body = pf_clean_string($body, 0);
f226cba7 92
32f4e318 93 // clean up everything else...
94 $subject = pf_clean_string($subject, $num_leading_spaces);
95 $from = pf_clean_string($from, $num_leading_spaces);
96 $date = pf_clean_string($date, $num_leading_spaces);
f226cba7 97
32f4e318 98} // end cleanup
18680db6 99
32f4e318 100// --end display setup--
f226cba7 101
f226cba7 102
32f4e318 103/* --start browser output-- */
104displayHtmlHeader( _("Printer Friendly"), '', FALSE );
f226cba7 105
32f4e318 106echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n" .
ae426785 107 /* headers (we use table because translations are not all the same width) */
3c816b1a 108 html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"' ) .
1c663478 109 html_tag( 'tr',
7e1c2d41 110 html_tag( 'td', _("From").'&nbsp;', 'left' ,'','valign="top"') .
83be314a 111 html_tag( 'td', htmlspecialchars($from), 'left' )
1c663478 112 ) . "\n" .
113 html_tag( 'tr',
7e1c2d41 114 html_tag( 'td', _("Subject").'&nbsp;', 'left','','valign="top"' ) .
83be314a 115 html_tag( 'td', htmlspecialchars($subject), 'left' )
7e1c2d41 116 ) . "\n" .
117 html_tag( 'tr',
118 html_tag( 'td', _("Date").'&nbsp;', 'left' ) .
83be314a 119 html_tag( 'td', htmlspecialchars($date), 'left' )
7e1c2d41 120 ) . "\n" .
121 html_tag( 'tr',
122 html_tag( 'td', _("To").'&nbsp;', 'left','','valign="top"' ) .
83be314a 123 html_tag( 'td', htmlspecialchars($to), 'left' )
1c663478 124 ) . "\n";
125 if ( strlen($cc) > 0 ) { /* only show CC: if it's there... */
126 echo html_tag( 'tr',
7e1c2d41 127 html_tag( 'td', _("CC").'&nbsp;', 'left','','valign="top"' ) .
83be314a 128 html_tag( 'td', htmlspecialchars($cc), 'left' )
1c663478 129 );
130 }
1c663478 131 /* body */
7e1c2d41 132 echo html_tag( 'tr',
1c663478 133 html_tag( 'td', '<hr noshade size=1><br>' . "\n" . $body, 'left', '', 'colspan="2"' )
134 ) . "\n" .
135
136 '</table>' . "\n" .
137 '</body></html>';
f226cba7 138
32f4e318 139/* --end browser output-- */
f226cba7 140
f226cba7 141
32f4e318 142/* --start pf-specific functions-- */
f226cba7 143
32f4e318 144/* $string = pf_clean_string($string, 9); */
f226cba7 145function pf_clean_string ( $unclean_string, $num_leading_spaces ) {
146 global $data_dir, $username;
147
f6d2358f 148 $wrap_at = getPref($data_dir, $username, 'wrap_at', 86);
32f4e318 149 $wrap_at = $wrap_at - $num_leading_spaces; /* header stuff */
f226cba7 150
151 $leading_spaces = '';
152 while ( strlen($leading_spaces) < $num_leading_spaces )
153 $leading_spaces .= ' ';
154
155 $clean_string = '';
156 while ( strlen($unclean_string) > $wrap_at )
157 {
158 $this_line = substr($unclean_string, 0, $wrap_at);
32f4e318 159 if ( strrpos( $this_line, "\n" ) ) /* this should NEVER happen with anything but the $body */
f226cba7 160 {
161 $clean_string .= substr( $this_line, 0, strrpos( $this_line, "\n" ));
162 $clean_string .= $leading_spaces;
163 $unclean_string = substr($unclean_string, strrpos( $this_line, "\n" ));
164 }
165 else
166 {
167 $clean_string .= substr( $this_line, 0, strrpos( $this_line, ' ' ));
168 $clean_string .= "\n" . $leading_spaces;
169 $unclean_string = substr($unclean_string, (1+strrpos( $this_line, ' ' )));
170 }
171 }
32f4e318 172
f226cba7 173 $clean_string .= $unclean_string;
174
175 return $clean_string;
32f4e318 176} /* end pf_clean_string() function */
f226cba7 177
32f4e318 178/* --end pf-specific functions */
f226cba7 179
ae426785 180?>