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');
26 echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
27 'align="center">' . "\n" .
28 '<tr><td bgcolor="' . $color[0] . '">' .
30 _("Viewing a Business Card") . " - ";
31 if (isset($where) && isset($what)) {
33 echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
34 '&passed_id=' . $passed_id . '&where=' . urlencode($where) .
35 '&what=' . urlencode($what). '">' . _("View message") . '</a>';
37 echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
38 '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
39 '&show_more=0">' . _("View message") . '</a>';
41 echo '</center></b></td></tr>';
43 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
45 $entity_vcard = getEntity($message,$passed_ent_id);
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);
62 $v = str_replace(';', "\n", $v);
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"));
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";
78 foreach ($vcard_nice as $k => $v) {
79 $v = htmlspecialchars($v);
81 $vcard_safe[$k] = trim(nl2br($v));
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"),
98 '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
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'] .
104 if (isset($vcard_safe['url'])) {
105 $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
106 $vcard_safe['url'] . '</A>';
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] .
118 '</td></tr></table>' .
119 '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
122 '<td bgcolor="' . $color[0] . '">' .
124 _("Add to Addressbook") .
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'] .
133 '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
134 '<select name="addaddr[label]">';
136 if (isset($vcard_nice['url'])) {
137 echo '<option value="' . htmlspecialchars($vcard_nice['url']) .
138 '">' . _("Web Page") . "</option>\n";
140 if (isset($vcard_nice['adr'])) {
141 echo '<option value="' . $vcard_nice['adr'] .
142 '">' . _("Address") . "</option>\n";
144 if (isset($vcard_nice['title'])) {
145 echo '<option value="' . $vcard_nice['title'] .
146 '">' . _("Title") . "</option>\n";
148 if (isset($vcard_nice['org'])) {
149 echo '<option value="' . $vcard_nice['org'] .
150 '">' . _("Organization / Department") . "</option>\n";
152 if (isset($vcard_nice['title'])) {
153 echo '<option value="' . $vcard_nice['title'] .
154 '; ' . $vcard_nice['org'] .
155 '">' . _("Title & Org. / Dept.") . "</option>\n";
157 if (isset($vcard_nice['tel;work'])) {
158 echo '<option value="' . $vcard_nice['tel;work'] .
159 '">' . _("Work Phone") . "</option>\n";
161 if (isset($vcard_nice['tel;home'])) {
162 echo '<option value="' . $vcard_nice['tel;home'] .
163 '">' . _("Home Phone") . "</option>\n";
165 if (isset($vcard_nice['tel;cell'])) {
166 echo '<option value="' . $vcard_nice['tel;cell'] .
167 '">' . _("Cellular Phone") . "</option>\n";
169 if (isset($vcard_nice['tel;fax'])) {
170 echo '<option value="' . $vcard_nice['tel;fax'] .
171 '">' . _("Fax") . "</option>\n";
173 if (isset($vcard_nice['note'])) {
174 echo '<option value="' . $vcard_nice['note'] .
175 '">' . _("Note") . "</option>\n";
179 '<tr><td colspan=2 align=center>' .
180 '<INPUT NAME="addaddr[email]" type=hidden value="' .
181 htmlspecialchars($vcard_nice['email;internet']) . '">' .
182 '<INPUT NAME="addaddr[firstname]" type=hidden value="' .
183 $vcard_safe['firstname'] . '">' .
184 '<INPUT NAME="addaddr[lastname]" type=hidden value="' .
185 $vcard_safe['lastname'] . '">' .
186 '<INPUT TYPE=submit NAME="addaddr[SUBMIT]" ' .
187 'VALUE="Add to Address Book">' .
192 '<tr><td align=center>' .
193 '<a href="../src/download.php?absolute_dl=true&passed_id=' .
194 $passed_id . '&mailbox=' . urlencode($mailbox) .
195 '&passed_ent_id=' . $passed_ent_id . '">' .
196 _("Download this as a file") . '</A>' .
197 '</TD></TR></TABLE>' .
199 '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
200 '<TR><TD BGCOLOR="' . $color[4] . '">' .
201 '</TD></TR></TABLE>' .