6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file shows an attched vcard
12 * @package squirrelmail
16 * Path for SquirrelMail required files.
19 Define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/date.php');
24 require_once(SM_PATH
. 'functions/page_header.php');
25 require_once(SM_PATH
. 'functions/mime.php');
26 require_once(SM_PATH
. 'include/load_prefs.php');
29 sqgetGlobalVar('username', $username, SQ_SESSION
);
30 sqgetGlobalVar('key', $key, SQ_COOKIE
);
31 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
33 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
);
34 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
35 sqgetGlobalVar('ent_id', $ent_id, SQ_GET
);
36 sqgetGlobalVar('startMessage', $startMessage, SQ_GET
);
39 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40 sqimap_mailbox_select($imapConnection, $mailbox);
43 displayPageHeader($color, 'None');
47 <table width
="100%" border
="0" cellspacing
="0" cellpadding
="2" align
="center">
51 echo '<td bgcolor="' . $color[0] . '">' .
53 _("Viewing a Business Card") . " - ";
54 $msg_url = 'read_body.php?mailbox='.urlencode($mailbox).
55 '&startMessage='.urlencode($startMessage).
56 '&passed_id='.urlencode($passed_id);
58 $msg_url = set_url_var($msg_url, 'ent_id', 0);
60 echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
62 echo '</center></b></td></tr>';
64 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
66 $entity_vcard = getEntity($message,$ent_id);
68 $vcard = mime_fetch_body ($imapConnection, $passed_id, $ent_id);
69 $vcard = decodeBody($vcard, $entity_vcard->header
->encoding
);
70 $vcard = explode ("\n",$vcard);
71 foreach ($vcard as $l) {
72 $k = substr($l, 0, strpos($l, ':'));
73 $v = substr($l, strpos($l, ':') +
1);
74 $attributes = explode(';', $k);
75 $k = strtolower(array_shift($attributes));
76 foreach ($attributes as $attr) {
77 if ($attr == 'quoted-printable')
78 $v = quoted_printable_decode($v);
80 $k .= ';' . strtolower($attr);
83 $v = str_replace(';', "\n", $v);
87 if ($vcard_nice['version'] == '2.1') {
88 // get firstname and lastname for sm addressbook
89 $vcard_nice['firstname'] = substr($vcard_nice['n'],
90 strpos($vcard_nice['n'], "\n") +
1, strlen($vcard_nice['n']));
91 $vcard_nice['lastname'] = substr($vcard_nice['n'], 0,
92 strpos($vcard_nice['n'], "\n"));
93 // workaround for Outlook, should be fixed in a better way,
94 // maybe in new 'vCard' class.
95 if (isset($vcard_nice['email;pref;internet'])) {
96 $vcard_nice['email;internet'] = $vcard_nice['email;pref;internet'];
99 echo '<tr><td align="center">' .
100 sprintf(_("vCard Version %s is not supported. Some information might not be converted correctly."),$vcard_nice['version']) .
104 foreach ($vcard_nice as $k => $v) {
105 $v = htmlspecialchars($v);
107 $vcard_safe[$k] = trim(nl2br($v));
112 'title' => _("Title"),
113 'email;internet' => _("Email"),
114 'url' => _("Web Page"),
115 'org' => _("Organization / Department"),
116 'adr' => _("Address"),
117 'tel;work' => _("Work Phone"),
118 'tel;home' => _("Home Phone"),
119 'tel;cell' => _("Cellular Phone"),
120 'tel;fax' => _("Fax"),
121 'note' => _("Note"));
123 echo '<tr><td><br />' .
124 '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
126 if (isset($vcard_safe['email;internet'])) {
127 $vcard_safe['email;internet'] = makeComposeLink('src/compose.php?send_to='.urlencode($vcard_safe['email;internet']),
128 $vcard_safe['email;internet']);
131 if (isset($vcard_safe['url'])) {
132 $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
133 $vcard_safe['url'] . '</A>';
136 foreach ($ShowValues as $k => $v) {
137 if (isset($vcard_safe[$k]) && $vcard_safe[$k]) {
138 echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
147 <table width
="100%" border
="0" cellspacing
="0" cellpadding
="2" align
="center">
148 <tr
><td bgcolor
="<?php echo $color[0]; ?>" align
="center">
149 <b
><?php
echo _("Add to Addressbook"); ?
></b
>
151 <tr
><td align
="center">
152 <?php
addForm('../src/addressbook.php', 'POST', 'f_add') ?
>
153 <table border
="0" cellpadding
="2" cellspacing
="0" align
="center">
154 <tr
><td align
="right"><b
><?php
echo _("Nickname:"); ?
></b
></td
>
156 <?php
addInput('addaddr[nickname]', $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'], '20'); ?
>
158 <tr
><td align
="right"><b
><?php
echo _("Note Field Contains:"); ?
></b
></td
><td
>
162 if (isset($vcard_nice['url'])) {
163 $opts[$vcard_nice['url']] = _("Web Page");
165 if (isset($vcard_nice['adr'])) {
166 $opts[$vcard_nice['adr']] = _("Address");
168 if (isset($vcard_nice['title'])) {
169 $opts[$vcard_nice['title']] = _("Title");
171 if (isset($vcard_nice['org'])) {
172 $opts[$vcard_nice['org']] = _("Organization / Department");
174 if (isset($vcard_nice['title'])) {
175 $opts[$vcard_nice['title'].'; '.$vcard_nice['org']] = _("Title & Org. / Dept.");
177 if (isset($vcard_nice['tel;work'])) {
178 $opts[$vcard_nice['tel;work']] = _("Work Phone");
180 if (isset($vcard_nice['tel;home'])) {
181 $opts[$vcard_nice['tel;home']] = _("Home Phone");
183 if (isset($vcard_nice['tel;cell'])) {
184 $opts[$vcard_nice['tel;cell']] = _("Cellular Phone");
186 if (isset($vcard_nice['tel;fax'])) {
187 $opts[$vcard_nice['tel;fax']] = _("Fax");
189 if (isset($vcard_nice['note'])) {
190 $opts[$vcard_nice['note']] = _("Note");
193 echo addSelect('addaddr[label]', $opts, '', TRUE);
197 <tr
><td colspan
="2" align
="center">
200 echo addHidden('addaddr[email]', $vcard_nice['email;internet']).
201 addHidden('addaddr[firstname]', $vcard_safe['firstname']).
202 addHidden('addaddr[lastname]', $vcard_safe['lastname']).
203 addSubmit(_("Add to Address Book"), 'addaddr[SUBMIT]');
210 <tr
><td align
="center">
213 echo '<a href="../src/download.php?absolute_dl=true&passed_id=' .
214 urlencode($passed_id) . '&mailbox=' . urlencode($mailbox) .
215 '&ent_id=' . urlencode($ent_id) . '">' .
216 _("Download this as a file") . '</a>';
220 <table border
="0" cellspacing
="0" cellpadding
="2" align
="center">
221 <tr
><td bgcolor
="<?php echo $color[4]; ?>"></td
></tr
>