/**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $uiconf_id = $this->getRequestParameter('uiconf_id');
     if (!$uiconf_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id');
     }
     $uiConf = uiConfPeer::retrieveByPK($uiconf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND);
     }
     $partner_id = $this->getRequestParameter('partner_id', $uiConf->getPartnerId());
     if (!$partner_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id');
     }
     $partner_host = myPartnerUtils::getHost($partner_id);
     $partner_cdnHost = myPartnerUtils::getCdnHost($partner_id);
     $use_cdn = $uiConf->getUseCdn();
     $host = $use_cdn ? $partner_cdnHost : $partner_host;
     $ui_conf_html5_url = $uiConf->getHtml5Url();
     if (kConf::hasMap("optimized_playback")) {
         $optimizedPlayback = kConf::getMap("optimized_playback");
         if (array_key_exists($partner_id, $optimizedPlayback)) {
             // force a specific kdp for the partner
             $params = $optimizedPlayback[$partner_id];
             if (array_key_exists('html5_url', $params)) {
                 $ui_conf_html5_url = $params['html5_url'];
             }
         }
     }
     if (kString::beginsWith($ui_conf_html5_url, "http")) {
         $url = $ui_conf_html5_url;
         // absolute URL
     } else {
         if ($ui_conf_html5_url) {
             $url = $host . $ui_conf_html5_url;
         } else {
             $html5_version = kConf::get('html5_version');
             $url = "{$host}/html5/html5lib/{$html5_version}/mwEmbedLoader.php";
         }
     }
     // append uiconf_id and partner id for optimizing loading of html5 library. append them only for "standard" urls by looking for the mwEmbedLoader.php suffix
     if (kString::endsWith($url, "mwEmbedLoader.php")) {
         $url .= "/p/{$partner_id}/uiconf_id/{$uiconf_id}";
         $entry_id = $this->getRequestParameter('entry_id');
         if ($entry_id) {
             $url .= "/entry_id/{$entry_id}";
         }
     }
     requestUtils::sendCachingHeaders(60);
     header("Pragma:");
     kFile::cacheRedirect($url);
     header("Location:{$url}");
     die;
 }
 private function dumpFile($file_path, $file_name, $wams_asset_id = null, $wams_url = null)
 {
     $relocate = $this->getRequestParameter("relocate");
     $directServe = $this->getRequestParameter("direct_serve");
     if (!$relocate) {
         $url = $_SERVER["REQUEST_URI"];
         if (strpos($url, "?") !== false) {
             $url .= "&relocate=";
         } else {
             $url .= "/relocate/";
         }
         $url .= $this->encodeUrl($file_name);
         kFile::cacheRedirect($url);
         header("Location: {$url}");
         die;
     } else {
         if (!$directServe) {
             header("Content-Disposition: attachment; filename=\"{$file_name}\"");
         }
         if (!empty($wams_asset_id)) {
             $fileSync = FileSyncPeer::retrieveByWamsAssetId($wams_asset_id);
             kWAMS::getInstance($fileSync->getPartnerId())->dumpFile($wams_asset_id, pathinfo($file_name, PATHINFO_EXTENSION));
         } else {
             $mime_type = kFile::mimeType($file_path);
             kFile::dumpFile($file_path, $mime_type);
         }
     }
 }
예제 #3
0
 /**
  * Will forward to the regular swf player according to the widget_id
  */
 public function execute()
 {
     $uiconf_id = $this->getRequestParameter('uiconf_id');
     if (!$uiconf_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id');
     }
     $uiConf = uiConfPeer::retrieveByPK($uiconf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND);
     }
     $partner_id = $this->getRequestParameter('partner_id', $uiConf->getPartnerId());
     if (!$partner_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id');
     }
     $widget_id = $this->getRequestParameter("widget_id", '_' . $partner_id);
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http";
     $host = myPartnerUtils::getCdnHost($partner_id, $protocol, 'api');
     $ui_conf_html5_url = $uiConf->getHtml5Url();
     if (kConf::hasMap("optimized_playback")) {
         $optimizedPlayback = kConf::getMap("optimized_playback");
         if (array_key_exists($partner_id, $optimizedPlayback)) {
             // force a specific kdp for the partner
             $params = $optimizedPlayback[$partner_id];
             if (array_key_exists('html5_url', $params)) {
                 $ui_conf_html5_url = $params['html5_url'];
             }
         }
     }
     $autoEmbed = $this->getRequestParameter('autoembed');
     $iframeEmbed = $this->getRequestParameter('iframeembed');
     $scriptName = $iframeEmbed ? 'mwEmbedFrame.php' : 'mwEmbedLoader.php';
     if ($ui_conf_html5_url && $iframeEmbed) {
         $ui_conf_html5_url = str_replace('mwEmbedLoader.php', 'mwEmbedFrame.php', $ui_conf_html5_url);
     }
     $relativeUrl = true;
     // true if ui_conf html5_url is relative (doesnt start with an http prefix)
     if (kString::beginsWith($ui_conf_html5_url, "http")) {
         $relativeUrl = false;
         $url = $ui_conf_html5_url;
         // absolute URL
     } else {
         if (!$iframeEmbed) {
             $host = "{$protocol}://" . kConf::get('html5lib_host') . "/";
         }
         if ($ui_conf_html5_url) {
             $url = $host . $ui_conf_html5_url;
         } else {
             $html5_version = kConf::get('html5_version');
             $url = "{$host}/html5/html5lib/{$html5_version}/" . $scriptName;
         }
     }
     // append uiconf_id and partner id for optimizing loading of html5 library. append them only for "standard" urls by looking for the mwEmbedLoader.php/mwEmbedFrame.php suffix
     if (kString::endsWith($url, $scriptName)) {
         $url .= "/p/{$partner_id}/uiconf_id/{$uiconf_id}";
         if (!$autoEmbed) {
             $entry_id = $this->getRequestParameter('entry_id');
             if ($entry_id) {
                 $url .= "/entry_id/{$entry_id}";
             }
         }
     }
     header("pragma:");
     if ($iframeEmbed) {
         $url .= (strpos($url, "?") === false ? "?" : "&") . 'wid=' . $widget_id . '&' . $_SERVER["QUERY_STRING"];
     } else {
         $params = "protocol={$protocol}&" . $_SERVER["QUERY_STRING"];
         $url .= (strpos($url, "?") === false ? "?" : "&") . $params;
         if ($relativeUrl) {
             header('Content-Type: application/javascript');
             kFileUtils::dumpUrl($url, true, false, array("X-Forwarded-For" => requestUtils::getRemoteAddress()));
         }
     }
     requestUtils::sendCachingHeaders(60, true, time());
     kFile::cacheRedirect($url);
     header("Location:{$url}");
     KExternalErrors::dieGracefully();
 }
예제 #4
0
 private function dumpFile($file_path, $file_name, $limit_file_size = 0)
 {
     $file_name = str_replace("\n", ' ', $file_name);
     $relocate = $this->getRequestParameter("relocate");
     $directServe = $this->getRequestParameter("direct_serve");
     if (!$relocate) {
         $url = $_SERVER["REQUEST_URI"];
         if (strpos($url, "?") !== false) {
             $url .= "&relocate=";
         } else {
             $url .= "/relocate/";
         }
         $url .= kString::stripInvalidUrlChars($file_name);
         kFile::cacheRedirect($url);
         header("Location: {$url}");
         KExternalErrors::dieGracefully();
     } else {
         if (!$directServe) {
             header("Content-Disposition: attachment; filename=\"{$file_name}\"");
         }
         $mime_type = kFile::mimeType($file_path);
         kFileUtils::dumpFile($file_path, $mime_type, null, $limit_file_size);
     }
 }