/i', $page, $matches); return ($matches); } function domainFromHyperlink ($hyperlink) { /* returns the domain name from $hyperlink, or false if there is none */ /*$pattern = "/()/i"; /* regex for domain from a hyperlink */ $pattern = "/.com/i"; if (preg_match($pattern, $hyperlink, $matches) === false) { return (false); } else { return ($matches); } } function crawl ($origin, $hostPrison) { /* recursive. returns an array of urls. won't get urls that arent on domain $host, if set */ foreach (hyperlinks(file_get_contents($origin)) as $link) { if (isset($hostPrison)) { /* check if hostPrison occurs within origin eg hostPrison="foo.com", origin="http://foo.com/bar.html" would satisfy this condition */ if (!strpos($origin, $hostPrison === false)) { $urls[] = crawl($link); // $urls[] = crawl($link); } } else { /* executed if $hostPrison is unset */ $urls[] = crawl($link); // $urls[] = crawl($link); } } unset ($hostPrison); return ($urls); } echo '
'; ?>