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

Documentation generated on Sat, 07 Oct 2006 16:34:04 +0300 by phpDocumentor 1.3.0RC6