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