6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file shows an attched vcard
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');
20 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21 sqimap_mailbox_select($imapConnection, $mailbox);
24 displayPageHeader($color, 'None');
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] ) .
31 _("Viewing a Business Card") . ' - ';
32 if (isset($where) && isset($what)) {
34 echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
35 '&passed_id=' . $passed_id . '&where=' . urlencode($where) .
36 '&what=' . urlencode($what). '">' . _("View message") . '</a>';
38 echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
39 '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
40 '&show_more=0">' . _("View message") . '</a>';
42 echo '</center></b></td></tr>';
44 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
46 $entity_vcard = getEntity($message,$passed_ent_id);
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);
63 $v = str_replace(';', "\n", $v);
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"));
75 html_tag( 'td', 'vCard Version ' . $vcard_nice['version'] .
76 ' is not supported. Some information might not be converted ' .
82 foreach ($vcard_nice as $k => $v) {
83 $v = htmlspecialchars($v);
85 $vcard_safe[$k] = trim(nl2br($v));
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"),
101 echo html_tag( 'tr' ) . html_tag( 'td', '', 'left' ) . '<br>' .
102 html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="0"' ) . "\n";
104 if (isset($vcard_safe['email;internet'])) { $vcard_safe['email;internet'] = '<a href="../src/compose.php?send_to=' .
105 $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
108 if (isset($vcard_safe['url'])) {
109 $vcard_safe['url'] = '<a href="' . $vcard_safe['url'] . '">' .
110 $vcard_safe['url'] . '</a>';
113 foreach ($ShowValues as $k => $v) {
114 if (isset($vcard_safe[$k]) && $vcard_safe[$k]) {
116 html_tag( 'td', '<b>' . $v . ':</b>', 'right' ) .
117 html_tag( 'td', $vcard_safe[$k], 'left' )
124 '</td></tr></table>' .
125 html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="0" width="100%"' ) . "\n";
129 _("Add to Addressbook") . '</b></center>' ,
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%"' ) .
141 '<input type=text name="addaddr[nickname]" size=20 value="' .
142 $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] . '">' ,
146 html_tag( 'td', '<b>Note Field Contains:</b>', 'right' ) .
147 html_tag( 'td', '', 'left' ) .
148 '<select name="addaddr[label]">';
150 if (isset($vcard_nice['url'])) {
151 echo '<option value="' . htmlspecialchars($vcard_nice['url']) .
152 '">' . _("Web Page") . "</option>\n";
154 if (isset($vcard_nice['adr'])) {
155 echo '<option value="' . $vcard_nice['adr'] .
156 '">' . _("Address") . "</option>\n";
158 if (isset($vcard_nice['title'])) {
159 echo '<option value="' . $vcard_nice['title'] .
160 '">' . _("Title") . "</option>\n";
162 if (isset($vcard_nice['org'])) {
163 echo '<option value="' . $vcard_nice['org'] .
164 '">' . _("Organization / Department") . "</option>\n";
166 if (isset($vcard_nice['title'])) {
167 echo '<option value="' . $vcard_nice['title'] .
168 '; ' . $vcard_nice['org'] .
169 '">' . _("Title & Org. / Dept.") . "</option>\n";
171 if (isset($vcard_nice['tel;work'])) {
172 echo '<option value="' . $vcard_nice['tel;work'] .
173 '">' . _("Work Phone") . "</option>\n";
175 if (isset($vcard_nice['tel;home'])) {
176 echo '<option value="' . $vcard_nice['tel;home'] .
177 '">' . _("Home Phone") . "</option>\n";
179 if (isset($vcard_nice['tel;cell'])) {
180 echo '<option value="' . $vcard_nice['tel;cell'] .
181 '">' . _("Cellular Phone") . "</option>\n";
183 if (isset($vcard_nice['tel;fax'])) {
184 echo '<option value="' . $vcard_nice['tel;fax'] .
185 '">' . _("Fax") . "</option>\n";
187 if (isset($vcard_nice['note'])) {
188 echo '<option value="' . $vcard_nice['note'] .
189 '">' . _("Note") . "</option>\n";
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"' )
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>' ,
220 html_tag( 'td', ' ', 'left', $color[4] )
222 'center', '', 'border="0" cellspacing="0" cellpadding="2"' ) .