本文整理汇总了PHP中requestUtils::handleConditionalGet方法的典型用法代码示例。如果您正苦于以下问题:PHP requestUtils::handleConditionalGet方法的具体用法?PHP requestUtils::handleConditionalGet怎么用?PHP requestUtils::handleConditionalGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requestUtils
的用法示例。
在下文中一共展示了requestUtils::handleConditionalGet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
requestUtils::handleConditionalGet();
$file_sync_id = $this->getRequestParameter("id");
$hash = $this->getRequestParameter("hash");
$file_name = $this->getRequestParameter("fileName");
if ($file_name) {
$file_name = base64_decode($file_name);
}
kDataCenterMgr::serveFileToRemoteDataCenter($file_sync_id, $hash, $file_name);
die;
}
示例2: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
requestUtils::handleConditionalGet();
$file_sync_id = $this->getRequestParameter("id");
$hash = $this->getRequestParameter("hash");
$file_name = $this->getRequestParameter("fileName");
if ($file_name) {
$file_name = base64_decode($file_name);
}
$file_sync = FileSyncPeer::retrieveByPk($file_sync_id);
if (!$file_sync) {
$current_dc_id = kDataCenterMgr::getCurrentDcId();
$error = "DC[{$current_dc_id}]: Cannot find FileSync with id [{$file_sync_id}]";
KalturaLog::err($error);
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveFile', $file_sync->getPartnerId());
kDataCenterMgr::serveFileToRemoteDataCenter($file_sync, $hash, $file_name);
die;
}
示例3: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
requestUtils::handleConditionalGet();
ignore_user_abort();
$entry_id = $this->getRequestParameter("entry_id");
$widget_id = $this->getRequestParameter("widget_id", 0);
$upload_token_id = $this->getRequestParameter("upload_token_id");
$version = $this->getIntRequestParameter("version", null, 0, 10000000);
$type = $this->getIntRequestParameter("type", 1, 1, 5);
//Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5.
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
if (strpos($width, "!") || strpos($height, "!")) {
$type = 5;
}
$width = $this->getFloatRequestParameter("width", -1, -1, 10000);
$height = $this->getFloatRequestParameter("height", -1, -1, 10000);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$quality = $this->getIntRequestParameter("quality", 0, 0, 100);
$src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000);
$src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000);
$src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000);
$src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000);
$vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
$density = $this->getFloatRequestParameter("density", 0, 0);
$stripProfiles = $this->getRequestParameter("strip", null);
$flavor_id = $this->getRequestParameter("flavor_id", null);
$file_name = $this->getRequestParameter("file_name", null);
$file_name = basename($file_name);
// actual width and height of image from which the src_* values were taken.
// these will be used to multiply the src_* parameters to make them relate to the original image size.
$rel_width = $this->getFloatRequestParameter("rel_width", -1, -1, 10000);
$rel_height = $this->getFloatRequestParameter("rel_height", -1, -1, 10000);
if ($width == -1 && $height == -1) {
$width = 120;
$height = 90;
} 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;
}
}
}
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
$partner = null;
// validating the inputs
if (!is_numeric($quality) || $quality < 0 || $quality > 100) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'quality must be between 20 and 100');
}
if (!is_numeric($src_x) || $src_x < 0 || $src_x > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_x must be between 0 and 10000');
}
if (!is_numeric($src_y) || $src_y < 0 || $src_y > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_y must be between 0 and 10000');
}
if (!is_numeric($src_w) || $src_w < 0 || $src_w > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_w must be between 0 and 10000');
}
if (!is_numeric($src_h) || $src_h < 0 || $src_h > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_h must be between 0 and 10000');
}
if (!is_numeric($width) || $width < 0 || $width > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'width must be between 0 and 10000');
}
if (!is_numeric($height) || $height < 0 || $height > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000');
}
if (!is_numeric($density) || $density < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive');
}
if (!is_numeric($vid_sec) || $vid_sec < -1) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive');
}
if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters');
}
if ($upload_token_id) {
$upload_token = UploadTokenPeer::retrieveByPK($upload_token_id);
if ($upload_token) {
$partnerId = $upload_token->getPartnerId();
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($density == 0) {
$density = $partner->getDefThumbDensity();
}
if (is_null($stripProfiles)) {
$stripProfiles = $partner->getStripThumbProfile();
}
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
//.........这里部分代码省略.........
示例4: execute
public function execute()
{
requestUtils::handleConditionalGet();
// 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);
$meta = $this->getRequestParameter("meta", false);
$file_info = $this->getRequestParameter("file_info");
$this->entry_id = 0;
$this->kshow_id = 0;
$version = $this->getRequestParameter("version", null);
// returned the version feature to allow rollback
$addPadding = false;
if (!empty($file_info)) {
$file_info_arr = explode("-", $file_info);
// the format of file_info is assumed <kshow_id>-<video|audio|voice>-<1|2|3>
// OR
// e<entry_id>-<video|audio|voice>-<1|2|3>
if (count($file_info_arr) == 0) {
$this->error = "Invalid request format [{$file_info}]";
return sfView::ERROR;
}
if ($file_info_arr[0][0] == 'e') {
$this->entry_id = substr($file_info_arr[0], 1);
} else {
$this->kshow_id = $file_info_arr[0];
}
if (count($file_info_arr) == 1) {
// on this case we assume that the single info parameter is an entry id
// we redirect to it !
$entry = entryPeer::retrieveByPK($this->entry_id);
if (!$entry) {
// very bad - no such entry !!
echo "no entry " . $this->entry_id;
die;
}
$dataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$path = kFileSyncUtils::getReadyLocalFilePathForKey($dataKey);
$host = requestUtils::getHost();
$this->redirect($host . $path);
}
$this->timeline = $file_info_arr[1];
if (count($file_info_arr) > 2) {
// this migth include a .flv suffix
$last_token = $file_info_arr[2];
$last_token_srr = explode(".", $last_token);
$this->streamNum = $last_token_srr[0];
if (count($file_info_arr) > 3) {
$version = $file_info_arr[3];
}
if (count($file_info_arr) > 4 && $file_info_arr[4] == "padding") {
$addPadding = true;
}
} else {
$this->streamNum = 3;
}
} else {
$this->kshow_id = @$_GET["kshow_id"];
$this->entry_id = @$_GET["entry_id"];
$this->timeline = @$_GET["timeline"];
$this->streamNum = $this->getRequestParameter('num', 3);
}
$entry = null;
if ($this->entry_id) {
$entry = entryPeer::retrieveByPK($this->entry_id);
if (!$entry) {
$this->error = "No such entry " . $this->entry_id;
return sfView::ERROR;
}
$this->kshow_id = $entry->getKshowId();
}
$kshow = kshowPeer::retrieveByPK($this->kshow_id);
if (!$kshow) {
$this->error = "No such kshow " . $this->kshow_id;
return sfView::ERROR;
}
if (!$entry) {
// if we received only the kshow (old widgets) retrieve the entry
$entry = entryPeer::retrieveByPK($kshow->getShowEntryId());
}
if (!$entry) {
$this->error = "No such entry for kshow " . $this->kshow_id;
return sfView::ERROR;
}
// update the widget log only for video && stream 1
if ($this->timeline == "video" && $this->streamNum == 1) {
$referer = @$_SERVER['HTTP_REFERER'];
//since we're using a cdn this is useless
//$kshow->incPlays();
//WidgetLog::incPlaysIfExists( $this->kshow_id , $this->entry_id );
}
$dataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
// replaced__getDataPath
$path = kFileSyncUtils::getReadyLocalFilePathForKey($dataKey);
$this->flv_streamer = new myFlvStreamer($path, $this->timeline, $this->streamNum, $addPadding);
$this->total_length = $this->flv_streamer->getTotalLength(true);
// $total_length;
//$this->getController()->setRenderMode ( sfView::RENDER_CLIENT );
//.........这里部分代码省略.........
示例5: 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
//.........这里部分代码省略.........
示例6: 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);
//.........这里部分代码省略.........
示例7: 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);
// 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
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
// 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.
die;
} 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);
kFile::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");
//
if (substr($streamer, 0, 4) == "rtmp") {
// the fms may add .mp4 to the end of the url
$streamer = "rtmp";
}
// grab seek_from_bytes parameter and normalize url
$seek_from_bytes = $this->getRequestParameter("seek_from_bytes", -1);
$request = str_replace("/seek_from_bytes/{$seek_from_bytes}", "", $request);
if ($seek_from_bytes <= 0) {
$seek_from_bytes = -1;
}
// grab seek_from parameter and normalize url
$seek_from = $this->getRequestParameter("seek_from", -1);
$request = str_replace("/seek_from/{$seek_from}", "", $request);
if ($seek_from <= 0) {
$seek_from = -1;
}
$this->dump_from_byte = 0;
// reset accurate seek from timestamp
$seek_from_timestamp = -1;
// backward compatibility
if ($flavor === "0") {
// for edit version
$flavor = "edit";
//.........这里部分代码省略.........
示例8: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
KExternalErrors::setResponseErrorCode(KExternalErrors::HTTP_STATUS_NOT_FOUND);
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
requestUtils::handleConditionalGet();
ignore_user_abort();
$entry_id = $this->getRequestParameter("entry_id");
$widget_id = $this->getRequestParameter("widget_id", 0);
$upload_token_id = $this->getRequestParameter("upload_token_id");
$version = $this->getIntRequestParameter("version", null, 0, 10000000);
$type = $this->getIntRequestParameter("type", 1, 1, 5);
//Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5.
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
if (strpos($width, "!") || strpos($height, "!")) {
$type = 5;
}
$width = $this->getFloatRequestParameter("width", -1, -1, 10000);
$height = $this->getFloatRequestParameter("height", -1, -1, 10000);
$nearest_aspect_ratio = $this->getIntRequestParameter("nearest_aspect_ratio", 0, 0, 1);
$imageFilePath = null;
$crop_provider = $this->getRequestParameter("crop_provider", null);
$quality = $this->getIntRequestParameter("quality", 0, 0, 100);
$src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000);
$src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000);
$src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000);
$src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000);
$vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
$density = $this->getFloatRequestParameter("density", 0, 0);
$stripProfiles = $this->getRequestParameter("strip", null);
$flavor_id = $this->getRequestParameter("flavor_id", null);
$file_name = $this->getRequestParameter("file_name", null);
$file_name = basename($file_name);
// actual width and height of image from which the src_* values were taken.
// these will be used to multiply the src_* parameters to make them relate to the original image size.
$rel_width = $this->getFloatRequestParameter("rel_width", -1, -1, 10000);
$rel_height = $this->getFloatRequestParameter("rel_height", -1, -1, 10000);
$def_width = $this->getFloatRequestParameter("def_width", -1, -1, 10000);
$def_height = $this->getFloatRequestParameter("def_height", -1, -1, 10000);
if ($width == -1 && $height == -1) {
if ($def_width == -1) {
$width = 120;
} else {
$width = $def_width;
}
if ($def_height == -1) {
$height = 90;
} else {
$height = $def_height;
}
} else {
if ($width == -1) {
$width = 0;
} else {
if ($height == -1) {
$height = 0;
}
}
}
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
$partner = null;
$format = $this->getRequestParameter("format", null);
// validating the inputs
if (!is_numeric($quality) || $quality < 0 || $quality > 100) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'quality must be between 20 and 100');
}
if (!is_numeric($src_x) || $src_x < 0 || $src_x > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_x must be between 0 and 10000');
}
if (!is_numeric($src_y) || $src_y < 0 || $src_y > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_y must be between 0 and 10000');
}
if (!is_numeric($src_w) || $src_w < 0 || $src_w > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_w must be between 0 and 10000');
}
if (!is_numeric($src_h) || $src_h < 0 || $src_h > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_h must be between 0 and 10000');
}
if (!is_numeric($width) || $width < 0 || $width > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'width must be between 0 and 10000');
}
if (!is_numeric($height) || $height < 0 || $height > 10000) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000');
}
if (!is_numeric($density) || $density < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive');
}
if (!is_numeric($vid_sec) || $vid_sec < -1) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive');
}
if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters');
}
if ($vid_slices != -1 && $vid_slices <= 0 || !is_numeric($vid_slices)) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_slices must be positive');
//.........这里部分代码省略.........
示例9: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
requestUtils::handleConditionalGet();
ignore_user_abort();
$entry_id = $this->getRequestParameter("entry_id");
$widget_id = $this->getRequestParameter("widget_id", 0);
$upload_token_id = $this->getRequestParameter("upload_token_id");
$version = $this->getRequestParameter("version", null);
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
$type = $this->getRequestParameter("type", 1);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$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);
// actual width and height of image from which the src_* values were taken.
// these will be used to multiply the src_* parameters to make them relate to the original image size.
$rel_width = $this->getRequestParameter("rel_width", -1);
$rel_height = $this->getRequestParameter("rel_height", -1);
if ($width == -1 && $height == -1) {
$width = 120;
$height = 90;
} 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;
}
}
}
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
if ($upload_token_id) {
$upload_token = UploadTokenPeer::retrieveByPK($upload_token_id);
if ($upload_token) {
$thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg");
kFile::fullMkdir($thumb_full_path);
if (file_exists($upload_token->getUploadTempPath())) {
$src_full_path = $upload_token->getUploadTempPath();
$valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP);
$image_type = exif_imagetype($src_full_path);
if (!in_array($image_type, $valid_image_types)) {
// capture full frame
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3);
if (!file_exists($thumb_full_path)) {
myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0);
}
$src_full_path = $thumb_full_path;
}
// and resize it
myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h);
kFile::dumpFile($thumb_full_path);
}
}
}
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
// multiply the passed $src_* values so that they will relate to the original image size, according to $src_display_*
if ($rel_width != -1) {
$widthRatio = $entry->getWidth() / $rel_width;
$src_x = $src_x * $widthRatio;
$src_w = $src_w * $widthRatio;
}
if ($rel_height != -1) {
$heightRatio = $entry->getHeight() / $rel_height;
$src_y = $src_y * $heightRatio;
$src_h = $src_h * $heightRatio;
}
if (!$entry) {
// get the widget
$widget = widgetPeer::retrieveByPK($widget_id);
if (!$widget) {
KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND);
}
// get the kshow
$kshow_id = $widget->getKshowId();
$kshow = kshowPeer::retrieveByPK($kshow_id);
if ($kshow) {
$entry_id = $kshow->getShowEntryId();
} else {
$entry_id = $widget->getEntryId();
}
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
}
//.........这里部分代码省略.........
示例10: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
requestUtils::handleConditionalGet();
$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 = entryPeer::retrieveByPK($entry_id);
if (!$entry) {
// what to return ??
die;
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$securyEntryHelper = new KSecureEntryHelper($entry, $ks, $referrer);
$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 = flavorAssetPeer::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) {
// use the fileSync from the entry
if ($type == "download" && $format) {
$flavor_asset = flavorAssetPeer::retrieveByEntryIdAndExtension($entry_id, $format);
} else {
$flavor_asset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id);
}
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;
}
// Gonen 2010-08-05 workaround to make sure file name includes correct extension
// make sure a file extension is added to the downloaded file so browser will identify and
// allow opening with default program
// for direct serve we do not want to send content-disposition header
if (!$direct_serve) {
$ext = pathinfo($file_sync->getFullPath(), PATHINFO_EXTENSION);
if ($relocate) {
// remove relocate file extension
//.........这里部分代码省略.........