dd36b66235204b93eb65e157f2819c66c811b1e8
3 /* Path for SquirrelMail required files. */
4 if (!defined('SM_PATH')) {
5 define('SM_PATH','../../');
8 /* SquirrelMail required files. */
9 require_once(SM_PATH
. 'functions/url_parser.php');
11 /* Address Take -- steals addresses from incoming email messages. Searches
12 the To, Cc, From and Reply-To headers, also searches the body of the
15 function squirrelmail_plugin_init_abook_take()
17 global $squirrelmail_plugin_hooks;
19 $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
20 $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
21 $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
22 $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
26 function valid_email ($email, $verify)
28 global $abook_take_verify, $Email_RegExp_Match;
30 if (! eregi('^' . $Email_RegExp_Match . '$', $email))
36 if (! checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
43 function abook_take_read_string($str)
45 global $abook_found_email, $Email_RegExp_Match;
48 while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
50 $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
51 if (! isset($abook_found_email[$hits[0]]))
53 echo "<input type=\"hidden\" name=\"email[]\" value=\"$hits[0]\">\n";
54 $abook_found_email[$hits[0]] = 1;
61 function abook_take_read_array($array)
64 while ($i < count($array))
66 abook_take_read_string($array[$i]->getAddress());
72 function abook_take_read()
74 global $color, $abook_take_location;
75 global $body, $abook_take_hide, $message, $imapConnection;
80 echo '<form action="../plugins/abook_take/take.php" method="post">' . "\n" .
81 html_tag( 'table', '', $abook_take_location, $color[10], 'cellpadding="3" cellspacing="0" border="0"' ) .
83 html_tag( 'td', '', 'left' ) .
84 html_tag( 'table', '', '', $color[5], 'cellpadding="2" cellspacing="1" border="0"' ) .
88 if (isset($message->rfc822_header
->from
))
89 abook_take_read_array($message->rfc822_header
->from
);
90 if (isset($message->rfc822_header
->cc
))
91 abook_take_read_array($message->rfc822_header
->cc
);
92 if (isset($message->rfc822_header
->reply_to
))
93 abook_take_read_array($message->rfc822_header
->reply_to
);
94 if (isset($message->rfc822_header
->to
))
95 abook_take_read_array($message->rfc822_header
->to
);
99 $pos = strpos($new_body,
100 '">' . _("Download this as a file") . '</a></center><br></small>');
103 $new_body = substr($new_body, 0, $pos);
106 $trans = get_html_translation_table(HTML_ENTITIES
);
107 $trans[' '] = ' ';
108 $trans = array_flip($trans);
109 $new_body = strtr($new_body, $trans);
111 $new_body = urldecode($new_body);
112 $new_body = strip_tags($new_body);
114 $new_body = strtr($new_body, "\n", ' ');
116 abook_take_read_string($body);
118 echo '<input type="submit" value="' . _("Take Address") . '">';
130 function abook_take_pref()
132 global $username, $data_dir;
133 global $abook_take_hide, $abook_take_location, $abook_take_verify;
135 $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
136 if ($abook_take_location == '')
137 $abook_take_location = 'center';
139 $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
140 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
144 function abook_take_options()
146 global $abook_take_location, $abook_take_hide, $abook_take_verify;
148 echo html_tag( 'tr' ) .
149 html_tag( 'td', _("Address Book Take") . ':', 'right', '', 'nowrap valign="top"' ) .
150 html_tag( 'td', '', 'left' ) .
151 '<select name="abook_take_abook_take_location">' .
152 '<option value="left"';
153 if ($abook_take_location == 'left')
155 echo '>' . _("Left aligned") . '</option>' .
156 '<option value="center"';
157 if ($abook_take_location == 'center')
159 echo '>' . _("Centered") . '</option>' .
160 '<option value="right"';
161 if ($abook_take_location == 'right')
163 echo '>' . _("Right aligned") . '</option>' .
164 '</select> ' . _("on the Read screen") .'<br>' .
165 '<input type="checkbox" name="abook_take_abook_take_hide"';
166 if ($abook_take_hide)
168 echo '> ' . _("Hide the box") . '<br>' .
169 '<input type=checkbox name="abook_take_abook_take_verify"';
170 if ($abook_take_verify)
172 echo '> ' . _("Try to verify addresses") . '</td></tr>';
176 function abook_take_save()
178 global $username, $data_dir;
179 global $abook_take_abook_take_location;
180 global $abook_take_abook_take_hide;
181 global $abook_take_abook_take_verify;
184 if (isset($abook_take_abook_take_location))
186 setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
190 setPref($data_dir, $username, 'abook_take_location', 'center');
193 if (isset($abook_take_abook_take_hide))
195 setPref($data_dir, $username, 'abook_take_hide', '1');
199 setPref($data_dir, $username, 'abook_take_hide', '');
202 if (isset($abook_take_abook_take_verify))
204 setPref($data_dir, $username, 'abook_take_verify', '1');
208 setPref($data_dir, $username, 'abook_take_verify', '');