functions.php 2.5 KB

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