Wrong include path
[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
32f4e318 29$pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay');
18680db6 30$mailbox = urldecode($mailbox);
31$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
32sqimap_mailbox_select($imapConnection, $mailbox);
33$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
5caf2d0c 34$id = $passed_id;
35if (isset($passed_ent_id)) {
36 $message = $message->getEntity($passed_ent_id);
37}
38
32f4e318 39
40/* --start display setup-- */
41
7e1c2d41 42$rfc822_header = $message->rfc822_header;
32f4e318 43/* From and Date are usually fine as they are... */
7e1c2d41 44$from = decodeHeader($rfc822_header->getAddr_s('from'));
45$date = getLongDateString($rfc822_header->date);
46$subject = trim(decodeHeader($rfc822_header->subject));
32f4e318 47
48/* we can clean these up if the list is too long... */
7e1c2d41 49$cc = decodeHeader($rfc822_header->getAddr_s('cc'));
50$to = decodeHeader($rfc822_header->getAddr_s('to'));
32f4e318 51
c8d6aef3 52if ($show_html_default == 1) {
53 $ent_ar = $message->findDisplayEntity(array());
54} else {
55 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
56}
18680db6 57$body = '';
58if ($ent_ar[0] != '') {
59 for ($i = 0; $i < count($ent_ar); $i++) {
60 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
5caf2d0c 61 $body .= '<hr noshade size=1>';
18680db6 62 }
63 $hookResults = do_hook('message_body', $body);
64 $body = $hookResults[1];
32f4e318 65} else {
18680db6 66 $body = _("Message not printable");
32f4e318 67}
3bbf5974 68
32f4e318 69 /* now, if they choose to, we clean up the display a bit... */
18680db6 70
32f4e318 71if ( empty($pf_cleandisplay) || $pf_cleandisplay != 'no' ) {
f226cba7 72
32f4e318 73 $num_leading_spaces = 9; // nine leading spaces for indentation
f226cba7 74
32f4e318 75 // sometimes I see ',,' instead of ',' seperating addresses *shrug*
76 $cc = pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces);
77 $to = pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces);
f226cba7 78
32f4e318 79 // the body should have no leading zeros
5caf2d0c 80 // disabled because it destroys html mail
81
82// $body = pf_clean_string($body, 0);
f226cba7 83
32f4e318 84 // clean up everything else...
85 $subject = pf_clean_string($subject, $num_leading_spaces);
86 $from = pf_clean_string($from, $num_leading_spaces);
87 $date = pf_clean_string($date, $num_leading_spaces);
f226cba7 88
32f4e318 89} // end cleanup
18680db6 90
32f4e318 91// --end display setup--
f226cba7 92
f226cba7 93
32f4e318 94/* --start browser output-- */
95displayHtmlHeader( _("Printer Friendly"), '', FALSE );
f226cba7 96
32f4e318 97echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n" .
ae426785 98 /* headers (we use table because translations are not all the same width) */
6206f6c4 99 html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0"' ) .
1c663478 100 html_tag( 'tr',
7e1c2d41 101 html_tag( 'td', _("From").'&nbsp;', 'left' ,'','valign="top"') .
83be314a 102 html_tag( 'td', htmlspecialchars($from), 'left' )
1c663478 103 ) . "\n" .
104 html_tag( 'tr',
7e1c2d41 105 html_tag( 'td', _("Subject").'&nbsp;', 'left','','valign="top"' ) .
83be314a 106 html_tag( 'td', htmlspecialchars($subject), 'left' )
7e1c2d41 107 ) . "\n" .
108 html_tag( 'tr',
109 html_tag( 'td', _("Date").'&nbsp;', 'left' ) .
83be314a 110 html_tag( 'td', htmlspecialchars($date), 'left' )
7e1c2d41 111 ) . "\n" .
112 html_tag( 'tr',
113 html_tag( 'td', _("To").'&nbsp;', 'left','','valign="top"' ) .
83be314a 114 html_tag( 'td', htmlspecialchars($to), 'left' )
1c663478 115 ) . "\n";
116 if ( strlen($cc) > 0 ) { /* only show CC: if it's there... */
117 echo html_tag( 'tr',
7e1c2d41 118 html_tag( 'td', _("CC").'&nbsp;', 'left','','valign="top"' ) .
83be314a 119 html_tag( 'td', htmlspecialchars($cc), 'left' )
1c663478 120 );
121 }
1c663478 122 /* body */
7e1c2d41 123 echo html_tag( 'tr',
1c663478 124 html_tag( 'td', '<hr noshade size=1><br>' . "\n" . $body, 'left', '', 'colspan="2"' )
125 ) . "\n" .
126
127 '</table>' . "\n" .
128 '</body></html>';
f226cba7 129
32f4e318 130/* --end browser output-- */
f226cba7 131
f226cba7 132
32f4e318 133/* --start pf-specific functions-- */
f226cba7 134
32f4e318 135/* $string = pf_clean_string($string, 9); */
f226cba7 136function pf_clean_string ( $unclean_string, $num_leading_spaces ) {
137 global $data_dir, $username;
138
f6d2358f 139 $wrap_at = getPref($data_dir, $username, 'wrap_at', 86);
32f4e318 140 $wrap_at = $wrap_at - $num_leading_spaces; /* header stuff */
f226cba7 141
142 $leading_spaces = '';
143 while ( strlen($leading_spaces) < $num_leading_spaces )
144 $leading_spaces .= ' ';
145
146 $clean_string = '';
147 while ( strlen($unclean_string) > $wrap_at )
148 {
149 $this_line = substr($unclean_string, 0, $wrap_at);
32f4e318 150 if ( strrpos( $this_line, "\n" ) ) /* this should NEVER happen with anything but the $body */
f226cba7 151 {
152 $clean_string .= substr( $this_line, 0, strrpos( $this_line, "\n" ));
153 $clean_string .= $leading_spaces;
154 $unclean_string = substr($unclean_string, strrpos( $this_line, "\n" ));
155 }
156 else
157 {
158 $clean_string .= substr( $this_line, 0, strrpos( $this_line, ' ' ));
159 $clean_string .= "\n" . $leading_spaces;
160 $unclean_string = substr($unclean_string, (1+strrpos( $this_line, ' ' )));
161 }
162 }
32f4e318 163
f226cba7 164 $clean_string .= $unclean_string;
165
166 return $clean_string;
32f4e318 167} /* end pf_clean_string() function */
f226cba7 168
32f4e318 169/* --end pf-specific functions */
f226cba7 170
ae426785 171?>