6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Address Take -- steals addresses from incoming email messages. Searches
10 * the To, Cc, From and Reply-To headers, also searches the body of the
16 if (!defined('SM_PATH')) {
17 define('SM_PATH','../../');
20 /* SquirrelMail required files. */
21 require_once(SM_PATH
. 'functions/url_parser.php');
23 function squirrelmail_plugin_init_abook_take()
25 global $squirrelmail_plugin_hooks;
27 $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
28 $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
29 $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
30 $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
33 function valid_email ($email, $verify)
35 global $Email_RegExp_Match;
37 if (! eregi('^' . $Email_RegExp_Match . '$', $email))
43 return checkdnsrr(substr(strstr($email, '@'), 1), 'ANY') ;
46 function abook_take_read_string($str)
48 global $abook_found_email, $Email_RegExp_Match;
50 while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
52 $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
53 if (! isset($abook_found_email[$hits[0]]))
55 echo '<input type="hidden" name="email[]" value="' .
56 htmlspecialchars($hits[0]) . "\" />\n";
57 $abook_found_email[$hits[0]] = 1;
64 function abook_take_read_array($array)
66 foreach ($array as $item)
67 abook_take_read_string($item->getAddress());
70 function abook_take_read()
74 echo '<br /><form action="../plugins/abook_take/take.php" method="post"><center>'."\n";
76 if (isset($message->rfc822_header
->reply_to
))
77 abook_take_read_array($message->rfc822_header
->reply_to
);
78 if (isset($message->rfc822_header
->from
))
79 abook_take_read_array($message->rfc822_header
->from
);
80 if (isset($message->rfc822_header
->cc
))
81 abook_take_read_array($message->rfc822_header
->cc
);
82 if (isset($message->rfc822_header
->to
))
83 abook_take_read_array($message->rfc822_header
->to
);
85 echo '<input type="submit" value="' . _("Take Address") . '" />' .
89 function abook_take_pref()
91 global $username, $data_dir, $abook_take_verify;
93 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
96 function abook_take_options()
98 global $abook_take_verify;
100 echo '<tr><td align="right" nowrap>' . _("Address Book Take:") . "</td>\n" .
101 '<td><input name="abook_take_abook_take_verify" type="checkbox"';
102 if (isset($abook_take_verify) && $abook_take_verify)
104 echo ' /> ' . _("Try to verify addresses") . "</td></tr>\n";
108 function abook_take_save()
110 global $username, $data_dir;
112 if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST
))
113 setPref($data_dir, $username, 'abook_take_verify', '1');
115 setPref($data_dir, $username, 'abook_take_verify', '');