예제 #1
0
파일: OpenID.php 프로젝트: shupp/EZRP
 /**
  * Creates an assertion object and tries to verify its validity.
  *
  * @return array of the OpenID_Assertion_Result and OpenID_Message objects
  */
 public function getVerifyResultsAndMessage()
 {
     $rp = $this->getORPInstance();
     $url = 'http';
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $url .= 's';
     }
     $url .= '://' . $_SERVER['SERVER_NAME'];
     if ($_SERVER['SERVER_PORT'] != '80') {
         $url .= ':' . $_SERVER['SERVER_PORT'];
     }
     $url .= $_SERVER['PHP_SELF'];
     // Get the message contents
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // Can't use $_POST, it f***s with the keys (. -> _)
         $queryString = $this->getPHPInput();
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'GET') {
             $netURL = new Net_URL2($url . '?' . $_SERVER['QUERY_STRING']);
             $queryString = $netURL->getQuery();
             if ($queryString === false) {
                 throw new OpenID_Exception('Invalid request');
             }
         } else {
             throw new OpenID_Exception('Unknown HTTP method');
         }
     }
     $requestedURL = $url . '?' . $queryString;
     $message = new OpenID_Message($queryString, OpenID_Message::FORMAT_HTTP);
     $result = $rp->verify(new Net_URL2($requestedURL), $message);
     return array('result' => $result, 'message' => $message);
 }
예제 #2
0
 /**
  * Returns the query portion of the url.
  * 
  * @return string
  */
 public function getQuery()
 {
     return $this->_url->getQuery();
 }
예제 #3
0
 /**
  * Property getter interceptor to handle "uri" and "host" special cases.
  *
  * @param string $property The property to retrieve
  * 
  * @return mixed
  */
 public function __get($property)
 {
     switch ($property) {
         case 'uri':
             if ($this->_uri !== null) {
                 return $this->_uri->getURL();
             }
             return null;
         case 'proxy':
             return $this->_proxy;
         case 'path':
             if ($this->_uri === null) {
                 return null;
             }
             if ($this->httpVersion == self::HTTP_VERSION_1_0 || $this->proxy) {
                 // if http 1.0 or proxy given, the request uri must be absolute
                 return $this->_uri->getURL();
             }
             if (($path = $this->_uri->getPath()) === false) {
                 $path = '/';
             }
             if (($query = $this->_uri->getQuery()) !== false) {
                 $path .= '?' . $query;
             }
             if (($fragment = $this->_uri->getFragment()) !== false) {
                 $path .= '#' . $fragment;
             }
             return $path;
         case 'host':
             if (isset($this->headers['host'])) {
                 return trim($this->headers['host']);
             }
             if ($this->_proxy !== null) {
                 return $this->_proxy;
             }
             if ($this->_uri !== null) {
                 $host = $this->_uri->getHost();
                 if (($port = $this->_uri->getPort()) !== false) {
                     $host .= ':' . $port;
                 }
             }
             return $host;
         case 'port':
             $port = $this->_uri->getPort();
             if (!is_numeric($port)) {
                 return $this->isSecure() ? 443 : 80;
             }
             return $port;
         case 'connection':
             if ($this->_connection === null) {
                 include_once 'HTTP/Connection.php';
                 $this->_connection = HTTP_Connection::factory('Socket');
             }
             return $this->_connection;
         default:
             return parent::__get($property);
     }
 }
예제 #4
0
 /**
  * This is some example code from a bugreport. Trying to proof that
  * the parsing works indeed.
  *
  * @return void
  * @link   http://pear.php.net/bugs/bug.php?id=17036
  */
 public function testQueryVariables()
 {
     $queryString = 'start=10&test[0][first][1.1][20]=coucou';
     $url = new Net_URL2('?' . $queryString);
     $vars = array();
     parse_str($url->getQuery(), $vars);
     $this->assertEquals('10', $vars['start']);
     $this->assertEquals('coucou', $vars['test'][0]['first']['1.1'][20]);
 }
예제 #5
0
 /**
  * This is a regression test to test that recovering from
  * a wrongly encoded URL is possible.
  *
  * It was requested as Request #19684 on 2011-12-31 02:07 UTC
  * that redirects containing spaces should work.
  *
  * @return void
  */
 public function test19684()
 {
     // Location: URL obtained Thu, 25 Apr 2013 20:51:31 GMT
     $urlWithSpace = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS N' . 'o.&term=108-88-3&lang=en&region=US&mode=match+partialmax&N=0+2200030' . '48+219853269+219853286';
     $urlCorrect = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS%20N' . 'o.&term=108-88-3&lang=en&region=US&mode=match+partialmax&N=0+2200030' . '48+219853269+219853286';
     $url = new Net_URL2($urlWithSpace);
     $this->assertTrue($url->isAbsolute());
     $urlPart = parse_url($urlCorrect, PHP_URL_PATH);
     $this->assertSame($urlPart, $url->getPath());
     $urlPart = parse_url($urlCorrect, PHP_URL_QUERY);
     $this->assertSame($urlPart, $url->getQuery());
     $this->assertSame($urlCorrect, (string) $url);
     $input = 'http://example.com/get + + to my nose/';
     $expected = 'http://example.com/get%20+%20+%20to%20my%20nose/';
     $actual = new Net_URL2($input);
     $this->assertEquals($expected, $actual);
     $actual->normalize();
 }