6351cfb520f1e129e3064a15c695504fecab31e2
[squirrelmail.git] / plugins / abook_take / functions.php
1 <?php
2
3 /**
4 * functions.php
5 *
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Functions for the Address Take plugin
10 *
11 * $Id$
12 * @package plugins
13 * @subpackage abook_take
14 */
15
16 /* SquirrelMail required files. */
17 require_once(SM_PATH . 'functions/url_parser.php');
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 {
41 echo '<input type="hidden" name="email[]" value="' .
42 htmlspecialchars($hits[0]) . "\" />\n";
43 $abook_found_email[$hits[0]] = 1;
44 }
45 }
46
47 return;
48 }
49
50 function abook_take_read_array($array)
51 {
52 foreach ($array as $item)
53 abook_take_read_string($item->getAddress());
54 }
55
56 function abook_take_read()
57 {
58 global $message;
59
60 echo '<br /><form action="../plugins/abook_take/take.php" method="post"><center>'."\n";
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
71 echo '<input type="submit" value="' . _("Take Address") . '" />' .
72 '</center></form>';
73 }
74
75 function abook_take_pref()
76 {
77 global $username, $data_dir, $abook_take_verify;
78
79 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
80 }
81
82 function abook_take_options()
83 {
84 global $abook_take_verify;
85
86 echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','nowrap') . "\n" .
87 '<td><input name="abook_take_abook_take_verify" type="checkbox"';
88 if (isset($abook_take_verify) && $abook_take_verify)
89 echo ' checked';
90 echo ' /> ' . _("Try to verify addresses") . "</td></tr>\n";
91 }
92
93 function abook_take_save()
94 {
95 global $username, $data_dir;
96
97 if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST))
98 setPref($data_dir, $username, 'abook_take_verify', '1');
99 else
100 setPref($data_dir, $username, 'abook_take_verify', '');
101 }
102
103 ?>