Source for file vcard.php

Documentation is available at vcard.php

  1. <?php
  2. /**
  3. * vcard.php
  4. *
  5. * This file shows an attched vcard
  6. *
  7. * @copyright 1999-2020 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id: vcard.php 14840 2020年01月07日 07:42:38Z pdontthink $
  10. * @package squirrelmail
  11. */
  12. /** This is the vcard page */
  13. define ('PAGE_NAME', 'vcard');
  14. /**
  15. * Path for SquirrelMail required files.
  16. * @ignore
  17. */
  18. Define('SM_PATH','../');
  19. /* SquirrelMail required files. */
  20. require_once(SM_PATH . 'include/validate.php');
  21. require_once(SM_PATH . 'functions/date.php');
  22. require_once(SM_PATH . 'functions/page_header.php');
  23. require_once(SM_PATH . 'functions/mime.php');
  24. require_once(SM_PATH . 'include/load_prefs.php');
  25. /* globals */
  26. sqgetGlobalVar ('username', $username, SQ_SESSION );
  27. sqgetGlobalVar ('key', $key, SQ_COOKIE );
  28. sqgetGlobalVar ('onetimepad', $onetimepad, SQ_SESSION );
  29. sqgetGlobalVar ('passed_id', $passed_id, SQ_GET );
  30. sqgetGlobalVar ('mailbox', $mailbox, SQ_GET );
  31. sqgetGlobalVar ('ent_id', $ent_id, SQ_GET );
  32. sqgetGlobalVar ('startMessage', $startMessage, SQ_GET );
  33. /* end globals */
  34. global $imap_stream_options; // in case not defined in config
  35. $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  36. sqimap_mailbox_select ($imapConnection, $mailbox);
  37. displayPageHeader ($color, 'None');
  38. echo '<br /><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
  39. 'align="center">' . "\n" .
  40. '<tr><td bgcolor="' . $color[0] . '">' .
  41. '<b><center>' .
  42. _ ("Viewing a Business Card") . " - ";
  43. $msg_url = 'read_body.php?mailbox='.urlencode ($mailbox).
  44. '&amp;startMessage='.urlencode ($startMessage).
  45. '&amp;passed_id='.urlencode ($passed_id);
  46. $msg_url = set_url_var ($msg_url, 'ent_id', 0);
  47. echo '<a href="'.$msg_url.'">'. _ ("View message") . '</a>';
  48. echo '</center></b></td></tr>';
  49. $message = sqimap_get_message ($imapConnection, $passed_id, $mailbox);
  50. $entity_vcard = getEntity ($message,$ent_id);
  51. $vcard = mime_fetch_body ($imapConnection, $passed_id, $ent_id);
  52. $vcard = decodeBody ($vcard, $entity_vcard->header ->encoding);
  53. $vcard = explode ("\n",$vcard);
  54. foreach ($vcard as $l) {
  55. $k = substr ($l, 0, strpos ($l, ':'));
  56. $v = substr ($l, strpos ($l, ':') + 1);
  57. $attributes = explode (';', $k);
  58. $k = strtolower (array_shift ($attributes));
  59. foreach ($attributes as $attr) {
  60. if ($attr == 'quoted-printable')
  61. else
  62. $k .= ';' . strtolower ($attr);
  63. }
  64. $v = str_replace (';', "\n", $v);
  65. $vcard_nice[$k] = $v;
  66. }
  67. if ($vcard_nice['version'] == '2.1') {
  68. // get firstname and lastname for sm addressbook
  69. $vcard_nice['firstname'] = substr ($vcard_nice['n'],
  70. strpos ($vcard_nice['n'], "\n") + 1, strlen ($vcard_nice['n']));
  71. $vcard_nice['lastname'] = substr ($vcard_nice['n'], 0,
  72. strpos ($vcard_nice['n'], "\n"));
  73. // workaround for Outlook, should be fixed in a better way,
  74. // maybe in new 'vCard' class.
  75. if (isset($vcard_nice['email;pref;internet'])) {
  76. $vcard_nice['email;internet'] = $vcard_nice['email;pref;internet'];
  77. }
  78. } else {
  79. echo '<tr><td align="center">' .
  80. sprintf (_ ("vCard Version %s is not supported. Some information might not be converted correctly."),
  81. sm_encode_html_special_chars ($vcard_nice['version'])) .
  82. "</td></tr>\n";
  83. $vcard_nice['firstname'] = '';
  84. $vcard_nice['lastname'] = '';
  85. }
  86. foreach ($vcard_nice as $k => $v) {
  87. $v = trim ($v);
  88. $vcard_safe[$k] = trim (nl2br ($v));
  89. }
  90. $ShowValues = array(
  91. 'fn' => _ ("Name"),
  92. 'title' => _ ("Title"),
  93. 'email;internet' => _ ("E-mail"),
  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. echo '<tr><td><br />' .
  103. '<table border="0" cellpadding="2" cellspacing="0" align="center">' . "\n";
  104. if (isset($vcard_safe['email;internet'])) {
  105. $vcard_safe['email;internet'] = '<a href="../src/compose.php?send_to=' .
  106. $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
  107. '</a>';
  108. }
  109. if (isset($vcard_safe['url'])) {
  110. $vcard_safe['url'] = '<a href="' . $vcard_safe['url'] . '">' .
  111. $vcard_safe['url'] . '</a>';
  112. }
  113. foreach ($ShowValues as $k => $v) {
  114. if (isset($vcard_safe[$k]) && $vcard_safe[$k]) {
  115. echo "<tr><td align=\"right\"><b>$v:</b></td><td>" . $vcard_safe[$k] .
  116. "</td><tr>\n";
  117. }
  118. }
  119. echo '</table>' .
  120. '<br />' .
  121. '</td></tr></table>' .
  122. '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
  123. 'align="center">' .
  124. '<tr>' .
  125. '<td bgcolor="' . $color[0] . '">' .
  126. '<b><center>' .
  127. _ ("Add to address book") .
  128. '</td></tr>' .
  129. '<tr><td align="center">' .
  130. '<form action="../src/addressbook.php" method="post" name="f_add">' .
  131. '<input type="hidden" name="smtoken" value="' . sm_generate_security_token () . '" />' .
  132. '<table border="0" cellpadding="2" cellspacing="0" align="center">' .
  133. '<tr><td align="right"><b>' . _ ("Nickname") . ':</b></td>' .
  134. '<td>' .
  135. '<input type="text" name="addaddr[nickname]" size="20" value="' .
  136. $vcard_safe['firstname'] . '-' . $vcard_safe['lastname'] . '" />' .
  137. '</td></tr>' .
  138. '<tr><td align="right"><b>' . _ ("Additional info") . ':</b></td><td>' .
  139. '<select name="addaddr[label]">';
  140. if (isset($vcard_nice['url'])) {
  141. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['url']) .
  142. '">' . _ ("Web Page") . "</option>\n";
  143. }
  144. if (isset($vcard_nice['adr'])) {
  145. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['adr']) .
  146. '">' . _ ("Address") . "</option>\n";
  147. }
  148. if (isset($vcard_nice['title'])) {
  149. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['title']) .
  150. '">' . _ ("Title") . "</option>\n";
  151. }
  152. if (isset($vcard_nice['org'])) {
  153. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['org']) .
  154. '">' . _ ("Organization / Department") . "</option>\n";
  155. }
  156. if (isset($vcard_nice['title'])) {
  157. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['title']) .
  158. '; ' . sm_encode_html_special_chars ($vcard_nice['org']) .
  159. '">' . _ ("Title &amp; Org. / Dept.") . "</option>\n";
  160. }
  161. if (isset($vcard_nice['tel;work'])) {
  162. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['tel;work']) .
  163. '">' . _ ("Work Phone") . "</option>\n";
  164. }
  165. if (isset($vcard_nice['tel;home'])) {
  166. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['tel;home']) .
  167. '">' . _ ("Home Phone") . "</option>\n";
  168. }
  169. if (isset($vcard_nice['tel;cell'])) {
  170. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['tel;cell']) .
  171. '">' . _ ("Cellular Phone") . "</option>\n";
  172. }
  173. if (isset($vcard_nice['tel;fax'])) {
  174. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['tel;fax']) .
  175. '">' . _ ("Fax") . "</option>\n";
  176. }
  177. if (isset($vcard_nice['note'])) {
  178. echo '<option value="' . sm_encode_html_special_chars ($vcard_nice['note']) .
  179. '">' . _ ("Note") . "</option>\n";
  180. }
  181. echo '</select>';
  182. ?>
  183. </td></tr>
  184. <tr><td colspan="2" align="center">
  185. <?php
  186. echo '<input name="addaddr[email]" type="hidden" value="' .
  187. sm_encode_html_special_chars (!empty($vcard_nice['email;internet'])?$vcard_nice['email;internet']:'') . '" />' .
  188. '<input name="addaddr[firstname]" type="hidden" value="' .
  189. $vcard_safe['firstname'] . '" />' .
  190. '<input name="addaddr[lastname]" type="hidden" value="' .
  191. $vcard_safe['lastname'] . '" />' .
  192. '<input type="submit" name="addaddr[SUBMIT]" ' .
  193. 'value="'._ ("Add to address book").'" />';
  194. ?>
  195. </td></tr>
  196. </table>
  197. </form>
  198. </td></tr>
  199. <tr><td align="center">
  200. <?php
  201. echo '<a href="../src/download.php?absolute_dl=true&amp;passed_id='.
  202. urlencode ($passed_id) . '&amp;mailbox=' . urlencode ($mailbox) .
  203. '&amp;ent_id=' . urlencode ($ent_id) .'">'.
  204. _ ("Download this as a file") . '</a>';
  205. ?>
  206. </td></tr></table>
  207. <table border="0" cellspacing="0" cellpadding="2" align="center">
  208. <tr><td bgcolor="<?php echo $color[4]; ?>">
  209. </td></tr></table>
  210. </body></html>

Documentation generated on 2020年1月13日 04:25:25 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /