コード例 #1
0
 private function sendAPICall($url, $options = null, $noDecoding = false)
 {
     KalturaLog::debug("sending API call - {$url}");
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if ($options) {
         curl_setopt_array($ch, $options);
     }
     $result = curl_exec($ch);
     if (($errString = curl_error($ch)) !== '' || ($errNum = curl_errno($ch)) !== 0) {
         KalturaLog::err('problem with curl - ' . $errString . ' error num - ' . $errNum);
         curl_close($ch);
         throw new Exception("curl error with url " . $url);
     }
     if (!$noDecoding) {
         $stringResult = $result;
         $result = json_decode($result);
         if (json_last_error() !== JSON_ERROR_NONE) {
             KalturaLog::err("bad response from service provider");
             curl_close($ch);
             throw new Exception("json decode error with response - " . $stringResult);
         }
     }
     KalturaLog::debug('result is - ' . var_dump($result));
     curl_close($ch);
     return $result;
 }
コード例 #2
0
 public function execute()
 {
     $ksStr = $this->getP("ks");
     if ($ksStr) {
         $ksObj = null;
         try {
             $ksObj = ks::fromSecureString($ksStr);
         } catch (Exception $e) {
         }
         if ($ksObj) {
             $partner = PartnerPeer::retrieveByPK($ksObj->partner_id);
             if (!$partner) {
                 KExternalErrors::dieError(KExternalErrors::PARTNER_NOT_FOUND);
             }
             if (!$partner->validateApiAccessControl()) {
                 KExternalErrors::dieError(KExternalErrors::SERVICE_ACCESS_CONTROL_RESTRICTED);
             }
             $ksObj->kill();
         }
         KalturaLog::info("Killing session with ks - [{$ksStr}], decoded - [" . base64_decode($ksStr) . "]");
     } else {
         KalturaLog::err('logoutAction called with no KS');
     }
     setcookie('pid', "", 0, "/");
     setcookie('subpid', "", 0, "/");
     setcookie('kmcks', "", 0, "/");
     return sfView::NONE;
     //redirection to kmc/kmc is done from java script
 }
コード例 #3
0
 /**
  * @param BaseObject $object
  * @return bool true if should continue to the next consumer
  */
 public function objectAdded(BaseObject $object)
 {
     if (!$object instanceof FileSync || $object->getStatus() != FileSync::FILE_SYNC_STATUS_PENDING || $object->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_FILE || $object->getDc() == kDataCenterMgr::getCurrentDcId()) {
         return true;
     }
     $c = new Criteria();
     $c->addAnd(FileSyncPeer::OBJECT_ID, $object->getObjectId());
     $c->addAnd(FileSyncPeer::VERSION, $object->getVersion());
     $c->addAnd(FileSyncPeer::OBJECT_TYPE, $object->getObjectType());
     $c->addAnd(FileSyncPeer::OBJECT_SUB_TYPE, $object->getObjectSubType());
     $c->addAnd(FileSyncPeer::ORIGINAL, '1');
     $original_filesync = FileSyncPeer::doSelectOne($c);
     if (!$original_filesync) {
         KalturaLog::err('Original filesync not found for object_id[' . $object->getObjectId() . '] version[' . $object->getVersion() . '] type[' . $object->getObjectType() . '] subtype[' . $object->getObjectSubType() . ']');
         return true;
     }
     $sourceFileUrl = $original_filesync->getExternalUrl();
     if (!$sourceFileUrl) {
         KalturaLog::err('External URL not found for filesync id [' . $object->getId() . ']');
         return true;
     }
     $job = kMultiCentersManager::addFileSyncImportJob($this->getEntryId($object), $object->getPartnerId(), $object->getId(), $sourceFileUrl);
     $job->setDc($object->getDc());
     $job->save();
     return true;
 }
コード例 #4
0
 /**
  * 
  * @param int $offset
  * @param int $itemCountPerPage
  */
 protected function callService($offset, $itemCountPerPage)
 {
     $client = Infra_ClientHelper::getClient();
     if ($this->impersonatedPartnerId) {
         Infra_ClientHelper::impersonate($this->impersonatedPartnerId);
     }
     $pager = new Kaltura_Client_Type_FilterPager();
     $pager->pageIndex = (int) ($offset / $itemCountPerPage) + 1;
     $pager->pageSize = $itemCountPerPage;
     $action = $this->action;
     $params = $this->args;
     $params[] = $pager;
     try {
         $response = call_user_func_array(array($this->service, $action), $params);
     } catch (Kaltura_Client_Exception $e) {
         KalturaLog::err($e->getMessage());
         return array();
     }
     $this->totalCount = $response->totalCount;
     $this->total = $response->total;
     if (!$response->objects) {
         return array();
     }
     return $response->objects;
 }
コード例 #5
0
 public function run($jobs = null)
 {
     $filter = new KalturaLiveStreamEntryFilter();
     $filter->isLive = KalturaNullableBoolean::TRUE_VALUE;
     $filter->orderBy = KalturaLiveStreamEntryOrderBy::CREATED_AT_ASC;
     $filter->moderationStatusIn = KalturaEntryModerationStatus::PENDING_MODERATION . ',' . KalturaEntryModerationStatus::APPROVED . ',' . KalturaEntryModerationStatus::REJECTED . ',' . KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW . ',' . KalturaEntryModerationStatus::AUTO_APPROVED;
     $pager = new KalturaFilterPager();
     $pager->pageSize = 500;
     $pager->pageIndex = 1;
     $entries = self::$kClient->liveStream->listAction($filter, $pager);
     while (count($entries->objects)) {
         foreach ($entries->objects as $entry) {
             try {
                 /* @var $entry KalturaLiveEntry */
                 self::impersonate($entry->partnerId);
                 self::$kClient->liveStream->validateRegisteredMediaServers($entry->id);
                 self::unimpersonate();
                 $filter->createdAtGreaterThanOrEqual = $entry->createdAt;
             } catch (KalturaException $e) {
                 self::unimpersonate();
                 KalturaLog::err("Caught exception with message [" . $e->getMessage() . "]");
             }
         }
         $pager->pageIndex++;
         $entries = self::$kClient->liveStream->listAction($filter, $pager);
     }
 }
コード例 #6
0
 protected function deleteFilesPHP($searchPath, $minutesOld, $simulateOnly)
 {
     $secondsOld = $minutesOld * 60;
     $files = glob($searchPath);
     KalturaLog::info("Found [" . count($files) . "] to scan");
     $now = time();
     KalturaLog::info("Deleting files that are " . $secondsOld . " seconds old (modified before " . date('c', $now - $secondsOld) . ")");
     $deletedCount = 0;
     foreach ($files as $file) {
         $filemtime = filemtime($file);
         if ($filemtime > $now - $secondsOld) {
             continue;
         }
         if ($simulateOnly) {
             KalturaLog::info("Simulating: Deleting file [{$file}], it's last modification time was " . date('c', $filemtime));
             continue;
         }
         KalturaLog::info("Deleting file [{$file}], it's last modification time was " . date('c', $filemtime));
         $res = @unlink($file);
         if (!$res) {
             KalturaLog::err("Error: problem while deleting [{$file}]");
             continue;
         }
         $deletedCount++;
     }
 }
コード例 #7
0
ファイル: CuePointService.php プロジェクト: AdiTal/server
 /**
  * Allows you to add an cue point object associated with an entry
  * 
  * @action add
  * @param KalturaCuePoint $cuePoint
  * @return KalturaCuePoint
  */
 function addAction(KalturaCuePoint $cuePoint)
 {
     $dbCuePoint = $cuePoint->toInsertableObject();
     if ($cuePoint->systemName) {
         $existingCuePoint = CuePointPeer::retrieveBySystemName($cuePoint->entryId, $cuePoint->systemName);
         if ($existingCuePoint) {
             throw new KalturaAPIException(KalturaCuePointErrors::CUE_POINT_SYSTEM_NAME_EXISTS, $cuePoint->systemName, $existingCuePoint->getId());
         }
     }
     /* @var $dbCuePoint CuePoint */
     $dbCuePoint->setPartnerId($this->getPartnerId());
     $dbCuePoint->setPuserId(is_null($cuePoint->userId) ? $this->getKuser()->getPuserId() : $cuePoint->userId);
     $dbCuePoint->setStatus(CuePointStatus::READY);
     if ($this->getCuePointType()) {
         $dbCuePoint->setType($this->getCuePointType());
     }
     $created = $dbCuePoint->save();
     if (!$created) {
         KalturaLog::err("Cue point not created");
         return null;
     }
     $cuePoint = KalturaCuePoint::getInstance($dbCuePoint->getType());
     if (!$cuePoint) {
         KalturaLog::err("API Cue point not instantiated");
         return null;
     }
     $cuePoint->fromObject($dbCuePoint, $this->getResponseProfile());
     return $cuePoint;
 }
コード例 #8
0
 protected function copyLiveMetadata(baseEntry $object, $liveEntryId)
 {
     $recordedEntryId = $object->getId();
     $partnerId = $object->getPartnerId();
     $metadataProfiles = MetadataProfilePeer::retrieveAllActiveByPartnerId($partnerId, MetadataObjectType::ENTRY);
     foreach ($metadataProfiles as $metadataProfile) {
         $originMetadataObj = MetadataPeer::retrieveByObject($metadataProfile->getId(), MetadataObjectType::ENTRY, $liveEntryId);
         if ($originMetadataObj) {
             $metadataProfileId = $metadataProfile->getId();
             $metadataProfileVersion = $metadataProfile->getVersion();
             $destMetadataObj = new Metadata();
             $destMetadataObj->setPartnerId($partnerId);
             $destMetadataObj->setMetadataProfileId($metadataProfileId);
             $destMetadataObj->setMetadataProfileVersion($metadataProfileVersion);
             $destMetadataObj->setObjectType(MetadataObjectType::ENTRY);
             $destMetadataObj->setObjectId($recordedEntryId);
             $destMetadataObj->setStatus(KalturaMetadataStatus::VALID);
             $originMetadataKey = $originMetadataObj->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
             $originXml = kFileSyncUtils::file_get_contents($originMetadataKey, true, false);
             // validate object exists
             $object = kMetadataManager::getObjectFromPeer($destMetadataObj);
             if ($object) {
                 $destMetadataObj->save();
             } else {
                 KalturaLog::err('invalid object type');
                 continue;
             }
             $destMetadataKey = $destMetadataObj->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
             kFileSyncUtils::file_put_contents($destMetadataKey, $originXml);
         }
     }
 }
 /**
  * Adds conditions, matches and where clauses to the query
  * @param IKalturaIndexQuery $query
  */
 public function applyCondition(IKalturaDbQuery $query)
 {
     switch ($this->getComparison()) {
         case KalturaSearchConditionComparison::EQUAL:
             $comparison = ' = ';
             break;
         case KalturaSearchConditionComparison::GREATER_THAN:
             $comparison = ' > ';
             break;
         case KalturaSearchConditionComparison::GREATER_THAN_OR_EQUAL:
             $comparison = ' >= ';
             break;
         case KalturaSearchConditionComparison::LESS_THAN:
             $comparison = " < ";
             break;
         case KalturaSearchConditionComparison::LESS_THAN_OR_EQUAL:
             $comparison = " <= ";
             break;
         case KalturaSearchConditionComparison::NOT_EQUAL:
             $comparison = " <> ";
             break;
         default:
             KalturaLog::ERR("Missing comparison type");
             return;
     }
     $field = $this->getField();
     $value = $this->getValue();
     $fieldValue = $this->getFieldValue($field);
     if (is_null($fieldValue)) {
         KalturaLog::err('Unknown field [' . $field . ']');
         return;
     }
     $newCondition = $fieldValue . $comparison . KalturaCriteria::escapeString($value);
     $query->addCondition($newCondition);
 }
コード例 #10
0
 /**
  * @param KSchedularTaskConfig $taskConfig
  */
 public function __construct(KSchedularTaskConfig $taskConfig = null)
 {
     /*
      *  argv[0] - the script name
      *  argv[1] - serialized KSchedulerConfig config
      */
     global $argv, $g_context;
     $this->sessionKey = uniqid('sess');
     $this->start = microtime(true);
     if (is_null($taskConfig)) {
         $this->taskConfig = unserialize(base64_decode($argv[1]));
     } else {
         $this->taskConfig = $taskConfig;
     }
     if (!$this->taskConfig) {
         die("Task config not supplied");
     }
     date_default_timezone_set($this->taskConfig->getTimezone());
     // clear seperator between executions
     KalturaLog::debug('___________________________________________________________________________________');
     KalturaLog::info(file_get_contents(dirname(__FILE__) . "/../VERSION.txt"));
     if (!$this->taskConfig instanceof KSchedularTaskConfig) {
         KalturaLog::err('config is not a KSchedularTaskConfig');
         die;
     }
     KalturaLog::debug("set_time_limit({$this->taskConfig->maximumExecutionTime})");
     set_time_limit($this->taskConfig->maximumExecutionTime);
 }
コード例 #11
0
 public function __construct($message, $code = null, $data = null)
 {
     KalturaLog::err("Code: [{$code}] Message: [{$message}]");
     $this->message = $message;
     $this->code = $code;
     $this->data = $data;
 }
コード例 #12
0
 protected static function init()
 {
     if (!kConf::hasParam('monitor_uri')) {
         return null;
     }
     $uri = kConf::get('monitor_uri');
     $pathInfo = parse_url($uri);
     if (isset($pathInfo['host']) && $pathInfo['port']) {
         $host = $pathInfo['host'];
         if (isset($pathInfo['scheme'])) {
             $host = $pathInfo['scheme'] . "://{$host}";
         }
         $errno = null;
         $errstr = null;
         self::$stream = fsockopen($host, $pathInfo['port'], $errno, $errstr, 1);
         if (self::$stream) {
             return true;
         }
         if (class_exists('KalturaLog')) {
             KalturaLog::err("Open socket failed: {$errstr}");
         }
     }
     self::$stream = fopen($uri, 'a');
     if (self::$stream) {
         return true;
     }
     self::$stream = false;
     // prevent init from being called again
     return false;
 }
コード例 #13
0
ファイル: ksrAction.class.php プロジェクト: DBezemer/server
 /**
  * Will return a JS library for integrating the KSR (similar to HTML5 in concept)
  * uiconfId specifies from which uiconf to fetch different settings that should be replaced in the JS
  */
 public function execute()
 {
     // make sure output is not parsed as HTML
     header("Content-type: application/x-javascript");
     $uiconfId = $this->getRequestParameter("uiconfId");
     // replace all $_GET with $this->getRequestParameter()
     // load uiconf from DB.
     $this->uiconfObj = uiConfPeer::retrieveByPK($uiconfId);
     if (!$this->uiconfObj) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND);
     }
     $ui_conf_swf_url = $this->uiconfObj->getSwfUrl();
     if (!$ui_conf_swf_url) {
         KExternalErrors::dieError(KExternalErrors::ILLEGAL_UI_CONF, "SWF URL not found in UI conf");
     }
     @libxml_use_internal_errors(true);
     try {
         $this->uiconfXmlObj = new SimpleXMLElement(trim($this->uiconfObj->getConfFile()));
     } catch (Exception $e) {
         KalturaLog::err("malformed uiconf XML - base64 encoded: [" . base64_encode(trim($this->uiconfObj->getConfFile())) . "]");
     }
     if (!$this->uiconfXmlObj instanceof SimpleXMLElement) {
         // no xml or invalid XML, so throw exception
         throw new Exception('uiconf XML is invalid');
     }
     // unsupress the xml errors
     @libxml_use_internal_errors(false);
     $this->_initReplacementTokens();
     $this->_prepareLibJs();
     $this->_prepareJs();
     echo $this->jsResult;
     die;
 }
コード例 #14
0
 public function validateForSubmission(EntryDistribution $entryDistribution, $action)
 {
     $validationErrors = parent::validateForSubmission($entryDistribution, $action);
     $inListOrNullFields = array(FacebookDistributionField::CALL_TO_ACTION_TYPE_VALID_VALUES => explode(',', self::CALL_TO_ACTION_TYPE_VALID_VALUES));
     if (count($entryDistribution->getFlavorAssetIds())) {
         $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
     } else {
         $flavorAssets = assetPeer::retrieveReadyFlavorsByEntryId($entryDistribution->getEntryId());
     }
     $validVideo = false;
     foreach ($flavorAssets as $flavorAsset) {
         $validVideo = $this->validateVideo($flavorAsset);
         if ($validVideo) {
             // even one valid video is enough
             break;
         }
     }
     if (!$validVideo) {
         KalturaLog::err("No valid video found for entry [" . $entryDistribution->getEntryId() . "]");
         $validationErrors[] = $this->createCustomValidationError($action, DistributionErrorType::INVALID_DATA, 'flavorAsset', ' No valid flavor found');
     }
     $allFieldValues = $this->getAllFieldValues($entryDistribution);
     if (!$allFieldValues || !is_array($allFieldValues)) {
         KalturaLog::err('Error getting field values from entry distribution id [' . $entryDistribution->getId() . '] profile id [' . $this->getId() . ']');
         return $validationErrors;
     }
     if ($allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME] && $allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME] > time() && !dateUtils::isWithinTimeFrame($allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME], FacebookConstants::FACEBOOK_MIN_POSTPONE_POST_IN_SECONDS, FacebookConstants::FACEBOOK_MAX_POSTPONE_POST_IN_SECONDS)) {
         KalturaLog::err("Scheduled time to publish defies the facebook restriction of six minute to six months from now got" . $allFieldValues[FacebookDistributionField::SCHEDULE_PUBLISHING_TIME]);
         $validationErrors[] = $this->createCustomValidationError($action, DistributionErrorType::INVALID_DATA, 'sunrise', 'Distribution sunrise is invalid (should be 6 minutes to 6 months from now)');
     }
     $validationErrors = array_merge($validationErrors, $this->validateInListOrNull($inListOrNullFields, $allFieldValues, $action));
     return $validationErrors;
 }
コード例 #15
0
 protected function distribute(KalturaBatchJob $job, KalturaDistributionJobData $data)
 {
     if ($job->queueTime + self::$taskConfig->params->maxTimeBeforeFail < time()) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CLOSER_TIMEOUT, 'Timed out', KalturaBatchJobStatus::FAILED);
     }
     try {
         $this->engine = $this->getDistributionEngine($job->jobSubType, $data);
         if (!$this->engine) {
             KalturaLog::err('Cannot create DistributeEngine of type [' . $job->jobSubType . ']');
             $this->closeJob($job, KalturaBatchJobErrorTypes::APP, null, 'Error: Cannot create DistributeEngine of type [' . $job->jobSubType . ']', KalturaBatchJobStatus::FAILED);
             return $job;
         }
         $job = $this->updateJob($job, "Engine found [" . get_class($this->engine) . "]", KalturaBatchJobStatus::QUEUED);
         $closed = $this->execute($data);
         if ($closed) {
             return $this->closeJob($job, null, null, null, KalturaBatchJobStatus::FINISHED, $data);
         }
         return $this->closeJob($job, null, null, null, KalturaBatchJobStatus::ALMOST_DONE, $data);
     } catch (KalturaDistributionException $ex) {
         $job = $this->closeJob($job, KalturaBatchJobErrorTypes::APP, $ex->getCode(), "Error: " . $ex->getMessage(), KalturaBatchJobStatus::RETRY, $job->data);
     } catch (Exception $ex) {
         $job = $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, $ex->getCode(), "Error: " . $ex->getMessage(), KalturaBatchJobStatus::FAILED, $job->data);
     }
     return $job;
 }
 public function entryHandled(entry $dbEntry)
 {
     parent::entryHandled($dbEntry);
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($dbEntry->getId());
     $syncKey = $originalFlavorAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $sourceFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
     // call mediaInfo for file
     $dbMediaInfo = new mediaInfo();
     try {
         $mediaInfoParser = new KMediaInfoMediaParser($sourceFilePath, kConf::get('bin_path_mediainfo'));
         $mediaInfo = $mediaInfoParser->getMediaInfo();
         $dbMediaInfo = $mediaInfo->toInsertableObject($dbMediaInfo);
         $dbMediaInfo->setFlavorAssetId($originalFlavorAsset->getId());
         $dbMediaInfo->save();
     } catch (Exception $e) {
         KalturaLog::err("Getting media info: " . $e->getMessage());
         $dbMediaInfo = null;
     }
     // fix flavor asset according to mediainfo
     if ($dbMediaInfo) {
         KDLWrap::ConvertMediainfoCdl2FlavorAsset($dbMediaInfo, $originalFlavorAsset);
         $flavorTags = KDLWrap::CDLMediaInfo2Tags($dbMediaInfo, array(flavorParams::TAG_WEB, flavorParams::TAG_MBR));
         $originalFlavorAsset->setTags(implode(',', array_unique($flavorTags)));
     }
     $originalFlavorAsset->setStatusLocalReady();
     $originalFlavorAsset->save();
     $dbEntry->setStatus(entryStatus::READY);
     $dbEntry->save();
 }
コード例 #17
0
 /**
  * Add bulk upload job
  * @param DropFolder $folder
  * @param DropFolderFile $leadDropFolderFile
  * @throws Exception
  */
 private function addXMLBulkUploadJob(DropFolder $folder, DropFolderFile $leadDropFolderFile)
 {
     /* @var $leadDropFolderFile FeedDropFolderFile */
     KalturaLog::info('Adding BulkUpload job');
     try {
         $coreBulkUploadType = BulkUploadXmlPlugin::getBulkUploadTypeCoreValue(BulkUploadXmlType::XML);
         $objectId = $leadDropFolderFile->getId();
         $objectType = DropFolderXmlBulkUploadPlugin::getBatchJobObjectTypeCoreValue(DropFolderBatchJobObjectType::DROP_FOLDER_FILE);
         $partner = PartnerPeer::retrieveByPK($folder->getPartnerId());
         $data = KalturaPluginManager::loadObject('kBulkUploadJobData', $coreBulkUploadType);
         /* @var $data kBulkUploadJobData */
         $data->setUploadedBy(kDropFolderXmlEventsConsumer::UPLOADED_BY);
         KalturaLog::info("Feed XML path: " . $leadDropFolderFile->getFeedXmlPath());
         $data->setFilePath($leadDropFolderFile->getFeedXmlPath());
         $data->setFileName(basename($data->getFilePath()) . '.xml');
         $objectData = new kBulkUploadEntryData();
         KalturaLog::info('Conversion profile id: ' . $folder->getConversionProfileId());
         $objectData->setConversionProfileId($folder->getConversionProfileId());
         $data->setObjectData($objectData);
         $job = kJobsManager::addBulkUploadJob($partner, $data, $coreBulkUploadType, $objectId, $objectType);
         $this->setFileToProcessing($leadDropFolderFile);
         return $job;
     } catch (Exception $e) {
         KalturaLog::err("Error adding BulkUpload job -" . $e->getMessage());
         throw new Exception(DropFolderXmlBulkUploadPlugin::ERROR_ADDING_BULK_UPLOAD_MESSAGE, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::ERROR_ADDING_BULK_UPLOAD));
     }
 }
コード例 #18
0
 /**
  * Will return the first virus scan profile of the entry's partner, that defines an entry filter suitable for the given entry.
  * @param int $entryId
  * @return VirusScanProfile the suitable profile object, or null if none found
  */
 public static function getSuitableProfile($entryId)
 {
     $entry = entryPeer::retrieveByPK($entryId);
     if (!$entry) {
         KalturaLog::err('Cannot find entry with id [' . $entryId . ']');
         return null;
     }
     if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
         return null;
     }
     $cProfile = new Criteria();
     $cProfile->addAnd(VirusScanProfilePeer::PARTNER_ID, $entry->getPartnerId());
     $cProfile->addAnd(VirusScanProfilePeer::STATUS, VirusScanProfileStatus::ENABLED, Criteria::EQUAL);
     $profiles = VirusScanProfilePeer::doSelect($cProfile);
     if (!$profiles) {
         KalturaLog::debug('No virus scan profiles found for partner [' . $entry->getPartnerId() . ']');
         return null;
     }
     foreach ($profiles as $profile) {
         $virusEntryFilter = $profile->getEntryFilterObject();
         if ($virusEntryFilter->matches($entry)) {
             KalturaLog::debug('Returning profile with id [' . $profile->getId() . ']');
             return $profile;
         }
     }
     return null;
 }
コード例 #19
0
 /**
  * Tests EntryDistributionService->addAction()
  * @param KalturaEntryDistribution $entryDistribution
  * @return int
  * @dataProvider provideData
  */
 public function testAdd(KalturaEntryDistribution $entryDistribution)
 {
     try {
         $resultEntryDistribution = $this->client->entryDistribution->add($entryDistribution);
         $this->assertType('KalturaEntryDistribution', $resultEntryDistribution);
         $this->assertNotNull($resultEntryDistribution->id);
         KalturaLog::debug("Returns Entry Distribution ID [{$resultEntryDistribution->id}]");
         return $resultEntryDistribution->id;
     } catch (KalturaException $e) {
         KalturaLog::err("Add EntryDistribution Exception code [" . $e->getCode() . "] message [" . $e->getMessage() . "]");
         if ($e->getCode() != 'ENTRY_DISTRIBUTION_ALREADY_EXISTS') {
             throw $e;
         }
     }
     $entryDistributionFilter = new KalturaEntryDistributionFilter();
     $entryDistributionFilter->entryIdIn = $entryDistribution->entryId;
     $entryDistributionFilter->distributionProfileIdEqual = $entryDistribution->distributionProfileId;
     $entryDistributionList = $this->client->entryDistribution->listAction($entryDistributionFilter);
     $this->assertType('KalturaEntryDistributionListResponse', $entryDistributionList);
     $this->assertNotEquals($entryDistributionList->totalCount, 0);
     $this->assertEquals($entryDistributionList->totalCount, count($entryDistributionList->objects));
     $resultEntryDistribution = reset($entryDistributionList->objects);
     $this->assertType('KalturaEntryDistribution', $resultEntryDistribution);
     $this->assertNotNull($resultEntryDistribution->id);
     KalturaLog::debug("Returns Entry Distribution ID [{$resultEntryDistribution->id}]");
     return $resultEntryDistribution->id;
 }
コード例 #20
0
 protected function getCmdLine()
 {
     $cmdLine = parent::getCmdLine();
     $cmdLine = KConversionEngineFfmpeg::experimentalFixing($cmdLine, $this->data->flavorParamsOutput, $this->cmd, $this->inFilePath, $this->outFilePath);
     $cmdLine = KConversionEngineFfmpeg::expandForcedKeyframesParams($cmdLine);
     $wmStr = strstr($this->operator->params, "watermark:");
     if ($wmStr == false) {
         return $cmdLine;
     }
     $wmStr = trim(substr($this->operator->params, strlen("watermark:")));
     /*
      * If no watermarkData, carry on 
      */
     if ($wmStr == null) {
         return $cmdLine;
     }
     KalturaLog::log("Watermark string({$wmStr})");
     $wmData = json_decode($wmStr);
     if (!isset($wmData)) {
         KalturaLog::err("Bad watermark JSON string({$wmStr}), carry on without watermark");
     }
     KalturaLog::log("Watermark data:\n" . print_r($wmData, 1));
     // impersonite
     KBatchBase::impersonate($this->data->flavorParamsOutput->partnerId);
     // !!!!!!!!!!!$this->job->partnerId);
     $wmCmdLine = KConversionEngineFfmpeg::buildWatermarkedCommandLine($wmData, $this->data->destFileSyncLocalPath, $cmdLine, KBatchBase::$taskConfig->params->ffmpegCmd, KBatchBase::$taskConfig->params->mediaInfoCmd);
     // un-impersonite
     KBatchBase::unimpersonate();
     if (isset($wmCmdLine)) {
         $cmdLine = $wmCmdLine;
     }
     return $cmdLine;
 }
コード例 #21
0
 /**
  * @param KalturaBaseEntry $object
  */
 function processObject($object)
 {
     /** @var KalturaConvertEntryFlavorsObjectTask $objectTask */
     $objectTask = $this->getObjectTask();
     $entryId = $object->id;
     $reconvert = $objectTask->reconvert;
     $client = $this->getClient();
     $flavorParamsIds = explode(',', $objectTask->flavorParamsIds);
     foreach ($flavorParamsIds as $flavorParamsId) {
         try {
             $this->impersonate($object->partnerId);
             $flavorAssetFilter = new KalturaFlavorAssetFilter();
             $flavorAssetFilter->entryIdEqual = $entryId;
             $flavorAssetFilter->flavorParamsIdEqual = $flavorParamsId;
             $flavorAssetFilter->statusEqual = KalturaFlavorAssetStatus::READY;
             $flavorAssetResponse = $client->flavorAsset->listAction($flavorAssetFilter);
             if (!count($flavorAssetResponse->objects) || $reconvert) {
                 $client->flavorAsset->convert($entryId, $flavorParamsId);
             }
             $this->unimpersonate();
         } catch (Exception $ex) {
             KalturaLog::err(sprintf('Failed to convert entry id %s with flavor params id %s', $entryId, $flavorParamsId));
             KalturaLog::err($ex);
         }
     }
 }
コード例 #22
0
 /**
  * @action notify
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $id integration job id
  */
 public function notifyAction($id)
 {
     $coreType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = BatchJobPeer::retrieveByPK($id);
     $invalidJobId = false;
     $invalidKs = false;
     if (!self::validateKs($batchJob)) {
         $invalidKs = true;
         KalturaLog::err("ks not valid for notifying job [{$id}]");
     } elseif (!$batchJob) {
         $invalidJobId = true;
         KalturaLog::err("Job [{$id}] not found");
     } elseif ($batchJob->getJobType() != $coreType) {
         $invalidJobId = true;
         KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . $coreType . "]");
     } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) {
         $invalidJobId = true;
         KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]");
     } elseif ($batchJob->getPartnerId() != kCurrentContext::getCurrentPartnerId()) {
         $invalidKs = true;
         KalturaLog::err("Job [{$id}] of wrong partner [" . $batchJob->getPartnerId() . "] expected [" . kCurrentContext::getCurrentPartnerId() . "]");
     }
     if ($invalidJobId) {
         throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id);
     }
     if ($invalidKs) {
         throw new KalturaAPIException(KalturaIntegrationErrors::INTEGRATION_NOTIFY_FAILED);
     }
     kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED);
 }
コード例 #23
0
ファイル: kCoreException.php プロジェクト: AdiTal/server
 public function __construct($message, $code = null, $data = null)
 {
     $this->message = $message;
     $this->code = $code;
     $this->data = $data;
     KalturaLog::err($this);
 }
コード例 #24
0
 /**
  * Get license for encrypted content playback
  * 
  * @action getLicense
  * @param string $flavorAssetId
  * @param string $referrer 64base encoded  
  * @return string $response
  * 
  */
 public function getLicenseAction($flavorAssetId, $referrer = null)
 {
     KalturaResponseCacher::disableCache();
     KalturaLog::debug('get license for flavor asset: ' . $flavorAssetId);
     try {
         $requestParams = requestUtils::getRequestParams();
         if (!array_key_exists(WidevineLicenseProxyUtils::ASSETID, $requestParams)) {
             KalturaLog::err('assetid is missing on the request');
             return WidevineLicenseProxyUtils::createErrorResponse(KalturaWidevineErrorCodes::WIDEVINE_ASSET_ID_CANNOT_BE_NULL, 0);
         }
         $wvAssetId = $requestParams[WidevineLicenseProxyUtils::ASSETID];
         $this->validateLicenseRequest($flavorAssetId, $wvAssetId, $referrer);
         $privileges = null;
         $isAdmin = false;
         if (kCurrentContext::$ks_object) {
             $privileges = kCurrentContext::$ks_object->getPrivileges();
             $isAdmin = kCurrentContext::$ks_object->isAdmin();
         }
         $response = WidevineLicenseProxyUtils::sendLicenseRequest($requestParams, $privileges, $isAdmin);
     } catch (KalturaWidevineLicenseProxyException $e) {
         KalturaLog::err($e);
         $response = WidevineLicenseProxyUtils::createErrorResponse($e->getWvErrorCode(), $wvAssetId);
     } catch (Exception $e) {
         KalturaLog::err($e);
         $response = WidevineLicenseProxyUtils::createErrorResponse(KalturaWidevineErrorCodes::GENERAL_ERROR, $wvAssetId);
     }
     WidevineLicenseProxyUtils::printLicenseResponseStatus($response);
     return $response;
 }
コード例 #25
0
ファイル: httpMgr.class.php プロジェクト: DBezemer/server
 protected function doConnect($http_server, &$http_port)
 {
     // try connecting to server
     if (!$http_port || $http_port == 0) {
         $http_port = 80;
     }
     $http_server .= $http_server . ':' . $http_port;
     try {
         $url_parts = parse_url($http_server);
         if (isset($url_parts["scheme"])) {
             if ($url_parts["scheme"] != "http" && $url_parts["scheme"] != "https") {
                 KalturaLog::err("URL [{$http_server}] is not http");
                 return false;
             }
         } else {
             $http_server = 'http://' . $http_server;
         }
     } catch (Exception $exception) {
         $http_server = 'http://' . $http_server;
     }
     $this->server = $http_server;
     $this->ch = curl_init();
     curl_setopt($this->ch, CURLOPT_USERAGENT, $this->userAgent);
     curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($this->ch, CURLOPT_NOSIGNAL, true);
     curl_setopt($this->ch, CURLOPT_FORBID_REUSE, true);
     curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($this->ch, CURLOPT_HEADER, false);
     curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
     return $this->ch;
 }
コード例 #26
0
ファイル: oauth2Action.class.php プロジェクト: dozernz/server
 protected function processKs($ksStr, $requiredPermission = null)
 {
     try {
         kCurrentContext::initKsPartnerUser($ksStr);
     } catch (Exception $ex) {
         KalturaLog::err($ex);
         return false;
     }
     if (kCurrentContext::$ks_object->type != ks::SESSION_TYPE_ADMIN) {
         KalturaLog::err('Ks is not admin');
         return false;
     }
     try {
         kPermissionManager::init(kConf::get('enable_cache'));
     } catch (Exception $ex) {
         if (strpos($ex->getCode(), 'INVALID_ACTIONS_LIMIT') === false) {
             KalturaLog::err($ex);
             return false;
         }
     }
     if ($requiredPermission) {
         if (!kPermissionManager::isPermitted(PermissionName::ADMIN_PUBLISHER_MANAGE)) {
             KalturaLog::err('Ks is missing "ADMIN_PUBLISHER_MANAGE" permission');
             return false;
         }
     }
     return true;
 }
コード例 #27
0
ファイル: LiveEntry.php プロジェクト: DBezemer/server
 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)
 {
     if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
         KalturaLog::log("rejected live stream entry - not serving thumbnail");
         KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
     }
     $contentPath = myContentStorage::getFSContentRootPath();
     $liveEntryExist = false;
     $liveThumbEntry = null;
     $liveThumbEntryId = null;
     $partner = $this->getPartner();
     if ($partner) {
         $liveThumbEntryId = $partner->getLiveThumbEntryId();
     }
     if ($liveThumbEntryId) {
         $liveThumbEntry = entryPeer::retrieveByPK($liveThumbEntryId);
     }
     if ($liveThumbEntry && $liveThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $fileSyncVersion = $partner->getLiveThumbEntryVersion();
         $liveEntryKey = $liveThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion);
         $contentPath = kFileSyncUtils::getLocalFilePathForKey($liveEntryKey);
         if ($contentPath) {
             $msgPath = $contentPath;
             $liveEntryExist = true;
         } else {
             KalturaLog::err('no local file sync for audio entry id');
         }
     }
     if (!$liveEntryExist) {
         $msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg";
     }
     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, $msgPath, $density, $stripProfiles);
 }
コード例 #28
0
 public function objectReplaced(BaseObject $object, BaseObject $replacingObject, BatchJob $raisedJob = null)
 {
     KalturaLog::debug("check for DRM key replacement");
     try {
         $replacingDrmKey = $this->getDrmKey($replacingObject);
         if ($replacingDrmKey) {
             $newKeyId = $replacingDrmKey->getDrmKey();
             KalturaLog::debug("replacing drm key with: " . $newKeyId);
             $entryDrmKey = $this->getDrmKey($object);
             if (!$entryDrmKey) {
                 $entryDrmKey = new DrmKey();
                 $entryDrmKey->setPartnerId($object->getPartnerId());
                 $entryDrmKey->setObjectId($object->getId());
                 $entryDrmKey->setObjectType(DrmKeyObjectType::ENTRY);
                 $entryDrmKey->setProvider(PlayReadyPlugin::getPlayReadyProviderCoreValue());
             }
             $entryDrmKey->setDrmKey($newKeyId);
             $entryDrmKey->save();
             $object->putInCustomData(PlayReadyPlugin::ENTRY_CUSTOM_DATA_PLAY_READY_KEY_ID, $newKeyId);
             $object->save();
         }
     } catch (Exception $e) {
         KalturaLog::err("Failed to update drm key for entry " . $object->getId());
     }
     return true;
 }
 public function validateForSubmission(EntryDistribution $entryDistribution, $action)
 {
     $validationErrors = parent::validateForSubmission($entryDistribution, $action);
     //validation of flavor format
     $flavorAsset = null;
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds()));
     // if we have specific flavor assets for this distribution, grab the first one
     if (count($flavorAssets)) {
         $flavorAsset = reset($flavorAssets);
         $fileExt = $flavorAsset->getFileExt();
         $allowedExts = explode(',', self::FLAVOR_VALID_FORMATS);
         if (!in_array($fileExt, $allowedExts)) {
             KalturaLog::debug('flavor asset id [' . $flavorAsset->getId() . '] does not have a valid extension [' . $fileExt . ']');
             $errorMsg = 'Flavor format must be one of [' . self::FLAVOR_VALID_FORMATS . ']';
             $validationError = $this->createValidationError($action, DistributionErrorType::INVALID_DATA);
             $validationError->setValidationErrorType(DistributionValidationErrorType::CUSTOM_ERROR);
             $validationError->setValidationErrorParam($errorMsg);
             $validationError->setDescription($errorMsg);
             $validationErrors[] = $validationError;
         }
     }
     $inListOrNullFields = array(IdeticDistributionField::GENRE => explode(',', self::GENRE_VALID_VALUES));
     $allFieldValues = $this->getAllFieldValues($entryDistribution);
     if (!$allFieldValues || !is_array($allFieldValues)) {
         KalturaLog::err('Error getting field values from entry distribution id [' . $entryDistribution->getId() . '] profile id [' . $this->getId() . ']');
         return $validationErrors;
     }
     $validationErrors = array_merge($validationErrors, $this->validateInListOrNull($inListOrNullFields, $allFieldValues, $action));
     //validating Slot is a whole number
     $validationErrors = array_merge($validationErrors, $this->validateIsWholeNumber(IdeticDistributionField::SLOT, $allFieldValues, $action));
     return $validationErrors;
 }
コード例 #30
0
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaUverseDistributionProfile) {
         return;
     }
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     if (count($flavorAssets)) {
         // if we have specific flavor assets for this distribution, grab the first one
         $flavorAsset = reset($flavorAssets);
     } else {
         // take the source asset
         $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId);
     }
     if ($flavorAsset) {
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         if (kFileSyncUtils::fileSync_exists($syncKey)) {
             $this->localAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         }
     }
     $entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
     if ($entryDistributionDb) {
         $this->remoteAssetUrl = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL);
         $this->remoteAssetFileName = $entryDistributionDb->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_FILE_NAME);
     } else {
         KalturaLog::err('Entry distribution [' . $distributionJobData->entryDistributionId . '] not found');
     }
 }