5 ** This file shows an attched vcard
10 require_once('../src/validate.php');
11 require_once('../functions/date.php');
12 require_once('../functions/page_header.php');
13 require_once('../functions/mime.php');
14 require_once('../src/load_prefs.php');
16 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
17 sqimap_mailbox_select($imapConnection, $mailbox);
20 displayPageHeader($color, 'None');
22 echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
23 'align="center">' . "\n" .
24 '<tr><td bgcolor="' . $color[0] . '">' .
26 _("Viewing a Business Card") . " - ";
27 if (isset($where) && isset($what)) {
29 echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
30 '&passed_id=' . $passed_id . '&where=' . urlencode($where) .
31 '&what=' . urlencode($what). '">' . _("View message") . '</a>';
33 echo '<a href="../src/read_body.php?mailbox=' . urlencode($mailbox) .
34 '&passed_id=' . $passed_id . '&startMessage=' . $startMessage .
35 '&show_more=0">' . _("View message") . '</a>';
37 echo '</center></b></td></tr>';
39 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
41 $entity_vcard = getEntity($message,$passed_ent_id);
43 $vcard = mime_fetch_body ($imapConnection, $passed_id, $passed_ent_id);
44 $vcard = decodeBody($vcard, $entity_vcard->header
->encoding
);
45 $vcard = explode ("\n",$vcard);
46 foreach ($vcard as $l)
48 $k = substr($l, 0, strpos($l, ':'));
49 $v = substr($l, strpos($l, ':') +
1);
50 $attributes = explode(';', $k);
51 $k = strtolower(array_shift($attributes));
52 foreach ($attributes as $attr)
54 if ($attr == 'quoted-printable')
55 $v = quoted_printable_decode($v);
60 $v = ereg_replace(';', "\n", $v);
64 if ($vcard_nice['version'] == '2.1')
66 // get firstname and lastname for sm addressbook
67 $vcard_nice["firstname"] = substr($vcard_nice["n"],
68 strpos($vcard_nice["n"], "\n") +
1, strlen($vcard_nice["n"]));
69 $vcard_nice["lastname"] = substr($vcard_nice["n"], 0,
70 strpos($vcard_nice["n"], "\n"));
74 echo '<tr><td align=center>vCard Version ' . $vcard_nice['version'] .
75 ' is not supported. Some information might not be converted ' .
76 "correctly.</td></tr>\n";
79 foreach ($vcard_nice as $k => $v)
81 $v = htmlspecialchars($v);
83 $vcard_safe[$k] = trim(nl2br($v));
88 'title' => _("Title"),
89 'email;internet' => _("Email"),
90 'url' => _("Web Page"),
91 'org' => _("Organization / Department"),
92 'adr' => _("Address"),
93 'tel;work' => _("Work Phone"),
94 'tel;home' => _("Home Phone"),
95 'tel;cell' => _("Cellular Phone"),
96 'tel;fax' => _("Fax"),
100 '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
102 if (isset($vcard_safe['email;internet'])) {
103 $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
104 $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
107 if (isset($vcard_safe['url'])) {
108 $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
109 $vcard_safe['url'] . '</A>';
112 foreach ($ShowValues as $k => $v)
114 if (isset($vcard_safe[$k]) && $vcard_safe[$k])
116 echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
123 '</td></tr></table>' .
124 '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
127 '<td bgcolor="' . $color[0] . '">' .
129 _("Add to Addressbook") .
131 '<tr><td align=center>' .
132 '<FORM ACTION="../src/addressbook.php" METHOD="POST" NAME=f_add>' .
133 '<table border=0 cellpadding=2 cellspacing=0 align=center>' .
134 '<tr><td align=right><b>Nickname:</b></td>' .
135 '<td><input type=text name="addaddr[nickname]" size=20 value="' .
136 $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] .
138 '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
139 '<select name="addaddr[label]">';
141 if (isset($vcard_nice['url']))
142 echo '<option value="' . htmlspecialchars($vcard_nice['url']) .
143 '">' . _("Web Page") . "</option>\n";
144 if (isset($vcard_nice['adr']))
145 echo '<option value="' . $vcard_nice['adr'] .
146 '">' . _("Address") . "</option>\n";
147 if (isset($vcard_nice['title']))
148 echo '<option value="' . $vcard_nice['title'] .
149 '">' . _("Title") . "</option>\n";
150 if (isset($vcard_nice['org']))
151 echo '<option value="' . $vcard_nice['org'] .
152 '">' . _("Organization / Department") . "</option>\n";
153 if (isset($vcard_nice['title']))
154 echo '<option value="' . $vcard_nice['title'] .
155 '; ' . $vcard_nice['org'] .
156 '">' . _("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";
160 if (isset($vcard_nice['tel;home']))
161 echo '<option value="' . $vcard_nice['tel;home'] .
162 '">' . _("Home Phone") . "</option>\n";
163 if (isset($vcard_nice['tel;cell']))
164 echo '<option value="' . $vcard_nice['tel;cell'] .
165 '">' . _("Cellular Phone") . "</option>\n";
166 if (isset($vcard_nice['tel;fax']))
167 echo '<option value="' . $vcard_nice['tel;fax'] .
168 '">' . _("Fax") . "</option>\n";
169 if (isset($vcard_nice['note']))
170 echo '<option value="' . $vcard_nice['note'] .
171 '">' . _("Note") . "</option>\n";
175 '<tr><td colspan=2 align=center>' .
176 '<INPUT NAME="addaddr[email]" type=hidden value="' .
177 htmlspecialchars($vcard_nice['email;internet']) . '">' .
178 '<INPUT NAME="addaddr[firstname]" type=hidden value="' .
179 $vcard_safe['firstname'] . '">' .
180 '<INPUT NAME="addaddr[lastname]" type=hidden value="' .
181 $vcard_safe['lastname'] . '">' .
182 '<INPUT TYPE=submit NAME="addaddr[SUBMIT]" ' .
183 'VALUE="Add to Address Book">' .
188 '<tr><td align=center>' .
189 '<a href="../src/download.php?absolute_dl=true&passed_id=' .
190 $passed_id . '&mailbox=' . urlencode($mailbox) .
191 '&passed_ent_id=' . $passed_ent_id . '">' .
192 _("Download this as a file") . '</A>' .
193 '</TD></TR></TABLE>' .
195 '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
196 '<TR><TD BGCOLOR="' . $color[4] . '">' .
197 '</TD></TR></TABLE>' .