Source code for file /openid/Services/Yadis/XRI.php
Documentation is available at XRI.php
* Routines for XRI resolution.
* @copyright 2005 Janrain, Inc.
* @license http://www.gnu.org/copyleft/lesser.html LGPL
require_once 'Services/Yadis/Misc.php';
require_once 'Services/Yadis/Yadis.php';
require_once 'Auth/OpenID.php';
$DEFAULT_PROXY =
'http://proxy.xri.net/';
$XRI_AUTHORITIES =
array('!', '=', '@', '+', '$', '(');
foreach (array_merge($__UCSCHAR, $__IPRIVATE) as $pair) {
$_xref_re =
'/\((.*?)\)/';
(in_array($identifier[0], $XRI_AUTHORITIES))) {
// According to RFC 3987, section 3.1, "Mapping of IRIs to URIs"
'_pct_escape_unicode', $iri);
// Append some arguments to an HTTP query. Yes, this is just like
// OpenID's appendArgs, but with special seasoning for XRI
// Non-empty array; if it is an array of arrays, use multisort;
foreach ($keys as $key) {
$new_args[] =
array($key, $args[$key]);
// According to XRI Resolution section "QXRI query parameters":
// "If the original QXRI had a null query component (only a
// leading question mark), or a query component consisting of
// only question marks, one additional leading question mark MUST
// be added when adding any XRI resolution parameters."
return $url .
$sep .
Auth_OpenID::httpBuildQuery($args);
$lastbang =
strrpos($canonicalID, '!');
$p =
substr($canonicalID, 0, $lastbang);
return $p ==
$providerID;
// Return the root authority for an XRI.
$authority =
explode('/', $xri, 2);
$authority =
$authority[0];
if ($authority[0] ==
'(') {
// XXX: This is incorrect if someone nests cross-references so
// there is another close-paren in there. Hopefully nobody
// does that before we have a real xriparse function.
// Hopefully nobody does that *ever*.
} else if (in_array($authority[0], $XRI_AUTHORITIES)) {
$_segments =
explode("!", $authority);
foreach ($_segments as $s) {
// Returns FALSE or a canonical ID value.
// Now nodes are in reverse order.
$parser =
& $xrds->parser;
$canonicalID_nodes =
$parser->evalXPath('xrd:CanonicalID', $node);
if (!$canonicalID_nodes) {
$canonicalID =
$canonicalID_nodes[count($canonicalID_nodes) -
1];
for ($i =
1; $i <
count($xrd_list); $i++
) {
foreach ($parser->evalXPath('xrd:CanonicalID', $xrd) as $c) {
if (!in_array($parent_sought, $parent_list)) {
$childID =
$parent_sought;