/** * @param $configName string * @param $context string */ public static function InitLogger($configName, $context = null) { if (KalturaLog::getLogger()) { // already initialized return; } if (function_exists('apc_fetch')) { $cacheKey = self::LOGGER_APC_CACHE_KEY_PREFIX . $configName; $logger = apc_fetch($cacheKey); if ($logger) { list($logger, $cacheVersionId) = $logger; if ($cacheVersionId == kConf::getCachedVersionId()) { KalturaLog::setLogger($logger); return; } } } try { $config = new Zend_Config(kConf::getMap('logger')); KalturaLog::initLog($config->{$configName}); if ($context) { KalturaLog::setContext($context); } if (function_exists('apc_store')) { apc_store($cacheKey, array(KalturaLog::getLogger(), kConf::getCachedVersionId())); } } catch (Zend_Config_Exception $ex) { } }
public function __construct() { // check that rabbit_mq.ini file exists if (kConf::hasMap('rabbit_mq')) { // check configuration is correctly set $rabbitConfig = kConf::getMap('rabbit_mq'); if (isset($rabbitConfig['username'])) { $this->username = $rabbitConfig['username']; } if (isset($rabbitConfig['password'])) { $this->password = $rabbitConfig['password']; } if (isset($rabbitConfig['server'])) { $this->MQserver = $rabbitConfig['server']; } if (isset($rabbitConfig['port'])) { $this->port = $rabbitConfig['port']; } if (isset($rabbitConfig['curl_port'])) { $this->curlPort = $rabbitConfig['curl_port']; } if (isset($rabbitConfig['timeout'])) { $this->timeout = $rabbitConfig['timeout']; } } else { KalturaLog::err("RabbitMQ configuration file (rabbit_mq.ini) wasn't found!"); } }
function getExcludeFileSyncMap() { $result = array(); $dcConfig = kConf::getMap("dc_config"); if (isset($dcConfig['sync_exclude_types'])) { foreach ($dcConfig['sync_exclude_types'] as $syncExcludeType) { $configObjectType = $syncExcludeType; $configObjectSubType = null; if (strpos($syncExcludeType, ':') > 0) { list($configObjectType, $configObjectSubType) = explode(':', $syncExcludeType, 2); } // translate api dynamic enum, such as contentDistribution.EntryDistribution - {plugin name}.{object name} if (!is_numeric($configObjectType)) { $configObjectType = kPluginableEnumsManager::apiToCore('FileSyncObjectType', $configObjectType); } // translate api dynamic enum, including the enum type, such as conversionEngineType.mp4box.Mp4box - {enum class name}.{plugin name}.{object name} if (!is_null($configObjectSubType) && !is_numeric($configObjectSubType)) { list($enumType, $configObjectSubType) = explode('.', $configObjectSubType); $configObjectSubType = kPluginableEnumsManager::apiToCore($enumType, $configObjectSubType); } if (!isset($result[$configObjectType])) { $result[$configObjectType] = array(); } if (!is_null($configObjectSubType)) { $result[$configObjectType][] = $configObjectSubType; } } } return $result; }
public static function getForcedDeliveryTypeFromConfig($key) { $playersConfig = kConf::getMap('players'); if (is_array($playersConfig) && isset($playersConfig['forced_delivery_types'])) { $deliveryTypeConfig = $playersConfig['forced_delivery_types']; if (isset($deliveryTypeConfig[$key])) { return $deliveryTypeConfig[$key]; } } return null; }
/** * 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; }
public static function getConfigParam($configName, $key) { $config = kConf::getMap($configName); if (!is_array($config)) { KalturaLog::err($configName . ' config section is not defined'); return null; } if (!isset($config[$key])) { KalturaLog::err('The key ' . $key . ' was not found in the ' . $configName . ' config section'); return null; } return $config[$key]; }
public function getPlaybackHost($protocol = 'http', $format = null, $deliveryType = null) { $mediaServerGlobalConfig = array(); if (kConf::hasMap('media_servers')) { $mediaServerGlobalConfig = array_merge($mediaServerGlobalConfig, kConf::getMap('media_servers')); } if ($this->partner_media_server_config) { $mediaServerGlobalConfig = array_merge($mediaServerGlobalConfig, $this->partner_media_server_config); } $domain = $this->getDomainByProtocolAndFormat($mediaServerGlobalConfig, $protocol, $format); $port = $this->getPortByProtocolAndFormat($mediaServerGlobalConfig, $protocol, $format); $appPrefix = $this->getApplicationPrefix($mediaServerGlobalConfig); return "{$domain}:{$port}/{$appPrefix}"; }
public static function getAllDcs($include_current = false) { $dc_config = kConf::getMap("dc_config"); $dc_list = $dc_config["list"]; if ($include_current == false) { unset($dc_list[$dc_config["current"]]); } $fixed_list = array(); foreach ($dc_list as $dc_id => $dc_props) { $dc_props["id"] = $dc_id; $fixed_list[] = $dc_props; } return $fixed_list; }
function setCacheExpiry($entriesCount, $feedId) { $expiryArr = kConf::hasMap("v3cache_getfeed_expiry") ? kConf::getMap("v3cache_getfeed_expiry") : array(); foreach ($expiryArr as $item) { if ($item["key"] == "partnerId" && $item["value"] == kCurrentContext::$partner_id || $item["key"] == "feedId" && $item["value"] == $feedId) { KalturaResponseCacher::setExpiry($item["expiry"]); return; } } $expiry = kConf::get("v3cache_getfeed_default_cache_time_frame", 'local', 86400); if (kConf::hasParam("v3cache_getfeed_short_limits_array")) { $shortLimits = kConf::get("v3cache_getfeed_short_limits_array"); } else { $shortLimits = array(50 => 900, 100 => 1800, 200 => 3600, 400 => 7200); } foreach ($shortLimits as $numOfEntries => $cacheTimeFrame) { if ($entriesCount <= $numOfEntries) { $expiry = min($expiry, $cacheTimeFrame); } } KalturaResponseCacher::setExpiry($expiry); }
/** * Check if specific file sync that belong to object type and sub type should be synced * * @param int $objectType * @param int $objectSubType * @return bool */ public static function shouldSyncFileObjectType($fileSync) { if (is_null(self::$excludedSyncFileObjectTypes)) { self::$excludedSyncFileObjectTypes = array(); $dcConfig = kConf::getMap("dc_config"); if (isset($dcConfig['sync_exclude_types'])) { foreach ($dcConfig['sync_exclude_types'] as $syncExcludeType) { $configObjectType = $syncExcludeType; $configObjectSubType = null; if (strpos($syncExcludeType, ':') > 0) { list($configObjectType, $configObjectSubType) = explode(':', $syncExcludeType, 2); } // translate api dynamic enum, such as contentDistribution.EntryDistribution - {plugin name}.{object name} if (!is_numeric($configObjectType)) { $configObjectType = kPluginableEnumsManager::apiToCore('FileSyncObjectType', $configObjectType); } // translate api dynamic enum, including the enum type, such as conversionEngineType.mp4box.Mp4box - {enum class name}.{plugin name}.{object name} if (!is_null($configObjectSubType) && !is_numeric($configObjectSubType)) { list($enumType, $configObjectSubType) = explode('.', $configObjectSubType); $configObjectSubType = kPluginableEnumsManager::apiToCore($enumType, $configObjectSubType); } if (!isset(self::$excludedSyncFileObjectTypes[$configObjectType])) { self::$excludedSyncFileObjectTypes[$configObjectType] = array(); } if (!is_null($configObjectSubType)) { self::$excludedSyncFileObjectTypes[$configObjectType][] = $configObjectSubType; } } } } if (!isset(self::$excludedSyncFileObjectTypes[$fileSync->getObjectType()])) { return true; } if (count(self::$excludedSyncFileObjectTypes[$fileSync->getObjectType()]) && !in_array($fileSync->getObjectSubType(), self::$excludedSyncFileObjectTypes[$fileSync->getObjectType()])) { return true; } return false; }
if ($kConf->hasParam('remote_addr_header_salt')) { $wgKalturaRemoteAddressSalt = $kConf->get('remote_addr_header_salt'); } // Disable Apple HLS if defined in kConf if ($kConf->hasParam('use_apple_adaptive')) { $wgKalturaUseAppleAdaptive = $kConf->get('use_apple_adaptive'); } // Get Kaltura Supported API Features if ($kConf->hasParam('features')) { $wgKalturaApiFeatures = $kConf->get('features'); } // Allow Iframe to connect remote service $wgKalturaAllowIframeRemoteService = true; // Set debug for true (testing only) $wgEnableScriptDebug = false; // Get PlayReady License URL if ($kConf->hasMap('playReady')) { $playReadyMap = $kConf->getMap('playReady'); if ($playReadyMap) { $wgKalturaLicenseServerUrl = $playReadyMap['license_server_url']; } } // A helper function to get full URL of host function wgGetUrl($hostKey = null) { global $wgHTTPProtocol, $wgServerPort, $kConf; if ($hostKey && $kConf->hasParam($hostKey)) { return $wgHTTPProtocol . '://' . $kConf->get($hostKey) . $wgServerPort; } return null; }
/** * This action delivers entry-related data, based on the user's context: access control, restriction, playback format and storage information. * @action getContextData * @param string $entryId * @param KalturaEntryContextDataParams $contextDataParams * @return KalturaEntryContextDataResult */ public function getContextData($entryId, KalturaEntryContextDataParams $contextDataParams) { $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } $ks = $this->getKs(); $isAdmin = false; if ($ks) { $isAdmin = $ks->isAdmin(); } $accessControl = $dbEntry->getAccessControl(); /* @var $accessControl accessControl */ $result = new KalturaEntryContextDataResult(); $result->isAdmin = $isAdmin; $result->isScheduledNow = $dbEntry->isScheduledNow($contextDataParams->time); if ($dbEntry->getStartDate() && abs($dbEntry->getStartDate(null) - time()) <= 86400 || $dbEntry->getEndDate() && abs($dbEntry->getEndDate(null) - time()) <= 86400) { KalturaResponseCacher::setConditionalCacheExpiry(600); } if ($accessControl && $accessControl->hasRules()) { $disableCache = true; if (kConf::hasMap("optimized_playback")) { $partnerId = $accessControl->getPartnerId(); $optimizedPlayback = kConf::getMap("optimized_playback"); if (array_key_exists($partnerId, $optimizedPlayback)) { $params = $optimizedPlayback[$partnerId]; if (array_key_exists('cache_kdp_acccess_control', $params) && $params['cache_kdp_acccess_control']) { $disableCache = false; } } } $accessControlScope = $accessControl->getScope(); $contextDataParams->toObject($accessControlScope); $accessControlScope->setEntryId($entryId); $result->isAdmin = $accessControlScope->getKs() && $accessControlScope->getKs()->isAdmin(); $dbResult = new kEntryContextDataResult(); if ($accessControl->applyContext($dbResult) && $disableCache) { KalturaResponseCacher::disableCache(); } $result->fromObject($dbResult); } $partner = PartnerPeer::retrieveByPK($dbEntry->getPartnerId()); if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE_DELIVERY_PRIORITY, $dbEntry->getPartnerId()) && $partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) { if (is_null($contextDataParams->flavorAssetId)) { if ($contextDataParams->flavorTags) { $assets = assetPeer::retrieveReadyByEntryIdAndTag($entryId, $contextDataParams->flavorTags); $asset = reset($assets); } else { $asset = assetPeer::retrieveBestPlayByEntryId($entryId); } if (!$asset) { throw new KalturaAPIException(KalturaErrors::NO_FLAVORS_FOUND, $entryId); } } else { $asset = assetPeer::retrieveByPK($contextDataParams->flavorAssetId); if (!$asset) { throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $contextDataParams->flavorAssetId); } } if (!$asset) { throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $entryId); } $assetSyncKey = $asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $fileSyncs = kFileSyncUtils::getAllReadyExternalFileSyncsForKey($assetSyncKey); $storageProfilesXML = new SimpleXMLElement("<StorageProfiles/>"); foreach ($fileSyncs as $fileSync) { $storageProfileId = $fileSync->getDc(); $storageProfile = StorageProfilePeer::retrieveByPK($storageProfileId); if (!$storageProfile->getDeliveryRmpBaseUrl() && (!$contextDataParams->streamerType || $contextDataParams->streamerType == StorageProfile::PLAY_FORMAT_AUTO)) { $contextDataParams->streamerType = StorageProfile::PLAY_FORMAT_HTTP; $contextDataParams->mediaProtocol = StorageProfile::PLAY_FORMAT_HTTP; } $storageProfileXML = $storageProfilesXML->addChild("StorageProfile"); $storageProfileXML->addAttribute("storageProfileId", $storageProfileId); $storageProfileXML->addChild("Name", $storageProfile->getName()); $storageProfileXML->addChild("SystemName", $storageProfile->getSystemName()); } $result->storageProfilesXML = $storageProfilesXML->saveXML(); } if ($contextDataParams->streamerType && $contextDataParams->streamerType != StorageProfile::PLAY_FORMAT_AUTO) { $result->streamerType = $contextDataParams->streamerType; $result->mediaProtocol = $contextDataParams->mediaProtocol ? $contextDataParams->mediaProtocol : $contextDataParams->streamerType; } else { $result->streamerType = $this->getPartner()->getStreamerType(); if (!$result->streamerType) { $result->streamerType = StorageProfile::PLAY_FORMAT_HTTP; } $result->mediaProtocol = $this->getPartner()->getMediaProtocol(); if (!$result->mediaProtocol) { $result->mediaProtocol = StorageProfile::PLAY_FORMAT_HTTP; } } return $result; }
protected function enforceEncryption() { $playbackParams = array(); if (kConf::hasMap("optimized_playback")) { $partnerId = $this->entry->getPartnerId(); $optimizedPlayback = kConf::getMap("optimized_playback"); if (array_key_exists($partnerId, $optimizedPlayback)) { $playbackParams = $optimizedPlayback[$partnerId]; } } // TODO add protocol limitation action to access control if (array_key_exists('enforce_encryption', $playbackParams) && $playbackParams['enforce_encryption']) { if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') { KExternalErrors::dieError(KExternalErrors::ACCESS_CONTROL_RESTRICTED, 'unencrypted manifest request - forbidden'); } $allowedProtocols = array('https', 'rtmpe', 'rtmpte'); if (!in_array(strtolower($this->deliveryAttributes->getMediaProtocol()), $allowedProtocols)) { KExternalErrors::dieError(KExternalErrors::ACCESS_CONTROL_RESTRICTED, 'unencrypted playback protocol - forbidden'); } } }
/** * 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(); }
$configDir->close(); //try //{ // $config = new Zend_Config(kConf::getAll()); // $configWriter = new Zend_Config_Writer_Xml(); // $configWriter->write($xmlFilename, $config); // KalturaLog::info("Saved config to history [$xmlFilename]"); //} //catch(Exception $e) //{ // KalturaLog::err($e->getMessage()); //} $reports = array(); foreach ($tamplates as $mapName => $tamplate) { try { $map = kConf::getMap($mapName); } catch (Exception $e) { $msg = $e->getMessage(); $reports[] = $msg; KalturaLog::debug($msg); continue; } $iniFile = realpath("{$configPath}/{$mapName}.ini"); $mapReports = compareMaps($mapName, $tamplate, $map); if (count($mapReports)) { $reports[] = "Config map [{$mapName}] file [{$iniFile}] issues:"; foreach ($mapReports as $report) { $reports[] = " - {$report}"; } $reports[] = ''; } else {
public function getLiveStreamBroadcastUrlConfigurations($dc = null) { $config = !is_null($dc) ? kConf::get($dc, 'broadcast') : kConf::getMap('broadcast'); $partnerConfig = $this->getFromCustomData($dc, 'live_stream_broadcast_url_configurations'); if ($partnerConfig) { $config = kConf::mergeConfigItem($config, $partnerConfig, true); } return $config; }
private function applyAccessControlOnContextData(accessControlScope $accessControlScope) { if ($this->isAdmin) { return; } $accessControl = $this->entry->getAccessControl(); /* @var $accessControl accessControl */ if ($accessControl && $accessControl->hasRules()) { $this->isSecured = true; if (kConf::hasMap("optimized_playback")) { $partnerId = $accessControl->getPartnerId(); $optimizedPlayback = kConf::getMap("optimized_playback"); if (array_key_exists($partnerId, $optimizedPlayback)) { $params = $optimizedPlayback[$partnerId]; if (array_key_exists('cache_kdp_access_control', $params) && $params['cache_kdp_access_control'] && (strpos(strtolower(kCurrentContext::$client_lang), "kdp") !== false || strpos(strtolower(kCurrentContext::$client_lang), "html") !== false)) { return; } } } $accessControlScope->setEntryId($this->entry->getId()); $this->isAdmin = $accessControlScope->getKs() && $accessControlScope->getKs()->isAdmin(); $this->disableCache = $accessControl->applyContext($this->contextDataResult); } }
/** * @param string $service * @return KalturaMediaServerClient */ public function getWebService($service) { if (!isset(self::$webServices[$service])) { return null; } $serviceClass = self::$webServices[$service]; $domain = $this->getHostname(); $port = MediaServer::DEFAULT_WEB_SERVICES_PORT; $protocol = 'http'; if (kConf::hasMap('media_servers')) { $mediaServers = kConf::getMap('media_servers'); if (isset($mediaServers['service-port'])) { $port = $mediaServers['service-port']; } if (isset($mediaServers['protocol'])) { $protocol = $mediaServers['protocol']; } if (isset($mediaServers['internal_domain'])) { $domain = $mediaServers['internal_domain']; } elseif (isset($mediaServers['internal_search_regex_pattern']) && isset($mediaServers['internal_replacement'])) { $domain = preg_replace($mediaServers['internal_search_regex_pattern'], $mediaServers['internal_replacement'], $domain); } if (isset($mediaServers[$this->getHostname()])) { $mediaServer = $mediaServers[$this->getHostname()]; if (isset($mediaServer['service-port'])) { $port = $mediaServer['service-port']; } if (isset($mediaServer['protocol'])) { $protocol = $mediaServer['protocol']; } if (isset($mediaServer['internal_domain'])) { $domain = $mediaServer['internal_domain']; } } } $url = "{$protocol}://{$domain}:{$port}/{$service}?wsdl"; KalturaLog::debug("Service URL: {$url}"); return new $serviceClass($url); }
/** * find the url manager which sent the current request * @return string */ public static function getUrlManagerIdentifyRequest() { $urlManagers = kConf::getMap('url_managers'); foreach ($urlManagers as $cdnHost => $data) { $class = $data["class"]; $params = @$data["params"]; $manager = new $class(null, $params); $result = $manager->identifyRequest(); if ($result !== false) { return $result; } } return false; }
/** * @action getPlayerDeliveryTypes * @return KalturaPlayerDeliveryTypesArray */ public function getPlayerDeliveryTypesAction() { $map = kConf::getMap('players'); return KalturaPlayerDeliveryTypesArray::fromDbArray($map['delivery_types'], $this->getResponseProfile()); }
private function initCacheModes() { if (!is_null($this->_cacheModes)) { return; } $this->_cacheModes = array(); if ($this->_cacheStatus == self::CACHE_STATUS_DISABLED) { return; } $ks = null; try { $ks = kSessionUtils::crackKs($this->_ks); } catch (Exception $e) { KalturaLog::err($e->getMessage()); self::disableCache(); return; } if ($ks && ($ks->valid_until <= time() || $ks->isSetLimitAction())) { self::disableCache(); return; } $isAnonymous = !$ks || !$ks->isAdmin() && ($ks->user === "0" || $ks->user === null); // force caching of actions listed in kConf even if admin ks is used if (!$isAnonymous && kConf::hasMap('v3cache_ignore_admin_ks')) { $v3cacheIgnoreAdminKS = kConf::getMap('v3cache_ignore_admin_ks'); if (isset($v3cacheIgnoreAdminKS[$ks->partner_id])) { $actions = explode(',', $v3cacheIgnoreAdminKS[$ks->partner_id]); foreach ($actions as $action) { list($serviceId, $actionId) = explode('.', $action); if ($this->_params['service'] == $serviceId && $this->_params['action'] == $actionId) { $isAnonymous = true; break; } } } } if (!$isAnonymous && $this->_cacheStatus == self::CACHE_STATUS_ANONYMOUS_ONLY) { self::disableCache(); return; } if ($isAnonymous) { $this->_cacheModes[] = self::CACHE_MODE_ANONYMOUS; } if ($this->_cacheStatus != self::CACHE_STATUS_ANONYMOUS_ONLY) { $this->_cacheModes[] = self::CACHE_MODE_CONDITIONAL; } }
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*")); KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/sphinx/' . basename(__FILE__) . '.cache'); KAutoloader::register(); $skipExecutedUpdates = false; error_reporting(E_ALL); KalturaLog::setLogger(new KalturaStdoutLogger()); $hostname = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : gethostname(); $configFile = ROOT_DIR . "/configurations/sphinx/populate/{$hostname}.ini"; if (!file_exists($configFile)) { KalturaLog::err("Configuration file [{$configFile}] not found."); exit(-1); } $config = parse_ini_file($configFile); $sphinxServer = $config['sphinxServer']; $sphinxPort = isset($config['sphinxPort']) ? $config['sphinxPort'] : 9312; $systemSettings = kConf::getMap('system'); if (!$systemSettings || !$systemSettings['LOG_DIR']) { KalturaLog::err("LOG_DIR not found in system configuration."); exit(-1); } $pid = $systemSettings['LOG_DIR'] . '/populate.pid'; if (file_exists($pid)) { KalturaLog::err("Scheduler already running - pid[" . file_get_contents($pid) . "]"); exit(1); } file_put_contents($pid, getmypid()); $dbConf = kConf::getDB(); DbManager::setConfig($dbConf); DbManager::initialize(); $limit = 1000; // The number of sphinxLog records we want to query
protected function addInternalCacheParams() { $this->_params['___cache___protocol'] = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http"; $this->_params['___cache___host'] = @$_SERVER['HTTP_HOST']; $this->_params['___cache___version'] = self::CACHE_VERSION; $this->_params['___internal'] = intval(kIpAddressUtils::isInternalIp()); if (kConf::hasMap("optimized_playback")) { $optimizedPlayback = kConf::getMap("optimized_playback"); if (array_key_exists($this->_ksPartnerId, $optimizedPlayback)) { $params = $optimizedPlayback[$this->_ksPartnerId]; if (array_key_exists('cache_kdp_access_control', $params) && $params['cache_kdp_access_control']) { $clientTag = 'none'; if (strpos(strtolower($this->clientTag), "kdp") !== false || strpos(strtolower($this->clientTag), "html") !== false) { $clientTag = 'player'; } $this->_params['___cache___clientTag'] = $clientTag; } } } if ($this->clientTag) { $matches = null; if (preg_match("/cache_st:(\\d+)/", $this->clientTag, $matches)) { if ($matches[1] > time()) { $this->_params['___cache___start'] = $matches[1]; } } } }
public function execute() { $this->seekFrom = $this->getRequestParameter("seekFrom", -1); if ($this->seekFrom <= 0) { $this->seekFrom = -1; } $this->clipTo = $this->getRequestParameter("clipTo", 0); $this->deliveryCode = $this->getRequestParameter("deliveryCode", null); $playbackContext = $this->getRequestParameter("playbackContext", null); $this->protocol = $this->getRequestParameter("protocol", null); if (!$this->protocol || $this->protocol === "null") { $this->protocol = StorageProfile::PLAY_FORMAT_HTTP; } $this->format = $this->getRequestParameter("format"); if (!$this->format) { $this->format = StorageProfile::PLAY_FORMAT_HTTP; } $this->tags = $this->getRequestParameter("tags", null); if (!$this->tags) { switch ($this->format) { case StorageProfile::PLAY_FORMAT_SILVER_LIGHT: $this->tags = array(array(assetParams::TAG_SLWEB)); break; case StorageProfile::PLAY_FORMAT_APPLE_HTTP: case StorageProfile::PLAY_FORMAT_HDS: $this->tags = array(array(assetParams::TAG_APPLEMBR), array('ipadnew', 'iphonenew'), array('ipad', 'iphone')); break; default: $this->tags = array(array(assetParams::TAG_MBR), array(assetParams::TAG_WEB)); } } else { $this->tags = array(array($this->tags)); } $this->cdnHost = $this->getRequestParameter("cdnHost", null); $this->preferredBitrate = $this->getRequestParameter("preferredBitrate", null); $this->maxBitrate = $this->getRequestParameter("maxBitrate", null); if ($this->maxBitrate && (!is_numeric($this->maxBitrate) || $this->maxBitrate <= 0)) { KExternalErrors::dieError(KExternalErrors::INVALID_MAX_BITRATE); } $this->initEntry(); $this->initFlavorIds(); $this->storageId = $this->getRequestParameter("storageId", null); $this->validateStorageId(); $partner = $this->entry->getPartner(); if (!$this->cdnHost || $partner->getForceCdnHost()) { $this->cdnHost = myPartnerUtils::getCdnHost($this->entry->getPartnerId(), $this->protocol); } $playbackParams = array(); if (kConf::hasMap("optimized_playback")) { $partnerId = $this->entry->getPartnerId(); $optimizedPlayback = kConf::getMap("optimized_playback"); if (array_key_exists($partnerId, $optimizedPlayback)) { $playbackParams = $optimizedPlayback[$partnerId]; } } if (array_key_exists('enforce_encryption', $playbackParams) && $playbackParams['enforce_encryption']) { if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') { KExternalErrors::dieError(KExternalErrors::ACCESS_CONTROL_RESTRICTED, 'unencrypted manifest request - forbidden'); } if (strtolower($this->protocol) != 'https') { KExternalErrors::dieError(KExternalErrors::ACCESS_CONTROL_RESTRICTED, 'unencrypted playback protocol - forbidden'); } } $renderer = null; switch ($this->format) { case StorageProfile::PLAY_FORMAT_HTTP: $renderer = $this->serveHttp(); break; case StorageProfile::PLAY_FORMAT_RTMP: $renderer = $this->serveRtmp(); break; case StorageProfile::PLAY_FORMAT_SILVER_LIGHT: $renderer = $this->serveSilverLight(); break; case StorageProfile::PLAY_FORMAT_APPLE_HTTP: $renderer = $this->serveAppleHttp(); break; case StorageProfile::PLAY_FORMAT_HDS: $renderer = $this->serveHds(); break; case "url": $this->format = "http"; // build url for an http delivery $renderer = $this->serveUrl(); break; case "rtsp": $renderer = $this->serveRtsp(); break; case "hdnetworksmil": $renderer = $this->serveHDNetworkSmil(); break; case "hdnetwork": $renderer = $this->serveHDNetwork(); break; case "hdnetworkmanifest": $renderer = $this->serveHDNetworkManifest(); break; } if (!$renderer) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'This format is unsupported'); } $canCacheAccessControl = false; if (!$this->secureEntryHelper) { $canCacheAccessControl = true; // TODO: reconsider this if/when expired ktokens will be used } else { if (!$this->secureEntryHelper->shouldDisableCache() && !$this->secureEntryHelper->isKsAdmin() && ($this->secureEntryHelper->isKsWidget() || !$this->secureEntryHelper->hasRules())) { $canCacheAccessControl = true; } } if (!$renderer->tokenizer && $canCacheAccessControl) { // Note: kApiCache::hasExtraFields is checked in kManifestRenderers $renderer->cachingHeadersAge = 60; } if (!$this->secureEntryHelper || !$this->secureEntryHelper->shouldDisableCache()) { $cache = kPlayManifestCacher::getInstance(); $cache->storeCache($renderer); } $renderer->output($playbackContext); }
public function execute() { $this->uiconf_id = intval($this->getRequestParameter('uiconf_id')); if (!$this->uiconf_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id'); } $this->uiConf = uiConfPeer::retrieveByPK($this->uiconf_id); if (!$this->uiConf) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND); } $this->partner_id = intval($this->getRequestParameter('partner_id', $this->uiConf->getPartnerId())); if (!$this->partner_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id'); } // Single Player parameters $this->entry_id = htmlspecialchars($this->getRequestParameter('entry_id')); if ($this->entry_id) { $entry = entryPeer::retrieveByPK($this->entry_id); if ($entry) { $this->entry_name = $entry->getName(); $this->entry_description = $entry->getDescription(); $this->entry_thumbnail_url = $entry->getThumbnailUrl(); $this->entry_thumbnail_secure_url = $entry->getThumbnailUrl(null, 'https'); $this->entry_duration = $entry->getDuration(); $flavor_tag = $this->getRequestParameter('flavor_tag', 'iphone'); $flavor_assets = assetPeer::retrieveReadyFlavorsByEntryIdAndTag($this->entry_id, $flavor_tag); $flavor_asset = reset($flavor_assets); /* @var $flavor_asset flavorAsset */ $this->flavor_asset_id = null; if ($flavor_asset) { $this->flavor_asset_id = $flavor_asset->getId(); } } else { $this->entry_id = null; } } $playlist_name = null; $playlist_description = null; $embed_host = kConf::hasParam('cdn_api_host') ? kConf::get('cdn_api_host') : kConf::get('www_host'); $embed_host_https = kConf::hasParam('cdn_api_host_https') ? kConf::get('cdn_api_host_https') : kConf::get('www_host'); // Check if HTTPS enabled and set protocol $https_enabled = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; $protocol = $https_enabled ? 'https' : 'http'; $this->framed = isset($_GET['framed']) ? true : false; $this->embedType = $this->getRequestParameter('embed') ? $this->getRequestParameter('embed') : 'legacy'; $cacheSt = time() + 60 * 15; // Basic embed options $embedParams = array('host' => $embed_host, 'securedHost' => $embed_host_https, 'partnerId' => $this->partner_id, 'protocol' => $protocol, 'embedType' => $this->embedType, 'uiConfId' => $this->uiconf_id, 'width' => $this->uiConf->getWidth(), 'height' => $this->uiConf->getHeight(), 'includeKalturaLinks' => true, 'cacheSt' => $cacheSt); // Add entry Id and Metadata if ($this->entry_id) { $embedParams['entryId'] = $this->entry_id; $embedParams['includeSeoMetadata'] = true; $embedParams['entryMeta'] = array('name' => $this->entry_name, 'description' => $this->entry_description, 'thumbnailUrl' => $this->entry_thumbnail_url, 'duration' => $this->entry_duration); } // Add flashVars if (isset($_GET['flashvars'])) { $flashVars = array(); if (is_array($_GET['flashvars'])) { foreach ($_GET['flashvars'] as $key => $val) { if ($this->isJson($val)) { $val = json_decode($val, true); } $flashVars[$key] = $val; } } //Check for playlist name if (isset($_GET['flashvars']['playlistAPI.kpl0Name'])) { $playlist_name = htmlspecialchars($_GET['flashvars']['playlistAPI.kpl0Name']); } // Get playlist name from playlist id if (isset($_GET['flashvars']['playlistAPI.kpl0Id'])) { $playlistId = htmlspecialchars($_GET['flashvars']['playlistAPI.kpl0Id']); $playlist = entryPeer::retrieveByPK($playlistId); if ($playlist) { $playlist_name = $playlist->getName(); $playlist_description = $playlist->getDescription(); } } } else { $this->partner_host = myPartnerUtils::getHost($this->partner_id); $this->playlist_id = htmlspecialchars($this->getRequestParameter('playlist_id')); // Get delivery types from player.ini $map = kConf::getMap('players'); $deliveryTypes = $map['delivery_types']; $flashVars = array(); if (isset($deliveryTypes[$this->getRequestParameter('delivery')]) && isset($deliveryTypes[$this->getRequestParameter('delivery')]['flashvars'])) { $flashVars = $deliveryTypes[$this->getRequestParameter('delivery')]['flashvars']; } if ($this->playlist_id && $this->playlist_id != 'multitab_playlist') { // build playlist url $playlist_url = $this->partner_host . "/index.php/partnerservices2/executeplaylist?"; $playlist_url .= "partner_id=" . $this->partner_id . "&subp_id=" . $this->partner_id . "00&format=8&ks={ks}&playlist_id=" . $this->playlist_id; $playlist_name = htmlspecialchars($this->getRequestParameter('playlist_name')); // Add playlist flashVars $flashVars["playlistAPI.kpl0Name"] = $playlist_name; $flashVars["playlistAPI.kpl0Url"] = urlencode($playlist_url); } } // Don't include flashvars if empty array if (count($flashVars)) { $embedParams['flashVars'] = $flashVars; } // Export embedParams to our view $this->embedParams = $embedParams; // Build SWF Path $swfPath = "/index.php/kwidget"; $swfPath .= "/cache_st/" . $cacheSt; $swfPath .= "/wid/_" . $this->partner_id; $swfPath .= "/uiconf_id/" . $this->uiconf_id; if ($this->entry_id) { $swfPath .= "/entry_id/" . $this->entry_id; } // Set SWF URLs $this->swfUrl = 'http://' . $embed_host . $swfPath; $this->swfSecureUrl = 'https://' . $embed_host_https . $swfPath; // URL to this page $port = $_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : ''; $this->pageURL = $protocol . '://' . $_SERVER["SERVER_NAME"] . $port . $_SERVER["REQUEST_URI"]; // Set flavor Url if (isset($this->flavor_asset_id)) { $this->flavorUrl = 'https://' . $embed_host_https . '/p/' . $this->partner_id . '/sp/' . $this->partner_id . '00/playManifest/entryId/' . $this->entry_id . '/flavorId/' . $this->flavor_asset_id . '/format/url/protocol/' . $protocol . '/a.mp4'; } // set player url $this->playerUrl = 'https://' . $embed_host_https . '/p/' . $this->partner_id . '/sp/' . $this->partner_id . '00/embedIframeJs/uiconf_id/' . $this->uiconf_id . '/partner_id/' . $this->partner_id . '?iframeembed=true&entry_id=' . $this->entry_id . '&flashvars[streamerType]=auto'; // Set Page name if (!$this->entry_id) { $this->entry_name = $playlist_name ? $playlist_name : 'Kaltura Player'; $this->entry_description = $playlist_description ? $playlist_description : ''; } }
public static function getWhitelabelData(Partner $partner, $param = null) { // no param, return null if (!$param) { return null; } if (kConf::hasMap("whitelabel")) { $whitelabel = kConf::getMap("whitelabel"); $params = array(); // Search for partner Id if (array_key_exists($partner->getId(), $whitelabel)) { $params = $whitelabel[$partner->getId()]; } else { if (array_key_exists($partner->getPartnerParentId(), $whitelabel)) { $params = $whitelabel[$partner->getPartnerParentId()]; } } // If we have params, find out param if (is_array($params) && array_key_exists($param, $params)) { return $params[$param]; } return null; } return null; }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $uv_cookie = @$_COOKIE['uv']; if (strlen($uv_cookie) != 35) { $uv_cookie = "uv_" . md5(uniqid(rand(), true)); } setrawcookie('uv', $uv_cookie, time() + 3600 * 24 * 365, '/'); // check if this is a request for the kdp without a wrapper // in case of an application loading the kdp (e.g. kmc) $nowrapper = $this->getRequestParameter("nowrapper", false); // allow caching if either the cache start time (cache_st) parameter // wasn't specified or if it is past the specified time $cache_st = $this->getRequestParameter("cache_st"); $allowCache = !$cache_st || $cache_st < time(); $referer = @$_SERVER['HTTP_REFERER']; $externalInterfaceDisabled = strstr($referer, "bebo.com") === false && strstr($referer, "myspace.com") === false && strstr($referer, "current.com") === false && strstr($referer, "myyearbook.com") === false && strstr($referer, "facebook.com") === false && strstr($referer, "friendster.com") === false ? "" : "&externalInterfaceDisabled=1"; // if there is no wrapper the loader is responsible for setting extra params to the kdp $noncached_params = ""; if (!$nowrapper) { $noncached_params = $externalInterfaceDisabled . "&referer=" . urlencode($referer); } $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http"; $requestKey = $protocol . $_SERVER["REQUEST_URI"]; // check if we cached the redirect url $cache = new myCache("kwidget", 10 * 60); // 10 minutes $cachedResponse = $cache->get($requestKey); if ($allowCache && $cachedResponse) { header("X-Kaltura:cached-action"); header("Expires: Sun, 19 Nov 2000 08:52:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Location:{$cachedResponse}" . $noncached_params); die; } // check if we cached the patched swf with flashvars $cache_swfdata = new myCache("kwidgetswf", 10 * 60); // 10 minutes $cachedResponse = $cache_swfdata->get($requestKey); if ($allowCache && $cachedResponse) { header("X-Kaltura:cached-action"); requestUtils::sendCdnHeaders("swf", strlen($cachedResponse), 60 * 10, null, false, time()); echo $cachedResponse; die; } $widget_id = $this->getRequestParameter("wid"); $show_version = $this->getRequestParameter("v"); $debug_kdp = $this->getRequestParameter("debug_kdp", false); $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { die; } // because of the routing rule - the entry_id & kmedia_type WILL exist. be sure to ignore them if smaller than 0 $kshow_id = $widget->getKshowId(); $entry_id = $widget->getEntryId(); $gallery_widget = !$kshow_id && !$entry_id; if (!$entry_id) { $entry_id = -1; } if ($widget->getSecurityType() != widget::WIDGET_SECURITY_TYPE_TIMEHASH) { // try eid - if failed entry_id $eid = $this->getRequestParameter("eid", $this->getRequestParameter("entry_id")); // try kid - if failed kshow_id $kid = $this->getRequestParameter("kid", $this->getRequestParameter("kshow_id")); if ($eid != null) { $entry_id = $eid; } elseif ($kid != null) { $kshow_id = $kid; } } if ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_MATCH_IP) { $allowCache = false; // here we'll attemp to match the ip of the request with that from the customData of the widget $custom_data = $widget->getCustomData(); $valid_country = false; if ($custom_data) { // in this case the custom_data should be of format: // valid_county_1,valid_country_2,...,valid_country_n;falback_entry_id $arr = explode(";", $custom_data); $countries_str = $arr[0]; $fallback_entry_id = isset($arr[1]) ? $arr[1] : null; $fallback_kshow_id = isset($arr[2]) ? $arr[2] : null; $current_country = ""; $valid_country = requestUtils::matchIpCountry($countries_str, $current_country); if (!$valid_country) { KalturaLog::log("kwidgetAction: Attempting to access widget [{$widget_id}] and entry [{$entry_id}] from country [{$current_country}]. Retrning entry_id: [{$fallback_entry_id}] kshow_id [{$fallback_kshow_id}]"); $entry_id = $fallback_entry_id; $kshow_id = $fallback_kshow_id; } } } elseif ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_FORCE_KS) { } $kmedia_type = -1; // support either uiconf_id or ui_conf_id $uiconf_id = $this->getRequestParameter("uiconf_id"); if (!$uiconf_id) { $uiconf_id = $this->getRequestParameter("ui_conf_id"); } if ($uiconf_id) { $widget_type = $uiconf_id; $uiconf_id_str = "&uiconf_id={$uiconf_id}"; } else { $widget_type = $widget->getUiConfId(); $uiconf_id_str = ""; } if (empty($widget_type)) { $widget_type = 3; } $kdata = $widget->getCustomData(); $partner_host = myPartnerUtils::getHost($widget->getPartnerId()); $partner_cdnHost = myPartnerUtils::getCdnHost($widget->getPartnerId()); $host = $partner_host; if ($widget_type == 10) { $swf_url = $host . "/swf/weplay.swf"; } else { $swf_url = $host . "/swf/kplayer.swf"; } $partner_id = $widget->getPartnerId(); $subp_id = $widget->getSubpId(); if (!$subp_id) { $subp_id = 0; } $uiConf = uiConfPeer::retrieveByPK($widget_type); // new ui_confs which are deleted should stop the script // the check for >100000 is for supporting very old mediawiki and such players if (!$uiConf && $widget_type > 100000) { die; } if ($uiConf) { $ui_conf_swf_url = $uiConf->getSwfUrl(); if (kString::beginsWith($ui_conf_swf_url, "http")) { $swf_url = $ui_conf_swf_url; // absolute URL } else { $use_cdn = $uiConf->getUseCdn(); $host = $use_cdn ? $partner_cdnHost : $partner_host; $swf_url = $host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url; } if ($debug_kdp) { $swf_url = str_replace("/kdp/", "/kdp_debug/", $swf_url); } } if ($show_version < 0) { $show_version = null; } $ip = requestUtils::getRemoteAddress(); // to convert back, use long2ip // the widget log should change to reflect the new data, but for now - i used $widget_id instead of the widgget_type // WidgetLog::createWidgetLog( $referer , $ip , $kshow_id , $entry_id , $kmedia_type , $widget_id ); if ($entry_id == -1) { $entry_id = null; } $kdp3 = false; $base_wrapper_swf = myContentStorage::getFSFlashRootPath() . "/kdpwrapper/" . kConf::get('kdp_wrapper_version') . "/kdpwrapper.swf"; $widgetIdStr = "widget_id={$widget_id}"; $partnerIdStr = "partner_id={$partner_id}&subp_id={$subp_id}"; $entryVarName = 'entryId'; if ($widget->getIsPlayList()) { $entryVarName = 'playlistId'; } if ($uiConf) { $ks_flashvars = ""; $conf_vars = $uiConf->getConfVars(); if ($conf_vars) { $conf_vars = "&" . $conf_vars; } $wrapper_swf = $base_wrapper_swf; $partner = PartnerPeer::retrieveByPK($partner_id); if ($partner) { $partner_type = $partner->getType(); } if (version_compare($uiConf->getSwfUrlVersion(), "3.0", ">=")) { $kdp3 = true; // further in the code, $wrapper_swf is being used and not $base_wrapper_swf $wrapper_swf = $base_wrapper_swf = myContentStorage::getFSFlashRootPath() . '/kdp3wrapper/' . kConf::get('kdp3_wrapper_version') . '/kdp3wrapper.swf'; $widgetIdStr = "widgetId={$widget_id}"; $uiconf_id_str = "&uiConfId={$uiconf_id}"; $partnerIdStr = "partnerId={$partner_id}&subpId={$subp_id}"; } // if we are loaded without a wrapper (directly in flex) // 1. dont create the ks - keep url the same for caching // 2. dont patch the uiconf - patching is done only to wrapper anyway if ($nowrapper) { $dynamic_date = $widgetIdStr . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", $partner_cdnHost)) . $uiconf_id_str . $conf_vars; $url = "{$swf_url}?{$dynamic_date}"; } else { // if kdp version >= 2.5 if (version_compare($uiConf->getSwfUrlVersion(), "2.5", ">=")) { // create an anonymous session $ks = ""; $privileges = "view:*,widget:1"; if ($widget->getIsPlayList()) { $privileges = "list:*,widget:1"; } if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $partner_id) && !$widget->getEnforceEntitlement() && $widget->getEntryId()) { $privileges .= ',' . kSessionBase::PRIVILEGE_DISABLE_ENTITLEMENT_FOR_ENTRY . ':' . $widget->getEntryId(); } if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $partner_id) && !is_null($widget->getPrivacyContext()) && $widget->getPrivacyContext() != '') { $privileges .= ',' . kSessionBase::PRIVILEGE_PRIVACY_CONTEXT . ':' . $widget->getPrivacyContext(); } $result = kSessionUtils::createKSessionNoValidations($partner_id, 0, $ks, 86400, false, "", $privileges); $ks_flashvars = "&{$partnerIdStr}&uid=0&ts=" . microtime(true); if ($widget->getSecurityType() != widget::WIDGET_SECURITY_TYPE_FORCE_KS) { $ks_flashvars = "&ks={$ks}" . $ks_flashvars; } // patch kdpwrapper with getwidget and getuiconf $root = myContentStorage::getFSContentRootPath(); $confFile_mtime = $uiConf->getUpdatedAt(null); $new_swf_path = "widget_{$widget_id}_{$widget_type}_{$confFile_mtime}_" . md5($base_wrapper_swf . $swf_url) . ".swf"; $md5 = md5($new_swf_path); $new_swf_path = "content/cacheswf/" . substr($md5, 0, 2) . "/" . substr($md5, 2, 2) . "/" . $new_swf_path; $cached_swf = "{$root}/{$new_swf_path}"; if (!file_exists($cached_swf) || filemtime($cached_swf) < $confFile_mtime) { kFile::fullMkdir($cached_swf); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "api_v3" . DIRECTORY_SEPARATOR . "bootstrap.php"; $dispatcher = KalturaDispatcher::getInstance(); try { $widget_result = $dispatcher->dispatch("widget", "get", array("ks" => $ks, "id" => $widget_id)); $ui_conf_result = $dispatcher->dispatch("uiConf", "get", array("ks" => $ks, "id" => $widget_type)); } catch (Exception $ex) { die; } if (!$ui_conf_result->confFile) { die; } ob_start(); $serializer = new KalturaXmlSerializer(false); $serializer->serialize($widget_result); $widget_xml = ob_get_contents(); ob_end_clean(); ob_start(); $serializer = new KalturaXmlSerializer(false); $serializer->serialize($ui_conf_result); $ui_conf_xml = ob_get_contents(); ob_end_clean(); $patcher = new kPatchSwf($root . $base_wrapper_swf); $result = "<xml><result>{$widget_xml}</result><result>{$ui_conf_xml}</result></xml>"; $patcher->patch($result, $cached_swf); } if (file_exists($cached_swf)) { $wrapper_swf = $new_swf_path; } } $kdp_version_2 = strpos($swf_url, "kdp/v2.") > 0; if ($partner_host == "http://www.kaltura.com" && !$kdp_version_2 && !$kdp3) { $partner_host = 1; // otherwise the kdp will try going to cdnwww.kaltura.com } $track_wrapper = ''; if (kConf::get('track_kdpwrapper') && kConf::get('kdpwrapper_track_url')) { $track_wrapper = "&wrapper_tracker_url=" . urlencode(kConf::get('kdpwrapper_track_url') . "?activation_key=" . kConf::get('kaltura_activation_key') . "&package_version=" . kConf::get('kaltura_version')); } 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('kdp_version', $params)) { $swf_url = $partner_cdnHost . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "/flash/kdp3/" . $params['kdp_version'] . "/kdp3.swf"; } if (array_key_exists('conf_vars', $params)) { $conf_vars .= "&" . $params['conf_vars']; } // cache immidiately $cache_st = 0; $allowCache = true; } } $stats_host = $protocol == "https" ? kConf::get("stats_host_https") : kConf::get("stats_host"); $wrapper_stats = kConf::get('kdp3_wrapper_stats_url') ? "&wrapper_stats_url={$protocol}://{$stats_host}" . urlencode(str_replace("{partnerId}", $partner_id, kConf::get('kdp3_wrapper_stats_url'))) : ""; $dynamic_date = $widgetIdStr . $track_wrapper . $wrapper_stats . "&kdpUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", $partner_cdnHost)) . ($protocol == "https" ? "&statistics.statsDomain={$stats_host}" : "") . ($show_version ? "&entryVersion={$show_version}" : "") . ($kshow_id ? "&kshowId={$kshow_id}" : "") . ($entry_id ? "&{$entryVarName}={$entry_id}" : "") . $uiconf_id_str . $ks_flashvars . ($cache_st ? "&clientTag=cache_st:{$cache_st}" : "") . $conf_vars; // for now changed back to $host since kdp version prior to 1.0.15 didnt support loading by external domain kdpwrapper $url = $host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "/{$wrapper_swf}?{$dynamic_date}"; // patch wrapper with flashvars and dump to browser if (version_compare($uiConf->getSwfUrlVersion(), "2.6.6", ">=")) { $patcher = new kPatchSwf($root . $wrapper_swf, "KALTURA_FLASHVARS_DATA"); ob_start(); $patcher->patch($dynamic_date . "&referer=" . urlencode($referer)); $wrapper_data = ob_get_contents(); ob_end_clean(); requestUtils::sendCdnHeaders("swf", strlen($wrapper_data), $allowCache ? 60 * 10 : 0, null, false, time()); echo $wrapper_data; if ($allowCache) { $cache_swfdata->put($requestKey, $wrapper_data); } die; } } } else { $dynamic_date = "kshowId={$kshow_id}" . "&host=" . requestUtils::getRequestHostId() . ($show_version ? "&entryVersion={$show_version}" : "") . ($entry_id ? "&{$entryVarName}={$entry_id}" : "") . ($entry_id ? "&KmediaType={$kmedia_type}" : ""); $dynamic_date .= "&isWidget={$widget_type}&referer=" . urlencode($referer); $dynamic_date .= "&kdata={$kdata}"; $url = "{$swf_url}?{$dynamic_date}"; } // if referer has a query string an IE bug will prevent out flashvars to propagate // when nowrapper is true we cant use /swfparams either as there isnt a kdpwrapper if (!$nowrapper && $uiConf && version_compare($uiConf->getSwfUrlVersion(), "2.6.6", ">=")) { // apart from the /swfparam/ format, add .swf suffix to the end of the stream in case // a corporate firewall looks at the file suffix $pos = strpos($url, "?"); $url = substr($url, 0, $pos) . "/swfparams/" . urlencode(substr($url, $pos + 1)) . ".swf"; } if ($allowCache) { $cache->put($requestKey, $url); } if (strpos($url, "/swfparams/") > 0) { $url = substr($url, 0, -4) . urlencode($noncached_params) . ".swf"; } else { $url .= $noncached_params; } $this->redirect($url); }
<?php chdir(dirname(__FILE__)); require_once dirname(__FILE__) . '/../bootstrap.php'; $dc_config = kConf::getMap("dc_config"); var_dump($dc_config);
} // Disable Apple HLS if defined in kConf if ($kConf->hasParam('use_apple_adaptive')) { $wgKalturaUseAppleAdaptive = $kConf->get('use_apple_adaptive'); } // Get Kaltura Supported API Features if ($kConf->hasParam('features')) { $wgKalturaApiFeatures = $kConf->get('features'); } // Allow Iframe to connect remote service $wgKalturaAllowIframeRemoteService = true; // Set debug for true (testing only) $wgEnableScriptDebug = false; // Get PlayReady License URL if ($kConf->hasMap('playReady')) { $playReadyMap = $kConf->getMap('playReady'); if ($playReadyMap) { $wgKalturaLicenseServerUrl = $playReadyMap['license_server_url']; } } // Get PlayReady License URL if ($kConf->hasMap('drm')) { $drmMap = $kConf->getMap('drm'); if ($drmMap) { $wgKalturaUdrmLicenseServerUrl = $drmMap['license_server_url']; } } if ($kConf->hasParam('overrideDomain')) { $wgEnableKalturaOverrideDomain = $kConf->get('overrideDomain'); } if ($kConf->hasParam('enableEmbedServicesRouting')) {
header('KalturaSyndication: Database error'); die; } catch (Exception $ex) { KalturaLog::err($ex->getMessage()); header('KalturaSyndication: ' . str_replace(array("\n", "\r"), array("\t", ''), $ex->getMessage())); die; } $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { header('KalturaSyndication: Feed Id not found'); die; } // small feeds will have a short if ($limit) { $short_limit = kConf::hasParam("v3cache_getfeed_short_limit") ? kConf::get("v3cache_getfeed_short_limit") : 50; if ($limit < $short_limit) { KalturaResponseCacher::setExpiry(kConf::hasParam("v3cache_getfeed_short_expiry") ? kConf::get("v3cache_getfeed_short_expiry") : 900); } } $partnerId = $syndicationFeedDB->getPartnerId(); $expiryArr = kConf::hasMap("v3cache_getfeed_expiry") ? kConf::getMap("v3cache_getfeed_expiry") : array(); foreach ($expiryArr as $item) { if ($item["key"] == "partnerId" && $item["value"] == $partnerId || $item["key"] == "feedId" && $item["value"] == $feedId) { KalturaResponseCacher::setExpiry($item["expiry"]); break; } } $end = microtime(true); KalturaLog::info("syndicationFeedRenderer-end [" . ($end - $start) . "]"); KalturaLog::debug("<------------------------------------- syndicationFeedRenderer -------------------------------------"); $cache->end();