zone = $z; $this->useHTTPS = false; $this->useCdnDomains = false; $this->zoneCache = array(); } public function getUpHost($accessKey, $bucket) { $zone = $this->getZone($accessKey, $bucket); if ($this->useHTTPS === true) { $scheme = "https://"; } else { $scheme = "http://"; } $host = $zone->srcUpHosts[0]; if ($this->useCdnDomains === true) { $host = $zone->cdnUpHosts[0]; } return $scheme . $host; } public function getUpBackupHost($accessKey, $bucket) { $zone = $this->getZone($accessKey, $bucket); if ($this->useHTTPS === true) { $scheme = "https://"; } else { $scheme = "http://"; } $host = $zone->cdnUpHosts[0]; if ($this->useCdnDomains === true) { $host = $zone->srcUpHosts[0]; } return $scheme . $host; } public function getRsHost($accessKey, $bucket) { $zone = $this->getZone($accessKey, $bucket); if ($this->useHTTPS === true) { $scheme = "https://"; } else { $scheme = "http://"; } return $scheme . $zone->rsHost; } public function getRsfHost($accessKey, $bucket) { $zone = $this->getZone($accessKey, $bucket); if ($this->useHTTPS === true) { $scheme = "https://"; } else { $scheme = "http://"; } return $scheme . $zone->rsfHost; } public function getIovipHost($accessKey, $bucket) { $zone = $this->getZone($accessKey, $bucket); if ($this->useHTTPS === true) { $scheme = "https://"; } else { $scheme = "http://"; } return $scheme . $zone->iovipHost; } public function getApiHost($accessKey, $bucket) { $zone = $this->getZone($accessKey, $bucket); if ($this->useHTTPS === true) { $scheme = "https://"; } else { $scheme = "http://"; } return $scheme . $zone->apiHost; } private function getZone($accessKey, $bucket) { $cacheId = "$accessKey:$bucket"; if (isset($this->zoneCache[$cacheId])) { $zone = $this->zoneCache[$cacheId]; } elseif (isset($this->zone)) { $zone = $this->zone; $this->zoneCache[$cacheId] = $zone; } else { $zone = Zone::queryZone($accessKey, $bucket); $this->zoneCache[$cacheId] = $zone; } return $zone; } }