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