+ // {{{ function parseUrlsFromArticle()
+
+ private function parseUrlsFromArticle()
+ {
+ $email_regex = '([a-z0-9.\-+_\$]+@([\-.+_]?[a-z0-9])+)';
+ $url_regex = '((https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+)';
+ $regex = '{' . $email_regex . '|' . $url_regex . '}i';
+
+ $matches = array();
+ $body_matches = array();
+ if (preg_match_all($regex, $this->body(), $body_matches)) {
+ $matches = array_merge($matches, $body_matches[0]);
+ }
+
+ $append_matches = array();
+ if (preg_match_all($regex, $this->append(), $append_matches)) {
+ $matches = array_merge($matches, $append_matches[0]);
+ }
+
+ return $matches;
+ }
+
+ // }}}
+ // {{{ function getLinkIps()
+
+ public function getLinkIps(&$blacklist_host_resolution_count)
+ {
+ $matches = $this->parseUrlsFromArticle();
+ $article_ips = array();
+
+ if (!empty($matches)) {
+ global $globals;
+
+ foreach ($matches as $match) {
+ $host = parse_url($match, PHP_URL_HOST);
+ if ($host == '') {
+ list(, $host) = explode('@', $match);
+ }
+
+ if ($blacklist_host_resolution_count >= $globals->mail->blacklist_host_resolution_limit) {
+ break;
+ }
+
+ if (!preg_match('/^(' . str_replace(' ', '|', $globals->mail->domain_whitelist) . ')$/i', $host)) {
+ $article_ips = array_merge($article_ips, array(gethostbyname($host) => $host));
+ ++$blacklist_host_resolution_count;
+ }
+ }
+ }
+
+ return $article_ips;
+ }
+
+ // }}}