Cloudinary::domain_shard PHP Method

domain_shard() private static method

private static domain_shard ( $source )
    private static function domain_shard($source)
    {
        return (crc32($source) % 5 + 5) % 5 + 1;
    }

Usage Example

示例#1
0
 private static function unsigned_download_url_prefix($source, $cloud_name, $private_cdn, $cdn_subdomain, $secure_cdn_subdomain, $cname, $secure, $secure_distribution)
 {
     $shared_domain = !$private_cdn;
     $prefix = NULL;
     if ($secure) {
         if (empty($secure_distribution) || $secure_distribution == Cloudinary::OLD_AKAMAI_SHARED_CDN) {
             $secure_distribution = $private_cdn ? $cloud_name . '-res.cloudinary.com' : Cloudinary::SHARED_CDN;
         }
         if (empty($shared_domain)) {
             $shared_domain = $secure_distribution == Cloudinary::SHARED_CDN;
         }
         if (is_null($secure_cdn_subdomain) && $shared_domain) {
             $secure_cdn_subdomain = $cdn_subdomain;
         }
         if ($secure_cdn_subdomain) {
             $secure_distribution = str_replace('res.cloudinary.com', "res-" . Cloudinary::domain_shard($source) . ".cloudinary.com", $secure_distribution);
         }
         $prefix = "https://" . $secure_distribution;
     } else {
         if ($cname) {
             $subdomain = $cdn_subdomain ? "a" . Cloudinary::domain_shard($source) . '.' : "";
             $prefix = "http://" . $subdomain . $cname;
         } else {
             $host = implode(array($private_cdn ? $cloud_name . "-" : "", "res", $cdn_subdomain ? "-" . Cloudinary::domain_shard($source) : "", ".cloudinary.com"));
             $prefix = "http://" . $host;
         }
     }
     if ($shared_domain) {
         $prefix = $prefix . '/' . $cloud_name;
     }
     return $prefix;
 }