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