| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Code for using a proxy XRI resolver. 5 */ 6 7 // Do not allow direct access 8 defined( '_JEXEC' ) or die( 'Restricted access' ); 9 10 require_once 'Auth/Yadis/XRDS.php'; 11 require_once 'Auth/Yadis/XRI.php'; 12 13 class Auth_Yadis_ProxyResolver { 14 function Auth_Yadis_ProxyResolver(&$fetcher, $proxy_url = null) 15 { 16 $this->fetcher =& $fetcher; 17 $this->proxy_url = $proxy_url; 18 if (!$this->proxy_url) { 19 $this->proxy_url = Auth_Yadis_getDefaultProxy(); 20 } 21 } 22 23 function queryURL($xri, $service_type = null) 24 { 25 // trim off the xri:// prefix 26 $qxri = substr(Auth_Yadis_toURINormal($xri), 6); 27 $hxri = $this->proxy_url . $qxri; 28 $args = array( 29 '_xrd_r' => 'application/xrds+xml' 30 ); 31 32 if ($service_type) { 33 $args['_xrd_t'] = $service_type; 34 } else { 35 // Don't perform service endpoint selection. 36 $args['_xrd_r'] .= ';sep=false'; 37 } 38 39 $query = Auth_Yadis_XRIAppendArgs($hxri, $args); 40 return $query; 41 } 42 43 function query($xri, $service_types, $filters = array()) 44 { 45 $services = array(); 46 $canonicalID = null; 47 foreach ($service_types as $service_type) { 48 $url = $this->queryURL($xri, $service_type); 49 $response = $this->fetcher->get($url); 50 if ($response->status != 200 and $response->status != 206) { 51 continue; 52 } 53 $xrds = Auth_Yadis_XRDS::parseXRDS($response->body); 54 if (!$xrds) { 55 continue; 56 } 57 $canonicalID = Auth_Yadis_getCanonicalID($xri, 58 $xrds); 59 60 if ($canonicalID === false) { 61 return null; 62 } 63 64 $some_services = $xrds->services($filters); 65 $services = array_merge($services, $some_services); 66 // TODO: 67 // * If we do get hits for multiple service_types, we're 68 // almost certainly going to have duplicated service 69 // entries and broken priority ordering. 70 } 71 return array($canonicalID, $services); 72 } 73 } 74 75 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |