public function toObject($object_to_fill = null, $props_to_skip = array())
 {
     $this->validateForUsage($object_to_fill, $props_to_skip);
     if (!$object_to_fill) {
         $object_to_fill = new kLocalFileResource();
     }
     $content = myContentStorage::getFSContentRootPath();
     $entryFullPaths = array('flv' => "{$content}/content/webcam/{$this->token}.flv", 'f4v' => "{$content}/content/webcam/{$this->token}.f4v", 'mp4' => "{$content}/content/webcam/{$this->token}.f4v.mp4");
     foreach ($entryFullPaths as $type => $entryFullPath) {
         if (file_exists($entryFullPath)) {
             if ($type == 'flv') {
                 $entryFixedFullPath = $entryFullPath . '.fixed.flv';
                 KalturaLog::debug("Fix webcam full path from [{$entryFullPath}] to [{$entryFixedFullPath}]");
                 myFlvStaticHandler::fixRed5WebcamFlv($entryFullPath, $entryFixedFullPath);
                 $entryNewFullPath = $entryFullPath . '.clipped.flv';
                 KalturaLog::debug("Clip webcam full path from [{$entryFixedFullPath}] to [{$entryNewFullPath}]");
                 myFlvStaticHandler::clipToNewFile($entryFixedFullPath, $entryNewFullPath, 0, 0);
                 $entryFullPath = $entryNewFullPath;
                 if (!file_exists($entryFullPath)) {
                     throw new KalturaAPIException(KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND);
                 }
             }
             $object_to_fill->setSourceType(KalturaSourceType::WEBCAM);
             $object_to_fill->setLocalFilePath($entryFullPath);
             return $object_to_fill;
         }
     }
     throw new KalturaAPIException(KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND);
 }
Esempio n. 2
0
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         die;
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     $host = myPartnerUtils::getHost($partner_id);
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         $ui_conf_swf_url = "/swf/simpleeditor.swf";
     }
     if (kString::beginsWith($ui_conf_swf_url, "http")) {
         $swf_url = $ui_conf_swf_url;
         // absolute URL
     } else {
         $use_cdn = $uiConf->getUseCdn();
         $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id);
         $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         // relative to the current host
     }
     // handle buggy case for backward compatiblity
     $partner_host = $host;
     if ($partner_host == "http://www.kaltura.com") {
         $partner_host = 1;
     }
     // otherwise the kse will build a flawed url with [[IMPORT]]
     $params = "contentUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", myPartnerUtils::getCdnHost($partner_id))) . "&uiConfId=" . $ui_conf_id . "&disableurlhashing=" . kConf::get('disable_url_hashing');
     $wrapper_swf = myContentStorage::getFSFlashRootPath() . "/flexwrapper/" . kConf::get('editors_flex_wrapper_version') . "/FlexWrapper.swf";
     $this->redirect($host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "{$wrapper_swf}?{$params}");
 }
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         die;
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     if (!$subp_id) {
         $subp_id = 0;
     }
     $host = myPartnerUtils::getHost($partner_id);
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         $ui_conf_swf_url = "/swf/ContributionWizard.swf";
     }
     if (kString::beginsWith($ui_conf_swf_url, "http")) {
         $swf_url = $ui_conf_swf_url;
         // absolute URL
     } else {
         $use_cdn = $uiConf->getUseCdn();
         $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id);
         $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         // relative to the current host
     }
     $params = "contentUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", myPartnerUtils::getCdnHost($partner_id))) . "&uiConfId=" . $ui_conf_id;
     $wrapper_swf = myContentStorage::getFSFlashRootPath() . "/flexwrapper/" . kConf::get('kcw_flex_wrapper_version') . "/FlexWrapper.swf";
     $this->redirect($host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "{$wrapper_swf}?{$params}");
 }
 /**
  * @param CaptionAsset $captionAsset
  * @param BatchJob $parentJob
  * @throws kCoreException FILE_NOT_FOUND
  * @return BatchJob
  */
 public function addParseCaptionAssetJob(CaptionAsset $captionAsset, BatchJob $parentJob = null)
 {
     $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
     if (!$fileSync) {
         if (!PermissionPeer::isValidForPartner(CaptionPermissionName::IMPORT_REMOTE_CAPTION_FOR_INDEXING, $captionAsset->getPartnerId())) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
         if (!$fileSync) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fullPath = myContentStorage::getFSUploadsPath() . '/' . $captionAsset->getId() . '.tmp';
         if (!kFile::downloadUrlToFile($fileSync->getExternalUrl($captionAsset->getEntryId()), $fullPath)) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, false, true);
     }
     $jobData = new kParseCaptionAssetJobData();
     $jobData->setCaptionAssetId($captionAsset->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($captionAsset->getEntryId());
         $batchJob->setPartnerId($captionAsset->getPartnerId());
     }
     return kJobsManager::addJob($batchJob, $jobData, CaptionSearchPlugin::getBatchJobTypeCoreValue(CaptionSearchBatchJobType::PARSE_CAPTION_ASSET));
 }
Esempio n. 5
0
    public function execute()
    {
        $this->forceSystemAuthentication();
        $this->basePath = "/content/dynamic/";
        $dynamicRoot = myContentStorage::getFSContentRootPath() . $this->basePath;
        if ($this->getRequest()->getMethod() == sfRequest::POST) {
            $origFilename = basename($_FILES['Filedata']['name']);
            $fullPath = $dynamicRoot . $origFilename;
            move_uploaded_file($_FILES['Filedata']['tmp_name'], $fullPath);
            chmod($fullPath, 0777);
            return $this->renderText("ok");
        } else {
            if ($this->getRequest()->getMethod() == sfRequest::DELETE) {
                $filename = basename($_REQUEST['fileName']);
                kFile::deleteFile($dynamicRoot . $filename);
                return $this->renderText("ok");
            }
        }
        $this->files = kFile::dirListExtended($dynamicRoot, false);
        $this->extraHead = <<<EOT
\t\t<style type="text/css">
\t\t\ttable{ font-size:1.2em; width:100%; margin:40px 0 0 0; }
\t\t\ttable thead{ font-size:1.4em; }
\t\t\t\ttable thead td{ border-bottom:1px solid #444; margin-bottom:20px; }
\t\t\ttable tbody td{ padding:2px 0; color:#ccc; }
\t\t\t\ttable tbody td b{ font-weight:normal; cursor:default; }
\t\t\t\ttable tbody td span.btn{ margin-right:12px;}
\t\t\tdiv#helper{ display:none; position:absolute; left:0; width:250px; }
\t\t\tdiv#helper img{ float:right; max-width:250px; }
\t\t</style>
EOT;
    }
 /**
  * Executes addComment action, which returns a form enabling the insertion of a comment
  * The request may include 1 fields: entry id.
  */
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     $version = @$_REQUEST["version"];
     // it's a path on the disk
     if (kString::beginsWith($version, ".")) {
         // someone is trying to hack in the system
         return sfView::ERROR;
     }
     // in case we're making a roughcut out of a regular invite, we start from scratch
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry->getDataPath($version) === null) {
         $this->xml_content = "<xml></xml>";
         return;
     }
     // fetch content of file from disk - it should hold the XML
     $file_name = myContentStorage::getFSContentRootPath() . "/" . $entry->getDataPath($version);
     //echo "[$file_name]";
     if (kString::endsWith($file_name, "xml")) {
         if (file_exists($file_name)) {
             $this->xml_content = kFile::getFileContent($file_name);
             //	echo "[" . $this->xml_content . "]" ;
         } else {
             $this->xml_content = "<xml></xml>";
         }
         myMetadataUtils::updateEntryForPending($entry, $version, $this->xml_content);
     } else {
         return sfView::ERROR;
     }
     // this is NOT an xml file we are looking for !
 }
Esempio n. 7
0
 /**
  * Will investigate a single entry
  */
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     //myDbHelper::DB_HELPER_CONN_PROPEL2;
     $status_list = $this->getP("status");
     $mode = $this->getP("mode");
     if ($mode == "old") {
         $preconvert = glob(myContentStorage::getFSContentRootPath() . "/content/preconvert/data/*");
         $preconvert_indicators = glob(myContentStorage::getFSContentRootPath() . "/content/preconvert/files/*");
         // indicators or inproc
     } else {
         $preconvert = glob(myContentStorage::getFSContentRootPath() . "/content/new_preconvert/*");
         $preconvert_indicators = glob(myContentStorage::getFSContentRootPath() . "/new_content/preconvert/*.in*");
         // indicators or inproc
     }
     $indicators = array();
     foreach ($preconvert_indicators as $file) {
         $file = pathinfo($file, PATHINFO_BASENAME);
         $name = substr($file, 0, strpos($file, "."));
         $indicators[$name] = $name;
     }
     $entry_ids = array();
     foreach ($preconvert as $file) {
         $file = pathinfo($file, PATHINFO_BASENAME);
         $name = substr($file, 0, strpos($file, "."));
         if (!isset($indicators[$name])) {
             $entry_ids[] = $name;
             // only those that don't have indicators
         }
     }
     $ids_str = "'" . implode("','", $entry_ids) . "'";
     echo "<html><body style='font-family:arial; font-size:12px;'>";
     echo "preconvert files: [" . count($preconvert) . "]<br>";
     echo "preconvert indicators : [" . count($preconvert_indicators) . "] [" . count($indicators) . "]<br>";
     echo "entry_ids: [" . count($entry_ids) . "]<br>";
     if (count($entry_ids)) {
         if (!$status_list) {
             $status_list = "1";
         }
         $connection = Propel::getConnection();
         $query = "SELECT id,partner_id,status,created_at FROM entry WHERE status IN ({$status_list}) AND id IN ({$ids_str}) ORDER BY created_at ASC ";
         echo "query: {$query}<br>";
         $statement = $connection->prepareStatement($query);
         $resultset = $statement->executeQuery();
         echo "<table cellpadding=2 cellspacing=0 border=1 style='font-family:arial; font-size:12px;'>";
         echo "<tr><td>partner_id</td><td>id</td><td>status</td><td>created_at</td></tr>";
         $real_count = 0;
         while ($resultset->next()) {
             echo "<tr>" . "<td>" . $resultset->getInt('partner_id') . "</td>" . "<td>" . $resultset->getString('id') . "</td>" . "<td>" . $resultset->getInt('status') . "</td>" . "<td>" . $resultset->get('created_at') . "</td>" . "</tr>";
             $real_count++;
         }
         echo "</table>";
         echo "count [{$real_count}]";
         $resultset->close();
     }
     echo "</body></html>";
     die;
 }
Esempio n. 8
0
 public function generateFilePathArr($sub_type, $version = null)
 {
     static::validateFileSyncSubType($sub_type);
     if ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_LIVE_PRIMARY || $sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_LIVE_SECONDARY) {
         $res = myContentStorage::getGeneralEntityPath('entry/data', $this->getIntId(), $this->getId(), $sub_type);
         return array(myContentStorage::getFSContentRootPath(), $res);
     }
     return parent::generateFilePathArr($sub_type, $version);
 }
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $preloader_path = myContentStorage::getFSContentRootPath() . "/content" . myContentStorage::getFSUiconfRootPath() . "/preloader_{$ui_conf_id}.swf";
     if (!file_exists($preloader_path)) {
         $preloader_path = myContentStorage::getFSContentRootPath() . "/content" . myContentStorage::getFSUiconfRootPath() . "/preloader_2.swf";
     }
     kFile::dumpFile($preloader_path);
 }
Esempio n. 10
0
 public function myFileIndicator($file_name)
 {
     if (!self::$s_indicator_path) {
         self::$s_indicator_path = myContentStorage::getFSContentRootPath() . "/indicators/";
         kFile::fullMkdir(self::$s_indicator_path . "dummy.txt");
     }
     $this->file_name = $file_name;
     $this->pattern = "/" . $this->file_name . '\\..*/';
 }
Esempio n. 11
0
 public function execute()
 {
     $this->forceSystemAuthentication();
     $kshow_id = @$_REQUEST["kshow_id"];
     $this->kshow_id = $kshow_id;
     $this->kshow = NULL;
     $entry_id = @$_REQUEST["entry_id"];
     $this->entry_id = $entry_id;
     $this->entry = NULL;
     $this->message = "";
     if (!empty($kshow_id)) {
         $this->kshow = kshowPeer::retrieveByPK($kshow_id);
         if (!$this->kshow) {
             $this->message = "Cannot find kshow [{$kshow_id}]";
         } else {
             $this->entry = $this->kshow->getShowEntry();
         }
     } elseif (!empty($kshow_id)) {
         $this->entry = entryPeer::retrieveByPK($entry_id);
         if (!$this->entry) {
             $this->message = "Cannot find entry [{$entry_id}]";
         } else {
             $this->kshow = $this->{$this}->entry->getKshow();
         }
     }
     if ($this->kshow) {
         $this->metadata = $this->kshow->getMetadata();
     } else {
         $this->metadata = "";
     }
     $pending_str = $this->getP("pending");
     $remove_pending = $this->getP("remove_pending");
     if ($this->metadata && ($remove_pending || $pending_str)) {
         if ($remove_pending) {
             $pending_str = "";
         }
         $xml_doc = new DOMDocument();
         $xml_doc->loadXML($this->metadata);
         $metadata = kXml::getFirstElement($xml_doc, "MetaData");
         $should_save = kXml::setChildElement($xml_doc, $metadata, "Pending", $pending_str, true);
         if ($remove_pending) {
             $should_save = kXml::setChildElement($xml_doc, $metadata, "LastPendingTimeStamp", "", true);
         }
         if ($should_save) {
             $fixed_content = $xml_doc->saveXML();
             $content_dir = myContentStorage::getFSContentRootPath();
             $file_name = realpath($content_dir . $this->entry->getDataPath());
             $res = file_put_contents($file_name, $fixed_content);
             // sync - NOTOK
             $this->metadata = $fixed_content;
         }
     }
     $this->pending = $pending_str;
     $this->kshow_id = $kshow_id;
     $this->entry_id = $entry_id;
 }
Esempio n. 12
0
 public function toObject($object_to_fill = null, $props_to_skip = array())
 {
     if (!$object_to_fill) {
         $object_to_fill = new kLocalFileResource();
     }
     file_put_contents($fname = tempnam(myContentStorage::getFSUploadsPath(), "KFR"), $this->content);
     $object_to_fill->setLocalFilePath($fname);
     $object_to_fill->setSourceType(entry::ENTRY_MEDIA_SOURCE_TEXT);
     return parent::toObject($object_to_fill, $props_to_skip);
 }
Esempio n. 13
0
 public function generateFilePathArr($sub_type, $version = null)
 {
     self::validateFileSyncSubType($sub_type);
     if (!$version) {
         $version = $this->getFileSyncVersion($sub_type);
     }
     $dir = intval($this->getId() / 1000000) . '/' . intval($this->getId() / 1000) % 1000;
     $path = "/content/distribution/profile/{$dir}/" . $this->generateFileName($sub_type, $version);
     return array(myContentStorage::getFSContentRootPath(), $path);
 }
Esempio n. 14
0
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     if (!is_numeric($ui_conf_id)) {
         throw new Exception("Illegal Input was supplied");
     }
     $preloader_path = myContentStorage::getFSContentRootPath() . "/content" . myContentStorage::getFSUiconfRootPath() . "/preloader_{$ui_conf_id}.swf";
     if (!file_exists($preloader_path)) {
         $preloader_path = myContentStorage::getFSContentRootPath() . "/content" . myContentStorage::getFSUiconfRootPath() . "/preloader_2.swf";
     }
     kFileUtils::dumpFile($preloader_path);
 }
Esempio n. 15
0
 public function execute()
 {
     // Prevent the page fron being embeded in an iframe
     header('X-Frame-Options: DENY');
     // Check if user already logged in and redirect to kmc2
     if ($this->getRequest()->getCookie('kmcks')) {
         $this->redirect('kmc/kmc2');
     }
     if (infraRequestUtils::getProtocol() != infraRequestUtils::PROTOCOL_HTTPS && kConf::get('kmc_secured_login')) {
         $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
         header('Location:' . $url);
         die;
     }
     $this->www_host = kConf::get('www_host');
     $https_enabled = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? true : false;
     $this->securedLogin = kConf::get('kmc_secured_login') || $https_enabled ? true : false;
     $swfUrl = $this->securedLogin ? 'https://' : 'http://';
     $swfUrl .= $this->www_host . myContentStorage::getFSFlashRootPath();
     $swfUrl .= '/kmc/login/' . kConf::get('kmc_login_version') . '/login.swf';
     $this->swfUrl = $swfUrl;
     $this->partner_id = $this->getRequestParameter("partner_id");
     $this->logoUrl = null;
     if ($this->partner_id) {
         $partner = PartnerPeer::retrieveByPK($this->partner_id);
         if ($partner) {
             $this->logoUrl = kmcUtils::getWhitelabelData($partner, 'logo_url');
         }
     }
     $this->beta = $this->getRequestParameter("beta");
     //prevent script injections - allow only base64_encode chars , which is used when creating A new hash key
     $passHashparam = $this->getRequestParameter("setpasshashkey");
     if ($passHashparam && !preg_match(self::BASE64_ENCODE_CHARS_REGEX, $passHashparam)) {
         KExternalErrors::dieError(KExternalErrors::INVALID_HASH);
     }
     $this->setPassHashKey = $passHashparam;
     $this->hashKeyErrorCode = null;
     $this->displayErrorFromServer = false;
     if ($this->setPassHashKey) {
         try {
             $loginData = UserLoginDataPeer::isHashKeyValid($this->setPassHashKey);
             $partnerId = $loginData->getConfigPartnerId();
             $partner = PartnerPeer::retrieveByPK($partnerId);
             if ($partner && $partner->getPasswordStructureValidations()) {
                 $this->displayErrorFromServer = true;
             }
         } catch (kCoreException $e) {
             $this->hashKeyErrorCode = $e->getCode();
         }
     }
     sfView::SUCCESS;
 }
Esempio n. 16
0
 /**
  * Serve update file
  *
  * @action serveUpdate
  * @param string $os
  * @param string $version
  * @return file
  * @throws CaptureSpaceErrors::NO_UPDATE_IS_AVAILABLE
  */
 public function serveUpdateAction($os, $version)
 {
     $filename = kCaptureSpaceVersionManager::getUpdateFile($os, $version);
     if (!$filename) {
         throw new KalturaAPIException(CaptureSpaceErrors::NO_UPDATE_IS_AVAILABLE, $version, $os);
     }
     $actualFilePath = myContentStorage::getFSContentRootPath() . "/content/third_party/capturespace/{$filename}";
     if (!file_exists($actualFilePath)) {
         throw new KalturaAPIException(CaptureSpaceErrors::NO_UPDATE_IS_AVAILABLE, $version, $os);
     }
     $mimeType = kFile::mimeType($actualFilePath);
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     return $this->dumpFile($actualFilePath, $mimeType);
 }
 public function toObject($object_to_fill = null, $props_to_skip = array())
 {
     if (!$object_to_fill) {
         $object_to_fill = new kLocalFileResource();
     }
     $ext = pathinfo($this->fileData['name'], PATHINFO_EXTENSION);
     $uploadPath = $this->fileData['tmp_name'];
     $tempPath = myContentStorage::getFSUploadsPath() . '/' . uniqid(time()) . '.' . $ext;
     $moved = kFile::moveFile($uploadPath, $tempPath, true);
     if (!$moved) {
         throw new KalturaAPIException(KalturaErrors::UPLOAD_ERROR);
     }
     $object_to_fill->setLocalFilePath($tempPath);
     return $object_to_fill;
 }
Esempio n. 18
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $filename = $this->getP('filename');
     // strip the filename from invalid characters
     $token = $this->getKsUniqueString();
     //		$res = myUploadUtils::uploadFileByToken ( $_FILES['Filedata'] , $token , $filename );
     $origFilename = $_FILES['Filedata']['name'];
     $parts = pathinfo($origFilename);
     $extension = "flv";
     // always flv ! //strtolower($parts['extension']);
     $extra_id = null;
     $file_alias = $token . '_' . $filename;
     // add the file extension after the "." character
     $fullPath = myContentStorage::getFSContentRootPath() . "content/webcam/my_recorded_stream_" . $file_alias . ($extra_id ? "_" . $extra_id : "") . "." . $extension;
     myContentStorage::fullMkdir($fullPath);
     move_uploaded_file($_FILES['Filedata']['tmp_name'], $fullPath);
     chmod($fullPath, 0777);
     $res = array("token" => $token, "filename" => $filename, "origFilename" => $origFilename);
     // should upload the file with the token as the prefix
     $this->addMsg("result_ok", $res);
 }
function executeCropProvider($source_file, $target_file, $width, $height, $crop_type, $bgcolor, $force_jpeg)
{
    $content_path = myContentStorage::getFSContentRootPath();
    list($sourcewidth, $sourceheight, $type, $attr, $thumbail_image) = myFileConverter::createImageByFile($target_file);
    $wordpress_placeholder_image_path = $content_path . "content/templates/wordpress/wordpress_comment_player_placeholder.gif";
    list($placeholder_width, $placeholder_height, $type, $attr, $place_holder_image) = myFileConverter::createImageByFile($wordpress_placeholder_image_path);
    $wordpress_placeholder_image_path = $content_path . "content/templates/wordpress/wordpress_comment_play_overlay.png";
    list($overlay_width, $overlay_height, $type, $attr, $play_overlay_image) = myFileConverter::createImageByFile($wordpress_placeholder_image_path);
    $width = 240;
    $height = 180;
    $im = imagecreatetruecolor($placeholder_width, $placeholder_height);
    imagecopy($im, $place_holder_image, 0, 0, 0, 0, $placeholder_width, $placeholder_height);
    //imagecopyresampled($im, $thumbail_image, 5, 30, 0, 0, $width, $height, $width, $height);
    // copy with opacity change
    imagecopymerge($im, $thumbail_image, 5 + ($width - $sourcewidth) / 2, 30 + ($height - $sourceheight) / 2, 0, 0, $sourcewidth, $sourceheight, 50);
    imagecopy($im, $play_overlay_image, ($placeholder_width - $overlay_width) / 2, ($placeholder_height - $overlay_height) / 2, 0, 0, $overlay_width, $overlay_height);
    imagedestroy($place_holder_image);
    imagedestroy($thumbail_image);
    imagedestroy($play_overlay_image);
    imagejpeg($im, $target_file, 90);
    imagedestroy($im);
}
function executeCropProvider($source_file, $target_file, $width, $height, $crop_type, $bgcolor, $force_jpeg)
{
    $content_path = myContentStorage::getFSContentRootPath();
    list($sourcewidth, $sourceheight, $type, $attr, $thumbail_image) = myFileConverter::createImageByFile($target_file);
    if ($width == 400 && $height == 300) {
        $wordpress_placeholder_image_path = $content_path . "content/templates/wordpress/wordpress_large_player_placeholder.jpg";
        list($sourcewidth, $sourceheight, $type, $attr, $place_holder_image) = myFileConverter::createImageByFile($wordpress_placeholder_image_path);
        imagecopyresampled($place_holder_image, $thumbail_image, 6, 36, 0, 0, $width, $height, $width, $height);
    } elseif ($width == 400 && $height == 225) {
        $wordpress_placeholder_image_path = $content_path . "content/templates/wordpress/wordpress_large_wide_screen_player_placeholder.jpg";
        list($sourcewidth, $sourceheight, $type, $attr, $place_holder_image) = myFileConverter::createImageByFile($wordpress_placeholder_image_path);
        imagecopyresampled($place_holder_image, $thumbail_image, 6, 36, 0, 0, $width, $height, $width, $height);
    } else {
        $width = 240;
        $height = 180;
        $wordpress_placeholder_image_path = $content_path . "content/templates/wordpress/wordpress_small_player_placeholder.jpg";
        list($sourcewidth, $sourceheight, $type, $attr, $place_holder_image) = myFileConverter::createImageByFile($wordpress_placeholder_image_path);
        imagecopyresampled($place_holder_image, $thumbail_image, 6, 28, 0, 0, $width, $height, $width, $height);
    }
    imagedestroy($thumbail_image);
    imagejpeg($place_holder_image, $target_file, 90);
    imagedestroy($place_holder_image);
}
 protected function prepare(KalturaBatchJob $job, KalturaWebcamPrepareJobData $data)
 {
     DbManager::setConfig(kConf::getDB());
     DbManager::initialize();
     $dbEntry = entryPeer::retrieveByPK($job->entryId);
     $webcamTokenId = $data->webcamTokenId;
     $dbEntry->setStatus(entryStatus::PRECONVERT);
     $dbEntry->save();
     // check that the webcam file exists
     $content = myContentStorage::getFSContentRootPath();
     $this->webcam_basePath = $content . "/content/webcam/" . $webcamTokenId;
     $this->entryFullPath = $this->webcam_basePath . '.flv';
     if (!file_exists($this->entryFullPath)) {
         $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
         $dbEntry->save();
         return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, null, "Error: " . self::MSG_ERROR_FILE_NOT_EXISTS, KalturaBatchJobStatus::FAILED);
     }
     $duration = myFlvStaticHandler::getLastTimestamp($this->entryFullPath);
     $this->fixFlv();
     $kWAMSWebcam = new kWAMSWebcam($this->webcam_basePath);
     if ($kWAMSWebcam->prepare()) {
         $this->entryFullPath = $kWAMSWebcam->getOutputFilePath();
     } else {
         $dbEntry->setStatus(entryStatus::ERROR_CONVERTING);
         $dbEntry->save();
         return $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, null, "Error: " . self::MSG_ERROR_WAMS_FAIL, KalturaBatchJobStatus::FAILED);
     }
     $kshowId = $dbEntry->getKshowId();
     // setup the needed params for my insert entry helper
     $paramsArray = array("entry_media_source" => KalturaSourceType::WEBCAM, "entry_media_type" => $dbEntry->getMediaType(), "webcam_suffix" => $webcamTokenId, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags(), "duration" => $duration);
     $token = $this->getClient()->getKs();
     $insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
     $insert_entry_helper->setPartnerId($job->partnerId, $job->partnerId * 100);
     $insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
     return $this->closeJob($job, null, null, '', KalturaBatchJobStatus::FINISHED, $data);
 }
 /**
  * Executes index action
  */
 protected function executeImpl(kshow $kshow)
 {
     $this->xml_content = "";
     $kshow_id = $this->kshow_id;
     if ($kshow_id == NULL || $kshow_id == 0) {
         return sfView::SUCCESS;
     }
     $metadata_creator = new myKshowMetadataCreator();
     $this->show_metadata = $metadata_creator->createMetadata($kshow_id);
     //		$kshow = kshowPeer:retrieveByPK( $kshow_id );
     $entry = entryPeer::retrieveByPK($kshow->getShowEntryId());
     // TODO - this should never happen
     if ($entry == NULL) {
         // there is no show entry for this show !
         $entry = $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $kshow->getProducerId());
     }
     $content_path = myContentStorage::getFSContentRootPath();
     $file_path = $content_path . $entry->getDataPath();
     // check to see if the content of the file changed
     $current_metadata = kFile::getFileContent($file_path);
     $comp_result = strcmp($this->show_metadata, $current_metadata);
     if ($comp_result != 0) {
         $ext = pathinfo($file_path, PATHINFO_EXTENSION);
         if ($ext != "xml") {
             // this is for the first time - override the template path by setting the data to NULL
             $entry->setData(NULL);
             $file_path = pathinfo($file_path, PATHINFO_DIRNAME) . "/" . kFile::getFileNameNoExtension($file_path) . ".xml";
         }
         // this will increment the name if needed
         $entry->setData($file_path);
         $file_path = $content_path . $entry->getDataPath();
         $entry->save();
         kFile::fullMkdir($file_path);
         kFile::setFileContent($file_path, $this->show_metadata);
         $this->xml_content = $this->show_metadata;
     }
 }
Esempio n. 23
0
 /**
  * will create thumbnail according to the entry type
  * @return the thumbnail path.
  */
 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)
 {
     $contentPath = myContentStorage::getFSContentRootPath();
     // if entry type is audio - serve generic thumb:
     if ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
         if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
             KalturaLog::log("rejected audio entry - not serving thumbnail");
             KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
         }
         $audioEntryExist = false;
         $audioThumbEntry = null;
         $audioThumbEntryId = null;
         $partner = $this->getPartner();
         if ($partner) {
             $audioThumbEntryId = $partner->getAudioThumbEntryId();
         }
         if ($audioThumbEntryId) {
             $audioThumbEntry = entryPeer::retrieveByPK($audioThumbEntryId);
         }
         if ($audioThumbEntry && $audioThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
             $fileSyncVersion = $partner->getAudioThumbEntryVersion();
             $audioEntryKey = $audioThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion);
             $contentPath = kFileSyncUtils::getLocalFilePathForKey($audioEntryKey);
             if ($contentPath) {
                 $msgPath = $contentPath;
                 $audioEntryExist = true;
             } else {
                 KalturaLog::err('no local file sync for entry id');
             }
         }
         if (!$audioEntryExist) {
             $msgPath = $contentPath . "content/templates/entry/thumbnail/audio_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);
     } elseif ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
         // roughcut without any thumbnail, probably just created
         $msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.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);
     } elseif ($this->getType() == entryType::MEDIA_CLIP) {
         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);
         } catch (Exception $ex) {
             if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
                 // get original flavor asset
                 $origFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->getId());
                 if ($origFlavorAsset) {
                     $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                     list($readyFileSync, $isLocal) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, TRUE, FALSE);
                     if ($readyFileSync) {
                         if ($isLocal) {
                             KalturaLog::err('Trying to redirect to myself - stop here.');
                             KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
                         }
                         //Ready fileSync is on the other DC - dumping
                         kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
                     }
                     KalturaLog::err('No ready fileSync found on any DC.');
                     KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
                 }
             }
         }
     }
 }
Esempio n. 24
0
 protected function getReportDirectory($partnerId)
 {
     $folderPath = "/content/reports/live/{$partnerId}";
     $directory = myContentStorage::getFSContentRootPath() . $folderPath;
     if (!file_exists($directory)) {
         mkdir($directory);
     }
     return $directory;
 }
Esempio n. 25
0
 /**
  * (non-PHPdoc)
  * @see lib/model/ISyncableFile#generateFilePathArr()
  */
 public function generateFilePathArr($sub_type, $version = null)
 {
     self::validateFileSyncSubType($sub_type);
     $path = '/content/batchfiles/' . $this->getPartnerId() . '/' . $this->generateFileName($sub_type, $version);
     return array(myContentStorage::getFSContentRootPath(), $path);
 }
 public function setPicture($filename)
 {
     if (kCurrentContext::isApiV3Context()) {
         parent::setPicture($filename);
         return;
     }
     parent::setPicture(myContentStorage::generateRandomFileName($filename, $this->getPicture()));
 }
 /**
  * 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();
                 $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, $density, $stripProfiles);
                 kFile::dumpFile($thumb_full_path);
             } else {
                 KalturaLog::debug("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC");
                 $remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI'];
                 kFile::dumpUrl($remoteUrl);
             }
         }
     }
     if ($entry_id) {
         $entry = entryPeer::retrieveByPKNoFilter($entry_id);
         if (!$entry) {
             // problem could be due to replication lag
             kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
         }
     } else {
         // 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);
         }
     }
     $partner = $entry->getPartner();
     if ($density == 0) {
         $density = $partner->getDefThumbDensity();
     }
     $thumbParams = new kThumbnailParameters();
     $thumbParams->setSupportAnimatedThumbnail($partner->getSupportAnimatedThumbnails());
     if (is_null($stripProfiles)) {
         $stripProfiles = $partner->getStripThumbProfile();
     }
     //checks whether the thumbnail display should be restricted by KS
     $base64Referrer = $this->getRequestParameter("referrer");
     $referrer = base64_decode($base64Referrer);
     if (!is_string($referrer)) {
         $referrer = "";
     }
     // base64_decode can return binary data
     if (!$referrer) {
         $referrer = kApiCache::getHttpReferrer();
     }
     $ksStr = $this->getRequestParameter("ks");
     $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, accessControlContextType::THUMBNAIL);
     $securyEntryHelper->validateForPlay();
     // 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;
     }
     $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
     }
     KalturaLog::debug("get thumbnail filesyncs");
     $dataKey = $entry->getSyncKey($subType);
     list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($dataKey, true, false);
     $tempThumbPath = null;
     $entry_status = $entry->getStatus();
     // both 640x480 and 0x0 requests are probably coming from the kdp
     // 640x480 - old kdp version requesting thumbnail
     // 0x0 - new kdp version requesting the thumbnail of an unready entry
     // we need to distinguish between calls from the kdp and calls from a browser: <img src=...>
     // that can't handle swf input
     if (($width == 640 && $height == 480 || $width == 0 && $height == 0) && ($entry_status == entryStatus::PRECONVERT || $entry_status == entryStatus::IMPORT || $entry_status == entryStatus::ERROR_CONVERTING || $entry_status == entryStatus::DELETED)) {
         $contentPath = myContentStorage::getFSContentRootPath();
         $msgPath = $contentPath . "content/templates/entry/bigthumbnail/";
         if ($entry_status == entryStatus::DELETED) {
             $msgPath .= $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK ? "entry_blocked.swf" : "entry_deleted.swf";
         } else {
             $msgPath .= $entry_status == entryStatus::ERROR_CONVERTING ? "entry_error.swf" : "entry_converting.swf";
         }
         kFile::dumpFile($msgPath, null, 0);
     }
     if (!$file_sync) {
         $tempThumbPath = $entry->getLocalThumbFilePath($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $density, $stripProfiles, $flavor_id, $file_name);
         if (!$tempThumbPath) {
             KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
         }
     }
     if (!$local && !$tempThumbPath && $file_sync) {
         if (!in_array($file_sync->getDc(), kDataCenterMgr::getDcIds())) {
             $remoteUrl = $file_sync->getExternalUrl($entry->getId());
             header("Location: {$remoteUrl}");
             die;
         }
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']);
         kFile::dumpUrl($remoteUrl);
     }
     // 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, null, $density, $stripProfiles, $thumbParams);
         } catch (Exception $ex) {
             if ($ex->getCode() != kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
                 KalturaLog::log("Error - resize image failed");
                 KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
             }
             // get original flavor asset
             $origFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id);
             if (!$origFlavorAsset) {
                 KalturaLog::log("Error - no original flavor for entry [{$entry_id}]");
                 KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
             }
             $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);
             }
             if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) {
                 KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
             }
             $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync);
             kFile::dumpUrl($remoteUrl);
         }
     }
     $nocache = strpos($tempThumbPath, "_NOCACHE_") !== false;
     if ($securyEntryHelper->shouldDisableCache() || kApiCache::hasExtraFields() || !$securyEntryHelper->isKsWidget() && $securyEntryHelper->hasRules()) {
         $nocache = true;
     }
     // 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)
 }
 /**
  * @param AttachmentAsset $attachmentAsset
  * @param string $url
  */
 protected function attachUrl(AttachmentAsset $attachmentAsset, $url)
 {
     $fullPath = myContentStorage::getFSUploadsPath() . '/' . basename($url);
     if (kFile::downloadUrlToFile($url, $fullPath)) {
         return $this->attachFile($attachmentAsset, $fullPath);
     }
     if ($attachmentAsset->getStatus() == AttachmentAsset::ASSET_STATUS_QUEUED || $attachmentAsset->getStatus() == AttachmentAsset::ASSET_STATUS_NOT_APPLICABLE) {
         $attachmentAsset->setDescription("Failed downloading file[{$url}]");
         $attachmentAsset->setStatus(AttachmentAsset::ASSET_STATUS_ERROR);
         $attachmentAsset->save();
     }
     throw new KalturaAPIException(KalturaAttachmentErrors::ATTACHMENT_ASSET_DOWNLOAD_FAILED, $url);
 }
 public static function shalowClone(kshow $source_kshow, $new_prodcuer_id)
 {
     $target_kshow = $source_kshow->copy();
     $target_kshow->setProducerId($new_prodcuer_id);
     $target_kshow->save();
     self::resetKshowStats($target_kshow, true);
     if (!$source_kshow->getEpisodeId()) {
         $target_kshow->setEpisodeId($source_kshow->getId());
     }
     //$target_kshow->setHasRoughcut($source_kshow->getHasRoughcut());
     $target_show_entry = $target_kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $new_prodcuer_id);
     $content = myContentStorage::getFSContentRootPath();
     $source_thumbnail_path = $source_kshow->getThumbnailPath();
     $target_kshow->setThumbnail(null);
     $target_kshow->setThumbnail($source_kshow->getThumbnail());
     $target_thumbnail_path = $target_kshow->getThumbnailPath();
     //		myContentStorage::moveFile( $content . $source_thumbnail_path , $content . $target_thumbnail_path , false , true );
     $target_kshow->save();
     // copy the show_entry file content
     $source_show_entry = entryPeer::retrieveByPK($source_kshow->getShowEntryId());
     $source_show_entry_data_key = $source_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     $target_show_entry->setData(null);
     $target_show_entry->setData($source_show_entry->getData());
     $target_show_entry_data_key = $target_show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     $target_show_entry->setName($source_show_entry->getName());
     $target_show_entry->setLengthInMsecs($source_show_entry->getLengthInMsecs());
     kFileSyncUtils::softCopy($source_show_entry_data_key, $target_show_entry_data_key);
     //myContentStorage::moveFile( $content . $source_show_entry_path , $content . $target_show_entry_path , false , true );
     myEntryUtils::createThumbnail($target_show_entry, $source_show_entry, true);
     //		$target_kshow->setHasRoughcut(true);
     //		$target_kshow->save();
     $target_show_entry->save();
     return $target_kshow;
 }
 public static function getUploadPathAndUrl($token, $file_alias, $extra_id = null, $extension = "")
 {
     //		$extension = ""; // strtolower($parts['extension']);
     $filename = $token . '_' . $file_alias;
     // add the file extension after the "." character
     $suffix = $filename . ($extra_id ? "_" . $extra_id : "") . "." . $extension;
     $fullPath = myContentStorage::getFSUploadsPath() . $suffix;
     $fullUrl = requestUtils::getRequestHost() . "/" . myContentStorage::getFSUploadsPath(false) . $suffix;
     return array($fullPath, $fullUrl);
 }