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 | |
17 | /*****************************************************************/ |
18 | /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ |
19 | /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ |
20 | /*** + Base level indent should begin at left margin, as ***/ |
21 | /*** the require_once below looks. ***/ |
22 | /*** + All identation should consist of four space blocks ***/ |
23 | /*** + Tab characters are evil. ***/ |
24 | /*** + all comments should use "slash-star ... star-slash" ***/ |
25 | /*** style -- no pound characters, no slash-slash style ***/ |
26 | /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ |
27 | /*** ALWAYS USE { AND } CHARACTERS!!! ***/ |
28 | /*** + Please use ' instead of ", when possible. Note " ***/ |
29 | /*** should always be used in _( ) function calls. ***/ |
30 | /*** Thank you for your help making the SM code more readable. ***/ |
31 | /*****************************************************************/ |
32 | |
33 | require_once('../src/validate.php'); |
34 | require_once('../functions/strings.php'); |
35 | require_once('../config/config.php'); |
36 | require_once('../src/load_prefs.php'); |
37 | require_once('../functions/imap.php'); |
38 | require_once('../functions/page_header.php'); |
f226cba7 |
39 | |
40 | $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay'); |
41 | |
42 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
43 | sqimap_mailbox_select($imap_stream, $mailbox); |
44 | $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); |
45 | |
46 | |
47 | // --start display setup-- |
48 | |
49 | // From and Date are usually fine as they are... |
50 | $from = decodeHeader($message->header->from); |
51 | $date = getLongDateString($message->header->date); |
52 | |
53 | // we can clean these up if the list is too long... |
54 | $cc = decodeHeader(getLineOfAddrs($message->header->cc)); |
55 | $to = decodeHeader(getLineOfAddrs($message->header->to)); |
56 | |
57 | // and Body and Subject could easily stream off the page... |
58 | $body = mime_fetch_body($imap_stream, $passed_id, $passed_ent_id); |
59 | $body = str_replace("\n", "\n", trim(decodeBody($body, $message->header->encoding))); |
60 | $subject = trim(decodeHeader($message->header->subject)); |
61 | |
62 | // now, if they choose to, we clean up the display a bit... |
63 | if ( empty($pf_cleandisplay) || $pf_cleandisplay != 'no' ) |
64 | { |
65 | |
66 | $num_leading_spaces = 9; // nine leading spaces for indentation |
67 | |
68 | // sometimes I see ',,' instead of ',' seperating addresses *shrug* |
69 | $cc = pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces); |
70 | $to = pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces); |
71 | |
72 | // the body should have no leading zeros |
73 | $body = pf_clean_string($body, 0); |
74 | |
75 | // clean up everything else... |
76 | $subject = pf_clean_string($subject, $num_leading_spaces); |
77 | $from = pf_clean_string($from, $num_leading_spaces); |
78 | $date = pf_clean_string($date, $num_leading_spaces); |
79 | |
80 | } // end cleanup |
81 | |
692155b7 |
82 | // --end display setup-- |
f226cba7 |
83 | |
84 | |
692155b7 |
85 | // --start browser output-- |
86 | displayHtmlHeader( _("Printer Friendly"), '', FALSE ); |
f226cba7 |
87 | |
692155b7 |
88 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n" . |
89 | // headers (we use table becasue translations are not all the same width) |
90 | '<table>'. |
91 | '<tr><td>' . _("From") . ':</td><td>' . htmlentities($from) . "</td></td>\n". |
92 | '<tr><td>' . _("To") . ':</td><td>' . htmlentities($to) . "</td></td>\n"; |
93 | if ( strlen($cc) > 0 ) { // only show CC: if it's there... |
94 | echo '<tr><td>' . _("CC") . ':</td><td>' . htmlentities($cc) . "</td></td>\n"; |
f226cba7 |
95 | } |
692155b7 |
96 | echo '<tr><td>' . _("Date") . ':</td><td>' . htmlentities($date) . "</td></td>\n". |
97 | '<tr><td>' . _("Subject") . ':</td><td>' . htmlentities($subject) . "</td></td>\n". |
98 | '</table>'. |
99 | "\n<pre>"; |
f226cba7 |
100 | |
f226cba7 |
101 | |
102 | // body |
103 | echo "<hr noshade size=1>\n"; |
104 | echo htmlentities($body); |
105 | |
106 | // --end browser output-- |
107 | |
108 | |
109 | ?></pre> |
110 | </body> |
111 | </html> |
112 | |
113 | <? |
114 | |
115 | // --start pf-specific functions-- |
116 | |
117 | |
118 | // $string = pf_clean_string($string, 9); |
119 | function pf_clean_string ( $unclean_string, $num_leading_spaces ) { |
120 | global $data_dir, $username; |
121 | |
f6d2358f |
122 | $wrap_at = getPref($data_dir, $username, 'wrap_at', 86); |
f226cba7 |
123 | $wrap_at = $wrap_at - $num_leading_spaces; // header stuff |
124 | |
125 | $leading_spaces = ''; |
126 | while ( strlen($leading_spaces) < $num_leading_spaces ) |
127 | $leading_spaces .= ' '; |
128 | |
129 | $clean_string = ''; |
130 | while ( strlen($unclean_string) > $wrap_at ) |
131 | { |
132 | $this_line = substr($unclean_string, 0, $wrap_at); |
133 | if ( strrpos( $this_line, "\n" ) ) // this should NEVER happen with anything but the $body |
134 | { |
135 | $clean_string .= substr( $this_line, 0, strrpos( $this_line, "\n" )); |
136 | $clean_string .= $leading_spaces; |
137 | $unclean_string = substr($unclean_string, strrpos( $this_line, "\n" )); |
138 | } |
139 | else |
140 | { |
141 | $clean_string .= substr( $this_line, 0, strrpos( $this_line, ' ' )); |
142 | $clean_string .= "\n" . $leading_spaces; |
143 | $unclean_string = substr($unclean_string, (1+strrpos( $this_line, ' ' ))); |
144 | } |
145 | } |
146 | $clean_string .= $unclean_string; |
147 | |
148 | return $clean_string; |
149 | } // end pf_clean_string() function |
150 | |
151 | // --end pf-specific functions |
152 | |
153 | ?> |