本文整理汇总了PHP中kDataCenterMgr::getRedirectExternalUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP kDataCenterMgr::getRedirectExternalUrl方法的具体用法?PHP kDataCenterMgr::getRedirectExternalUrl怎么用?PHP kDataCenterMgr::getRedirectExternalUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kDataCenterMgr
的用法示例。
在下文中一共展示了kDataCenterMgr::getRedirectExternalUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
// where file is {entryId/flavorId}.{ism,ismc,ismv}
$objectId = $type = null;
$objectIdStr = $this->getRequestParameter("objectId");
if ($objectIdStr) {
list($objectId, $type) = @explode(".", $objectIdStr);
}
if (!$type || !$objectId) {
KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER);
}
$ks = $this->getRequestParameter("ks");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$syncKey = $this->getFileSyncKey($objectId, $type);
KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveIsm', $this->entry->getPartnerId());
myPartnerUtils::enforceDelivery($this->entry, $this->flavorAsset);
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for type [{$type}] objectId [{$objectId}]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFileUtils::dumpUrl($remoteUrl);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
if ($type == 'ism') {
$fileData = $this->fixIsmManifestForReplacedEntry($path);
$renderer = new kRendererString($fileData, 'image/ism');
$renderer->output();
KExternalErrors::dieGracefully();
} else {
kFileUtils::dumpFile($path);
}
}
示例2: execute
public function execute()
{
//entitlement should be disabled to serveFlavor action as we do not get ks on this action.
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
requestUtils::handleConditionalGet();
$flavorId = $this->getRequestParameter("flavorId");
$shouldProxy = $this->getRequestParameter("forceproxy", false);
$fileName = $this->getRequestParameter("fileName");
$fileParam = $this->getRequestParameter("file");
$fileParam = basename($fileParam);
$pathOnly = $this->getRequestParameter("pathOnly", false);
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$flavorAsset = assetPeer::retrieveById($flavorId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entryId = $this->getRequestParameter("entryId");
if (!is_null($entryId) && $flavorAsset->getEntryId() != $entryId) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if ($fileName) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
header("Content-Type: application/force-download");
header("Content-Description: File Transfer");
}
$clipTo = null;
$entry = $flavorAsset->getentry();
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveFlavor', $flavorAsset->getPartnerId());
myPartnerUtils::enforceDelivery($entry, $flavorAsset);
$version = $this->getRequestParameter("v");
if (!$version) {
$version = $flavorAsset->getVersion();
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
if ($pathOnly && kIpAddressUtils::isInternalIp($_SERVER['REMOTE_ADDR'])) {
$path = null;
list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
if ($file_sync) {
$parent_file_sync = kFileSyncUtils::resolve($file_sync);
$path = $parent_file_sync->getFullPath();
if ($fileParam && is_dir($path)) {
$path .= "/{$fileParam}";
}
}
$renderer = new kRendererString('{"sequences":[{"clips":[{"type":"source","path":"' . $path . '"}]}]}', 'application/json');
if ($path) {
$this->storeCache($renderer, $flavorAsset->getPartnerId());
}
$renderer->output();
KExternalErrors::dieGracefully();
}
if (kConf::hasParam('serve_flavor_allowed_partners') && !in_array($flavorAsset->getPartnerId(), kConf::get('serve_flavor_allowed_partners'))) {
KExternalErrors::dieError(KExternalErrors::ACTION_BLOCKED);
}
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
// always dump remote urls so they will be cached by the cdn transparently
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFileUtils::dumpUrl($remoteUrl);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$isFlv = false;
if (!$shouldProxy) {
$flvWrapper = new myFlvHandler($path);
$isFlv = $flvWrapper->isFlv();
}
$clipFrom = $this->getRequestParameter("clipFrom", 0);
// milliseconds
if (is_null($clipTo)) {
$clipTo = $this->getRequestParameter("clipTo", self::NO_CLIP_TO);
}
// milliseconds
if ($clipTo == 0) {
$clipTo = self::NO_CLIP_TO;
}
if (!is_numeric($clipTo) || $clipTo < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'clipTo must be a positive number');
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
if ($fileParam && is_dir($path)) {
$path .= "/{$fileParam}";
kFileUtils::dumpFile($path, null, null);
//.........这里部分代码省略.........
示例3: handleFileSyncRedirection
private function handleFileSyncRedirection(FileSyncKey $syncKey)
{
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
if (!$local) {
$remote_url = kDataCenterMgr::getRedirectExternalUrl($fileSync);
$this->redirect($remote_url);
}
}
示例4: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
// where file is {entryId/flavorId}.{ism,ismc,ismv}
$objectId = $type = null;
$objectIdStr = $this->getRequestParameter("objectId");
list($objectId, $type) = @explode(".", $objectIdStr);
if (!$type || !$objectId) {
die;
}
$ks = $this->getRequestParameter("ks");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
if ($type == "ism" || $type == "ismc") {
// backward compatiblity - to be removed once ismc is created with pure objectId.ext instead of entryId_flavorId_version.ext
if (strlen($objectId) != 10) {
$version = substr($objectId, 13);
$objectId = substr($objectId, 0, 10);
} else {
$version = null;
}
$entry = entryPeer::retrieveByPK($objectId);
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
$syncKey = $entry->getSyncKey($type == "ism" ? entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM : entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC, $version);
} else {
if ($type == "ismv") {
// backward compatiblity - to be removed once ismc is created with pure objectId.ext instead of entryId_flavorId_version.ext
if (strlen($objectId) != 10) {
$version = substr($objectId, 22);
$objectId = substr($objectId, 11, 10);
} else {
$version = null;
}
$flavorAsset = flavorAssetPeer::retrieveById($objectId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
} else {
die;
}
}
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for type [{$type}] objectId [{$objectId}]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFile::dumpUrl($remoteUrl);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
kFile::dumpFile($path);
}
示例5: execute
//.........这里部分代码省略.........
}
// we will throw an error later
} elseif (is_null($flavor) && !is_null($flavor_param_id)) {
$flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entry->getId(), $flavor_param_id);
if ($flavorAsset && $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$flavorAsset = null;
}
// we will throw an error later
} else {
if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
$flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry->getId());
} else {
$flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId());
}
if (!$flavorAsset) {
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($entry->getId(), flavorParams::TAG_WEB);
if (count($flavorAssets) > 0) {
$flavorAsset = $flavorAssets[0];
}
}
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::file_exists($syncKey, false)) {
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
} else {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
$this->redirect($remoteUrl);
}
$flv_wrapper = new myFlvHandler($path);
$isFlv = $flv_wrapper->isFlv();
// scrubbing is not allowed within mp4 files
if (!$isFlv) {
$seek_from = $seek_from_bytes = -1;
}
if ($seek_from !== -1 && $seek_from !== 0) {
if ($audio_only === '0') {
// audio_only was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flv_wrapper->getFirstVideoTimestamp() < 0) {
$audio_only = true;
}
list($bytes, $duration, $first_tag_byte, $to_byte) = $flv_wrapper->clip(0, -1, $audio_only);
list($bytes, $duration, $from_byte, $to_byte, $seek_from_timestamp) = $flv_wrapper->clip($seek_from, -1, $audio_only);
$seek_from_bytes = myFlvHandler::FLV_HEADER_SIZE + $flv_wrapper->getMetadataSize($audio_only) + $from_byte - $first_tag_byte;
}
// the direct path without a cdn is "http://s3kaltura.s3.amazonaws.com".$entry->getDataPath();
$extStorageUrl = $entry->getExtStorageUrl();
if ($extStorageUrl && substr_count($extStorageUrl, 's3kaltura')) {
// if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
if ($seek_from_timestamp == -1) {
$seek_from_timestamp = $seek_from;
}
$request_host = parse_url($extStorageUrl, PHP_URL_HOST);
$akamai_url = str_replace($request_host, "cdns3akmi.kaltura.com", $extStorageUrl);
$akamai_url .= $seek_from_bytes == -1 ? "" : "?aktimeoffset=" . floor($seek_from_timestamp / 1000);
header("Location: {$akamai_url}");
die;
} elseif ($extStorageUrl) {
// if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
示例6: serveAction
/**
* serve action returan the file from dataContent field.
*
* @action serve
* @serverOnly
* @param string $entryId Data entry id
* @param int $version Desired version of the data
* @param bool $forceProxy force to get the content without redirect
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
*/
function serveAction($entryId, $version = -1, $forceProxy = false)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DATA) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$ksObj = $this->getKs();
$ks = $ksObj ? $ksObj->getOriginalString() : null;
$securyEntryHelper = new KSecureEntryHelper($dbEntry, $ks, null);
$securyEntryHelper->validateForDownload();
if (!$version || $version == -1) {
$version = null;
}
$fileName = $dbEntry->getName();
$syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpUrl($remoteUrl);
} else {
// or redirect if no proxy
header("Location: {$remoteUrl}");
}
}
}
示例7: serveThumbToFile
/**
* @param FileSync $fileSync
* @param bool $local
* @param string $fileName
* @param bool $forceProxy
*/
protected function serveThumbToFile(FileSync $fileSync, $local, $fileName, $forceProxy = false)
{
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpUrl($remoteUrl);
} else {
// or redirect if no proxy
header("Location: {$remoteUrl}");
}
}
}
示例8: serveAction
/**
* Serves thumbnail by its id
*
* @action serve
* @param string $thumbAssetId
* @param int $version
* @param KalturaThumbParams $thumbParams
* @param KalturaThumbnailServeOptions $options
* @return file
*
* @throws KalturaErrors::THUMB_ASSET_IS_NOT_READY
* @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
*/
public function serveAction($thumbAssetId, $version = null, KalturaThumbParams $thumbParams = null, KalturaThumbnailServeOptions $options = null)
{
if (!kCurrentContext::$ks) {
$thumbAsset = kCurrentContext::initPartnerByAssetId($thumbAssetId);
if (!$thumbAsset || $thumbAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
kEntitlementUtils::initEntitlementEnforcement();
} else {
$thumbAsset = assetPeer::retrieveById($thumbAssetId);
}
if (!$thumbAsset || !$thumbAsset instanceof thumbAsset) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$entry = entryPeer::retrieveByPK($thumbAsset->getEntryId());
if (!$entry) {
//we will throw thumb asset not found, as the user is not entitled, and should not know that the entry exists.
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, ContextType::THUMBNAIL);
$securyEntryHelper->validateAccessControl();
$ext = $thumbAsset->getFileExt();
if (is_null($ext)) {
$ext = 'jpg';
}
$fileName = $thumbAsset->getEntryId() . "_" . $thumbAsset->getId() . ".{$ext}";
if (!$thumbParams) {
if ($options && $options->download) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
}
return $this->serveAsset($thumbAsset, $fileName, $version);
}
$thumbParams->validate();
$syncKey = $thumbAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $version);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
/* @var $fileSync FileSync */
if (!$local) {
if (!in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
header("Location: {$remoteUrl}");
die;
}
$filePath = $fileSync->getFullPath();
$thumbVersion = $thumbAsset->getId() . '_' . $version;
$tempThumbPath = myEntryUtils::resizeEntryImage($entry, $thumbVersion, $thumbParams->width, $thumbParams->height, $thumbParams->cropType, $thumbParams->backgroundColor, null, $thumbParams->quality, $thumbParams->cropX, $thumbParams->cropY, $thumbParams->cropWidth, $thumbParams->cropHeight, -1, 0, -1, $filePath, $thumbParams->density, $thumbParams->stripProfiles, null);
if ($options && $options->download) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
}
$mimeType = kFile::mimeType($tempThumbPath);
return $this->dumpFile($tempThumbPath, $mimeType);
}
示例9: execute
//.........这里部分代码省略.........
if ($entry->getStatus() == entryStatus::DELETED && $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected live stream entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$contentPath = myContentStorage::getFSContentRootPath();
$msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg";
$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, $msgPath);
} elseif ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
$contentPath = myContentStorage::getFSContentRootPath();
$msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.jpg";
$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, $msgPath);
//kFile::dumpFile($tempThumbPath, null, 0);
} elseif ($entry->getType() == entryType::MEDIA_CLIP) {
// commenting out the new behavior, in this case the thumbnail will be created in resizeEntryImage
//$contentPath = myContentStorage::getFSContentRootPath();
//$msgPath = $contentPath."content/templates/entry/thumbnail/broken_thumb.jpg";
//header("Xkaltura-app: entry [$entry_id] in conversion, returning template broken thumb");
//KalturaLog::log( "Entry in conversion, no thumbnail yet [$entry_id], created dynamic 1x1 jpg");
//kFile::dumpFile($msgPath, null, 0);
try {
$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);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
// get original flavor asset
$origFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id);
if ($origFlavorAsset) {
$syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false);
if (!$remoteFileSync) {
// file does not exist on any DC - die
KalturaLog::log("Error - no FileSync for entry [{$entry_id}]");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) {
KalturaLog::log("ERROR - Trying to redirect to myself - stop here.");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
$remote_url = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync, $_SERVER['REQUEST_URI']);
KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]");
$this->redirect($remote_url);
}
}
}
} else {
// file does not exist on any DC - die
KalturaLog::log("Error - no FileSync for entry [{$entry_id}]");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
}
if (!$local && !$tempThumbPath) {
$remote_url = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']);
KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]");
$this->redirect($remote_url);
}
// if we didnt return a template for the player die and dont return the original deleted thumb
if ($entry_status == entryStatus::DELETED) {
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
if (!$tempThumbPath) {
try {
$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);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
// get original flavor asset
$origFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id);
if ($origFlavorAsset) {
$syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false);
if (!$remoteFileSync) {
// file does not exist on any DC - die
KalturaLog::log("Error - no FileSync for entry [{$entry_id}]");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) {
KalturaLog::log("ERROR - Trying to redirect to myself - stop here.");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
$remote_url = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync, $_SERVER['REQUEST_URI']);
KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]");
$this->redirect($remote_url);
}
}
}
}
$nocache = strpos($tempThumbPath, "_NOCACHE_") !== false;
// notify external proxy, so it'll cache this url
if (!$nocache && requestUtils::getHost() == kConf::get("apphome_url") && file_exists($tempThumbPath)) {
self::notifyProxy($_SERVER["REQUEST_URI"]);
}
// cache result
if (!$nocache) {
$requestKey = $_SERVER["REQUEST_URI"];
$cache = new myCache("thumb", 86400 * 30);
// 30 days
$cache->put($requestKey, $tempThumbPath);
}
kFile::dumpFile($tempThumbPath, null, $nocache ? 0 : null);
// TODO - can delete from disk assuming we caneasily recreate it and it will anyway be cached in the CDN
// however dumpfile dies at the end so we cant just write it here (maybe register a shutdown callback)
}
示例10: redirectFileSyncIfRemote
/**
*
* @param $entry
* @param $sub_type
* @param $version
* @return FileSync
*/
private function redirectFileSyncIfRemote($file_sync, $local)
{
if (!$local) {
$shouldProxy = $this->getRequestParameter("forceproxy", false);
$remote_url = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']);
KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]");
if ($shouldProxy) {
kFile::dumpUrl($remote_url);
} else {
// or redirect if no proxy
$this->redirect($remote_url);
}
}
return $file_sync;
}
示例11: serveAction
/**
* serve action returns the original file.
*
* @action serve
* @param int $id job id
* @return file
*
*/
function serveAction($id)
{
$c = new Criteria();
$c->addAnd(BatchJobPeer::ID, $id);
$c->addAnd(BatchJobPeer::PARTNER_ID, $this->getPartnerId());
$c->addAnd(BatchJobPeer::JOB_TYPE, BatchJobType::BULKUPLOAD);
$batchJob = BatchJobPeer::doSelectOne($c);
if (!$batchJob) {
throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_NOT_FOUND, $id);
}
KalturaLog::info("Batch job found for jobid [{$id}] bulk upload type [" . $batchJob->getJobSubType() . "]");
$syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Type: text/plain; charset=UTF-8");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
return $this->dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
header("Location: {$remoteUrl}");
die;
}
}
示例12: serveFile
/**
* @param ISyncableFile $syncable
* @param int $fileSubType
* @param string $fileName
* @param bool $forceProxy
* @throws KalturaErrors::FILE_DOESNT_EXIST
*/
protected function serveFile(ISyncableFile $syncable, $fileSubType, $fileName, $entryId = null, $forceProxy = false)
{
/* @var $fileSync FileSync */
$syncKey = $syncable->getSyncKey($fileSubType);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$wamsAssetId = $fileSync->getWamsAssetId();
if (empty($wamsAssetId)) {
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
kWAMS::getInstance($fileSync->getPartnerId())->dumpFile($wamsAssetId, pathinfo($filePath, PATHINFO_EXTENSION));
}
} else {
if (in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpApiRequest($remoteUrl);
} else {
//TODO find or build function which redurects the API request with all its parameters without using curl.
// or redirect if no proxy
header("Location: {$remoteUrl}");
die;
}
} else {
$remoteUrl = $fileSync->getExternalUrl($entryId);
header("Location: {$remoteUrl}");
die;
}
}
}
示例13: serveFile
/**
* @param ISyncableFile $syncable
* @param int $fileSubType
* @param string $fileName
* @param bool $forceProxy
* @throws KalturaErrors::FILE_DOESNT_EXIST
*/
protected function serveFile(ISyncableFile $syncable, $fileSubType, $fileName, $entryId = null, $forceProxy = false)
{
/* @var $fileSync FileSync */
$syncKey = $syncable->getSyncKey($fileSubType);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
return $this->dumpFile($filePath, $mimeType);
} else {
if (in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFileUtils::dumpApiRequest($remoteUrl);
} else {
//TODO find or build function which redurects the API request with all its parameters without using curl.
// or redirect if no proxy
header("Location: {$remoteUrl}");
die;
}
} else {
$remoteUrl = $fileSync->getExternalUrl($entryId);
header("Location: {$remoteUrl}");
die;
}
}
}
示例14: getLocalThumbFilePath
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null)
{
KalturaLog::log("flavor_id [{$flavorId}] file_name [{$fileName}]");
if (is_null($flavorId)) {
KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'flavor_id');
}
$flavor = assetPeer::retrieveById($flavorId);
if (is_null($flavor)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND, $flavorId);
}
$flavorSyncKey = $flavor->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$file_path = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
$orig_image_path = null;
if (is_dir($file_path)) {
if (is_null($fileName)) {
KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'file name');
}
$orig_image_path = $file_path . DIRECTORY_SEPARATOR . $fileName;
}
try {
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $orig_image_path, $density);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
$remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($flavorSyncKey, false);
if (!$remoteFileSync) {
// file does not exist on any DC - die
KalturaLog::err("No FileSync for flavor [{$flavorId}]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) {
KalturaLog::err("Trying to redirect to myself - stop here.");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) {
KalturaLog::err("Origin file sync is on remote storage.");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync);
kFileUtils::dumpUrl($remoteUrl);
}
}
}
示例15: execute
public function execute()
{
requestUtils::handleConditionalGet();
$flavorId = $this->getRequestParameter("flavorId");
$shouldProxy = $this->getRequestParameter("forceproxy", false);
$ks = $this->getRequestParameter("ks");
$fileParam = $this->getRequestParameter("file");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$flavorAsset = flavorAssetPeer::retrieveById($flavorId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($flavorAsset->getPartnerId());
myPartnerUtils::enforceDelivery($flavorAsset->getPartnerId());
//disabled enforce cdn because of rtmp delivery
//requestUtils::enforceCdnDelivery($flavorAsset->getPartnerId());
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
// always dump remote urls so they will be cached by the cdn transparently
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFile::dumpUrl($remoteUrl, true, true);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$flvWrapper = new myFlvHandler($path);
$isFlv = $flvWrapper->isFlv();
$clipFrom = $this->getRequestParameter("clipFrom", 0);
// milliseconds
$clipTo = $this->getRequestParameter("clipTo", 2147483647);
// milliseconds
if ($clipTo == 0) {
$clipTo = 2147483647;
}
if (is_dir($path) && $fileParam) {
$path .= "/{$fileParam}";
//echo "path($path),file($fileParam)";
kFile::dumpFile($path, null, null);
die;
} else {
if (!$isFlv) {
$limit_file_size = 0;
if ($clipTo != 2147483647) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$limit_file_size = floor(@filesize($path) * ($clipTo / $duration));
}
}
kFile::dumpFile($path, null, null, $limit_file_size);
die;
}
}
$audioOnly = $this->getRequestParameter("audioOnly");
// milliseconds
if ($audioOnly === '0') {
// audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
$audioOnly = true;
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
$bytes = 0;
if ($seekFrom !== -1 && $seekFrom !== 0) {
list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
$seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
} else {
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
}
$metadataSize = $flvWrapper->getMetadataSize($audioOnly);
$dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
$totalLength = $dataOffset + $bytes;
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
if ($totalLength < 1000) {
// (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
} else {
requestUtils::sendCdnHeaders("flv", $rangeLength);
}
header('Content-Disposition: attachment; filename="video.flv"');
// dont inject cuepoint into the stream
//.........这里部分代码省略.........