ef0ff40e1e4d0d0dd31cc32f1c7682365adf590f
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 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
17 /* SquirrelMail required files. */
18 require_once(SM_PATH
. 'include/validate.php');
19 require_once(SM_PATH
. 'functions/date.php');
20 require_once(SM_PATH
. 'functions/page_header.php');
21 require_once(SM_PATH
. 'functions/mime.php');
22 require_once(SM_PATH
. 'include/load_prefs.php');
24 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
25 sqimap_mailbox_select($imapConnection, $mailbox);
28 displayPageHeader($color, 'None');
30 echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
31 'align="center">' . "\n" .
32 '<tr><td bgcolor="' . $color[0] . '">' .
34 _("Viewing a Business Card") . " - ";
35 $msg_url = 'read_body.php?' . $QUERY_STRING;
36 $msg_url = set_url_var($msg_url, 'ent_id', 0);
37 echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
39 echo '</center></b></td></tr>';
41 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
43 $entity_vcard = getEntity($message,$ent_id);
45 $vcard = mime_fetch_body ($imapConnection, $passed_id, $ent_id);
46 $vcard = decodeBody($vcard, $entity_vcard->header
->encoding
);
47 $vcard = explode ("\n",$vcard);
48 foreach ($vcard as $l) {
49 $k = substr($l, 0, strpos($l, ':'));
50 $v = substr($l, strpos($l, ':') +
1);
51 $attributes = explode(';', $k);
52 $k = strtolower(array_shift($attributes));
53 foreach ($attributes as $attr) {
54 if ($attr == 'quoted-printable')
55 $v = quoted_printable_decode($v);
60 $v = str_replace(';', "\n", $v);
64 if ($vcard_nice['version'] == '2.1') {
65 // get firstname and lastname for sm addressbook
66 $vcard_nice["firstname"] = substr($vcard_nice["n"],
67 strpos($vcard_nice["n"], "\n") +
1, strlen($vcard_nice["n"]));
68 $vcard_nice["lastname"] = substr($vcard_nice["n"], 0,
69 strpos($vcard_nice["n"], "\n"));
71 echo '<tr><td align=center>vCard Version ' . $vcard_nice['version'] .
72 ' is not supported. Some information might not be converted ' .
73 "correctly.</td></tr>\n";
76 foreach ($vcard_nice as $k => $v) {
77 $v = htmlspecialchars($v);
79 $vcard_safe[$k] = trim(nl2br($v));
84 'title' => _("Title"),
85 'email;internet' => _("Email"),
86 'url' => _("Web Page"),
87 'org' => _("Organization / Department"),
88 'adr' => _("Address"),
89 'tel;work' => _("Work Phone"),
90 'tel;home' => _("Home Phone"),
91 'tel;cell' => _("Cellular Phone"),
92 'tel;fax' => _("Fax"),
96 '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
98 if (isset($vcard_safe['email;internet'])) { $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
99 $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
102 if (isset($vcard_safe['url'])) {
103 $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
104 $vcard_safe['url'] . '</A>';
107 foreach ($ShowValues as $k => $v) {
108 if (isset($vcard_safe[$k]) && $vcard_safe[$k]) {
109 echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
116 '</td></tr></table>' .
117 '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
120 '<td bgcolor="' . $color[0] . '">' .
122 _("Add to Addressbook") .
124 '<tr><td align=center>' .
125 '<FORM ACTION="../src/addressbook.php" METHOD="POST" NAME=f_add>' .
126 '<table border=0 cellpadding=2 cellspacing=0 align=center>' .
127 '<tr><td align=right><b>Nickname:</b></td>' .
128 '<td><input type=text name="addaddr[nickname]" size=20 value="' .
129 $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] .
131 '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
132 '<select name="addaddr[label]">';
134 if (isset($vcard_nice['url'])) {
135 echo '<option value="' . htmlspecialchars($vcard_nice['url']) .
136 '">' . _("Web Page") . "</option>\n";
138 if (isset($vcard_nice['adr'])) {
139 echo '<option value="' . $vcard_nice['adr'] .
140 '">' . _("Address") . "</option>\n";
142 if (isset($vcard_nice['title'])) {
143 echo '<option value="' . $vcard_nice['title'] .
144 '">' . _("Title") . "</option>\n";
146 if (isset($vcard_nice['org'])) {
147 echo '<option value="' . $vcard_nice['org'] .
148 '">' . _("Organization / Department") . "</option>\n";
150 if (isset($vcard_nice['title'])) {
151 echo '<option value="' . $vcard_nice['title'] .
152 '; ' . $vcard_nice['org'] .
153 '">' . _("Title & Org. / Dept.") . "</option>\n";
155 if (isset($vcard_nice['tel;work'])) {
156 echo '<option value="' . $vcard_nice['tel;work'] .
157 '">' . _("Work Phone") . "</option>\n";
159 if (isset($vcard_nice['tel;home'])) {
160 echo '<option value="' . $vcard_nice['tel;home'] .
161 '">' . _("Home Phone") . "</option>\n";
163 if (isset($vcard_nice['tel;cell'])) {
164 echo '<option value="' . $vcard_nice['tel;cell'] .
165 '">' . _("Cellular Phone") . "</option>\n";
167 if (isset($vcard_nice['tel;fax'])) {
168 echo '<option value="' . $vcard_nice['tel;fax'] .
169 '">' . _("Fax") . "</option>\n";
171 if (isset($vcard_nice['note'])) {
172 echo '<option value="' . $vcard_nice['note'] .
173 '">' . _("Note") . "</option>\n";
177 '<tr><td colspan=2 align=center>' .
178 '<INPUT NAME="addaddr[email]" type=hidden value="' .
179 htmlspecialchars($vcard_nice['email;internet']) . '">' .
180 '<INPUT NAME="addaddr[firstname]" type=hidden value="' .
181 $vcard_safe['firstname'] . '">' .
182 '<INPUT NAME="addaddr[lastname]" type=hidden value="' .
183 $vcard_safe['lastname'] . '">' .
184 '<INPUT TYPE=submit NAME="addaddr[SUBMIT]" ' .
185 'VALUE="Add to Address Book">' .
190 '<tr><td align=center>' .
191 '<a href="../src/download.php?absolute_dl=true&passed_id=' .
192 $passed_id . '&mailbox=' . urlencode($mailbox) .
193 '&passed_ent_id=' . $passed_ent_id . '">' .
194 _("Download this as a file") . '</A>' .
195 '</TD></TR></TABLE>' .
197 '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
198 '<TR><TD BGCOLOR="' . $color[4] . '">' .
199 '</TD></TR></TABLE>' .