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