本文整理汇总了PHP中kCurrentContext::initPartnerByEntryId方法的典型用法代码示例。如果您正苦于以下问题:PHP kCurrentContext::initPartnerByEntryId方法的具体用法?PHP kCurrentContext::initPartnerByEntryId怎么用?PHP kCurrentContext::initPartnerByEntryId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kCurrentContext
的用法示例。
在下文中一共展示了kCurrentContext::initPartnerByEntryId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serveAction
/**
* Serve XML rendition of the Kaltura Live Transcoding Profile usable by the Wowza transcoding add-on
*
* @action serve
* @param string $streamName the id of the live entry with it's stream suffix
* @param string $hostname the media server host name
* @return file
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws WowzaErrors::INVALID_STREAM_NAME
*/
public function serveAction($streamName, $hostname = null)
{
$matches = null;
if (!preg_match('/^(\\d_.{8})_(\\d+)$/', $streamName, $matches)) {
throw new KalturaAPIException(WowzaErrors::INVALID_STREAM_NAME, $streamName);
}
$entryId = $matches[1];
$suffix = $matches[2];
$entry = null;
if (!kCurrentContext::$ks) {
kEntitlementUtils::initEntitlementEnforcement(null, false);
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry || $entry->getStatus() == entryStatus::DELETED) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
} else {
$entry = entryPeer::retrieveByPK($entryId);
}
if (!$entry || $entry->getType() != KalturaEntryType::LIVE_STREAM || !in_array($entry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$mediaServer = null;
if ($hostname) {
$mediaServer = MediaServerPeer::retrieveByHostname($hostname);
}
$conversionProfileId = $entry->getConversionProfileId();
$liveParams = assetParamsPeer::retrieveByProfile($conversionProfileId);
$liveParamsInput = null;
$disableIngested = true;
foreach ($liveParams as $liveParamsItem) {
/* @var $liveParamsItem liveParams */
if ($liveParamsItem->getStreamSuffix() == $suffix) {
$liveParamsInput = $liveParamsItem;
if (!$liveParamsInput->hasTag(assetParams::TAG_SOURCE)) {
$liveParams = array($liveParamsInput);
$disableIngested = false;
}
break;
}
}
$ignoreLiveParamsIds = array();
if ($disableIngested) {
$conversionProfileAssetParams = flavorParamsConversionProfilePeer::retrieveByConversionProfile($conversionProfileId);
foreach ($conversionProfileAssetParams as $conversionProfileAssetParamsItem) {
/* @var $conversionProfileAssetParamsItem flavorParamsConversionProfile */
if ($conversionProfileAssetParamsItem->getOrigin() == assetParamsOrigin::INGEST) {
$ignoreLiveParamsIds[] = $conversionProfileAssetParamsItem->getFlavorParamsId();
}
}
}
// translate the $liveParams to XML according to doc: http://www.wowza.com/forums/content.php?304#configTemplate
$root = new SimpleXMLElement('<Root/>');
$transcode = $root->addChild('Transcode');
$encodes = $transcode->addChild('Encodes');
$groups = array();
foreach ($liveParams as $liveParamsItem) {
/* @var $liveParamsItem liveParams */
if (!$liveParamsItem->hasTag(assetParams::TAG_SOURCE) && in_array($liveParamsItem->getId(), $ignoreLiveParamsIds)) {
continue;
}
$this->appendLiveParams($entry, $mediaServer, $encodes, $liveParamsItem);
$tags = $liveParamsItem->getTagsArray();
$tags[] = 'all';
foreach ($tags as $tag) {
if (!isset($groups[$tag])) {
$groups[$tag] = array();
}
$systemName = $liveParamsItem->getSystemName() ? $liveParamsItem->getSystemName() : $liveParamsItem->getId();
$groups[$tag][] = $systemName;
}
}
$decode = $transcode->addChild('Decode');
$video = $decode->addChild('Video');
$video->addChild('Deinterlace', 'false');
$streamNameGroups = $transcode->addChild('StreamNameGroups');
foreach ($groups as $groupName => $groupMembers) {
$streamNameGroup = $streamNameGroups->addChild('StreamNameGroup');
$streamNameGroup->addChild('Name', $groupName);
$streamNameGroup->addChild('StreamName', '${SourceStreamName}_' . $groupName);
$members = $streamNameGroup->addChild('Members');
foreach ($groupMembers as $groupMember) {
$member = $members->addChild('Member');
$member->addChild('EncodeName', $groupMember);
}
}
$properties = $transcode->addChild('Properties');
$dom = new DOMDocument("1.0");
//.........这里部分代码省略.........
示例2: flagEntry
protected function flagEntry(KalturaModerationFlag $moderationFlag, $entryType = null)
{
$moderationFlag->validatePropertyNotNull("flaggedEntryId");
$entryId = $moderationFlag->flaggedEntryId;
$dbEntry = kCurrentContext::initPartnerByEntryId($entryId);
// before returning any error, let's validate partner's access control
if ($dbEntry) {
$this->validateApiAccessControl($dbEntry->getPartnerId());
}
if (!$dbEntry || $entryType !== null && $dbEntry->getType() != $entryType) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$validModerationStatuses = array(KalturaEntryModerationStatus::APPROVED, KalturaEntryModerationStatus::AUTO_APPROVED, KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW);
if (!in_array($dbEntry->getModerationStatus(), $validModerationStatuses)) {
throw new KalturaAPIException(KalturaErrors::ENTRY_CANNOT_BE_FLAGGED);
}
$dbModerationFlag = new moderationFlag();
$dbModerationFlag->setPartnerId($dbEntry->getPartnerId());
$dbModerationFlag->setKuserId($this->getKuser()->getId());
$dbModerationFlag->setFlaggedEntryId($dbEntry->getId());
$dbModerationFlag->setObjectType(KalturaModerationObjectType::ENTRY);
$dbModerationFlag->setStatus(KalturaModerationFlagStatus::PENDING);
$dbModerationFlag->setFlagType($moderationFlag->flagType);
$dbModerationFlag->setComments($moderationFlag->comments);
$dbModerationFlag->save();
$dbEntry->setModerationStatus(KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW);
$updateOccurred = $dbEntry->save();
$moderationFlag = new KalturaModerationFlag();
$moderationFlag->fromObject($dbModerationFlag, $this->getResponseProfile());
// need to notify the partner that an entry was flagged - use the OLD moderation onject that is required for the
// NOTIFICATION_TYPE_ENTRY_REPORT notification
// TODO - change to moderationFlag object to implement the interface for the notification:
// it should have "objectId", "comments" , "reportCode" as getters
$oldModerationObj = new moderation();
$oldModerationObj->setPartnerId($dbEntry->getPartnerId());
$oldModerationObj->setComments($moderationFlag->comments);
$oldModerationObj->setObjectId($dbEntry->getId());
$oldModerationObj->setObjectType(moderation::MODERATION_OBJECT_TYPE_ENTRY);
$oldModerationObj->setReportCode("");
if ($updateOccurred) {
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_REPORT, $oldModerationObj, $dbEntry->getPartnerId());
}
return $moderationFlag;
}
示例3: isLiveAction
/**
* Delivering the status of a live stream (on-air/offline) if it is possible
*
* @action isLive
* @param string $id ID of the live stream
* @param KalturaPlaybackProtocol $protocol protocol of the stream to test.
* @return bool
*
* @throws KalturaErrors::LIVE_STREAM_STATUS_CANNOT_BE_DETERMINED
* @throws KalturaErrors::INVALID_ENTRY_ID
*/
public function isLiveAction($id, $protocol)
{
if (!kCurrentContext::$ks) {
kEntitlementUtils::initEntitlementEnforcement(null, false);
$liveStreamEntry = kCurrentContext::initPartnerByEntryId($id);
if (!$liveStreamEntry || $liveStreamEntry->getStatus() == entryStatus::DELETED) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $id);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
} else {
$liveStreamEntry = entryPeer::retrieveByPK($id);
}
if (!$liveStreamEntry || $liveStreamEntry->getType() != entryType::LIVE_STREAM) {
throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $id);
}
if (!in_array($liveStreamEntry->getSource(), LiveEntry::$kalturaLiveSourceTypes)) {
KalturaResponseCacher::setConditionalCacheExpiry(self::ISLIVE_ACTION_NON_KALTURA_LIVE_CONDITIONAL_CACHE_EXPIRY);
}
/* @var $liveStreamEntry LiveStreamEntry */
if (in_array($liveStreamEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
return $this->responseHandlingIsLive($liveStreamEntry->hasMediaServer());
}
$dpda = new DeliveryProfileDynamicAttributes();
$dpda->setEntryId($id);
$dpda->setFormat($protocol);
switch ($protocol) {
case KalturaPlaybackProtocol::HLS:
case KalturaPlaybackProtocol::APPLE_HTTP:
$url = $liveStreamEntry->getHlsStreamUrl();
foreach (array(KalturaPlaybackProtocol::HLS, KalturaPlaybackProtocol::APPLE_HTTP) as $hlsProtocol) {
$config = $liveStreamEntry->getLiveStreamConfigurationByProtocol($hlsProtocol, requestUtils::getProtocol());
if ($config) {
$url = $config->getUrl();
$protocol = $hlsProtocol;
break;
}
}
KalturaLog::info('Determining status of live stream URL [' . $url . ']');
$urlManager = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
if ($urlManager) {
return $this->responseHandlingIsLive($urlManager->isLive($url));
}
break;
case KalturaPlaybackProtocol::HDS:
case KalturaPlaybackProtocol::AKAMAI_HDS:
$config = $liveStreamEntry->getLiveStreamConfigurationByProtocol($protocol, requestUtils::getProtocol());
if ($config) {
$url = $config->getUrl();
KalturaLog::info('Determining status of live stream URL [' . $url . ']');
$urlManager = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
if ($urlManager) {
return $this->responseHandlingIsLive($urlManager->isLive($url));
}
}
break;
}
throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_STATUS_CANNOT_BE_DETERMINED, $protocol);
}
示例4: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
$entryId = $this->getRequestParameter("entry_id");
$flavorId = $this->getRequestParameter("flavor");
$fileName = $this->getRequestParameter("file_name");
$fileName = basename($fileName);
$ksStr = $this->getRequestParameter("ks");
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$entry = null;
if ($ksStr) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
kEntitlementUtils::initEntitlementEnforcement();
if (!$entry) {
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, accessControlContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload($entry, $ksStr);
$flavorAsset = null;
if ($flavorId) {
// get flavor asset
$flavorAsset = assetPeer::retrieveById($flavorId);
if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
// the request flavor should belong to the requested entry
if ($flavorAsset->getEntryId() != $entryId) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
} else {
$flavorAsset = assetPeer::retrieveBestPlayByEntryId($entry->getId());
}
// Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source
if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
}
if ($flavorAsset) {
$syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset);
} else {
$syncKey = $this->getBestSyncKeyForEntry($entry);
}
if (is_null($syncKey)) {
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$this->handleFileSyncRedirection($syncKey);
$filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
$wamsURL = kFileSyncUtils::getWamsURLForKey($syncKey);
list($fileBaseName, $fileExt) = $this->getFileName($entry, $flavorAsset);
if (!$fileName) {
$fileName = $fileBaseName;
}
if ($fileExt && !is_dir($filePath)) {
$fileName = $fileName . '.' . $fileExt;
}
//enable downloading file_name which inside the flavor asset directory
if (is_dir($filePath)) {
$filePath = $filePath . DIRECTORY_SEPARATOR . $fileName;
}
$this->dumpFile($filePath, $fileName, $wamsAssetId, $wamsURL);
die;
// no view
}
示例5: execute
public function execute()
{
requestUtils::handleConditionalGet();
$entry_id = $this->getRequestParameter("entry_id");
$ks_str = $this->getRequestParameter("ks");
$base64_referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($base64_referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$clip_from = $this->getRequestParameter("clip_from", 0);
// milliseconds
$clip_to = $this->getRequestParameter("clip_to", 2147483647);
// milliseconds
if ($clip_to == 0) {
$clip_to = 2147483647;
}
$request = $_SERVER["REQUEST_URI"];
// remove dynamic fields from the url so we'll request a single url from the cdn
$request = str_replace("/referrer/{$base64_referrer}", "", $request);
$request = str_replace("/ks/{$ks_str}", "", $request);
$entry = null;
if ($ks_str) {
try {
kCurrentContext::initKsPartnerUser($ks_str);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
kEntitlementUtils::initEntitlementEnforcement();
// workaround the filter which hides all the deleted entries -
// now that deleted entries are part of xmls (they simply point to the 'deleted' templates), we should allow them here
if (!$entry) {
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
KalturaMonitorClient::initApiMonitor(false, 'keditorservices.flvclipper', $entry->getPartnerId());
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_BLOCK_FLVCLIPPER_ACTION, $entry->getPartnerId())) {
KExternalErrors::dieError(KExternalErrors::ACTION_BLOCKED);
}
// set the memory size to be able to serve big files in a single chunk
ini_set("memory_limit", "64M");
// set the execution time to be able to serve big files in a single chunk
ini_set("max_execution_time", 240);
if ($entry->getType() == entryType::MIX && $entry->getStatus() == entryStatus::DELETED) {
// because the fiter was turned off - a manual check for deleted entries must be done.
KExternalErrors::dieGracefully();
} else {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$version = $this->getRequestParameter("version", null);
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
$type = $this->getRequestParameter("type", 1);
$quality = $this->getRequestParameter("quality", 0);
$src_x = $this->getRequestParameter("src_x", 0);
$src_y = $this->getRequestParameter("src_y", 0);
$src_w = $this->getRequestParameter("src_w", 0);
$src_h = $this->getRequestParameter("src_h", 0);
$vid_sec = $this->getRequestParameter("vid_sec", -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
if ($width == -1 && $height == -1) {
$width = 640;
$height = 480;
} else {
if ($width == -1) {
// if only either width or height is missing reset them to zero, and convertImage will handle them
$width = 0;
} else {
if ($height == -1) {
$height = 0;
}
}
}
$tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices);
kFileUtils::dumpFile($tempThumbPath, null, strpos($tempThumbPath, "_NOCACHE_") === false ? null : 0);
}
}
$audio_only = $this->getRequestParameter("audio_only");
// milliseconds
$flavor = $this->getRequestParameter("flavor", 1);
//
$flavor_param_id = $this->getRequestParameter("flavor_param_id", null);
//
$streamer = $this->getRequestParameter("streamer");
//.........这里部分代码省略.........
示例6: initEntry
protected function initEntry()
{
$this->entryId = $this->getRequestParameter("entryId", null);
// look for a valid token
$expiry = $this->getRequestParameter("expiry");
if ($expiry && $expiry <= time()) {
KExternalErrors::dieError(KExternalErrors::EXPIRED_TOKEN);
}
$urlToken = $this->getRequestParameter("kt");
if ($urlToken) {
if ($_SERVER["REQUEST_METHOD"] != "GET" || !self::validateKalturaToken($_SERVER["REQUEST_URI"], $urlToken)) {
KExternalErrors::dieError(KExternalErrors::INVALID_TOKEN);
}
}
// initalize the context
$ksStr = $this->getRequestParameter("ks");
if ($ksStr && !$urlToken) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$this->entry = kCurrentContext::initPartnerByEntryId($this->entryId);
if (!$this->entry || $this->entry->getStatus() == entryStatus::DELETED) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
// no need for any further check if a token was used
if ($urlToken) {
return;
}
// enforce entitlement
kEntitlementUtils::initEntitlementEnforcement();
if (!$this->entry) {
$this->entry = entryPeer::retrieveByPKNoFilter($this->entryId);
if (!$this->entry || $this->entry->getStatus() == entryStatus::DELETED) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($this->entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
myPartnerUtils::blockInactivePartner($this->entry->getPartnerId());
// enforce access control
$base64Referrer = $this->getRequestParameter("referrer");
$hashes = $this->getRequestParameter("hashes");
$keyValueHashes = array();
if ($hashes) {
$hashes = urldecode($hashes);
$hashes = explode(",", $hashes);
foreach ($hashes as $keyValueHashString) {
list($key, $value) = explode('=', $keyValueHashString);
$keyValueHashes[$key] = $value;
}
}
// replace space in the base64 string with + as space is invalid in base64 strings and caused
// by symfony calling str_parse to replace + with spaces.
// this happens only with params passed in the url path and not the query strings. specifically the ~ char at
// a columns divided by 3 causes this issue (e.g. http://www.xyzw.com/~xxx)
//replace also any - with + and _ with /
$referrer = base64_decode(str_replace(array('-', '_', ' '), array('+', '/', '+'), $base64Referrer));
if (!is_string($referrer)) {
$referrer = "";
}
// base64_decode can return binary data
$this->secureEntryHelper = new KSecureEntryHelper($this->entry, $ksStr, $referrer, ContextType::PLAY, $keyValueHashes);
if ($this->secureEntryHelper->shouldPreview()) {
$previewLengthInMsecs = $this->secureEntryHelper->getPreviewLength() * 1000;
$entryLengthInMsecs = $this->entry->getLengthInMsecs();
if ($previewLengthInMsecs < $entryLengthInMsecs) {
$this->deliveryAttributes->setClipTo($previewLengthInMsecs);
}
} else {
$this->secureEntryHelper->validateForPlay();
}
if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $this->entry->getPartnerId()) || $this->secureEntryHelper->hasRules()) {
$this->forceUrlTokenization = true;
}
}
示例7: serveByEntryIdAction
/**
* Serves caption by entry id and thumnail params id
*
* @action serveByEntryId
* @param string $entryId
* @param int $captionParamId if not set, default caption will be used.
* @return file
*
* @throws KalturaCaptionErrors::CAPTION_ASSET_PARAMS_ID_NOT_FOUND
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
*/
public function serveByEntryIdAction($entryId, $captionParamId = null)
{
$entry = null;
if (!kCurrentContext::$ks) {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry || $entry->getStatus() == entryStatus::DELETED) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
// enforce entitlement
kEntitlementUtils::initEntitlementEnforcement();
if (!kEntitlementUtils::isEntryEntitled($entry)) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
} else {
$entry = entryPeer::retrieveByPK($entryId);
}
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, accessControlContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload();
$captionAsset = null;
if (is_null($captionParamId)) {
$captionAssets = assetPeer::retrieveByEntryId($entryId, array(CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION)));
foreach ($captionAssets as $checkCaptionAsset) {
if ($checkCaptionAsset->getDefault()) {
$captionAsset = $checkCaptionAsset;
break;
}
}
} else {
$captionAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $captionParamId);
}
if (!$captionAsset) {
throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_PARAMS_ID_NOT_FOUND, $captionParamId);
}
$fileName = $captionAsset->getId() . '.' . $captionAsset->getFileExt();
return $this->serveAsset($captionAsset, $fileName);
}
示例8: serveByEntryIdAction
/**
* Serves thumbnail by entry id and thumnail params id
*
* @action serveByEntryId
* @param string $entryId
* @param int $thumbParamId if not set, default thumbnail will be used.
* @return file
*
* @throws KalturaErrors::THUMB_ASSET_IS_NOT_READY
* @throws KalturaErrors::THUMB_ASSET_PARAMS_ID_NOT_FOUND
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
*/
public function serveByEntryIdAction($entryId, $thumbParamId = null)
{
$entry = null;
if (!kCurrentContext::$ks) {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry || $entry->getStatus() == entryStatus::DELETED) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
// enforce entitlement
kEntitlementUtils::initEntitlementEnforcement();
if (!kEntitlementUtils::isEntryEntitled($entry)) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
} else {
$entry = entryPeer::retrieveByPK($entryId);
}
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, accessControlContextType::THUMBNAIL);
$securyEntryHelper->validateAccessControl();
$fileName = $entry->getId() . '.jpg';
if (is_null($thumbParamId)) {
return $this->serveFile($entry, entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB, $fileName, $entryId);
}
$thumbAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $thumbParamId);
if (!$thumbAsset) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_PARAMS_ID_NOT_FOUND, $thumbParamId);
}
return $this->serveAsset($thumbAsset, $fileName);
}
示例9: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
requestUtils::handleConditionalGet();
$wams_asset_id = NULL;
$wams_url = NULL;
$entry_id = $this->getRequestParameter("entry_id");
$type = $this->getRequestParameter("type");
$ks = $this->getRequestParameter("ks");
$file_sync = null;
$ret_file_name = "name";
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$request_file_name = $this->getRequestParameter("file_name");
if ($request_file_name) {
$ret_file_name = $request_file_name;
}
$direct_serve = $this->getRequestParameter("direct_serve");
$entry = null;
if ($ks) {
try {
kCurrentContext::initKsPartnerUser($ks);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entry_id);
if (!$entry) {
die;
}
}
kEntitlementUtils::initEntitlementEnforcement();
if (!$entry) {
$entry = entryPeer::retrieveByPK($entry_id);
if (!$entry) {
die;
}
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
die;
}
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$securyEntryHelper = new KSecureEntryHelper($entry, $ks, $referrer, accessControlContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload();
// Rmoved by Tan-Tan - asked by Eran
// // allow access only via cdn unless these are documents (due to the current implementation of convert ppt2swf)
// if ($entry->getType() != entryType::DOCUMENT && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE)
// {
// requestUtils::enforceCdnDelivery($entry->getPartnerId());
// }
// relocate = did we use the redirect and added the extension to the name
$relocate = $this->getRequestParameter("relocate");
if ($ret_file_name == "name") {
$ret_file_name = $entry->getName();
}
if ($ret_file_name) {
//rawurlencode to content-disposition filename to handle spaces and other characters across different browsers
//$name = rawurlencode($ret_file_name);
// 19.04.2009 (Roman) - url encode is not needed when the filename in Content-Disposition header is in quotes
// IE6/FF3/Chrome - Will show the filename correctly
// IE7 - Will show the filename with underscores instead of spaces (this is better than showing %20)
$name = $ret_file_name;
if ($name) {
if ($relocate) {
// if we have a good file extension (from the first time) - use it in the content-disposition
// in some browsers it will be stronger than the URL's extension
$file_ext = pathinfo($relocate, PATHINFO_EXTENSION);
$name .= ".{$file_ext}";
}
if (!$direct_serve) {
header("Content-Disposition: attachment; filename=\"{$name}\"");
}
}
} else {
$ret_file_name = $entry_id;
}
$format = $this->getRequestParameter("format");
if ($type == "download" && $format && $entry->getType() != entryType::DOCUMENT) {
// this is a video for a specifc extension - use the proper flavorAsset
$flavor_asset = assetPeer::retrieveByEntryIdAndExtension($entry_id, $format);
if ($flavor_asset && $flavor_asset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$file_sync = $this->redirectIfRemote($flavor_asset, flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, null, true);
} else {
header('KalturaRaw: no flavor asset for extension');
header("HTTP/1.0 404 Not Found");
die;
}
$archive_file = $file_sync->getFullPath();
$mime_type = kFile::mimeType($archive_file);
kFile::dumpFile($archive_file, $mime_type);
}
// TODO - move to a different action - document should be plugin
if ($entry->getType() == entryType::DOCUMENT) {
//.........这里部分代码省略.........
示例10: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
$entryId = $this->getRequestParameter("entry_id");
$flavorId = $this->getRequestParameter("flavor");
$fileName = $this->getRequestParameter("file_name");
$fileName = basename($fileName);
$ksStr = $this->getRequestParameter("ks");
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$entry = null;
if ($ksStr) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
kEntitlementUtils::initEntitlementEnforcement();
if (!$entry) {
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
KalturaMonitorClient::initApiMonitor(false, 'extwidget.download', $entry->getPartnerId());
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$shouldPreview = false;
$securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, ContextType::DOWNLOAD);
if ($securyEntryHelper->shouldPreview()) {
$shouldPreview = true;
} else {
$securyEntryHelper->validateForDownload();
}
$flavorAsset = null;
if ($flavorId) {
// get flavor asset
$flavorAsset = assetPeer::retrieveById($flavorId);
if (is_null($flavorAsset) || !$flavorAsset->isLocalReadyStatus()) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
// the request flavor should belong to the requested entry
if ($flavorAsset->getEntryId() != $entryId) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if (!$securyEntryHelper->isAssetAllowed($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
} else {
$flavorAssets = assetPeer::retrieveReadyWebByEntryId($entry->getId());
foreach ($flavorAssets as $curFlavorAsset) {
if ($securyEntryHelper->isAssetAllowed($curFlavorAsset)) {
$flavorAsset = $curFlavorAsset;
break;
}
}
}
// Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source
if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$securyEntryHelper->isAssetAllowed($flavorAsset)) {
$flavorAsset = null;
}
}
if ($flavorAsset) {
$syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset);
} else {
$syncKey = $this->getBestSyncKeyForEntry($entry);
}
if (is_null($syncKey)) {
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$this->handleFileSyncRedirection($syncKey);
$filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
list($fileBaseName, $fileExt) = kAssetUtils::getFileName($entry, $flavorAsset);
if (!$fileName) {
$fileName = $fileBaseName;
}
if ($fileExt && !is_dir($filePath)) {
$fileName = $fileName . '.' . $fileExt;
}
$preview = 0;
if ($shouldPreview && $flavorAsset) {
$preview = $flavorAsset->estimateFileSize($entry, $securyEntryHelper->getPreviewLength());
} else {
//.........这里部分代码省略.........
示例11: initEntry
protected function initEntry()
{
$this->entryId = $this->getRequestParameter("entryId", null);
// look for a valid token
$expiry = $this->getRequestParameter("expiry");
if ($expiry && $expiry <= time()) {
KExternalErrors::dieError(KExternalErrors::EXPIRED_TOKEN);
}
$urlToken = $this->getRequestParameter("kt");
if ($urlToken) {
if ($_SERVER["REQUEST_METHOD"] != "GET" || !self::validateKalturaToken($_SERVER["REQUEST_URI"], $urlToken)) {
KExternalErrors::dieError(KExternalErrors::INVALID_TOKEN);
}
}
// initalize the context
$ksStr = $this->getRequestParameter("ks");
if ($ksStr && !$urlToken) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$this->entry = kCurrentContext::initPartnerByEntryId($this->entryId);
if (!$this->entry || $this->entry->getStatus() == entryStatus::DELETED) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
// no need for any further check if a token was used
if ($urlToken) {
return;
}
// enforce entitlement
kEntitlementUtils::initEntitlementEnforcement();
if (!$this->entry) {
$this->entry = entryPeer::retrieveByPKNoFilter($this->entryId);
if (!$this->entry || $this->entry->getStatus() == entryStatus::DELETED) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($this->entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
// enforce access control
$base64Referrer = $this->getRequestParameter("referrer");
// replace space in the base64 string with + as space is invalid in base64 strings and caused
// by symfony calling str_parse to replace + with spaces.
// this happens only with params passed in the url path and not the query strings. specifically the ~ char at
// a columns divided by 3 causes this issue (e.g. http://www.xyzw.com/~xxx)
$referrer = base64_decode(str_replace(" ", "+", $base64Referrer));
if (!is_string($referrer)) {
$referrer = "";
}
// base64_decode can return binary data
$this->secureEntryHelper = new KSecureEntryHelper($this->entry, $ksStr, $referrer, accessControlContextType::PLAY);
if ($this->secureEntryHelper->shouldPreview()) {
$this->clipTo = $this->secureEntryHelper->getPreviewLength() * 1000;
} else {
$this->secureEntryHelper->validateForPlay();
}
}