1130d9241e39649c81bca9203783eb5a4fa043c0
3 /* Path for SquirrelMail required files. */
4 define('SM_PATH','../../');
6 /* SquirrelMail required files. */
7 require_once(SM_PATH
. 'functions/url_parser.php');
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
13 function squirrelmail_plugin_init_abook_take()
15 global $squirrelmail_plugin_hooks;
17 $squirrelmail_plugin_hooks['read_body_bottom']['abook_take'] = 'abook_take_read';
18 $squirrelmail_plugin_hooks['loading_prefs']['abook_take'] = 'abook_take_pref';
19 $squirrelmail_plugin_hooks['options_display_inside']['abook_take'] = 'abook_take_options';
20 $squirrelmail_plugin_hooks['options_display_save']['abook_take'] = 'abook_take_save';
24 function valid_email ($email, $verify)
26 global $abook_take_verify, $Email_RegExp_Match;
28 if (! eregi('^' . $Email_RegExp_Match . '$', $email))
34 if (! checkdnsrr(substr(strstr($email, '@'), 1), 'ANY'))
41 function abook_take_read_string($str)
43 global $abook_found_email, $Email_RegExp_Match;
46 while (eregi('(' . $Email_RegExp_Match . ')', $str, $hits))
48 $str = substr(strstr($str, $hits[0]), strlen($hits[0]));
49 if (! isset($abook_found_email[$hits[0]]))
51 echo "<input type=\"hidden\" name=\"email[]\" value=\"$hits[0]\">\n";
52 $abook_found_email[$hits[0]] = 1;
59 function abook_take_read_array($array)
62 while ($i < count($array))
64 abook_take_read_string($array[$i]);
70 function abook_take_read()
72 global $color, $abook_take_location;
73 global $body, $abook_take_hide, $message, $imapConnection;
78 echo '<form action="../plugins/abook_take/take.php" method="post">' . "\n" .
79 html_tag( 'table', '', $abook_take_location, $color[10], 'cellpadding="3" cellspacing="0" border="0"' ) .
81 html_tag( 'td', '', 'left' ) .
82 html_tag( 'table', '', '', $color[5], 'cellpadding="2" cellspacing="1" border="0"' ) .
86 abook_take_read_string($message->header
->from
);
87 abook_take_read_array($message->header
->cc
);
88 abook_take_read_array($message->header
->reply_to
);
89 abook_take_read_array($message->header
->to
);
93 $pos = strpos($new_body,
94 '">' . _("Download this as a file") . '</a></center><br></small>');
97 $new_body = substr($new_body, 0, $pos);
100 $trans = get_html_translation_table(HTML_ENTITIES
);
101 $trans[' '] = ' ';
102 $trans = array_flip($trans);
103 $new_body = strtr($new_body, $trans);
105 $new_body = urldecode($new_body);
106 $new_body = strip_tags($new_body);
108 $new_body = strtr($new_body, "\n", ' ');
110 abook_take_read_string($body);
112 echo '<input type="submit" value="' . _("Take Address") . '">';
124 function abook_take_pref()
126 global $username, $data_dir;
127 global $abook_take_hide, $abook_take_location, $abook_take_verify;
129 $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
130 if ($abook_take_location == '')
131 $abook_take_location = 'center';
133 $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
134 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
138 function abook_take_options()
140 global $abook_take_location, $abook_take_hide, $abook_take_verify;
142 echo html_tag( 'tr' ) .
143 html_tag( 'td', _("Address Book Take") . ':', 'right', '', 'nowrap valign="top"' ) .
144 html_tag( 'td', '', 'left' ) .
145 '<select name="abook_take_abook_take_location">' .
146 '<option value="left"';
147 if ($abook_take_location == 'left')
149 echo '>' . _("Left aligned") . '</option>' .
150 '<option value="center"';
151 if ($abook_take_location == 'center')
153 echo '>' . _("Centered") . '</option>' .
154 '<option value="right"';
155 if ($abook_take_location == 'right')
157 echo '>' . _("Right aligned") . '</option>' .
158 '</select> ' . _("on the Read screen") .'<br>' .
159 '<input type="checkbox" name="abook_take_abook_take_hide"';
160 if ($abook_take_hide)
162 echo '> ' . _("Hide the box") . '<br>' .
163 '<input type=checkbox name="abook_take_abook_take_verify"';
164 if ($abook_take_verify)
166 echo '> ' . _("Try to verify addresses") . '</td></tr>';
170 function abook_take_save()
172 global $username, $data_dir;
173 global $abook_take_abook_take_location;
174 global $abook_take_abook_take_hide;
175 global $abook_take_abook_take_verify;
178 if (isset($abook_take_abook_take_location))
180 setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
184 setPref($data_dir, $username, 'abook_take_location', 'center');
187 if (isset($abook_take_abook_take_hide))
189 setPref($data_dir, $username, 'abook_take_hide', '1');
193 setPref($data_dir, $username, 'abook_take_hide', '');
196 if (isset($abook_take_abook_take_verify))
198 setPref($data_dir, $username, 'abook_take_verify', '1');
202 setPref($data_dir, $username, 'abook_take_verify', '');