3 require_once('../functions/url_parser.php');
6 /* Address Take -- steals addresses from incoming email messages. Searches
7 the To, Cc, From and Reply-To headers, also searches the body of the
10 function squirrelmail_plugin_init_abook_take()
12 global $squirrelmail_plugin_hooks;
14 $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
15 $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
16 $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
17 $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
21 function valid_email ($email, $verify)
23 global $abook_take_verify, $Email_RegExp_Match;
25 if (! eregi('^' . $Email_RegExp_Match . '$', $email))
31 if (! checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
38 function abook_take_read_string($str)
40 global $abook_found_email, $Email_RegExp_Match;
43 while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
45 $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
46 if (! isset($abook_found_email[$hits[0]]))
48 echo "<input type=\"hidden\" name=\"email[]\" value=\"$hits[0]\">\n";
49 $abook_found_email[$hits[0]] = 1;
56 function abook_take_read_array($array)
59 while ($i < count($array))
61 abook_take_read_string($array[$i]);
67 function abook_take_read()
69 global $color, $abook_take_location;
70 global $body, $abook_take_hide, $message, $imapConnection;
76 <FORM ACTION
="../plugins/abook_take/take.php" METHOD
=POST
>
78 echo $abook_take_location;
79 ?>" cellpadding
=3 cellspacing
=0 border
=0 bgcolor
="<?PHP
84 <table cellpadding
=2 cellspacing
=1 border
=0 bgcolor
="<?PHP
90 abook_take_read_string($message->header
->from
);
91 abook_take_read_array($message->header
->cc
);
92 abook_take_read_array($message->header
->reply_to
);
93 abook_take_read_array($message->header
->to
);
97 $pos = strpos($new_body,
98 '">Download this as a file</A></CENTER><BR></SMALL>');
101 $new_body = substr($new_body, 0, $pos);
104 $trans = get_html_translation_table(HTML_ENTITIES
);
105 $trans[' '] = ' ';
106 $trans = array_flip($trans);
107 $new_body = strtr($new_body, $trans);
109 $new_body = urldecode($new_body);
110 $new_body = strip_tags($new_body);
112 $new_body = strtr($new_body, "\n", ' ');
114 abook_take_read_string($body);
116 <INPUT TYPE
="submit" VALUE
="Take Address">
127 function abook_take_pref()
129 global $username, $data_dir;
130 global $abook_take_hide, $abook_take_location, $abook_take_verify;
132 $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
133 if ($abook_take_location == '')
134 $abook_take_location = 'center';
136 $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
137 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
141 function abook_take_options()
143 global $abook_take_location, $abook_take_hide, $abook_take_verify;
145 ?
><tr
><td align
=right nowrap valign
="top">Address Book Take
:</td
>
146 <td
><select name
="abook_take_abook_take_location">
147 <option value
="left"<?PHP
148 if ($abook_take_location == 'left')
150 ?
>>Left aligned
</option
>
151 <option value
="center"<?PHP
152 if ($abook_take_location == 'center')
155 <option value
="right"<?PHP
156 if ($abook_take_location == 'right')
158 ?
>>Right aligned
</option
>
159 </select
> on the Read screen
<br
>
160 <input type
=checkbox name
="abook_take_abook_take_hide"<?PHP
161 if ($abook_take_hide)
164 <input type
=checkbox name
="abook_take_abook_take_verify"<?PHP
165 if ($abook_take_verify)
167 ?
>> Try to verify addresses
172 function abook_take_save()
174 global $username, $data_dir;
175 global $abook_take_abook_take_location;
176 global $abook_take_abook_take_hide;
177 global $abook_take_abook_take_verify;
180 if (isset($abook_take_abook_take_location))
182 setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
186 setPref($data_dir, $username, 'abook_take_location', 'center');
189 if (isset($abook_take_abook_take_hide))
191 setPref($data_dir, $username, 'abook_take_hide', '1');
195 setPref($data_dir, $username, 'abook_take_hide', '');
198 if (isset($abook_take_abook_take_verify))
200 setPref($data_dir, $username, 'abook_take_verify', '1');
204 setPref($data_dir, $username, 'abook_take_verify', '');