| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * functions.php |
| 5 | * |
| 6 | * Functions for the Address Take plugin |
| 7 | * |
| 8 | * @copyright © 1999-2005 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 | /** SquirrelMail required files. */ |
| 16 | require_once(SM_PATH . 'functions/url_parser.php'); |
| 17 | require_once(SM_PATH . 'functions/forms.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 addHidden('email[]', $hits[0]); |
| 42 | $abook_found_email[$hits[0]] = 1; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | function abook_take_read_array($array) |
| 50 | { |
| 51 | foreach ($array as $item) |
| 52 | abook_take_read_string($item->getAddress()); |
| 53 | } |
| 54 | |
| 55 | function abook_take_read() |
| 56 | { |
| 57 | global $message; |
| 58 | |
| 59 | echo '<br />' . addForm(SM_PATH . 'plugins/abook_take/take.php') . |
| 60 | '<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 addSubmit(_("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', false); |
| 80 | } |
| 81 | |
| 82 | function abook_take_options() |
| 83 | { |
| 84 | global $abook_take_verify; |
| 85 | |
| 86 | echo '<tr>' . html_tag('td',_("Address Book Take:"),'right','','style="white-space: nowrap;"') . "\n" . '<td>' . |
| 87 | addCheckbox('abook_take_abook_take_verify', $abook_take_verify) . |
| 88 | _("Try to verify addresses") . "</td></tr>\n"; |
| 89 | } |
| 90 | |
| 91 | function abook_take_save() |
| 92 | { |
| 93 | global $username, $data_dir; |
| 94 | |
| 95 | if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST)) |
| 96 | setPref($data_dir, $username, 'abook_take_verify', '1'); |
| 97 | else |
| 98 | setPref($data_dir, $username, 'abook_take_verify', ''); |
| 99 | } |
| 100 | |
| 101 | ?> |