/** * Discovers the OpenID server information from the provided URL by parsing * the HTML page source. * * The format of the returned array is (example): * <code> * array( 'openid.server' => array( 0 => 'http://www.example-provider.com' ), * 'openid.delegate' => array( 0 => 'http://www.example-delegate.com' ) * ); * </code> * * @throws ezcAuthenticationOpenidConnectionException * if connection to the URL could not be opened * @param string $url URL to connect to and discover the OpenID information * @return array(string=>array) */ protected function discoverHtml($url) { $url = ezcAuthenticationUrl::normalize($url); $src = ezcAuthenticationUrl::getUrl($url, 'GET', 'text/html'); $result = array(); $pattern = "%<\\w.*rel\\=[\\s\"'`]*([\\w:?=@&\\/#._;-]+)[\\s\"'`]*[^>]*>%i"; preg_match_all($pattern, $src, $matches); $count = count($matches[0]); for ($i = 0; $i < $count; $i++) { if (stristr($matches[1][$i], 'openid') !== false) { $pattern = "%.*href\\=[\\s\"'`]*([\\w:?=@&\\/#._;-]+)[\\s\"'`]*%i"; preg_match($pattern, $matches[0][$i], $href); $result[strtolower($matches[1][$i])][] = $href[1]; } } return $result; }