Added systrans.otenet.gr options and updated strings.
[squirrelmail.git] / plugins / abook_take / setup.php
CommitLineData
e8b140ab 1<?php
2
b755a6b1 3/**
4 * setup.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Address Take -- steals addresses from incoming email messages. Searches
10 * the To, Cc, From and Reply-To headers, also searches the body of the
11 * message.
12 *
13 * $Id$
14 */
15
c3c84392 16if (!defined('SM_PATH')) {
b755a6b1 17 define('SM_PATH','../../');
c3c84392 18}
d55c0f66 19
08185f2a 20/* SquirrelMail required files. */
21require_once(SM_PATH . 'functions/url_parser.php');
e8b140ab 22
e8b140ab 23function squirrelmail_plugin_init_abook_take()
24{
b755a6b1 25 global $squirrelmail_plugin_hooks;
e8b140ab 26
b755a6b1 27 $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
28 $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
29 $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
30 $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
e8b140ab 31}
32
e8b140ab 33function valid_email ($email, $verify)
34{
b755a6b1 35 global $Email_RegExp_Match;
e8b140ab 36
b755a6b1 37 if (! eregi('^' . $Email_RegExp_Match . '$', $email))
38 return false;
e8b140ab 39
b755a6b1 40 if (! $verify)
41 return true;
d55c0f66 42
b755a6b1 43 return checkdnsrr(substr(strstr($email, '@'), 1), 'ANY') ;
e8b140ab 44}
45
e8b140ab 46function abook_take_read_string($str)
47{
b755a6b1 48 global $abook_found_email, $Email_RegExp_Match;
49
50 while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
51 {
52 $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
53 if (! isset($abook_found_email[$hits[0]]))
54 {
55 echo '<input type="hidden" name="email[]" value="' .
56 htmlspecialchars($hits[0]) . "\" />\n";
57 $abook_found_email[$hits[0]] = 1;
58 }
59 }
d55c0f66 60
b755a6b1 61 return;
e8b140ab 62}
63
e8b140ab 64function abook_take_read_array($array)
65{
b755a6b1 66 foreach ($array as $item)
67 abook_take_read_string($item->getAddress());
e8b140ab 68}
69
e8b140ab 70function abook_take_read()
71{
b755a6b1 72 global $message;
e8b140ab 73
b755a6b1 74 echo '<br /><form action="../plugins/abook_take/take.php" method="post"><center>'."\n";
75
76 if (isset($message->rfc822_header->reply_to))
77 abook_take_read_array($message->rfc822_header->reply_to);
78 if (isset($message->rfc822_header->from))
79 abook_take_read_array($message->rfc822_header->from);
80 if (isset($message->rfc822_header->cc))
81 abook_take_read_array($message->rfc822_header->cc);
82 if (isset($message->rfc822_header->to))
83 abook_take_read_array($message->rfc822_header->to);
84
85 echo '<input type="submit" value="' . _("Take Address") . '" />' .
86 '</center></form>';
e8b140ab 87}
88
89function abook_take_pref()
90{
b755a6b1 91 global $username, $data_dir, $abook_take_verify;
e8b140ab 92
b755a6b1 93 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
e8b140ab 94}
95
e8b140ab 96function abook_take_options()
97{
b755a6b1 98 global $abook_take_verify;
99
100 echo '<tr><td align="right" nowrap>' . _("Address Book Take:") . "</td>\n" .
101 '<td><input name="abook_take_abook_take_verify" type="checkbox"';
102 if (isset($abook_take_verify) && $abook_take_verify)
103 echo ' checked';
104 echo ' /> ' . _("Try to verify addresses") . "</td></tr>\n";
e8b140ab 105}
106
107
108function abook_take_save()
109{
b755a6b1 110 global $username, $data_dir;
e8b140ab 111
b755a6b1 112 if (sqgetGlobalVar('abook_take_abook_take_verify', $abook_take_abook_take_verify, SQ_POST))
113 setPref($data_dir, $username, 'abook_take_verify', '1');
114 else
115 setPref($data_dir, $username, 'abook_take_verify', '');
e8b140ab 116}
117
118?>