Exemplo n.º 1
0
 public function apply()
 {
     if ($this->_cacheStatus == self::CACHE_STATUS_DISABLED) {
         kApiCache::disableCache();
         return;
     }
     // common cache fields
     foreach ($this->_extraFields as $extraField) {
         call_user_func_array(array('kApiCache', 'addExtraField'), $extraField);
     }
     // anonymous cache fields
     if ($this->_expiry) {
         kApiCache::setExpiry($this->_expiry);
     }
     if ($this->_cacheStatus == self::CACHE_STATUS_ANONYMOUS_ONLY) {
         kApiCache::disableConditionalCache();
         return;
     }
     // conditional cache fields
     if ($this->_conditionalCacheExpiry) {
         kApiCache::setConditionalCacheExpiry($this->_conditionalCacheExpiry);
     }
     kApiCache::addInvalidationKeys(array_keys($this->_invalidationKeys), $this->_invalidationTime);
     kApiCache::addSqlQueryConditions($this->_sqlConditions);
 }
 public function buildServeFlavors()
 {
     if ($this->getManifestRedirect() && $this->getHostName() != $_SERVER['HTTP_HOST']) {
         kApiCache::setConditionalCacheExpiry(600);
         // the result contains a KS so we shouldn't cache it for a long time
         $parsedUrl = parse_url($this->getUrl());
         $flavor = array('urlPrefix' => $this->params->getMediaProtocol() . '://' . $parsedUrl['host'], 'url' => $_SERVER["REQUEST_URI"]);
         return array($flavor);
     }
     return parent::buildServeFlavors();
 }
Exemplo n.º 3
0
 public function isScheduledNow($time = null)
 {
     if (is_null($time)) {
         $time = time();
         // entry scheduling status changes within 24H
         if ($this->getStartDate() && abs($this->getStartDate(null) - time()) <= 86400 || $this->getEndDate() && abs($this->getEndDate(null) - time()) <= 86400) {
             kApiCache::setConditionalCacheExpiry(600);
         }
         // entry scheduling status changes within 10 min
         if ($this->getStartDate() && abs($this->getStartDate(null) - time()) <= 600 || $this->getEndDate() && abs($this->getEndDate(null) - time()) <= 600) {
             kApiCache::setExpiry(60);
             kApiCache::setConditionalCacheExpiry(60);
         }
     }
     $startDateCheck = !$this->getStartDate() || $this->getStartDate(null) <= $time;
     $endDateCheck = !$this->getEndDate() || $this->getEndDate(null) >= $time;
     return $startDateCheck && $endDateCheck;
 }
Exemplo n.º 4
0
 private function serveHDNetwork()
 {
     kApiCache::setConditionalCacheExpiry(600);
     // the result contains a KS so we shouldn't cache it for a long time
     $mediaUrl = requestUtils::getHost() . str_replace("f4m", "smil", str_replace("hdnetwork", "hdnetworksmil", $_SERVER["REQUEST_URI"]));
     $renderer = new kF4MManifestRenderer(array(), $this->entryId);
     $renderer->mediaUrl = $mediaUrl;
     return $renderer;
 }
Exemplo n.º 5
0
 private function serveHDNetwork()
 {
     kApiCache::setConditionalCacheExpiry(600);
     // the result contains a KS so we shouldn't cache it for a long time
     if ($this->deliveryAttributes->getMediaProtocol() == 'https' && kConf::hasParam('cdn_api_host_https')) {
         $mediaUrl = "https://" . kConf::get('cdn_api_host_https');
     } else {
         $mediaUrl = "http://" . kConf::get('cdn_api_host');
     }
     $mediaUrl .= str_replace("f4m", "smil", str_replace("hdnetwork", "hdnetworksmil", $_SERVER["REQUEST_URI"]));
     $renderer = new kF4MManifestRenderer(array(), $this->entryId);
     $renderer->mediaUrl = $mediaUrl;
     return $renderer;
 }