示例#1
0
 /**
  * Returns a URI string describing this connection
  *
  * @return String
  */
 public function getURI()
 {
     $uri = new \r8\URL();
     $uri->setScheme("db")->setUserName($this->username)->setPassword($this->password)->setHost($this->host)->setPort($this->port)->setPath($this->database)->setQuery(array_filter(array("persistent" => $this->persistent ? "t" : NULL, "forceNew" => $this->forceNew ? "t" : NULL)));
     return $uri->__toString();
 }
示例#2
0
 /**
  * Private method for building the URL object
  *
  * @return \r8\URL
  */
 private function buildURL()
 {
     $url = new \r8\URL();
     // Get the url Scheme from the server protocol
     if (self::hasKey($this->server, "SERVER_PROTOCOL")) {
         $url->setScheme(strtolower(strstr($this->server['SERVER_PROTOCOL'], "/", TRUE)));
     }
     // Pull the server host, if it is set
     if (self::hasKey($this->server, 'HTTP_HOST')) {
         $url->setHost($this->server['HTTP_HOST']);
     } else {
         if (self::hasKey($this->server, "SERVER_ADDR")) {
             $url->setHost($this->server['SERVER_ADDR']);
         }
     }
     // Pull the port
     if (self::hasKey($this->server, "SERVER_PORT")) {
         $url->setPort((int) $this->server['SERVER_PORT']);
     }
     // The path and file name
     if (self::hasKey($this->server, 'SCRIPT_NAME')) {
         $url->setPath($this->server['SCRIPT_NAME']);
     }
     // The faux directories
     if (self::hasKey($this->server, 'PATH_INFO')) {
         $url->setFauxDir(\r8\str\head($this->server['PATH_INFO'], "/"));
     }
     // Finally, pull the the URL query
     if (self::hasKey($this->server, 'QUERY_STRING')) {
         $url->setQuery($this->server['QUERY_STRING']);
     }
     return $url;
 }
示例#3
0
 public function testIsSameBase()
 {
     $url = new \r8\URL();
     $compare = new \r8\URL("http://www.example.edu:80");
     $this->assertFalse($url->isSameBase($compare));
     $url->setScheme("http");
     $this->assertFalse($url->isSameBase($compare));
     $url->setPort(80);
     $this->assertFalse($url->isSameBase($compare));
     $url->setHost("example.edu");
     $this->assertTrue($url->isSameBase($compare));
     $url->clearPort();
     $this->assertTrue($url->isSameBase($compare));
 }