Changed default value for SpamFilters_YourHop
[squirrelmail.git] / src / vcard.php
CommitLineData
7baf86a9 1<?php
895905c0 2
3 /**
4 ** vcard.php
5 **
6 ** Copyright (c) 1999-2001 The SquirrelMail Development Team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 **
9 ** This file shows an attched vcard
10 **
11 ** $Id$
12 **/
7baf86a9 13
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');
19
20 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21 sqimap_mailbox_select($imapConnection, $mailbox);
22
23
24 displayPageHeader($color, 'None');
25
26 echo '<br><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
27 'align="center">' . "\n" .
28 '<tr><td bgcolor="' . $color[0] . '">' .
29 '<b><center>' .
30 _("Viewing a Business Card") . " - ";
31 if (isset($where) && isset($what)) {
32 // from a search
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>';
36 } else {
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>';
40 }
41 echo '</center></b></td></tr>';
42
43 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
44
45 $entity_vcard = getEntity($message,$passed_ent_id);
46
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 {
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 {
58 if ($attr == 'quoted-printable')
59 $v = quoted_printable_decode($v);
60 else
61 $k .= ';' . $attr;
62 }
63
64 $v = ereg_replace(';', "\n", $v);
65 $vcard_nice[$k] = $v;
66 }
67
68 if ($vcard_nice['version'] == '2.1')
69 {
70 // get firstname and lastname for sm addressbook
71 $vcard_nice["firstname"] = substr($vcard_nice["n"],
72 strpos($vcard_nice["n"], "\n") + 1, strlen($vcard_nice["n"]));
73 $vcard_nice["lastname"] = substr($vcard_nice["n"], 0,
74 strpos($vcard_nice["n"], "\n"));
75 }
76 else
77 {
78 echo '<tr><td align=center>vCard Version ' . $vcard_nice['version'] .
79 ' is not supported. Some information might not be converted ' .
80 "correctly.</td></tr>\n";
81 }
82
83 foreach ($vcard_nice as $k => $v)
84 {
85 $v = htmlspecialchars($v);
86 $v = trim($v);
87 $vcard_safe[$k] = trim(nl2br($v));
88 }
89
90 $ShowValues = array(
91 'fn' => _("Name"),
92 'title' => _("Title"),
93 'email;internet' => _("Email"),
94 'url' => _("Web Page"),
95 'org' => _("Organization / Department"),
96 'adr' => _("Address"),
97 'tel;work' => _("Work Phone"),
98 'tel;home' => _("Home Phone"),
99 'tel;cell' => _("Cellular Phone"),
100 'tel;fax' => _("Fax"),
101 'note' => _("Note"));
102
103 echo '<tr><td><br>' .
104 '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
105
106 if (isset($vcard_safe['email;internet'])) {
107 $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
108 $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
109 '</A>';
110 }
111 if (isset($vcard_safe['url'])) {
112 $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
113 $vcard_safe['url'] . '</A>';
114 }
115
116 foreach ($ShowValues as $k => $v)
117 {
118 if (isset($vcard_safe[$k]) && $vcard_safe[$k])
119 {
120 echo "<tr><td align=right><b>$v:</b></td><td>" . $vcard_safe[$k] .
121 "</td><tr>\n";
122 }
123 }
124
125 echo '</table>' .
126 '<br>' .
127 '</td></tr></table>' .
128 '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
129 'align="center">' .
130 '<tr>' .
131 '<td bgcolor="' . $color[0] . '">' .
132 '<b><center>' .
133 _("Add to Addressbook") .
134 '</td></tr>' .
135 '<tr><td align=center>' .
136 '<FORM ACTION="../src/addressbook.php" METHOD="POST" NAME=f_add>' .
137 '<table border=0 cellpadding=2 cellspacing=0 align=center>' .
138 '<tr><td align=right><b>Nickname:</b></td>' .
139 '<td><input type=text name="addaddr[nickname]" size=20 value="' .
140 $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] .
141 '"></td></tr>' .
142 '<tr><td align=right><b>Note Field Contains:</b></td><td>' .
143 '<select name="addaddr[label]">';
144
145 if (isset($vcard_nice['url']))
146 echo '<option value="' . htmlspecialchars($vcard_nice['url']) .
147 '">' . _("Web Page") . "</option>\n";
148 if (isset($vcard_nice['adr']))
149 echo '<option value="' . $vcard_nice['adr'] .
150 '">' . _("Address") . "</option>\n";
151 if (isset($vcard_nice['title']))
152 echo '<option value="' . $vcard_nice['title'] .
153 '">' . _("Title") . "</option>\n";
154 if (isset($vcard_nice['org']))
155 echo '<option value="' . $vcard_nice['org'] .
156 '">' . _("Organization / Department") . "</option>\n";
157 if (isset($vcard_nice['title']))
158 echo '<option value="' . $vcard_nice['title'] .
159 '; ' . $vcard_nice['org'] .
160 '">' . _("Title & Org. / Dept.") . "</option>\n";
161 if (isset($vcard_nice['tel;work']))
162 echo '<option value="' . $vcard_nice['tel;work'] .
163 '">' . _("Work Phone") . "</option>\n";
164 if (isset($vcard_nice['tel;home']))
165 echo '<option value="' . $vcard_nice['tel;home'] .
166 '">' . _("Home Phone") . "</option>\n";
167 if (isset($vcard_nice['tel;cell']))
168 echo '<option value="' . $vcard_nice['tel;cell'] .
169 '">' . _("Cellular Phone") . "</option>\n";
170 if (isset($vcard_nice['tel;fax']))
171 echo '<option value="' . $vcard_nice['tel;fax'] .
172 '">' . _("Fax") . "</option>\n";
173 if (isset($vcard_nice['note']))
174 echo '<option value="' . $vcard_nice['note'] .
175 '">' . _("Note") . "</option>\n";
176
177 echo '</select>' .
178 '</td></tr>' .
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">' .
188 '</td></tr>' .
189 '</table>' .
190 '</FORM>' .
191 '</td></tr>' .
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>' .
198
199 '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>' .
200 '<TR><TD BGCOLOR="' . $color[4] . '">' .
201 '</TD></TR></TABLE>' .
202 '</body></html>';