Fixed spelling in comment.
[squirrelmail.git] / plugins / abook_take / functions.php
CommitLineData
70e61af6 1<?php
2
3/**
4 * functions.php
5 *
70e61af6 6 * Functions for the Address Take plugin
7 *
4b5049de 8 * @copyright &copy; 1999-2007 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
867fed37 15/** */
70e61af6 16function 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
29function 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 {
9d67bd53 38 echo addHidden('email[]', $hits[0]);
70e61af6 39 $abook_found_email[$hits[0]] = 1;
40 }
41 }
42
43 return;
44}
45
46function abook_take_read_array($array)
47{
48 foreach ($array as $item)
49 abook_take_read_string($item->getAddress());
50}
51
52function abook_take_read()
53{
54 global $message;
55
1bf86d6f 56 echo '<br />' . addForm(SM_PATH . 'plugins/abook_take/take.php') .
f265009a 57 '<div style="text-align: center;">' . "\n";
70e61af6 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
1bf86d6f 68 echo addSubmit(_("Take Address")) .
f265009a 69 '</div></form>';
70e61af6 70}
71
72function abook_take_pref()
73{
74 global $username, $data_dir, $abook_take_verify;
75
1bf86d6f 76 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify', false);
70e61af6 77}
78
79function abook_take_options()
80{
81 global $abook_take_verify;
82
c435f076 83 echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','style="white-space: nowrap;"') . "\n" . '<td>' .
1bf86d6f 84 addCheckbox('abook_take_abook_take_verify', $abook_take_verify) .
85 _("Try to verify addresses") . "</td></tr>\n";
70e61af6 86}
87
88function 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}