4 /* Address Take -- steals addresses from incoming email messages. Searches
5 the To, Cc, From and Reply-To headers, also searches the body of the
8 function squirrelmail_plugin_init_abook_take()
10 global $squirrelmail_plugin_hooks;
12 $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
13 $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
14 $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
15 $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
19 function valid_email ($email, $verify)
21 global $abook_take_verify;
23 if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](g|l|m|pa|t|u|v)?$",
31 if (checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
40 function abook_take_read_string($str)
42 global $abook_found_email;
44 $str = eregi_replace('[^-0-9a-z_.@]', ' ', $str);
45 $str = eregi_replace('[[:space:]]+', ' ', $str);
46 $chances = split(' ', $str);
48 while ($i < count($chances))
50 if (valid_email($chances[$i], 0) &&
51 ! isset($abook_found_email[$chances[$i]]))
53 //echo '<option value="' . $chances[$i] . '">' . $chances[$i] .
54 // '</option>' . "\n";
55 echo "<input type=\"hidden\" name=\"email[]\" value=\"$chances[$i]\">\n";
56 $abook_found_email[$chances[$i]] = 1;
63 function abook_take_read_array($array)
66 while ($i < count($array))
68 abook_take_read_string($array[$i]);
74 function abook_take_read()
76 global $color, $abook_take_location;
77 global $body, $abook_take_hide, $message, $imapConnection;
83 <FORM ACTION
="../plugins/abook_take/take.php" METHOD
=POST
>
85 echo $abook_take_location;
86 ?>" cellpadding
=3 cellspacing
=0 border
=0 bgcolor
="<?PHP
91 <table cellpadding
=2 cellspacing
=1 border
=0 bgcolor
="<?PHP
97 abook_take_read_string($message->header
->from
);
98 abook_take_read_array($message->header
->cc
);
99 abook_take_read_array($message->header
->reply_to
);
100 abook_take_read_array($message->header
->to
);
104 $pos = strpos($new_body,
105 '">Download this as a file</A></CENTER><BR></SMALL>');
108 $new_body = substr($new_body, 0, $pos);
111 $trans = get_html_translation_table(HTML_ENTITIES
);
112 $trans[' '] = ' ';
113 $trans = array_flip($trans);
114 $new_body = strtr($new_body, $trans);
116 $new_body = urldecode($new_body);
117 $new_body = strip_tags($new_body);
119 $new_body = strtr($new_body, "\n", ' ');
121 abook_take_read_string($body);
123 <INPUT TYPE
="submit" VALUE
="Take Address">
134 function abook_take_pref()
136 global $username, $data_dir;
137 global $abook_take_hide, $abook_take_location, $abook_take_verify;
139 $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
140 if ($abook_take_location == '')
141 $abook_take_location = 'center';
143 $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
144 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
148 function abook_take_options()
150 global $abook_take_location, $abook_take_hide, $abook_take_verify;
152 ?
><tr
><td align
=right nowrap valign
="top">Address Book Take
:</td
>
153 <td
><select name
="abook_take_abook_take_location">
154 <option value
="left"<?PHP
155 if ($abook_take_location == 'left')
157 ?
>>Left aligned
</option
>
158 <option value
="center"<?PHP
159 if ($abook_take_location == 'center')
162 <option value
="right"<?PHP
163 if ($abook_take_location == 'right')
165 ?
>>Right aligned
</option
>
166 </select
> on the Read screen
<br
>
167 <input type
=checkbox name
="abook_take_abook_take_hide"<?PHP
168 if ($abook_take_hide)
171 <input type
=checkbox name
="abook_take_abook_take_verify"<?PHP
172 if ($abook_take_verify)
174 ?
>> Try to verify addresses
179 function abook_take_save()
181 global $username, $data_dir;
182 global $abook_take_abook_take_location;
183 global $abook_take_abook_take_hide;
184 global $abook_take_abook_take_verify;
187 if (isset($abook_take_abook_take_location))
189 setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
193 setPref($data_dir, $username, 'abook_take_location', 'center');
196 if (isset($abook_take_abook_take_hide))
198 setPref($data_dir, $username, 'abook_take_hide', '1');
202 setPref($data_dir, $username, 'abook_take_hide', '');
205 if (isset($abook_take_abook_take_verify))
207 setPref($data_dir, $username, 'abook_take_verify', '1');
211 setPref($data_dir, $username, 'abook_take_verify', '');