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;
75 echo '<form action="../plugins/abook_take/take.php" method="post">' . "\n" .
76 html_tag( 'table', '', $abook_take_location, $color[10], 'cellpadding="3" cellspacing="0" border="0"' ) .
78 html_tag( 'td', '', 'left' ) .
79 html_tag( 'table', '', '', $color[5], 'cellpadding="2" cellspacing="1" border="0"' ) .
83 abook_take_read_string($message->header
->from
);
84 abook_take_read_array($message->header
->cc
);
85 abook_take_read_array($message->header
->reply_to
);
86 abook_take_read_array($message->header
->to
);
90 $pos = strpos($new_body,
91 '">' . _("Download this as a file") . '</a></center><br></small>');
94 $new_body = substr($new_body, 0, $pos);
97 $trans = get_html_translation_table(HTML_ENTITIES
);
98 $trans[' '] = ' ';
99 $trans = array_flip($trans);
100 $new_body = strtr($new_body, $trans);
102 $new_body = urldecode($new_body);
103 $new_body = strip_tags($new_body);
105 $new_body = strtr($new_body, "\n", ' ');
107 abook_take_read_string($body);
109 echo '<input type="submit" value="' . _("Take Address") . '">';
121 function abook_take_pref()
123 global $username, $data_dir;
124 global $abook_take_hide, $abook_take_location, $abook_take_verify;
126 $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
127 if ($abook_take_location == '')
128 $abook_take_location = 'center';
130 $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
131 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
135 function abook_take_options()
137 global $abook_take_location, $abook_take_hide, $abook_take_verify;
139 echo html_tag( 'tr' ) .
140 html_tag( 'td', _("Address Book Take") . ':', 'right', '', 'nowrap valign="top"' ) .
141 html_tag( 'td', '', 'left' ) .
142 '<select name="abook_take_abook_take_location">' .
143 '<option value="left"';
144 if ($abook_take_location == 'left')
146 echo '>' . _("Left aligned") . '</option>' .
147 '<option value="center"';
148 if ($abook_take_location == 'center')
150 echo '>' . _("Centered") . '</option>' .
151 '<option value="right"';
152 if ($abook_take_location == 'right')
154 echo '>' . _("Right aligned") . '</option>' .
155 '</select> ' . _("on the Read screen") .'<br>' .
156 '<input type="checkbox" name="abook_take_abook_take_hide"';
157 if ($abook_take_hide)
159 echo '> ' . _("Hide the box") . '<br>' .
160 '<input type=checkbox name="abook_take_abook_take_verify"';
161 if ($abook_take_verify)
163 echo '> ' . _("Try to verify addresses") . '</td></tr>';
167 function abook_take_save()
169 global $username, $data_dir;
170 global $abook_take_abook_take_location;
171 global $abook_take_abook_take_hide;
172 global $abook_take_abook_take_verify;
175 if (isset($abook_take_abook_take_location))
177 setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
181 setPref($data_dir, $username, 'abook_take_location', 'center');
184 if (isset($abook_take_abook_take_hide))
186 setPref($data_dir, $username, 'abook_take_hide', '1');
190 setPref($data_dir, $username, 'abook_take_hide', '');
193 if (isset($abook_take_abook_take_verify))
195 setPref($data_dir, $username, 'abook_take_verify', '1');
199 setPref($data_dir, $username, 'abook_take_verify', '');