public function init() { $this->data = array(); $content = \Ecodev\Newsletter\Tools::getUrl($this->getHtmlUrl()); switch ($this->getHtmlFetchType()) { case 'mailto': preg_match_all('|<a[^>]+href="mailto:([^"]+)"[^>]*>(.*)</a>|Ui', $content, $fetched_data); foreach ($fetched_data[1] as $i => $email) { $this->data[] = array('email' => $email, 'name' => $fetched_data[2][$i]); } break; case 'regex': default: preg_match_all("|[\\.a-z0-9!#\$%&'*+-/=?^_`{\\|}]+@[a-z0-9_-][\\.a-z0-9_-]*\\.[a-z]{2,}|i", $content, $fetched_data); foreach ($fetched_data[0] as $address) { $this->data[]['email'] = $address; } } }
/** * Return the content of the given URL * @param string $url * @return string */ protected function getURL($url) { return \Ecodev\Newsletter\Tools::getUrl($url); }