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