ed9e6e4d791d01d4061b7c5317e966d7141137e4
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]->getAddress());
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 if (isset($message->rfc822_header
->from
))
87 abook_take_read_array($message->rfc822_header
->from
);
88 if (isset($message->rfc822_header
->cc
))
89 abook_take_read_array($message->rfc822_header
->cc
);
90 if (isset($message->rfc822_header
->reply_to
))
91 abook_take_read_array($message->rfc822_header
->reply_to
);
92 if (isset($message->rfc822_header
->to
))
93 abook_take_read_array($message->rfc822_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 echo '<input type="submit" value="' . _("Take Address") . '">';
128 function abook_take_pref()
130 global $username, $data_dir;
131 global $abook_take_hide, $abook_take_location, $abook_take_verify;
133 $abook_take_location = getPref($data_dir, $username, 'abook_take_location');
134 if ($abook_take_location == '')
135 $abook_take_location = 'center';
137 $abook_take_hide = getPref($data_dir, $username, 'abook_take_hide');
138 $abook_take_verify = getPref($data_dir, $username, 'abook_take_verify');
142 function abook_take_options()
144 global $abook_take_location, $abook_take_hide, $abook_take_verify;
146 echo html_tag( 'tr' ) .
147 html_tag( 'td', _("Address Book Take") . ':', 'right', '', 'nowrap valign="top"' ) .
148 html_tag( 'td', '', 'left' ) .
149 '<select name="abook_take_abook_take_location">' .
150 '<option value="left"';
151 if ($abook_take_location == 'left')
153 echo '>' . _("Left aligned") . '</option>' .
154 '<option value="center"';
155 if ($abook_take_location == 'center')
157 echo '>' . _("Centered") . '</option>' .
158 '<option value="right"';
159 if ($abook_take_location == 'right')
161 echo '>' . _("Right aligned") . '</option>' .
162 '</select> ' . _("on the Read screen") .'<br>' .
163 '<input type="checkbox" name="abook_take_abook_take_hide"';
164 if ($abook_take_hide)
166 echo '> ' . _("Hide the box") . '<br>' .
167 '<input type=checkbox name="abook_take_abook_take_verify"';
168 if ($abook_take_verify)
170 echo '> ' . _("Try to verify addresses") . '</td></tr>';
174 function abook_take_save()
176 global $username, $data_dir;
177 global $abook_take_abook_take_location;
178 global $abook_take_abook_take_hide;
179 global $abook_take_abook_take_verify;
182 if (isset($abook_take_abook_take_location))
184 setPref($data_dir, $username, 'abook_take_location', $abook_take_abook_take_location);
188 setPref($data_dir, $username, 'abook_take_location', 'center');
191 if (isset($abook_take_abook_take_hide))
193 setPref($data_dir, $username, 'abook_take_hide', '1');
197 setPref($data_dir, $username, 'abook_take_hide', '');
200 if (isset($abook_take_abook_take_verify))
202 setPref($data_dir, $username, 'abook_take_verify', '1');
206 setPref($data_dir, $username, 'abook_take_verify', '');