示例#1
0
function Auth_OpenID_remove_dot_segments($path)
{
    $result_segments = array();
    while ($path) {
        if (Services_Yadis_startswith($path, '../')) {
            $path = substr($path, 3);
        } else {
            if (Services_Yadis_startswith($path, './')) {
                $path = substr($path, 2);
            } else {
                if (Services_Yadis_startswith($path, '/./')) {
                    $path = substr($path, 2);
                } else {
                    if ($path == '/.') {
                        $path = '/';
                    } else {
                        if (Services_Yadis_startswith($path, '/../')) {
                            $path = substr($path, 3);
                            if ($result_segments) {
                                array_pop($result_segments);
                            }
                        } else {
                            if ($path == '/..') {
                                $path = '/';
                                if ($result_segments) {
                                    array_pop($result_segments);
                                }
                            } else {
                                if ($path == '..' || $path == '.') {
                                    $path = '';
                                } else {
                                    $i = 0;
                                    if ($path[0] == '/') {
                                        $i = 1;
                                    }
                                    $i = strpos($path, '/', $i);
                                    if ($i === false) {
                                        $i = strlen($path);
                                    }
                                    $result_segments[] = substr($path, 0, $i);
                                    $path = substr($path, $i);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return implode('', $result_segments);
}
示例#2
0
function Services_Yadis_XRI($xri)
{
    if (!Services_Yadis_startswith($xri, 'xri://')) {
        $xri = 'xri://' . $xri;
    }
    return $xri;
}
示例#3
0
 function fetch($url, $body = null, $headers = null)
 {
     $this->fetchlog[] = array($url, $body, $headers);
     $u = parse_url($url);
     $proxy_host = $u['host'];
     $xri = $u['path'];
     $query = $u['query'];
     if (!$headers && !$query) {
         trigger_error('Error in mock XRI fetcher: no headers or query');
     }
     if (Services_Yadis_startswith($xri, '/')) {
         $xri = substr($xri, 1);
     }
     if (array_key_exists($xri, $this->documents)) {
         list($ctype, $body) = $this->documents[$xri];
         $status = 200;
     } else {
         $status = 404;
         $ctype = 'text/plain';
         $body = '';
     }
     return new Services_Yadis_HTTPResponse($url, $status, array('content-type' => $ctype), $body);
 }