コード例 #1
0
 public static function dieError($errorCode, $message = null)
 {
     $description = self::$errorDescriptionMap[$errorCode];
     $args = func_get_args();
     if (count($args) > 1) {
         array_shift($args);
         $description = @call_user_func_array('sprintf', array_merge(array($description), $args));
     }
     if ($message) {
         $description .= ", {$message}";
     }
     KalturaLog::err("exiting on error {$errorCode} - {$description}");
     $headers = array();
     if (self::$responseCode) {
         $headers[] = self::$errorCodeMap[self::$responseCode];
     }
     $headers[] = "X-Kaltura-App: exiting on error {$errorCode} - {$description}";
     foreach ($headers as $header) {
         header($header);
     }
     header("X-Kaltura:error-{$errorCode}");
     $headers[] = "X-Kaltura:cached-error-{$errorCode}";
     self::terminateDispatch();
     if ($errorCode != self::ACCESS_CONTROL_RESTRICTED && $errorCode != self::IP_COUNTRY_BLOCKED && $_SERVER["REQUEST_METHOD"] == "GET") {
         requestUtils::sendCachingHeaders(self::CACHE_EXPIRY, true, time());
         if (function_exists('apc_store')) {
             $protocol = infraRequestUtils::getProtocol();
             $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'];
             $uri = $_SERVER["REQUEST_URI"];
             apc_store("exterror-{$protocol}://{$host}{$uri}", $headers, self::CACHE_EXPIRY);
         }
     }
     die;
 }
 /**
  * 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;
 }
 /**
  * @param string $playbackContext
  */
 public function output($playbackContext)
 {
     if ($this->tokenizer) {
         $this->tokenizer->setPlaybackContext($playbackContext);
     }
     $this->tokenizeUrls();
     $headers = $this->getHeaders();
     foreach ($headers as $header) {
         header($header);
     }
     requestUtils::sendCachingHeaders(kApiCache::hasExtraFields() ? 0 : $this->cachingHeadersAge);
     echo $this->getBody();
     die;
 }
 public static function dieError($errorCode, $message = null)
 {
     $description = self::$errorDescriptionMap[$errorCode];
     $args = func_get_args();
     if (count($args) > 1) {
         array_shift($args);
         $description = @call_user_func_array('sprintf', array_merge(array($description), $args));
     }
     if ($message) {
         $description .= ", {$message}";
     }
     KalturaLog::err("exiting on error {$errorCode} - {$description}");
     header("X-Kaltura:error-{$errorCode}");
     header("X-Kaltura-App: exiting on error {$errorCode} - {$description}");
     if ($errorCode != self::ACCESS_CONTROL_RESTRICTED && $errorCode != self::IP_COUNTRY_BLOCKED) {
         requestUtils::sendCachingHeaders(60);
     }
     die;
 }
コード例 #5
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();
 }