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 | |
70e61af6 |
15 | function valid_email ($email, $verify) |
16 | { |
17 | global $Email_RegExp_Match; |
18 | |
19 | if (! eregi('^' . $Email_RegExp_Match . '$', $email)) |
20 | return false; |
21 | |
22 | if (! $verify) |
23 | return true; |
24 | |
25 | return checkdnsrr(substr(strstr($email, '@'), 1), 'ANY') ; |
26 | } |
27 | |
28 | function abook_take_read_string($str) |
29 | { |
30 | global $abook_found_email, $Email_RegExp_Match; |
31 | |
32 | while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits)) |
33 | { |
34 | $str = substr(strstr($str, $hits[0]), strlen($hits[0])); |
35 | if (! isset($abook_found_email[$hits[0]])) |
36 | { |
9d67bd53 |
37 | echo addHidden('email[]', $hits[0]); |
70e61af6 |
38 | $abook_found_email[$hits[0]] = 1; |
39 | } |
40 | } |
41 | |
42 | return; |
43 | } |
44 | |
45 | function abook_take_read_array($array) |
46 | { |
47 | foreach ($array as $item) |
48 | abook_take_read_string($item->getAddress()); |
49 | } |
50 | |
51 | function abook_take_read() |
52 | { |
53 | global $message; |
54 | |
1bf86d6f |
55 | echo '<br />' . addForm(SM_PATH . 'plugins/abook_take/take.php') . |
f265009a |
56 | '<div style="text-align: center;">' . "\n"; |
70e61af6 |
57 | |
58 | if (isset($message->rfc822_header->reply_to)) |
59 | abook_take_read_array($message->rfc822_header->reply_to); |
60 | if (isset($message->rfc822_header->from)) |
61 | abook_take_read_array($message->rfc822_header->from); |
62 | if (isset($message->rfc822_header->cc)) |
63 | abook_take_read_array($message->rfc822_header->cc); |
64 | if (isset($message->rfc822_header->to)) |
65 | abook_take_read_array($message->rfc822_header->to); |
66 | |
1bf86d6f |
67 | echo addSubmit(_("Take Address")) . |
f265009a |
68 | '</div></form>'; |
70e61af6 |
69 | } |
70 | |
71 | function abook_take_pref() |
72 | { |
73 | global $username, $data_dir, $abook_take_verify; |
74 | |
1bf86d6f |
75 | $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify', false); |
70e61af6 |
76 | } |
77 | |
78 | function abook_take_options() |
79 | { |
80 | global $abook_take_verify; |
81 | |
c435f076 |
82 | echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','style="white-space: nowrap;"') . "\n" . '<td>' . |
1bf86d6f |
83 | addCheckbox('abook_take_abook_take_verify', $abook_take_verify) . |
84 | _("Try to verify addresses") . "</td></tr>\n"; |
70e61af6 |
85 | } |
86 | |
87 | function abook_take_save() |
88 | { |
89 | global $username, $data_dir; |
90 | |
91 | if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST)) |
92 | setPref($data_dir, $username, 'abook_take_verify', '1'); |
93 | else |
94 | setPref($data_dir, $username, 'abook_take_verify', ''); |
95 | } |
96 | |
91e0dccc |
97 | ?> |