示例#1
0
 public static function getCdnHost($partner_id, $protocol = null, $hostType = null)
 {
     // in case the request came through https, force https url
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $protocol = 'https';
     }
     // temporary default is http since the system is not aligned to use https in all of its components (e.g. kmc)
     // right now, if a partner cdnHost is set to https:// the kmc wont work well if we reply with https prefix to its requests
     if ($protocol === null) {
         $protocol = 'http';
     }
     $partner = PartnerPeer::retrieveByPK($partner_id);
     if ($partner) {
         $whiteListHost = self::getWhiteListHost($partner);
         if (!is_null($whiteListHost)) {
             $cdnHost = $protocol . '://' . $whiteListHost;
             if (isset($_SERVER['SERVER_PORT'])) {
                 $cdnHost .= ":" . $_SERVER['SERVER_PORT'];
             }
             return $cdnHost;
         }
     }
     switch ($hostType) {
         case 'thumbnail':
             if ($partner && $partner->getThumbnailHost()) {
                 return preg_replace('/^https?/', $protocol, $partner->getThumbnailHost());
             }
             if ($partner && $partner->getCdnHost()) {
                 return preg_replace('/^https?/', $protocol, $partner->getCdnHost());
             }
             return requestUtils::getThumbnailCdnHost($protocol);
         case 'api':
             if ($protocol == 'https') {
                 $apiHost = kConf::hasParam('cdn_api_host_https') ? kConf::get('cdn_api_host_https') : kConf::get('www_host');
                 return 'https://' . $apiHost;
             } else {
                 $apiHost = kConf::hasParam('cdn_api_host') ? kConf::get('cdn_api_host') : kConf::get('www_host');
                 return 'http://' . $apiHost;
             }
             break;
         default:
             if ($partner && $partner->getCdnHost()) {
                 return preg_replace('/^https?/', $protocol, $partner->getCdnHost());
             }
             return requestUtils::getCdnHost($protocol);
     }
 }
示例#2
0
 public static function getCdnHost($partner_id, $protocol = null, $hostType = null)
 {
     // in case the request came through https, force https url
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $protocol = 'https';
     }
     // temporary default is http since the system is not aligned to use https in all of its components (e.g. kmc)
     // right now, if a partner cdnHost is set to https:// the kmc wont work well if we reply with https prefix to its requests
     if ($protocol === null) {
         $protocol = 'http';
     }
     $partner = PartnerPeer::retrieveByPK($partner_id);
     if (!$partner || !$partner->getCdnHost()) {
         return $hostType == "thumbnail" ? requestUtils::getThumbnailCdnHost($protocol) : requestUtils::getCdnHost($protocol);
     }
     $cdnHost = $partner->getCdnHost();
     // if a protocol was set manually (or by the temporary http default above) use it instead of the partner setting
     $cdnHost = preg_replace('/^https?/', $protocol, $cdnHost);
     return $cdnHost;
 }