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-2012 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: vcard.php 14345 2012-12-09 11:58:17Z kink $
  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. $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0);
  42. sqimap_mailbox_select($imapConnection$mailbox);
  43.  
  44.  
  45. displayPageHeader($color'None');
  46.  
  47. echo '<br /><table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
  48.         'align="center">' "\n" .
  49.      '<tr><td bgcolor="' $color[0'">' .
  50.      '<b><center>' .
  51.      _("Viewing a Business Card"" - ";
  52.  
  53. $msg_url 'read_body.php?mailbox='.urlencode($mailbox).
  54.     '&amp;startMessage='.urlencode($startMessage).
  55.     '&amp;passed_id='.urlencode($passed_id);
  56.  
  57. $msg_url set_url_var($msg_url'ent_id'0);
  58.  
  59. echo '<a href="'.$msg_url.'">'_("View message"'</a>';
  60.  
  61. echo '</center></b></td></tr>';
  62.  
  63. $message sqimap_get_message($imapConnection$passed_id$mailbox);
  64.  
  65. $entity_vcard getEntity($message,$ent_id);
  66.  
  67. $vcard mime_fetch_body ($imapConnection$passed_id$ent_id);
  68. $vcard decodeBody($vcard$entity_vcard->header->encoding);
  69. $vcard explode ("\n",$vcard);
  70. foreach ($vcard as $l{
  71.     $k substr($l0strpos($l':'));
  72.     $v substr($lstrpos($l':'1);
  73.     $attributes explode(';'$k);
  74.     $k strtolower(array_shift($attributes));
  75.     foreach ($attributes as $attr)     {
  76.         if ($attr == 'quoted-printable')
  77.         $v quoted_printable_decode($v);
  78.         else
  79.             $k .= ';' strtolower($attr);
  80.     }
  81.  
  82.     $v str_replace(';'"\n"$v);
  83.     $vcard_nice[$k$v;
  84. }
  85.  
  86. if ($vcard_nice['version'== '2.1'{
  87.     // get firstname and lastname for sm addressbook
  88.     $vcard_nice['firstname'substr($vcard_nice['n'],
  89.     strpos($vcard_nice['n']"\n"1strlen($vcard_nice['n']));
  90.     $vcard_nice['lastname'substr($vcard_nice['n']0,
  91.         strpos($vcard_nice['n']"\n"));
  92.     // workaround for Outlook, should be fixed in a better way,
  93.     // maybe in new 'vCard' class.
  94.     if (isset($vcard_nice['email;pref;internet'])) {
  95.        $vcard_nice['email;internet'$vcard_nice['email;pref;internet'];
  96.     }
  97. else {
  98.     echo '<tr><td align="center">' .
  99.          sprintf(_("vCard Version %s is not supported. Some information might not be converted correctly."),
  100.                  sm_encode_html_special_chars($vcard_nice['version'])) .
  101.          "</td></tr>\n";
  102.     $vcard_nice['firstname''';
  103.     $vcard_nice['lastname''';
  104. }
  105.  
  106. foreach ($vcard_nice as $k => $v{
  107.     $v sm_encode_html_special_chars($v);
  108.     $v trim($v);
  109.     $vcard_safe[$ktrim(nl2br($v));
  110. }
  111.  
  112. $ShowValues array(
  113.     'fn' =>             _("Name"),
  114.     'title' =>          _("Title"),
  115.     'email;internet' => _("E-mail"),
  116.     'url' =>            _("Web Page"),
  117.     'org' =>            _("Organization / Department"),
  118.     'adr' =>            _("Address"),
  119.     'tel;work' =>       _("Work Phone"),
  120.     'tel;home' =>       _("Home Phone"),
  121.     'tel;cell' =>       _("Cellular Phone"),
  122.     'tel;fax' =>        _("Fax"),
  123.     'note' =>           _("Note"));
  124.  
  125. echo '<tr><td><br />' .
  126.      '<table border="0" cellpadding="2" cellspacing="0" align="center">' "\n";
  127.  
  128. if (isset($vcard_safe['email;internet'])) {
  129.     $vcard_safe['email;internet''<a href="../src/compose.php?send_to=' .
  130.         $vcard_safe['email;internet''">' $vcard_safe['email;internet'.
  131.         '</a>';
  132. }
  133.  
  134. if (isset($vcard_safe['url'])) {
  135.     $vcard_safe['url''<a href="' $vcard_safe['url''">' .
  136.         $vcard_safe['url''</a>';
  137. }
  138.  
  139. foreach ($ShowValues as $k => $v{
  140.     if (isset($vcard_safe[$k]&& $vcard_safe[$k])     {
  141.         echo "<tr><td align=\"right\"><b>$v:</b></td><td>$vcard_safe[$k.
  142.                 "</td><tr>\n";
  143.     }
  144. }
  145.  
  146. echo '</table>' .
  147.      '<br />' .
  148.      '</td></tr></table>' .
  149.      '<table width="100%" border="0" cellspacing="0" cellpadding="2" ' .
  150.         'align="center">' .
  151.      '<tr>' .
  152.      '<td bgcolor="' $color[0'">' .
  153.      '<b><center>' .
  154.      _("Add to address book".
  155.      '</td></tr>' .
  156.      '<tr><td align="center">' .
  157.      '<form action="../src/addressbook.php" method="post" name="f_add">' .
  158.      '<input type="hidden" name="smtoken" value="' sm_generate_security_token('" />' .
  159.      '<table border="0" cellpadding="2" cellspacing="0" align="center">' .
  160.      '<tr><td align="right"><b>' _("Nickname"':</b></td>' .
  161.      '<td>' .
  162.      '<input type="text" name="addaddr[nickname]" size="20" value="' .
  163.      $vcard_safe['firstname''-' $vcard_safe['lastname''" />' .
  164.      '</td></tr>' .
  165.      '<tr><td align="right"><b>' _("Additional info"':</b></td><td>' .
  166.      '<select name="addaddr[label]">';
  167.  
  168. if (isset($vcard_nice['url'])) {
  169.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['url'].
  170.         '">' _("Web Page""</option>\n";
  171. }
  172. if (isset($vcard_nice['adr'])) {
  173.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['adr'].
  174.         '">' _("Address""</option>\n";
  175. }
  176. if (isset($vcard_nice['title'])) {
  177.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['title'].
  178.         '">' _("Title""</option>\n";
  179. }
  180. if (isset($vcard_nice['org'])) {
  181.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['org'].
  182.         '">' _("Organization / Department""</option>\n";
  183. }
  184. if (isset($vcard_nice['title'])) {
  185.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['title'].
  186.         '; ' sm_encode_html_special_chars($vcard_nice['org'].
  187.         '">' _("Title &amp; Org. / Dept.""</option>\n";
  188. }
  189. if (isset($vcard_nice['tel;work'])) {
  190.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['tel;work'].
  191.         '">' _("Work Phone""</option>\n";
  192. }
  193. if (isset($vcard_nice['tel;home'])) {
  194.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['tel;home'].
  195.         '">' _("Home Phone""</option>\n";
  196. }
  197. if (isset($vcard_nice['tel;cell'])) {
  198.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['tel;cell'].
  199.         '">' _("Cellular Phone""</option>\n";
  200. }
  201. if (isset($vcard_nice['tel;fax'])) {
  202.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['tel;fax'].
  203.         '">' _("Fax""</option>\n";
  204. }
  205. if (isset($vcard_nice['note'])) {
  206.     echo '<option value="' sm_encode_html_special_chars($vcard_nice['note'].
  207.         '">' _("Note""</option>\n";
  208. }
  209. echo '</select>';
  210. ?>
  211. </td></tr>
  212. <tr><td colspan="2" align="center">
  213. <?php
  214. echo '<input name="addaddr[email]" type="hidden" value="' .
  215.         sm_encode_html_special_chars(!empty($vcard_nice['email;internet'])?$vcard_nice['email;internet']:'''" />' .
  216.      '<input name="addaddr[firstname]" type="hidden" value="' .
  217.         $vcard_safe['firstname''" />' .
  218.      '<input name="addaddr[lastname]" type="hidden" value="' .
  219.         $vcard_safe['lastname''" />' .
  220.      '<input type="submit" name="addaddr[SUBMIT]" ' .
  221.         'value="'._("Add to address book").'" />';
  222.  
  223. ?>
  224. </td></tr>
  225. </table>
  226. </form>
  227. </td></tr>
  228. <tr><td align="center">
  229. <?php
  230. echo '<a href="../src/download.php?absolute_dl=true&amp;passed_id='.
  231.      urlencode($passed_id'&amp;mailbox=' urlencode($mailbox.
  232.      '&amp;ent_id=' urlencode($ent_id.'">'.
  233.      _("Download this as a file"'</a>';
  234. ?>
  235. </td></tr></table>
  236.  
  237. <table border="0" cellspacing="0" cellpadding="2" align="center">
  238. <tr><td bgcolor="<?php echo $color[4]?>">
  239. </td></tr></table>
  240. </body></html>

Documentation generated on Thu, 20 Jun 2013 04:23:29 +0200 by phpDocumentor 1.4.3