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 14845 2020年01月07日 08:09:34Z pdontthink $
  10. * @package squirrelmail
  11. */
  12. /** This is the vcard page */
  13. define ('PAGE_NAME', 'vcard');
  14. /**
  15. * Include the SquirrelMail initialization file.
  16. */
  17. require('../include/init.php');
  18. /* SquirrelMail required files. */
  19. /** imap functions depend on date functions */
  20. include_once(SM_PATH . 'functions/date.php');
  21. /** form functions */
  22. include_once(SM_PATH . 'functions/forms.php');
  23. /** mime decoding */
  24. include_once(SM_PATH . 'functions/mime.php');
  25. /** url parser */
  26. include_once(SM_PATH . 'functions/url_parser.php');
  27. /** imap functions used to retrieve vcard */
  28. include_once(SM_PATH . 'functions/imap_general.php');
  29. include_once(SM_PATH . 'functions/imap_messages.php');
  30. /* globals */
  31. sqgetGlobalVar ('passed_id', $passed_id, SQ_GET , NULL, SQ_TYPE_BIGINT );
  32. sqgetGlobalVar ('mailbox', $mailbox, SQ_GET );
  33. sqgetGlobalVar ('ent_id', $ent_id, SQ_GET );
  34. sqgetGlobalVar ('startMessage', $startMessage, SQ_GET );
  35. /* end globals */
  36. global $imap_stream_options; // in case not defined in config
  37. $imapConnection = sqimap_login ($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  38. sqimap_mailbox_select ($imapConnection, $mailbox);
  39. $msg_url = 'read_body.php?mailbox='.urlencode ($mailbox).
  40. '&amp;startMessage='.urlencode ($startMessage).
  41. '&amp;passed_id='.urlencode ($passed_id);
  42. $msg_url = set_url_var ($msg_url, 'ent_id', 0);
  43. $message = sqimap_get_message ($imapConnection, $passed_id, $mailbox);
  44. $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. else
  56. $k .= ';' . strtolower ($attr);
  57. }
  58. $v = str_replace (';', "\n", $v);
  59. $vcard_nice[$k] = $v;
  60. }
  61. if ($vcard_nice['version'] == '2.1') {
  62. // get firstname and lastname for sm addressbook
  63. $vcard_nice['firstname'] = substr ($vcard_nice['n'],
  64. strpos ($vcard_nice['n'], "\n") + 1, strlen ($vcard_nice['n']));
  65. $vcard_nice['lastname'] = substr ($vcard_nice['n'], 0,
  66. strpos ($vcard_nice['n'], "\n"));
  67. // workaround for Outlook, should be fixed in a better way,
  68. // maybe in new 'vCard' class.
  69. if (isset($vcard_nice['email;pref;internet'])) {
  70. $vcard_nice['email;internet'] = $vcard_nice['email;pref;internet'];
  71. }
  72. } else {
  73. $oTemplate->assign('note', sprintf (_ ("vCard Version %s is not supported. Some information might not be converted correctly."), sm_encode_html_special_chars ($vcard_nice['version'])));
  74. $oTemplate->display('note.tpl');
  75. $vcard_nice['firstname'] = '';
  76. $vcard_nice['lastname'] = '';
  77. }
  78. foreach ($vcard_nice as $k => $v) {
  79. $v = trim ($v);
  80. $vcard_safe[$k] = trim (nl2br ($v));
  81. }
  82. $ShowValues = array(
  83. 'fn' => _ ("Name"),
  84. 'title' => _ ("Title"),
  85. 'email;internet' => _ ("E-mail"),
  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"),
  93. 'note' => _ ("Note"));
  94. if (isset($vcard_safe['email;internet'])) {
  95. $vcard_safe['email;internet'] = makeComposeLink ('src/compose.php?send_to='.urlencode ($vcard_safe['email;internet']),
  96. $vcard_safe['email;internet']);
  97. }
  98. if (isset($vcard_safe['url'])) {
  99. $vcard_safe['url'] = '<a href="' . $vcard_safe['url'] . '" target="_blank">' .
  100. $vcard_safe['url'] . '</a>';
  101. }
  102. $vcard = array();
  103. foreach ($ShowValues as $k => $v) {
  104. if (isset($vcard_safe[$k]) && $vcard_safe[$k]) {
  105. $vcard[$v] = $vcard_safe[$k];
  106. }
  107. }
  108. $dl = '../src/download.php?absolute_dl=true&amp;passed_id=' .
  109. urlencode ($passed_id) . '&amp;mailbox=' . urlencode ($mailbox) .
  110. '&amp;ent_id=' . urlencode ($ent_id);
  111. if (isset($vcard_nice['email;internet'])) {
  112. $email = $vcard_nice['email;internet'];
  113. } else {
  114. $message = sqimap_get_message ($imapConnection, $passed_id, $mailbox);
  115. $header = $message->rfc822_header;
  116. $from_name = $header->getAddr_s('from');
  117. $email = getEmail (decodeHeader ($from_name));
  118. }
  119. $opts = array();
  120. if (isset($vcard_nice['url'])) {
  121. $opts[$vcard_nice['url']] = _ ("Web Page");
  122. }
  123. if (isset($vcard_nice['adr'])) {
  124. $opts[$vcard_nice['adr']] = _ ("Address");
  125. }
  126. if (isset($vcard_nice['title'])) {
  127. $opts[$vcard_nice['title']] = _ ("Title");
  128. }
  129. if (isset($vcard_nice['org'])) {
  130. $opts[$vcard_nice['org']] = _ ("Organization / Department");
  131. }
  132. if (isset($vcard_nice['title'])) {
  133. $opts[$vcard_nice['title'].'; '.$vcard_nice['org']] = _ ("Title &amp; Org. / Dept.");
  134. }
  135. if (isset($vcard_nice['tel;work'])) {
  136. $opts[$vcard_nice['tel;work']] = _ ("Work Phone");
  137. }
  138. if (isset($vcard_nice['tel;home'])) {
  139. $opts[$vcard_nice['tel;home']] = _ ("Home Phone");
  140. }
  141. if (isset($vcard_nice['tel;cell'])) {
  142. $opts[$vcard_nice['tel;cell']] = _ ("Cellular Phone");
  143. }
  144. if (isset($vcard_nice['tel;fax'])) {
  145. $opts[$vcard_nice['tel;fax']] = _ ("Fax");
  146. }
  147. if (isset($vcard_nice['note'])) {
  148. $opts[$vcard_nice['note']] = _ ("Note");
  149. }
  150. $oTemplate->assign('view_message_link', $msg_url);
  151. $oTemplate->assign('download_link', $dl);
  152. $oTemplate->assign('vcard', $vcard);
  153. $oTemplate->assign('nickname', $vcard_nice['firstname'].'-'.$vcard_safe['lastname']);
  154. $oTemplate->assign('firstname', $vcard_safe['firstname']);
  155. $oTemplate->assign('lastname', $vcard_safe['lastname']);
  156. $oTemplate->assign('email', $email);
  157. $oTemplate->assign('info', $opts);
  158. $oTemplate->display('vcard.tpl');
  159. $oTemplate->display('footer.tpl');

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

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