7baf86a9 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * vcard.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 | * This file shows an attched vcard |
10 | * |
11 | * $Id$ |
12 | */ |
7baf86a9 |
13 | |
35586184 |
14 | require_once('../src/validate.php'); |
15 | require_once('../functions/date.php'); |
16 | require_once('../functions/page_header.php'); |
17 | require_once('../functions/mime.php'); |
18 | require_once('../src/load_prefs.php'); |
7baf86a9 |
19 | |
65c3ec94 |
20 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
21 | sqimap_mailbox_select($imapConnection, $mailbox); |
7baf86a9 |
22 | |
23 | |
65c3ec94 |
24 | displayPageHeader($color, 'None'); |
7baf86a9 |
25 | |
fab3baa6 |
26 | echo '<br>' . |
27 | html_tag( 'table', '', 'center', '', 'width="100%" border="0" cellspacing="0" cellpadding="2"' ) ."\n" . |
28 | html_tag( 'tr' ) . "\n" . |
29 | html_tag( 'td', '', 'left', $color[0] ) . |
7baf86a9 |
30 | '<b><center>' . |
fab3baa6 |
31 | _("Viewing a Business Card") . ' - '; |
65c3ec94 |
32 | if (isset($where) && isset($what)) { |
33 | // from a search |
34 | echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) . |
5e9e90fd |
35 | '&passed_id=' . $passed_id . '&where=' . urlencode($where) . |
36 | '&what=' . urlencode($what). '">' . _("View message") . '</a>'; |
65c3ec94 |
37 | } else { |
38 | echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) . |
5e9e90fd |
39 | '&passed_id=' . $passed_id . '&startMessage=' . $startMessage . |
40 | '&show_more=0">' . _("View message") . '</a>'; |
65c3ec94 |
41 | } |
42 | echo '</center></b></td></tr>'; |
43 | |
44 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
45 | |
46 | $entity_vcard = getEntity($message,$passed_ent_id); |
47 | |
48 | $vcard = mime_fetch_body ($imapConnection, $passed_id, $passed_ent_id); |
49 | $vcard = decodeBody($vcard, $entity_vcard->header->encoding); |
50 | $vcard = explode ("\n",$vcard); |
51 | foreach ($vcard as $l) { |
52 | $k = substr($l, 0, strpos($l, ':')); |
53 | $v = substr($l, strpos($l, ':') + 1); |
54 | $attributes = explode(';', $k); |
55 | $k = strtolower(array_shift($attributes)); |
56 | foreach ($attributes as $attr) { |
57 | if ($attr == 'quoted-printable') |
58 | $v = quoted_printable_decode($v); |
59 | else |
7baf86a9 |
60 | $k .= ';' . $attr; |
65c3ec94 |
61 | } |
62 | |
0f8a1ce9 |
63 | $v = str_replace(';', "\n", $v); |
65c3ec94 |
64 | $vcard_nice[$k] = $v; |
65 | } |
66 | |
67 | if ($vcard_nice['version'] == '2.1') { |
68 | // get firstname and lastname for sm addressbook |
69 | $vcard_nice["firstname"] = substr($vcard_nice["n"], |
70 | strpos($vcard_nice["n"], "\n") + 1, strlen($vcard_nice["n"])); |
71 | $vcard_nice["lastname"] = substr($vcard_nice["n"], 0, |
72 | strpos($vcard_nice["n"], "\n")); |
73 | } else { |
fab3baa6 |
74 | echo html_tag( 'tr', |
75 | html_tag( 'td', 'vCard Version ' . $vcard_nice['version'] . |
76 | ' is not supported. Some information might not be converted ' . |
77 | 'correctly.' , |
78 | 'center' ) |
79 | ) . "\n"; |
65c3ec94 |
80 | } |
81 | |
82 | foreach ($vcard_nice as $k => $v) { |
83 | $v = htmlspecialchars($v); |
84 | $v = trim($v); |
85 | $vcard_safe[$k] = trim(nl2br($v)); |
86 | } |
87 | |
88 | $ShowValues = array( |
89 | 'fn' => _("Name"), |
90 | 'title' => _("Title"), |
91 | 'email;internet' => _("Email"), |
92 | 'url' => _("Web Page"), |
93 | 'org' => _("Organization / Department"), |
94 | 'adr' => _("Address"), |
95 | 'tel;work' => _("Work Phone"), |
96 | 'tel;home' => _("Home Phone"), |
97 | 'tel;cell' => _("Cellular Phone"), |
98 | 'tel;fax' => _("Fax"), |
99 | 'note' => _("Note")); |
100 | |
fab3baa6 |
101 | echo html_tag( 'tr' ) . html_tag( 'td', '', 'left' ) . '<br>' . |
102 | html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="0"' ) . "\n"; |
65c3ec94 |
103 | |
fab3baa6 |
104 | if (isset($vcard_safe['email;internet'])) { $vcard_safe['email;internet'] = '<a href="../src/compose.php?send_to=' . |
65c3ec94 |
105 | $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] . |
fab3baa6 |
106 | '</a>'; |
65c3ec94 |
107 | } |
108 | if (isset($vcard_safe['url'])) { |
fab3baa6 |
109 | $vcard_safe['url'] = '<a href="' . $vcard_safe['url'] . '">' . |
110 | $vcard_safe['url'] . '</a>'; |
65c3ec94 |
111 | } |
112 | |
113 | foreach ($ShowValues as $k => $v) { |
114 | if (isset($vcard_safe[$k]) && $vcard_safe[$k]) { |
6b4bd11f |
115 | echo html_tag( 'tr', |
116 | html_tag( 'td', '<b>' . $v . ':</b>', 'right' ) . |
117 | html_tag( 'td', $vcard_safe[$k], 'left' ) |
118 | ) . "\n"; |
65c3ec94 |
119 | } |
120 | } |
7baf86a9 |
121 | |
65c3ec94 |
122 | echo '</table>' . |
7baf86a9 |
123 | '<br>' . |
124 | '</td></tr></table>' . |
fab3baa6 |
125 | html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="0" width="100%"' ) . "\n"; |
126 | html_tag( 'tr', |
127 | html_tag( 'td', |
128 | '<b><center>' . |
129 | _("Add to Addressbook") . '</b></center>' , |
130 | 'left', $color[0] ) |
131 | ) . |
132 | html_tag( 'tr' ) . |
133 | html_tag( 'td', '', 'center' ) . |
134 | '<form action="../src/addressbook.php" method="post" name="f_add">' . |
135 | html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="0" width="100%"' ) . |
136 | html_tag( 'tr', |
137 | html_tag( 'td', |
138 | '<b>Nickname:</b>' , |
139 | 'right' ) . |
140 | html_tag( 'td', |
141 | '<input type=text name="addaddr[nickname]" size=20 value="' . |
142 | $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] . '">' , |
143 | 'left' ) |
144 | ) . |
145 | html_tag( 'tr' ) . |
146 | html_tag( 'td', '<b>Note Field Contains:</b>', 'right' ) . |
147 | html_tag( 'td', '', 'left' ) . |
7baf86a9 |
148 | '<select name="addaddr[label]">'; |
149 | |
65c3ec94 |
150 | if (isset($vcard_nice['url'])) { |
151 | echo '<option value="' . htmlspecialchars($vcard_nice['url']) . |
152 | '">' . _("Web Page") . "</option>\n"; |
153 | } |
154 | if (isset($vcard_nice['adr'])) { |
155 | echo '<option value="' . $vcard_nice['adr'] . |
156 | '">' . _("Address") . "</option>\n"; |
157 | } |
158 | if (isset($vcard_nice['title'])) { |
159 | echo '<option value="' . $vcard_nice['title'] . |
160 | '">' . _("Title") . "</option>\n"; |
161 | } |
162 | if (isset($vcard_nice['org'])) { |
163 | echo '<option value="' . $vcard_nice['org'] . |
164 | '">' . _("Organization / Department") . "</option>\n"; |
165 | } |
166 | if (isset($vcard_nice['title'])) { |
167 | echo '<option value="' . $vcard_nice['title'] . |
168 | '; ' . $vcard_nice['org'] . |
169 | '">' . _("Title & Org. / Dept.") . "</option>\n"; |
170 | } |
171 | if (isset($vcard_nice['tel;work'])) { |
172 | echo '<option value="' . $vcard_nice['tel;work'] . |
173 | '">' . _("Work Phone") . "</option>\n"; |
174 | } |
175 | if (isset($vcard_nice['tel;home'])) { |
176 | echo '<option value="' . $vcard_nice['tel;home'] . |
177 | '">' . _("Home Phone") . "</option>\n"; |
178 | } |
179 | if (isset($vcard_nice['tel;cell'])) { |
180 | echo '<option value="' . $vcard_nice['tel;cell'] . |
181 | '">' . _("Cellular Phone") . "</option>\n"; |
182 | } |
183 | if (isset($vcard_nice['tel;fax'])) { |
184 | echo '<option value="' . $vcard_nice['tel;fax'] . |
185 | '">' . _("Fax") . "</option>\n"; |
186 | } |
187 | if (isset($vcard_nice['note'])) { |
188 | echo '<option value="' . $vcard_nice['note'] . |
189 | '">' . _("Note") . "</option>\n"; |
190 | } |
191 | echo '</select>' . |
7baf86a9 |
192 | '</td></tr>' . |
fab3baa6 |
193 | html_tag( 'tr', |
194 | html_tag( 'td', |
195 | '<input name="addaddr[email]" type=hidden value="' . |
196 | htmlspecialchars($vcard_nice['email;internet']) . '">' . |
197 | '<input name="addaddr[firstname]" type=hidden value="' . |
198 | $vcard_safe['firstname'] . '">' . |
199 | '<input name="addaddr[lastname]" type=hidden value="' . |
200 | $vcard_safe['lastname'] . '">' . |
201 | '<input type="submit" name="addaddr[SUBMIT]" ' . |
202 | 'value="Add to Address Book">' , |
203 | 'center', '', 'colspan="2"' ) |
204 | ) . |
7baf86a9 |
205 | '</table>' . |
fab3baa6 |
206 | '</form>' . |
7baf86a9 |
207 | '</td></tr>' . |
fab3baa6 |
208 | html_tag( 'tr', |
209 | html_tag( 'td', |
210 | '<a href="../src/download.php?absolute_dl=true&passed_id=' . |
211 | $passed_id . '&mailbox=' . urlencode($mailbox) . |
212 | '&passed_ent_id=' . $passed_ent_id . '">' . |
213 | _("Download this as a file") . '</a>' , |
214 | 'center' ) |
215 | ) . |
216 | '</table>' . |
217 | |
218 | html_tag( 'table', |
219 | html_tag( 'tr', |
220 | html_tag( 'td', ' ', 'left', $color[4] ) |
221 | ) , |
222 | 'center', '', 'border="0" cellspacing="0" cellpadding="2"' ) . |
7baf86a9 |
223 | '</body></html>'; |
65c3ec94 |
224 | |
0f8a1ce9 |
225 | ?> |