Source for file vcard.php

Documentation is available at vcard.php

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

Documentation generated on Mon, 13 Jan 2020 04:25:25 +0100 by phpDocumentor 1.4.3