/**
  * Returns the URL of the data object
  *
  * If the object is new and doesn't have a name, then an exception is
  * thrown.
  *
  * @return string
  * @throws NoNameError
  */
 public function Url()
 {
     if (!$this->name) {
         throw new NoNameError(_('Object has no name'));
     }
     return noslash($this->container->Url()) . '/' . str_replace('%2F', '/', rawurlencode($this->name));
 }
 /**
  * Returns the URL of the container
  *
  * @return string
  * @throws NoNameError
  */
 public function Url()
 {
     if (!$this->name) {
         throw new NoNameError(_('Container does not have an identifier'));
     }
     return noslash($this->Service()->Url()) . '/' . $this->name;
 }
 /**
  * Returns the selected endpoint URL of this Service
  *
  * @param string $resource - a child resource. For example,
  *      passing 'servers' would return .../servers. Should *not* be
  *    prefixed with a slash (/).
  * @param array $args (optional) an array of key-value pairs for query
  *      strings to append to the URL
  * @returns string - the requested URL
  */
 public function Url($resource = '', $args = array())
 {
     $baseurl = parent::Url();
     if ($resource != '') {
         $baseurl = noslash($baseurl) . '/' . $resource;
     }
     if (!empty($args)) {
         $baseurl .= '?' . $this->MakeQueryString($args);
     }
     return $baseurl;
 }
Exemple #4
0
function noslash($s)
{
    if (is_array($s)) {
        if (!get_magic_quotes_gpc()) {
            return $s;
        }
        $res = array();
        foreach ($s as $k => $v) {
            $res[$k] = noslash($v);
        }
        return $res;
    }
    return get_magic_quotes_gpc() ? stripslashes($s) : $s;
}
Exemple #5
0
 function checkgeturl(&$url, $direct = false)
 {
     global $phpenv, $setctl;
     if ($this->check()) {
         if (!file_exists($this->getfname())) {
             $this->createsid();
         }
         $fname = $this->getfname();
         if (file_exists($fname)) {
             $sdir = noslash($setctl->get('storealbumrelative'));
             $imgsrc = slashstart($sdir) . '/' . kp_basename($fname);
             if (!$direct) {
                 $url = '<img alt="image" border="0" src="' . $imgsrc . '" height="' . $this->h . '" width="' . $this->w . '"/>';
             } else {
                 $url = $setctl->get('streamurl') . $phpenv['host'] . $imgsrc;
             }
             return true;
         }
     }
     return false;
 }
 /**
  * Returns the default URL of the object
  *
  * This may have to be overridden in subclasses.
  *
  * @param string $subresource optional sub-resource string
  * @param array $qstr optional k/v pairs for query strings
  * @return string
  * @throws UrlError if URL is not defined
  */
 public function Url($subresource = NULL, $qstr = array())
 {
     // find the primary key attribute name
     $pk = $this->PrimaryKeyField();
     // first, see if we have a [self] link
     $url = $this->FindLink('self');
     // next, check to see if we have an ID
     /**
      * Note that we use Parent() instead of Service(), since the parent
      * object might not be a service.
      */
     if (!$url && $this->{$pk}) {
         $url = noslash($this->Parent()->Url($this->ResourceName())) . '/' . $this->{$pk};
     }
     // add the subresource
     if ($url) {
         $url .= $subresource ? '/' . $subresource : '';
         // add the query strings
         if (count($qstr)) {
             $url .= '?' . $this->MakeQueryString($qstr);
         }
         // and return
         return $url;
     }
     // otherwise, we don't have a URL yet
     throw new UrlError(sprintf(_('%s does not have a URL yet'), get_class($this)));
     return FALSE;
 }
 /**
  * Returns the URL of this object
  *
  * @api
  * @return string
  */
 public function Url()
 {
     return noslash($this->url) . '/tokens';
 }
 /**
  * Returns the IP address block for the Server or for a specific network
  *
  * @api
  * @param string $network - if supplied, then only the IP(s) for
  *      the specified network are returned. Otherwise, all IPs are returned.
  * @return object
  * @throws ServerIpsError
  */
 public function ips($network = NULL)
 {
     $url = noslash($this->Url('ips/' . $network));
     $response = $this->Service()->Request($url);
     if ($response->HttpStatus() >= 300) {
         throw new ServerIpsError(sprintf(_('Error in Server::ips(), status [%d], response [%s]'), $response->HttpStatus(), $response->HttpBody()));
     }
     $obj = json_decode($response->HttpBody());
     if ($this->CheckJsonError()) {
         return new \stdClass();
     } elseif (isset($obj->addresses)) {
         return $obj->addresses;
     } elseif (isset($obj->network)) {
         return $obj->network;
     } else {
         return new \stdClass();
     }
 }
 /**
  * Returns the URL of the service, selected from the connection's
  * serviceCatalog
  */
 public function Url($param = array())
 {
     return noslash(parent::Url($param));
 }
 /**
  * Constructs a specified URL from the subresource
  *
  * Given a subresource (e.g., "extensions"), this constructs the proper
  * URL and retrieves the resource.
  *
  * @param string $resource The resource requested; should NOT have slashes
  *      at the beginning or end
  * @return \stdClass object
  */
 private function GetMetaUrl($resource)
 {
     $urlbase = $this->get_endpoint($this->service_type, $this->service_name, $this->service_region, RAXSDK_URL_PUBLIC);
     if ($urlbase == '') {
         return array();
     }
     $ext_url = noslash($urlbase) . '/' . $resource;
     $response = $this->Request($ext_url);
     // check for NOT FOUND response
     if ($response->HttpStatus() == 404) {
         return array();
     }
     // check for error status
     if ($response->HttpStatus() >= 300) {
         throw new HttpError(sprintf(_('Error accessing [%s] - status [%d], response [%s]'), $urlbase, $response->HttpStatus(), $response->HttpBody()));
     }
     // we're good; proceed
     $obj = json_decode($response->HttpBody());
     if ($this->CheckJsonError()) {
         return FALSE;
     }
     return $obj;
 }