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