functions.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * functions.php
  4. *
  5. * Copyright (c) 1999-2004 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Functions for the Address Take plugin
  9. *
  10. * $Id$
  11. * @package plugins
  12. * @subpackage abook_take
  13. */
  14. /** SquirrelMail required files. */
  15. require_once(SM_PATH . 'functions/url_parser.php');
  16. require_once(SM_PATH . 'functions/forms.php');
  17. function valid_email ($email, $verify)
  18. {
  19. global $Email_RegExp_Match;
  20. if (! eregi('^' . $Email_RegExp_Match . '$', $email))
  21. return false;
  22. if (! $verify)
  23. return true;
  24. return checkdnsrr(substr(strstr($email, '@'), 1), 'ANY') ;
  25. }
  26. function abook_take_read_string($str)
  27. {
  28. global $abook_found_email, $Email_RegExp_Match;
  29. while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
  30. {
  31. $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
  32. if (! isset($abook_found_email[$hits[0]]))
  33. {
  34. echo addHidden('email[]', $hits[0]);
  35. $abook_found_email[$hits[0]] = 1;
  36. }
  37. }
  38. return;
  39. }
  40. function abook_take_read_array($array)
  41. {
  42. foreach ($array as $item)
  43. abook_take_read_string($item->getAddress());
  44. }
  45. function abook_take_read()
  46. {
  47. global $message;
  48. echo '<br />' . addForm(SM_PATH . 'plugins/abook_take/take.php') .
  49. '<center>' . "\n";
  50. if (isset($message->rfc822_header->reply_to))
  51. abook_take_read_array($message->rfc822_header->reply_to);
  52. if (isset($message->rfc822_header->from))
  53. abook_take_read_array($message->rfc822_header->from);
  54. if (isset($message->rfc822_header->cc))
  55. abook_take_read_array($message->rfc822_header->cc);
  56. if (isset($message->rfc822_header->to))
  57. abook_take_read_array($message->rfc822_header->to);
  58. echo addSubmit(_("Take Address")) .
  59. '</center>';
  60. }
  61. function abook_take_pref()
  62. {
  63. global $username, $data_dir, $abook_take_verify;
  64. $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify', false);
  65. }
  66. function abook_take_options()
  67. {
  68. global $abook_take_verify;
  69. echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','nowrap') . "\n" . '<td>' .
  70. addCheckbox('abook_take_abook_take_verify', $abook_take_verify) .
  71. _("Try to verify addresses") . "</td></tr>\n";
  72. }
  73. function abook_take_save()
  74. {
  75. global $username, $data_dir;
  76. if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST))
  77. setPref($data_dir, $username, 'abook_take_verify', '1');
  78. else
  79. setPref($data_dir, $username, 'abook_take_verify', '');
  80. }
  81. ?>