/** * Retrieves a favicon for the given page. */ function getFavicon($url, $page) { $urlparts = parse_url($url); $regex = '!<link rel="(shortcut )?icon" href="([^"]+)" ?/?>!'; if (preg_match($regex, $page, $match)) { $icon = $match[2]; if (!preg_match("#^(http://)?[^/]+#i", $icon)) { $icon = $urlparts['scheme'] . '://' . $urlparts['host'] . ($icon[0] == '/' ? '' : '/') . $icon; } return $icon; } $icon = $urlparts['scheme'] . '://' . $urlparts['host'] . '/favicon.ico'; $http_client = new LinkbackHTTPClient(); $http_client->sendRequest($icon, array(), 'HEAD'); if ($http_client->status == 200) { return $icon; } else { return $this->getConf('favicon_default'); } }