/**
  * 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}");
 }
示例#2
0
 /**
  * Will forward to the uploader swf according to the ui_conf_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND, "UI conf not found");
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     $host = requestUtils::getRequestHost();
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         KExternalErrors::dieError(KExternalErrors::ILLEGAL_UI_CONF, "SWF URL not found in UI conf");
     }
     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
     }
     $conf_vars = $uiConf->getConfVars();
     if ($conf_vars) {
         $conf_vars = "&" . $conf_vars;
     }
     $params = "host=" . $host . "&uiConfId=" . $ui_conf_id . $conf_vars;
     KExternalErrors::terminateDispatch();
     $this->redirect("{$swf_url}?{$params}");
 }
示例#3
0
 /**
  * Will forward to the uploader swf according to the ui_conf_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 = requestUtils::getRequestHost();
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         die;
     }
     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
     }
     $conf_vars = $uiConf->getConfVars();
     if ($conf_vars) {
         $conf_vars = "&" . $conf_vars;
     }
     $params = "host=" . $host . "&uiConfId=" . $ui_conf_id . $conf_vars;
     $this->redirect("{$swf_url}?{$params}");
 }
 /**
  * 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 !
 }
示例#5
0
 public function setValueFromHtmlFieldName($prefix, $html_field_name, $value)
 {
     if (kString::beginsWith($html_field_name, $prefix)) {
         $field_name = substr($html_field_name, strlen($prefix));
         $this->setByName($field_name, $value);
     }
 }
示例#6
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}");
 }
 /**
  * @param FileSync $fileSync
  * @return string
  */
 protected function doGetFileSyncUrl(FileSync $fileSync)
 {
     $url = parent::doGetFileSyncUrl($fileSync);
     if (in_array($fileSync->getPartnerId(), array(666132, 628012, 357521, 560751)) && kString::beginsWith($url, "mp4:")) {
         $url .= ".mp4";
     }
     return $url;
 }
 protected function removeFiles($namePrefix)
 {
     $namePrefix = $this->normalizeSlashes($namePrefix);
     foreach ($this->_files as $name => $data) {
         if (kString::beginsWith($name, $namePrefix)) {
             unset($this->_files[$name]);
         }
     }
 }
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $uiconf_id = $this->getRequestParameter('uiconf_id');
     if (!$uiconf_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id');
     }
     $uiConf = uiConfPeer::retrieveByPK($uiconf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND);
     }
     $partner_id = $this->getRequestParameter('partner_id', $uiConf->getPartnerId());
     if (!$partner_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id');
     }
     $partner_host = myPartnerUtils::getHost($partner_id);
     $partner_cdnHost = myPartnerUtils::getCdnHost($partner_id);
     $use_cdn = $uiConf->getUseCdn();
     $host = $use_cdn ? $partner_cdnHost : $partner_host;
     $ui_conf_html5_url = $uiConf->getHtml5Url();
     if (kConf::hasMap("optimized_playback")) {
         $optimizedPlayback = kConf::getMap("optimized_playback");
         if (array_key_exists($partner_id, $optimizedPlayback)) {
             // force a specific kdp for the partner
             $params = $optimizedPlayback[$partner_id];
             if (array_key_exists('html5_url', $params)) {
                 $ui_conf_html5_url = $params['html5_url'];
             }
         }
     }
     if (kString::beginsWith($ui_conf_html5_url, "http")) {
         $url = $ui_conf_html5_url;
         // absolute URL
     } else {
         if ($ui_conf_html5_url) {
             $url = $host . $ui_conf_html5_url;
         } else {
             $html5_version = kConf::get('html5_version');
             $url = "{$host}/html5/html5lib/{$html5_version}/mwEmbedLoader.php";
         }
     }
     // append uiconf_id and partner id for optimizing loading of html5 library. append them only for "standard" urls by looking for the mwEmbedLoader.php suffix
     if (kString::endsWith($url, "mwEmbedLoader.php")) {
         $url .= "/p/{$partner_id}/uiconf_id/{$uiconf_id}";
         $entry_id = $this->getRequestParameter('entry_id');
         if ($entry_id) {
             $url .= "/entry_id/{$entry_id}";
         }
     }
     requestUtils::sendCachingHeaders(60);
     header("Pragma:");
     kFile::cacheRedirect($url);
     header("Location:{$url}");
     die;
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getP("entry_id");
     $kshow_id = $this->getP("kshow_id");
     // Make sure the request is for a ready roughcut
     $c = entryPeer::getCriteriaFilter()->getFilter();
     $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL);
     list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $version = $this->getP("version");
     // it's a path on the disk
     if (kString::beginsWith($version, ".")) {
         // someone is trying to hack in the system
         return sfView::ERROR;
     } elseif ($version == "-1") {
         $version = null;
     }
     // in case we're making a roughcut out of a regular invite, we start from scratch
     $entry_data_path = kFileSyncUtils::getLocalFilePathForKey($entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version));
     //replaced__getDataPath
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry_data_path === null) {
         $this->xml_content = "<xml></xml>";
         return;
     }
     $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
     $file_name = kFileSyncUtils::getReadyLocalFilePathForKey($sync_key, false);
     // fetch content of file from disk - it should hold the XML
     if (kString::endsWith($file_name, "xml")) {
         $xml_content = kFileSyncUtils::file_get_contents($sync_key, false, false);
         if (!$xml_content) {
             $xml_content = "<xml></xml>";
         }
         myMetadataUtils::updateEntryForPending($entry, $version, $xml_content);
         $this->addMsg("metadata", $xml_content);
     } else {
         $this->addError(APIErrors::INVALID_FILE_NAME, $file_name);
     }
 }
 /**
  * Will execute the virus scan for the given file path and return the output from virus scanner program
  * and the error description
  * @param string $filePath
  * @param boolean $cleanIfInfected
  * @param string $errorDescription
  */
 public function execute($filePath, $cleanIfInfected, &$output, &$errorDescription)
 {
     if (!file_exists($filePath)) {
         $errorDescription = 'Source file does not exists [' . $filePath . ']';
         return KalturaVirusScanJobResult::SCAN_ERROR;
     }
     $scanPolicy = $cleanIfInfected ? 'scanrepair' : 'scan';
     $scanCommand = "FILEMOD icap://" . self::SCAN_ENGINE_HOST . ":" . self::SCAN_ENGINE_PORT . "/SYMCScanResp-AV?action={$scanPolicy} ICAP/1.0\nHost: 127.0.0.1:1344\nX-Filepath: {$filePath}\nConnection: close\nEncapsulated: null-body=0\n\n";
     for ($scanAttempts = 0; $scanAttempts < $this->maxScanRetries; sleep($this->sleepBetweenScanRetries)) {
         $response = $this->sendCommandToScanEngine($scanCommand);
         if ($response === false) {
             continue;
             // don't count this as an attempt, since the command wasn't sent to the server
         }
         KalturaLog::debug("Buffer received from scan engine: {$response}");
         if (!kString::beginsWith($response, 'ICAP/1.0 ')) {
             KalturaLog::err("Response does not start with ICAP/1.0");
             $scanAttempts++;
             continue;
         }
         $statusCode = explode(' ', $response);
         $statusCode = $statusCode[1];
         $statusCode = substr($statusCode, 0, 3);
         switch ($statusCode) {
             case '200':
             case '204':
                 return KalturaVirusScanJobResult::FILE_IS_CLEAN;
             case '201':
                 return KalturaVirusScanJobResult::FILE_WAS_CLEANED;
             case '205':
             case '403':
                 return KalturaVirusScanJobResult::FILE_INFECTED;
             case '502':
                 $errorDescription = 'Scan engine failed to access source file [' . $filePath . ']';
                 return KalturaVirusScanJobResult::SCAN_ERROR;
                 // no reason to retry
             // no reason to retry
             case '539':
             case '558':
                 $errorDescription = 'No virus scan license';
                 return KalturaVirusScanJobResult::SCAN_ERROR;
                 // no reason to retry
             // no reason to retry
             default:
                 // incl: 500 - internal error
                 KalturaLog::err("Got invalid scan status {$statusCode}");
                 $scanAttempts++;
                 continue;
         }
     }
     return KalturaVirusScanJobResult::SCAN_ERROR;
 }
示例#12
0
 public function setConfFilePath($v)
 {
     if (kString::beginsWith($v, "..")) {
         $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [{$v}]";
         KalturaLog::log($err);
         throw new APIException(APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF, $v);
     }
     if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) {
         if (!kString::beginsWith($v, $this->getUiConfRootDirectory() . "uiconf/")) {
             $v = $this->getUiConfRootDirectory() . "uiconf/" . $v;
         }
         $real_v = realpath(dirname($v)) . "/" . pathinfo($v, PATHINFO_BASENAME);
         if ($v) {
             if ($real_v) {
                 /*
                  * TODO - add this id the service IS externally use via the API
                 					// the file exists - make sure we're not overiding someone elses file
                 					$ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() );
                 					foreach ( $ui_confs_with_same_path as $ui_conf  )
                 					{
                 						if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() )
                 						{
                 							$err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]";
                 							KalturaLog::log( $err );
                 							throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v );
                 						}
                 					}
                 */
                 $v = $real_v;
             }
         }
         parent::setConfFilePath($v);
     } else {
         parent::setConfFilePath($v);
         //			throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v );
     }
 }
示例#13
0
 public static function monitorDatabaseAccess($sql, $sqlTook, $hostName = null)
 {
     if (!self::$stream) {
         return;
     }
     // strip the comment
     if (kString::beginsWith($sql, '/*')) {
         $eventType = self::EVENT_DATABASE;
         $commentEndPos = strpos($sql, '*/') + 2;
         $comment = substr($sql, 0, $commentEndPos);
         $matches = null;
         if (preg_match('~^/\\* [^\\]]+\\[\\d+\\]\\[([^\\]]+)\\] \\*/~', $comment, $matches)) {
             $hostName = $matches[1];
         }
         $sql = trim(substr($sql, $commentEndPos));
     } else {
         $eventType = self::EVENT_SPHINX;
     }
     // extract the query type
     $queryType = null;
     foreach (self::$queryTypes as $prefix => $curQueryType) {
         if (kString::beginsWith($sql, $prefix)) {
             $sql = substr($sql, strlen($prefix));
             $queryType = $curQueryType;
             break;
         }
     }
     if (!$queryType) {
         return;
     }
     // extract the table name
     $tableNameStart = 0;
     if ($queryType == 'SELECT') {
         $fromPos = strpos($sql, ' FROM ');
         if ($fromPos === false) {
             return;
         }
         $tableNameStart = $fromPos + 6;
     }
     $tableNameEnd = strpos($sql, ' ', $tableNameStart);
     if ($tableNameEnd === false) {
         return;
     }
     $tableName = substr($sql, $tableNameStart, $tableNameEnd - $tableNameStart);
     $tableName = str_replace('`', '', $tableName);
     $data = array_merge(self::$basicEventInfo, array(self::FIELD_EVENT_TYPE => $eventType, self::FIELD_DATABASE => $hostName, self::FIELD_TABLE => $tableName, self::FIELD_QUERY_TYPE => $queryType, self::FIELD_EXECUTION_TIME => $sqlTook));
     self::writeDeferredEvent($data);
 }
示例#14
0
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $entry_id = $this->getRequestParameter("entry_id");
     $entry = null;
     $widget_id = null;
     $partner_id = null;
     if ($entry_id) {
         $entry = entryPeer::retrieveByPK($entry_id);
         if (!$entry) {
             KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
         }
         $partner_id = $entry->getPartnerId();
         $widget_id = '_' . $partner_id;
     }
     $widget_id = $this->getRequestParameter("widget_id", $widget_id);
     $widget = widgetPeer::retrieveByPK($widget_id);
     if (!$widget) {
         KExternalErrors::dieError(KExternalErrors::WIDGET_NOT_FOUND);
     }
     $subp_id = $widget->getSubpId();
     if (!$subp_id) {
         $subp_id = 0;
     }
     if (!$entry_id) {
         $entry_id = $widget->getEntryId();
         if ($entry_id) {
             $entry = entryPeer::retrieveByPK($entry_id);
             if (!$entry) {
                 KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
             }
         }
     }
     $allowCache = true;
     $securityType = $widget->getSecurityType();
     switch ($securityType) {
         case widget::WIDGET_SECURITY_TYPE_TIMEHASH:
             // TODO - I don't know what should be validated here
             break;
         case widget::WIDGET_SECURITY_TYPE_MATCH_IP:
             $allowCache = false;
             // here we'll attemp to match the ip of the request with that from the customData of the widget
             $custom_data = $widget->getCustomData();
             $valid_country = false;
             if ($custom_data) {
                 // in this case the custom_data should be of format:
                 //  valid_county_1,valid_country_2,...,valid_country_n;falback_entry_id
                 $arr = explode(";", $custom_data);
                 $countries_str = $arr[0];
                 $fallback_entry_id = isset($arr[1]) ? $arr[1] : null;
                 $fallback_kshow_id = isset($arr[2]) ? $arr[2] : null;
                 $current_country = "";
                 $valid_country = requestUtils::matchIpCountry($countries_str, $current_country);
                 if (!$valid_country) {
                     KalturaLog::log("Attempting to access widget [{$widget_id}] and entry [{$entry_id}] from country [{$current_country}]. Retrning entry_id: [{$fallback_entry_id}] kshow_id [{$fallback_kshow_id}]");
                     $entry_id = $fallback_entry_id;
                 }
             }
             break;
         case widget::WIDGET_SECURITY_TYPE_FORCE_KS:
             $ks_str = $this->getRequestParameter('ks');
             try {
                 $ks = kSessionUtils::crackKs($ks_str);
             } catch (Exception $e) {
                 KExternalErrors::dieError(KExternalErrors::INVALID_KS);
             }
             $res = kSessionUtils::validateKSession2(1, $partner_id, 0, $ks_str, $ks);
             if ($res <= 0) {
                 KExternalErrors::dieError(KExternalErrors::INVALID_KS);
             }
             break;
         default:
             break;
     }
     $requestKey = $_SERVER["REQUEST_URI"];
     // check if we cached the redirect url
     $cache = new myCache("embedIframe", 10 * 60);
     // 10 minutes
     $cachedResponse = $cache->get($requestKey);
     if ($allowCache && $cachedResponse) {
         header("X-Kaltura: cached-action");
         header("Expires: Sun, 19 Nov 2000 08:52:00 GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
         header("Pragma: no-cache");
         header("Location:{$cachedResponse}");
         KExternalErrors::dieGracefully();
     }
     $uiconf_id = $this->getRequestParameter('uiconf_id');
     if (!$uiconf_id) {
         $uiconf_id = $widget->getUiConfId();
     }
     if (!$uiconf_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id');
     }
     $partner_host = myPartnerUtils::getHost($partner_id);
     $partner_cdnHost = myPartnerUtils::getCdnHost($partner_id);
     $uiConf = uiConfPeer::retrieveByPK($uiconf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND);
     }
     $partner_host = myPartnerUtils::getHost($partner_id);
     $partner_cdnHost = myPartnerUtils::getCdnHost($partner_id);
     $html5_version = kConf::get('html5_version');
     $use_cdn = $uiConf->getUseCdn();
     $host = $use_cdn ? $partner_cdnHost : $partner_host;
     $ui_conf_html5_url = $uiConf->getHtml5Url();
     if ($ui_conf_html5_url) {
         $url = str_replace('mwEmbedLoader.php', 'mwEmbedFrame.php', $ui_conf_html5_url);
         if (!kString::beginsWith($ui_conf_html5_url, "http")) {
             // absolute URL
             $url = $host . $url;
         }
     } else {
         $url = $host;
         $url .= "/html5/html5lib/{$html5_version}/mwEmbedFrame.php";
     }
     if ($entry_id) {
         $url .= "/entry_id/{$entry_id}";
     }
     $url .= "/wid/{$widget_id}/uiconf_id/{$uiconf_id}";
     $url .= '?' . http_build_query($_GET, '', '&');
     // forward all GET parameters
     if ($allowCache) {
         $cache->put($requestKey, $url);
     }
     KExternalErrors::terminateDispatch();
     $this->redirect($url);
 }
 /**
  * Authenticates user on MySpace.com
  * @return boolean
  */
 function doAuthentication()
 {
     // Instructs to initialize cURL session
     $this->initCurl();
     // Sets the URL for authentication purpose
     $this->url = $this->loginURI;
     // Sets the number of fields to send via HTTP POST
     $this->usePostField = 1;
     // Sets the fields to be sent via HTTP POST as key=value
     $this->postFields = "email={$this->email}&password={$this->password}&Remember=&NextPage=fuseaction=profile.interests";
     $this->follow = 1;
     // Instructs to set Cookie Jar
     if ($this->setCookieJar() == FALSE) {
         $this->setError("cookie_error");
         return false;
     }
     // Checks if the cURL options are all set properly
     if ($this->setCurlOption()) {
         // Instructs to execute cURL session
         $this->hit_stack[] = "doAuthentication";
         $this->execCurl();
         // Checks if any cURL error is generated
         if ($this->getCurlError()) {
             $this->unlinkFile($this->cookieFileJar);
             $this->setError("curl_error");
             return false;
         }
         $this->log("step: 1\n");
         // Checks if the authentication failed, either invalid login or username is not registered
         if (preg_match("/Must Be Logged-In/i", $this->outputContent)) {
             // Instructs to close cURL session
             $this->closeCurl();
             // Unlinks the cookie file
             $this->unlinkFile($this->cookieFileJar);
             $this->setError("invalid_login");
             return false;
         }
         $this->log("step: 2\n");
         // Get the URL we are supposed to use for the Edit Profile action
         $link = self::getLinkString($this->outputContent, "Skip this Advertisement");
         if ($link != NULL) {
             $href = self::getHrefValue($link);
             if (!kString::beginsWith($href, "http")) {
                 $href = "http://login.myspace.com/index.cfm?" . $href;
             }
             $this->log("step: 3, Skip this Advertisement\n** href ** . {$href} ");
             $this->addDataURI = $href;
             $this->getDataURI = $href;
             $this->url = $href;
             //				$this->postFields = str_replace ( "fuseaction=profile.interests" , "fuseaction=user" , $this->postFields );
             $this->follow = 1;
             $this->setCurlOption();
             // have to follow an object that moved
             $this->execCurl();
             // Checks if any cURL error is generated
             if ($this->getCurlError()) {
                 $this->unlinkFile($this->cookieFileJar);
                 $this->setError("curl_error");
                 return false;
             }
             $this->log("step: 200, After - Skip this Advertisement\n");
             $link = self::getLinkString($this->outputContent, "here", "Object moved to");
             if ($link != NULL) {
                 $this->log("step: 300, Object moved to\n");
                 $href = self::getHrefValue($link);
                 $this->addDataURI = $href;
                 $this->getDataURI = $href;
             } else {
                 $this->log("step: 400, cannot follow href\n");
             }
         }
         $this->log("step: 4\n");
         // Try finding an 'Edit Profile' link
         $link = self::getLinkString($this->outputContent, "Edit Profile");
         $refinedURL = self::getHrefValue($link);
         if ($refinedURL == NULL) {
             $this->log("step: 7\n");
             $this->setError("parse_error");
             return false;
         }
         $this->log("step: 6\n ");
         $this->addDataURI = $refinedURL;
         $this->getDataURI = $refinedURL;
         $this->log("addDataURI: " . $this->addDataURI . " getDataURI: " . $this->getDataURI . "\n");
         $this->log("step: 9\n");
         $this->closeCurl();
     }
     unset($this->outputContent);
     $this->log("step: 10- ended doAuthentication successfully\n");
     return true;
 }
 protected static function parseMultiPart($contentType, $contents)
 {
     if (!kString::beginsWith($contentType, 'multipart/form-data; boundary=')) {
         KalturaLog::err("failed to parse multipart content type [{$contentType}]");
         return false;
     }
     $explodedContentType = explode('=', $contentType);
     $boundary = trim($explodedContentType[1]);
     $result = array();
     $curPos = 0;
     for (;;) {
         if (substr($contents, $curPos, 2 + strlen($boundary)) != '--' . $boundary) {
             KalturaLog::err("expected [--{$boundary}] at pos [{$curPos}]");
             return false;
         }
         $headerEndPos = strpos($contents, "\n\n", $curPos);
         if ($headerEndPos === false) {
             break;
         }
         $headerEndPos += 2;
         // skip the 2 newlines
         $dataEndPos = strpos($contents, "\n--" . $boundary, $headerEndPos);
         if ($dataEndPos === false) {
             KalturaLog::err("failed to find end boundary");
             return false;
         }
         $headers = explode("\n", substr($contents, $curPos, $headerEndPos - $curPos));
         $name = null;
         foreach ($headers as $header) {
             if (!kString::beginsWith($header, 'Content-Disposition: form-data; name="')) {
                 continue;
             }
             $explodedHeader = explode('"', $header);
             $name = $explodedHeader[1];
         }
         if (is_null($name)) {
             KalturaLog::err("failed to extract part name from " . print_r($headers, true));
             return false;
         }
         $result[$name] = substr($contents, $headerEndPos, $dataEndPos - $headerEndPos);
         $curPos = $dataEndPos + 1;
     }
     if (substr($contents, $curPos + 2 + strlen($boundary), 2) != '--') {
         KalturaLog::err("last boundary must end with --");
         return false;
     }
     return $result;
 }
示例#17
0
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $uv_cookie = @$_COOKIE['uv'];
     if (strlen($uv_cookie) != 35) {
         $uv_cookie = "uv_" . md5(uniqid(rand(), true));
     }
     setrawcookie('uv', $uv_cookie, time() + 3600 * 24 * 365, '/');
     // check if this is a request for the kdp without a wrapper
     // in case of an application loading the kdp (e.g. kmc)
     $nowrapper = $this->getRequestParameter("nowrapper", false);
     // allow caching if either the cache start time (cache_st) parameter
     // wasn't specified or if it is past the specified time
     $cache_st = $this->getRequestParameter("cache_st");
     $allowCache = !$cache_st || $cache_st < time();
     $referer = @$_SERVER['HTTP_REFERER'];
     $externalInterfaceDisabled = strstr($referer, "bebo.com") === false && strstr($referer, "myspace.com") === false && strstr($referer, "current.com") === false && strstr($referer, "myyearbook.com") === false && strstr($referer, "facebook.com") === false && strstr($referer, "friendster.com") === false ? "" : "&externalInterfaceDisabled=1";
     // if there is no wrapper the loader is responsible for setting extra params to the kdp
     $noncached_params = "";
     if (!$nowrapper) {
         $noncached_params = $externalInterfaceDisabled . "&referer=" . urlencode($referer);
     }
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http";
     $requestKey = $protocol . $_SERVER["REQUEST_URI"];
     // check if we cached the redirect url
     $cache = new myCache("kwidget", 10 * 60);
     // 10 minutes
     $cachedResponse = $cache->get($requestKey);
     if ($allowCache && $cachedResponse) {
         header("X-Kaltura:cached-action");
         header("Expires: Sun, 19 Nov 2000 08:52:00 GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
         header("Pragma: no-cache");
         header("Location:{$cachedResponse}" . $noncached_params);
         die;
     }
     // check if we cached the patched swf with flashvars
     $cache_swfdata = new myCache("kwidgetswf", 10 * 60);
     // 10 minutes
     $cachedResponse = $cache_swfdata->get($requestKey);
     if ($allowCache && $cachedResponse) {
         header("X-Kaltura:cached-action");
         requestUtils::sendCdnHeaders("swf", strlen($cachedResponse), 60 * 10);
         echo $cachedResponse;
         die;
     }
     $widget_id = $this->getRequestParameter("wid");
     $show_version = $this->getRequestParameter("v");
     $debug_kdp = $this->getRequestParameter("debug_kdp", false);
     $widget = widgetPeer::retrieveByPK($widget_id);
     if (!$widget) {
         die;
     }
     // because of the routing rule - the entry_id & kmedia_type WILL exist. be sure to ignore them if smaller than 0
     $kshow_id = $widget->getKshowId();
     $entry_id = $widget->getEntryId();
     $gallery_widget = !$kshow_id && !$entry_id;
     if (!$entry_id) {
         $entry_id = -1;
     }
     if ($widget->getSecurityType() != widget::WIDGET_SECURITY_TYPE_TIMEHASH) {
         // try eid - if failed entry_id
         $eid = $this->getRequestParameter("eid", $this->getRequestParameter("entry_id"));
         // try kid - if failed kshow_id
         $kid = $this->getRequestParameter("kid", $this->getRequestParameter("kshow_id"));
         if ($eid != null) {
             $entry_id = $eid;
         } elseif ($kid != null) {
             $kshow_id = $kid;
         }
     }
     if ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_MATCH_IP) {
         $allowCache = false;
         // here we'll attemp to match the ip of the request with that from the customData of the widget
         $custom_data = $widget->getCustomData();
         $valid_country = false;
         if ($custom_data) {
             // in this case the custom_data should be of format:
             //  valid_county_1,valid_country_2,...,valid_country_n;falback_entry_id
             $arr = explode(";", $custom_data);
             $countries_str = $arr[0];
             $fallback_entry_id = isset($arr[1]) ? $arr[1] : null;
             $fallback_kshow_id = isset($arr[2]) ? $arr[2] : null;
             $current_country = "";
             $valid_country = requestUtils::matchIpCountry($countries_str, $current_country);
             if (!$valid_country) {
                 KalturaLog::log("kwidgetAction: Attempting to access widget [{$widget_id}] and entry [{$entry_id}] from country [{$current_country}]. Retrning entry_id: [{$fallback_entry_id}] kshow_id [{$fallback_kshow_id}]");
                 $entry_id = $fallback_entry_id;
                 $kshow_id = $fallback_kshow_id;
             }
         }
     } elseif ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_FORCE_KS) {
     }
     $kmedia_type = -1;
     // support either uiconf_id or ui_conf_id
     $uiconf_id = $this->getRequestParameter("uiconf_id");
     if (!$uiconf_id) {
         $uiconf_id = $this->getRequestParameter("ui_conf_id");
     }
     if ($uiconf_id) {
         $widget_type = $uiconf_id;
         $uiconf_id_str = "&uiconf_id={$uiconf_id}";
     } else {
         $widget_type = $widget->getUiConfId();
         $uiconf_id_str = "";
     }
     if (empty($widget_type)) {
         $widget_type = 3;
     }
     $kdata = $widget->getCustomData();
     $partner_host = myPartnerUtils::getHost($widget->getPartnerId());
     $partner_cdnHost = myPartnerUtils::getCdnHost($widget->getPartnerId());
     $host = $partner_host;
     if ($widget_type == 10) {
         $swf_url = $host . "/swf/weplay.swf";
     } else {
         $swf_url = $host . "/swf/kplayer.swf";
     }
     $partner_id = $widget->getPartnerId();
     $subp_id = $widget->getSubpId();
     if (!$subp_id) {
         $subp_id = 0;
     }
     $uiConf = uiConfPeer::retrieveByPK($widget_type);
     // new ui_confs which are deleted should stop the script
     // the check for >100000 is for supporting very old mediawiki and such players
     if (!$uiConf && $widget_type > 100000) {
         die;
     }
     if ($uiConf) {
         $ui_conf_swf_url = $uiConf->getSwfUrl();
         if (kString::beginsWith($ui_conf_swf_url, "http")) {
             $swf_url = $ui_conf_swf_url;
             // absolute URL
         } else {
             $use_cdn = $uiConf->getUseCdn();
             $host = $use_cdn ? $partner_cdnHost : $partner_host;
             $swf_url = $host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         }
         if ($debug_kdp) {
             $swf_url = str_replace("/kdp/", "/kdp_debug/", $swf_url);
         }
     }
     if ($show_version < 0) {
         $show_version = null;
     }
     $ip = requestUtils::getRemoteAddress();
     // to convert back, use long2ip
     // the widget log should change to reflect the new data, but for now - i used $widget_id instead of the widgget_type
     //		WidgetLog::createWidgetLog( $referer , $ip , $kshow_id , $entry_id , $kmedia_type , $widget_id );
     if ($entry_id == -1) {
         $entry_id = null;
     }
     $kdp3 = false;
     $base_wrapper_swf = myContentStorage::getFSFlashRootPath() . "/kdpwrapper/" . kConf::get('kdp_wrapper_version') . "/kdpwrapper.swf";
     $widgetIdStr = "widget_id={$widget_id}";
     $partnerIdStr = "partner_id={$partner_id}&subp_id={$subp_id}";
     if ($uiConf) {
         $ks_flashvars = "";
         $conf_vars = $uiConf->getConfVars();
         if ($conf_vars) {
             $conf_vars = "&" . $conf_vars;
         }
         $wrapper_swf = $base_wrapper_swf;
         $partner = PartnerPeer::retrieveByPK($partner_id);
         if ($partner) {
             $partner_type = $partner->getType();
         }
         if (version_compare($uiConf->getSwfUrlVersion(), "3.0", ">=")) {
             $kdp3 = true;
             // further in the code, $wrapper_swf is being used and not $base_wrapper_swf
             $wrapper_swf = $base_wrapper_swf = myContentStorage::getFSFlashRootPath() . '/kdp3wrapper/' . kConf::get('kdp3_wrapper_version') . '/kdp3wrapper.swf';
             $widgetIdStr = "widgetId={$widget_id}";
             $uiconf_id_str = "&uiConfId={$uiconf_id}";
             $partnerIdStr = "partnerId={$partner_id}&subpId={$subp_id}";
         }
         // if we are loaded without a wrapper (directly in flex)
         // 1. dont create the ks - keep url the same for caching
         // 2. dont patch the uiconf - patching is done only to wrapper anyway
         if ($nowrapper) {
             $dynamic_date = $widgetIdStr . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", $partner_cdnHost)) . $uiconf_id_str . $conf_vars;
             $url = "{$swf_url}?{$dynamic_date}";
         } else {
             // if kdp version >= 2.5
             if (version_compare($uiConf->getSwfUrlVersion(), "2.5", ">=")) {
                 // create an anonymous session
                 $ks = "";
                 $result = kSessionUtils::createKSessionNoValidations($partner_id, 0, $ks, 86400, false, "", "view:*");
                 $ks_flashvars = "&{$partnerIdStr}&uid=0&ts=" . microtime(true);
                 if ($widget->getSecurityType() != widget::WIDGET_SECURITY_TYPE_FORCE_KS) {
                     $ks_flashvars = "&ks={$ks}" . $ks_flashvars;
                 }
                 // patch kdpwrapper with getwidget and getuiconf
                 $root = myContentStorage::getFSContentRootPath();
                 $confFile_mtime = $uiConf->getUpdatedAt(null);
                 $new_swf_path = "widget_{$widget_id}_{$widget_type}_{$confFile_mtime}_" . md5($base_wrapper_swf . $swf_url) . ".swf";
                 $md5 = md5($new_swf_path);
                 $new_swf_path = "content/cacheswf/" . substr($md5, 0, 2) . "/" . substr($md5, 2, 2) . "/" . $new_swf_path;
                 $cached_swf = "{$root}/{$new_swf_path}";
                 if (!file_exists($cached_swf) || filemtime($cached_swf) < $confFile_mtime) {
                     kFile::fullMkdir($cached_swf);
                     require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "api_v3" . DIRECTORY_SEPARATOR . "bootstrap.php";
                     $dispatcher = KalturaDispatcher::getInstance();
                     try {
                         $widget_result = $dispatcher->dispatch("widget", "get", array("ks" => $ks, "id" => $widget_id));
                         $ui_conf_result = $dispatcher->dispatch("uiConf", "get", array("ks" => $ks, "id" => $widget_type));
                     } catch (Exception $ex) {
                         die;
                     }
                     $serializer = new KalturaXmlSerializer(false);
                     $serializer->serialize($widget_result);
                     $widget_xml = $serializer->getSerializedData();
                     $serializer = new KalturaXmlSerializer(false);
                     $serializer->serialize($ui_conf_result);
                     $ui_conf_xml = $serializer->getSerializedData();
                     $patcher = new kPatchSwf($root . $base_wrapper_swf);
                     $result = "<xml><result>{$widget_xml}</result><result>{$ui_conf_xml}</result></xml>";
                     $patcher->patch($result, $cached_swf);
                 }
                 if (file_exists($cached_swf)) {
                     $wrapper_swf = $new_swf_path;
                 }
             }
             $kdp_version_2 = strpos($swf_url, "kdp/v2.") > 0;
             if ($partner_host == "http://www.kaltura.com" && !$kdp_version_2 && !$kdp3) {
                 $partner_host = 1;
                 // otherwise the kdp will try going to cdnwww.kaltura.com
             }
             $track_wrapper = '';
             if (kConf::get('track_kdpwrapper') && kConf::get('kdpwrapper_track_url')) {
                 $track_wrapper = "&wrapper_tracker_url=" . urlencode(kConf::get('kdpwrapper_track_url') . "?activation_key=" . kConf::get('kaltura_activation_key') . "&package_version=" . kConf::get('kaltura_version'));
             }
             $dynamic_date = $widgetIdStr . $track_wrapper . "&kdpUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", $partner_cdnHost)) . ($show_version ? "&entryVersion={$show_version}" : "") . ($kshow_id ? "&kshowId={$kshow_id}" : "") . ($entry_id ? "&entryId={$entry_id}" : "") . $uiconf_id_str . $ks_flashvars . ($cache_st ? "&clientTag=cache_st:{$cache_st}" : "") . $conf_vars;
             // for now changed back to $host since kdp version prior to 1.0.15 didnt support loading by external domain kdpwrapper
             $url = $host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "/{$wrapper_swf}?{$dynamic_date}";
             // patch wrapper with flashvars and dump to browser
             if (version_compare($uiConf->getSwfUrlVersion(), "2.6.6", ">=")) {
                 $patcher = new kPatchSwf($root . $wrapper_swf, "KALTURA_FLASHVARS_DATA");
                 ob_start();
                 $patcher->patch($dynamic_date . "&referer=" . urlencode($referer));
                 $wrapper_data = ob_get_contents();
                 ob_end_clean();
                 requestUtils::sendCdnHeaders("swf", strlen($wrapper_data), $allowCache ? 60 * 10 : 0);
                 echo $wrapper_data;
                 if ($allowCache) {
                     $cache_swfdata->put($requestKey, $wrapper_data);
                 }
                 die;
             }
         }
     } else {
         $dynamic_date = "kshowId={$kshow_id}" . "&host=" . requestUtils::getRequestHostId() . ($show_version ? "&entryVersion={$show_version}" : "") . ($entry_id ? "&entryId={$entry_id}" : "") . ($entry_id ? "&KmediaType={$kmedia_type}" : "");
         $dynamic_date .= "&isWidget={$widget_type}&referer=" . urlencode($referer);
         $dynamic_date .= "&kdata={$kdata}";
         $url = "{$swf_url}?{$dynamic_date}";
     }
     // if referer has a query string an IE bug will prevent out flashvars to propagate
     // when nowrapper is true we cant use /swfparams either as there isnt a kdpwrapper
     if (!$nowrapper && $uiConf && version_compare($uiConf->getSwfUrlVersion(), "2.6.6", ">=")) {
         // apart from the /swfparam/ format, add .swf suffix to the end of the stream in case
         // a corporate firewall looks at the file suffix
         $pos = strpos($url, "?");
         $url = substr($url, 0, $pos) . "/swfparams/" . urlencode(substr($url, $pos + 1)) . ".swf";
     }
     if ($allowCache) {
         $cache->put($requestKey, $url);
     }
     if (strpos($url, "/swfparams/") > 0) {
         $url = substr($url, 0, -4) . urlencode($noncached_params) . ".swf";
     } else {
         $url .= $noncached_params;
     }
     $this->redirect($url);
 }
示例#18
0
 public static function removeAllSecureCookies()
 {
     $cookies = $_COOKIE;
     $name = null;
     foreach ($cookies as $name => $value) {
         if (kString::beginsWith($name, self::SECURE_COOKIE_PREFIX)) {
             self::removeSecureCookieByName($name);
         }
     }
     if ($name) {
         setcookie(self::getHashedName($name), "", 0, "/");
     }
 }
示例#19
0
 /**
  * Serves the file content
  * 
  * @action serveByFlavorParamsId
  * @param string $entryId Document entry id
  * @param string $flavorParamsId Flavor params id
  * @param bool $forceProxy force to get the content without redirect
  * @return file
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
  * @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
  */
 public function serveByFlavorParamsIdAction($entryId, $flavorParamsId = null, $forceProxy = false)
 {
     // temporary workaround for getting the referrer from a url with the format ....&forceProxy/true/referrer/...
     $referrer = null;
     if (isset($_GET["forceProxy"]) && kString::beginsWith($_GET["forceProxy"], "true/referrer/")) {
         $referrer = substr($_GET["forceProxy"], strlen("true/referrer/"));
         $referrer = base64_decode($referrer);
     }
     KalturaResponseCacher::disableCache();
     myPartnerUtils::resetPartnerFilter('entry');
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != entryType::DOCUMENT) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $ksObj = $this->getKs();
     $ks = $ksObj ? $ksObj->getOriginalString() : null;
     $securyEntryHelper = new KSecureEntryHelper($dbEntry, $ks, $referrer, ContextType::DOWNLOAD);
     $securyEntryHelper->validateForDownload();
     $flavorAsset = null;
     if ($flavorParamsId) {
         $flavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $flavorParamsId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorParamsId);
         }
     } else {
         $flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
         if (!$flavorAsset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorParamsId);
         }
     }
     if (!$securyEntryHelper->isAssetAllowed($flavorAsset)) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorParamsId);
     }
     $fileName = $dbEntry->getName() . '.' . $flavorAsset->getFileExt();
     return $this->serveFlavorAsset($flavorAsset, $fileName, $forceProxy);
 }
 private static function tagNameFromField($key, $num_prefix)
 {
     //		echo "tagNameFromField ( $key , $num_prefix )<br>";
     if (is_numeric($key)) {
         return $num_prefix . $key;
     } elseif (kString::beginsWith($key, "__")) {
         $pat = "/^__[^_]*_(.*)\$/";
         //
         preg_match($pat, $key, $suffix);
         return $suffix[1];
     }
     return $key;
 }
示例#21
0
<?php

$host = requestUtils::getHost();
$recorderUrl = "";
if (!kString::beginsWith($host, "http://www.kaltura.com")) {
    $rtmp_host = str_replace("http:", "rtmp:", $host);
    $recorderUrl = "Red5ServerURL={$rtmp_host}/oflaDemo&";
}
echo 'wizardInitVars.recorderUrl = "' . $recorderUrl . '";';
?>

if (typeof(prodWizLogic) == 'undefined') // load the contribute.js only once
{
	activeWizard.waitForScript = true;
	createDynamicScript('/js/contribute.js');
}
else
	prodWizLogic.preInit();

</script>

<div class="cont2 step1" id="_prodWizPageType" autoFocus="true">
	<div class="top2_hint">
		<div class="top2 step1">
			<h1>Choose the type of Kaltura to create</h1>
		</div>
	</div>
	<div class="container">
		<div class="radioGroup clearfix">			
			<?php 
$types = kshow::getTypes();
 private static function getEntryType($entry)
 {
     $extended_entry_type = new extendedEntryMediaType();
     $entry_type = $entry->getMediaType();
     // this is assumed to be correct
     $data = kFileSyncUtils::getReadyLocalFilePathForKey($entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA));
     // replaced__getDataPath
     $ext = pathinfo($data, PATHINFO_EXTENSION);
     if ($ext == NULL || $ext == "") {
         // if tehre is no extensio - ASSUME : entry::ENTRY_MEDIA_TYPE_VIDEO
         $extended_entry_type->asset_type = self::VIDEO_ASSET;
         if (kString::beginsWith($data, self::$RTMP_PREFIX)) {
             $extended_entry_type->type = self::TYPE_RTMP;
         } else {
             $extended_entry_type->type = self::TYPE_PD;
             // assume progressive download
         }
     } else {
         // there is an extension -
         if (in_array($ext, self::$IMAGE_EXT)) {
             $extended_entry_type->asset_type = self::VIDEO_ASSET;
             $extended_entry_type->type = self::TYPE_IMG;
         } elseif (in_array($ext, self::$VIDEO_EXT)) {
             $extended_entry_type->asset_type = self::VIDEO_ASSET;
             $extended_entry_type->type = self::TYPE_PD;
             // for now - use RTMP as the download method for video
             //$extended_entry_type->type = self::TYPE_RTMP;
         } elseif (in_array($ext, self::$SWF_EXT)) {
             $extended_entry_type->asset_type = self::OBJECT_ASSET;
             $extended_entry_type->type = self::TYPE_SWF;
         } elseif (in_array($ext, self::$AUDIO_EXT)) {
             $extended_entry_type->asset_type = self::AUDIO_ASSET;
             $extended_entry_type->type = self::TYPE_PD;
         } else {
             // choose some default for unknown extensions
             $extended_entry_type->asset_type = self::OBJECT_ASSET;
             $extended_entry_type->type = self::TYPE_UNKNOWN;
         }
     }
     return $extended_entry_type;
 }
示例#23
0
 /**
  * Will execute the virus scan for the given file path and return the output from virus scanner program
  * and the error description
  * @param string $filePath
  * @param boolean $cleanIfInfected
  * @param string $errorDescription
  */
 public function execute($filePath, $cleanIfInfected, &$output, &$errorDescription)
 {
     if (!$this->binFile) {
         $errorDescription = 'Engine command line not set';
         return KalturaVirusScanJobResult::SCAN_ERROR;
     }
     if (!file_exists($filePath)) {
         $errorDescription = 'Source file does not exists [' . $filePath . ']';
         return KalturaVirusScanJobResult::SCAN_ERROR;
     }
     $scanMode = $cleanIfInfected ? 'scanrepair' : 'scan';
     $logFile = "{$filePath}.virusScan.log";
     $cmd = $this->binFile . " --action {$scanMode} --verbose -f {$filePath} > {$logFile} 2>&1";
     $errorDescription = null;
     $output = null;
     KalturaLog::debug("Executing - [{$cmd}]");
     for ($tries = 1; $tries <= self::NUM_OF_ATTEMPTS; $tries++) {
         while (!$this->isEngineRunning()) {
             KalturaLog::debug("Symantec engine not running, retrying in 10 seconds");
             sleep(10);
         }
         system($cmd, $return_value);
         $output = file($logFile);
         if (!count($output) || strpos($output[0], self::UNABLE_TO_SEND_DATA_TO_THE_SERVER) === false) {
             break;
         }
         KalturaLog::debug("Retrying scan.attempt number:" . $tries);
         sleep(10);
     }
     $found = false;
     foreach ($output as $line) {
         $matches = null;
         if (preg_match('/^ERROR: (.+)/', $line, $matches)) {
             $errorDescription = $matches[1];
             return KalturaVirusScanJobResult::SCAN_ERROR;
         }
         if (kString::beginsWith($line, self::STATUS_PREFIX)) {
             $found = $line;
             break;
         }
     }
     $output = implode(PHP_EOL, $output);
     if (!$found) {
         $errorDescription = 'Unknown error';
         return KalturaVirusScanJobResult::SCAN_ERROR;
     }
     $returnValue = trim(substr($found, strlen(self::STATUS_PREFIX)));
     if ($returnValue == 'Clean') {
         return KalturaVirusScanJobResult::FILE_IS_CLEAN;
     } else {
         if ($returnValue == 'Repaired') {
             return KalturaVirusScanJobResult::FILE_WAS_CLEANED;
         } else {
             if ($returnValue == 'Infected') {
                 return KalturaVirusScanJobResult::FILE_INFECTED;
             } else {
                 $errorDescription = "Unknown returned value from virus scanner";
             }
         }
     }
     return KalturaVirusScanJobResult::SCAN_ERROR;
 }
示例#24
0
 private function findCredential($cred_name)
 {
     $cred_list = $this->getUser()->listCredentials();
     $prefix = $cred_name . ":";
     foreach ($cred_list as $cred_index => $val) {
         if (kString::beginsWith($val, $prefix)) {
             return $val;
         }
     }
     return NULL;
 }
 /**
  * Will forward to the regular swf player according to the widget_id
  */
 public function execute()
 {
     $uiconf_id = $this->getRequestParameter('uiconf_id');
     if (!$uiconf_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id');
     }
     $uiConf = uiConfPeer::retrieveByPK($uiconf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND);
     }
     $partner_id = $this->getRequestParameter('partner_id', $uiConf->getPartnerId());
     if (!$partner_id) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id');
     }
     $widget_id = $this->getRequestParameter("widget_id", '_' . $partner_id);
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http";
     $host = myPartnerUtils::getCdnHost($partner_id, $protocol, 'api');
     $ui_conf_html5_url = $uiConf->getHtml5Url();
     if (kConf::hasMap("optimized_playback")) {
         $optimizedPlayback = kConf::getMap("optimized_playback");
         if (array_key_exists($partner_id, $optimizedPlayback)) {
             // force a specific kdp for the partner
             $params = $optimizedPlayback[$partner_id];
             if (array_key_exists('html5_url', $params)) {
                 $ui_conf_html5_url = $params['html5_url'];
             }
         }
     }
     $autoEmbed = $this->getRequestParameter('autoembed');
     $iframeEmbed = $this->getRequestParameter('iframeembed');
     $scriptName = $iframeEmbed ? 'mwEmbedFrame.php' : 'mwEmbedLoader.php';
     if ($ui_conf_html5_url && $iframeEmbed) {
         $ui_conf_html5_url = str_replace('mwEmbedLoader.php', 'mwEmbedFrame.php', $ui_conf_html5_url);
     }
     $relativeUrl = true;
     // true if ui_conf html5_url is relative (doesnt start with an http prefix)
     if (kString::beginsWith($ui_conf_html5_url, "http")) {
         $relativeUrl = false;
         $url = $ui_conf_html5_url;
         // absolute URL
     } else {
         if (!$iframeEmbed) {
             $host = "{$protocol}://" . kConf::get('html5lib_host') . "/";
         }
         if ($ui_conf_html5_url) {
             $url = $host . $ui_conf_html5_url;
         } else {
             $html5_version = kConf::get('html5_version');
             $url = "{$host}/html5/html5lib/{$html5_version}/" . $scriptName;
         }
     }
     // append uiconf_id and partner id for optimizing loading of html5 library. append them only for "standard" urls by looking for the mwEmbedLoader.php/mwEmbedFrame.php suffix
     if (kString::endsWith($url, $scriptName)) {
         $url .= "/p/{$partner_id}/uiconf_id/{$uiconf_id}";
         if (!$autoEmbed) {
             $entry_id = $this->getRequestParameter('entry_id');
             if ($entry_id) {
                 $url .= "/entry_id/{$entry_id}";
             }
         }
     }
     header("pragma:");
     if ($iframeEmbed) {
         $url .= (strpos($url, "?") === false ? "?" : "&") . 'wid=' . $widget_id . '&' . $_SERVER["QUERY_STRING"];
     } else {
         $params = "protocol={$protocol}&" . $_SERVER["QUERY_STRING"];
         $url .= (strpos($url, "?") === false ? "?" : "&") . $params;
         if ($relativeUrl) {
             header('Content-Type: application/javascript');
             kFileUtils::dumpUrl($url, true, false, array("X-Forwarded-For" => requestUtils::getRemoteAddress()));
         }
     }
     requestUtils::sendCachingHeaders(60, true, time());
     kFile::cacheRedirect($url);
     header("Location:{$url}");
     KExternalErrors::dieGracefully();
 }
示例#26
0
 private function fetchFromCache($field_name)
 {
     if ($this->objs_cache == null) {
         return null;
     }
     if (array_key_exists($field_name, $this->objs_cache)) {
         //			echo get_class ( $this );
         $cache_params = $this->objs_cache[$field_name];
         // will be in the format of <object_class>,<field_id>
         $arr = explode(",", $cache_params);
         $obj_clazz = $arr[0];
         $obj_id_field = $arr[1];
         $id = $this->get($obj_id_field);
         // this indicates the field is an array of objects
         if (kString::beginsWith($obj_clazz, "*")) {
             //				echo "\nfetchFromCache [$field_name] $obj_clazz\n";
             $obj_clazz = substr($obj_clazz, 1);
             $obj_from_cache = self::$s_cache->getArray($this->m_obj, $field_name);
         } else {
             $obj_from_cache = self::$s_cache->get($obj_clazz, $id);
         }
         /*
         if ( $obj_from_cache )
         {
         echo ( "\nfound $cache_params [$id]\n");
         }
         else
         {
         echo ( "\n" . $cache_params . " [$id] not found\n");
         }
         */
         return $obj_from_cache;
     } else {
         return null;
     }
 }
示例#27
0
 static function buildMultilineString($description, $indent = "")
 {
     $description = trim($description);
     if (!$description) {
         return "";
     }
     $description = str_replace("\n", "\n{$indent}", $description);
     # make sure the description does not start or end with '"'
     if (kString::beginsWith($description, '"')) {
         $description = " " . $description;
     }
     if (kString::endsWith($description, '"')) {
         $description .= " ";
     }
     return $indent . '"""' . $description . '"""';
 }
">MRSS</option>
</select> <input type="checkbox" /></div>
			<?php 
}
?>

			<div class="param"><label for="service">Select service:</label> <select
	name="service">
					<?php 
foreach ($services as $serviceId => $serviceActionItem) {
    /* @var $serviceActionItem KalturaServiceActionItem */
    $serviceId = $serviceActionItem->serviceId;
    $serviceName = $serviceActionItem->serviceInfo->serviceName;
    $serviceLabel = $serviceActionItem->serviceInfo->serviceName;
    $package = $serviceActionItem->serviceInfo->package;
    if (kString::beginsWith($package, 'plugins.')) {
        $package = explode('.', $package, 2);
        $pluginName = $package[1];
        $serviceName = "{$pluginName}.{$serviceName}";
    }
    if ($serviceActionItem->serviceInfo->deprecated) {
        $serviceLabel .= ' (deprecated)';
    }
    echo "<option value=\"{$serviceId}\" title=\"{$serviceName}\">{$serviceLabel}</option>";
}
?>
				</select></div>
<div class="param"><label for="action">Select action:</label> <select
	name="action">
	<option>Select a service...</option>
</select> <img id="actionHelp" src="images/help.png" class="help"
示例#29
0
 /**
 Will allow creation of multiple entries
 ASSUME - the prefix of the entries is entryX_ where X is the index starting at 1
 */
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     //        $logger = sfLogger::getInstance();
     self::$escape_text = true;
     /*		if ( !$puser_kuser )
             {
                 $this->addError( "No such user ..." );
                 return;
     
             }
         */
     // TODO - validate if the user can add entries to this kshow
     $kshow_id = $this->getP("kshow_id");
     $show_entry_id = $this->getP("show_entry_id");
     $conversion_quality = $this->getP("conversionquality");
     // must be all lower case
     // for now - by default use quick_edit
     $partner = PartnerPeer::retrieveByPK($partner_id);
     for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
         if ($i == 0) {
             $prefix = $this->getObjectPrefix() . "_";
         } else {
             $prefix = $this->getObjectPrefix() . "{$i}" . "_";
         }
         $source = $this->getP($prefix . "source");
         $filename = $this->getP($prefix . "filename");
         if ($source != entry::ENTRY_MEDIA_SOURCE_WEBCAM || !$filename) {
             continue;
         }
         $content = myContentStorage::getFSContentRootPath();
         $entryFullPath = "{$content}/content/webcam/{$filename}.flv";
         if (!file_exists($entryFullPath)) {
             $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId());
             if ($remoteDCHost) {
                 kFileUtils::dumpApiRequest($remoteDCHost);
             }
             $this->addError(APIErrors::INVALID_FILE_NAME, $filename);
             return;
         }
     }
     if (strpos($kshow_id, 'entry-') !== false && !$show_entry_id) {
         $show_entry_id = substr($kshow_id, 6);
     }
     $screen_name = $this->getP("screen_name");
     $site_url = $this->getP("site_url");
     $null_kshow = true;
     if ($show_entry_id) {
         // in this case we have the show_entry_id (of the relevant roughcut) - it suppresses the kshow_id
         $show_entry = entryPeer::retrieveByPK($show_entry_id);
         if ($show_entry) {
             $kshow_id = $show_entry->getKshowId();
         } else {
             $kshow_id = null;
         }
     }
     if ($kshow_id === kshow::SANDBOX_ID) {
         $this->addError(APIErrors::SANDBOX_ALERT);
         return;
     }
     $default_kshow_name = $this->getP("entry_name", null);
     if (!$default_kshow_name) {
         $default_kshow_name = $this->getP("entry1_name", null);
     }
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, false, $default_kshow_name);
         $null_kshow = false;
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
         // if the partner allows - create a new kshow
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true, $default_kshow_name);
         $null_kshow = false;
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } else {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         // the partner is attempting to add an entry to some invalid or non-existing kwho
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     // find permissions from kshow
     $permissions = $kshow->getPermissions();
     $kuser_id = $puser_kuser->getKuserId();
     // TODO - once the CW
     $quick_edit = myPolicyMgr::getPolicyFor("allowQuickEdit", $kshow, $partner);
     // let the user override the quick_edit propery
     if ($this->getP("quick_edit") == '0' || $this->getP("quick_edit") == "false") {
         $quick_edit = false;
     }
     if ($quick_edit == '0' || $quick_edit === "false" || !$quick_edit || $quick_edit == false) {
         KalturaLog::err('$quick_edit: [' . $quick_edit . ']');
         $quick_edit = false;
         //$quick_edit = true;
     }
     // works in one of 2 ways:
     // 1. get no requested name - will create a new kshow and return its details
     // 2. get some name - tries to fetch by name. if already exists - return it
     $new_entry_count = 0;
     $entries = array();
     $notification_ids = array();
     $notifications = array();
     $field_level = $this->isAdmin() ? 2 : 1;
     $updateable_fields = null;
     $imported_entries_count = 0;
     for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
         if ($i == 0) {
             $prefix = $this->getObjectPrefix() . "_";
         } else {
             $prefix = $this->getObjectPrefix() . "{$i}" . "_";
         }
         $file_name = $this->getP($prefix . "realFilename");
         if (!($this->getP($prefix . "name") || $file_name)) {
             continue;
         }
         // get the new properties for the kuser from the request
         $entry = new entry();
         $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
         if (!$updateable_fields) {
             $updateable_fields = $obj_wrapper->getUpdateableFields($field_level);
         }
         // fill the entry from request
         $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $prefix, $updateable_fields);
         // check that mandatory fields were set
         // TODO
         KalturaLog::err("addentry: fields_modified: " . print_r($fields_modified, true));
         $entry_source = $entry->getSource();
         if (!$entry->getType()) {
             // this is the default for backward compatiblity
             $entry->setType(entryType::MEDIA_CLIP);
         }
         $token = $this->getKsUniqueString();
         $entry_full_path = "";
         if ($entry_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
             $entry->setSourceLink($file_name);
             $file_alias = $this->getP($prefix . "filename");
             $file_extension = strtolower(pathinfo($this->getP($prefix . "realFilename"), PATHINFO_EXTENSION));
             $entry_full_path = myUploadUtils::getUploadPath($token, $file_alias, null, $file_extension);
             if (!file_exists($entry_full_path)) {
                 KalturaLog::err("Invalid UPLOAD PATH [" . $entry_full_path . "] while trying to add entry for partner id [" . $partner_id . "] with token [" . $token . "] & original name [" . $this->getP($prefix . "name") . "]");
                 $this->addError(APIErrors::INVALID_FILE_NAME);
                 continue;
             }
             myEntryUtils::setEntryTypeAndMediaTypeFromFile($entry, $entry_full_path);
         }
         //            No reason to rais the error
         //            Remarked by Tan-Tan
         //
         //            // when we reached this point the type and media type must be set
         //            if ($entry->getType() == entryType::AUTOMATIC || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUTOMATIC)
         //            {
         //				$this->addError ( APIErrors::CANNOT_USE_ENTRY_TYPE_AUTO_IN_IMPORT );
         //            	continue;
         //            }
         // limit two kinds of media
         // 1. not images - video/audio which are big files
         // 2. media which wasnt directly uploaded by the owner (the owner real content)
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE && $entry_source != entry::ENTRY_MEDIA_SOURCE_FILE) {
             if ($imported_entries_count >= 4) {
                 continue;
             }
             ++$imported_entries_count;
         }
         // the conversion_quality is set once for the whole list of entries
         if ($conversion_quality) {
             $entry->setConversionQuality($conversion_quality);
         } else {
             // HACK - if the conversion_quality was not set in the proper way -
             // see if the partner_data holds a hack - string that starts with conversionQuality= - this is set when the CW is opened in the KMC
             // the conversionQuality is of format conversionQuality=XXX;<the rest of the text>
             //
             if (kString::beginsWith($entry->getPartnerData(), "conversionQuality:")) {
                 $partner_data_arr = explode(";", $entry->getPartnerData(), 2);
                 $conversion_quality_arr = explode(":", $partner_data_arr[0]);
                 $conversion_quality = @$conversion_quality_arr[1];
                 // the value of the conversion_quality
                 $entry->setPartnerData(@$partner_data_arr[1]);
                 // the rest of the string
                 $entry->setConversionQuality($conversion_quality);
             }
         }
         $insert = true;
         $entry_modified = false;
         $create_entry = true;
         // I don't remember why we set the kshow to null every time ...
         // but when we fetched it automatically - hang on to it !
         if ($null_kshow) {
             $kshow = null;
         }
         if ($entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_USER_CLIPS || $entry_source == "100") {
             if ($entry_source == "100") {
                 $entry_id = $this->getP("media{$i}_id");
             } else {
                 $entry_id = $this->getP($prefix . "id");
             }
             // $this->getP ( $prefix . "url" );
             if ($entry_id === null) {
                 $entry_id = $entry->getMediaId();
             }
             if ($entry_id) {
                 $entry = entryPeer::retrieveByPK($entry_id);
                 if ($entry) {
                     $create_entry = false;
                     $insert = false;
                 } else {
                     $this->addError(APIErrors::INVALID_ENTRY_ID, $this->getObjectPrefix(), $entry_id);
                     return;
                 }
             }
         }
         $new_entry_count++;
         if ($create_entry) {
             $entry->setPartnerId($partner_id);
             $entry->setSubpId($subp_id);
             $entry->setKuserId($kuser_id);
             $entry->setCreatorKuserId($kuser_id);
             $entry->setKshowId($kshow_id);
             $entry->setSiteUrl($site_url);
             $entry->setScreenName($screen_name);
             if ($this->getGroup()) {
                 $entry->setGroupId($this->getGroup());
             }
             if ($entry->getPermissions() === null) {
                 $entry->setPermissions($permissions);
             }
             // inherited from the enclosing kshow
             $entry->setDefaultModerationStatus();
             $entry->save();
             $entry_modified = true;
             if (!$entry->getName()) {
                 if ($file_name) {
                     // TODO - fix the file_name to fit
                     $entry->setName($file_name);
                 } else {
                     $entry->setName($partner_prefix . $entry->getId());
                 }
                 $entry_modified = true;
             }
             // TODO - decide on file naming mechanism !!
             // there are 3 types of insert:
             // 1. upload - the file is assumed to be in the upload directory and it's name is explicitly set in the fname$i param
             // 2. webcam - the file is assumed to be in the webcam directory and it's name is explicitly set in the fname$i param
             // 3. URL - the url is given in the entry_url$i param
             /*
                         $media_source = $this->getParam('entry_media_source');
                         $media_type = $this->getParam('entry_media_type');
                         $entry_url = $this->getParam('entry_url');
                         $entry_source_link = $this->getParam('entry_source_link');
                         $entry_fileName = $this->getParam('entry_data');
                         $entry_thumbNum = $this->getParam('entry_thumb_num', 0);
                         $entry_thumbUrl  = $this->getParam('entry_thumb_url', '');
                         $entry_from_time  = $this->getParam('entry_from_time', 0);
                         $entry_to_time  = $this->getParam('entry_to_time', 0);
             
                         $should_copy = $this->getParam('should_copy' , false );
                         $skip_conversion = $this->getParam('skip_conversion' , false );
             */
             $paramsArray = array('entry_media_source' => $entry->getSource(), 'entry_media_type' => $entry->getMediaType());
             //			$entry_source = $entry->getSource() ;
             if ($entry_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
                 $paramsArray["entry_full_path"] = $entry_full_path;
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
                 $file_alias = $this->getP($prefix . "filename");
                 $paramsArray["webcam_suffix"] = $file_alias;
                 $paramsArray['entry_from_time'] = $this->getP($prefix . "fromTime", 0);
                 $paramsArray['entry_to_time'] = $this->getP($prefix . "toTime", 0);
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_PARTNER || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_PARTNER_KSHOW || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_KSHOW || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_USER_CLIPS) {
                 // optimize - no need to actually go through the import and conversion phase
                 // find the source entry_id from the url
                 /*
                                     $entry_url = $this->getP ( $prefix . "url" );
                                     $entry_thumb_url = $this->getP ( $prefix .  "thumbUrl" );
                 
                                     if ( myEntryUtils::copyData( $entry_url , $entry_thumb_url , $entry ) )
                 */
                 $source_entry_id = $this->getP("media{$i}_id");
                 // $this->getP ( $prefix . "url" );
                 if ($source_entry_id === null) {
                     $source_entry_id = $entry->getMediaId();
                 }
                 if (myEntryUtils::copyData($source_entry_id, $entry)) {
                     // copy worked ok - no need to use insertEntryHelper
                     //$entry->setStatus ( entryStatus::READY );
                     // force the data to be ready even if the policy is to moderate - this is kaltura's content and was already approved
                     // (roman) true argument removed, so kaltura's content will be moderated according to partner's moderation settings
                     $entry->setStatusReady();
                     $insert = false;
                     $entry_modified = true;
                     $entry->save();
                 }
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_URL || in_array($entry_source, myMediaSourceFactory::getAllMediaSourceProvidersIds())) {
                 // the URL is relevant
                 $paramsArray["entry_url"] = $this->getP($prefix . "url");
                 $paramsArray["entry_thumb_url"] = $this->getP($prefix . "thumbUrl");
                 // TODO - these fields are already set in the entry -
                 // the code in myInsertEntryHelper is redundant
                 $paramsArray["entry_license"] = $entry->getLicenseType();
                 $paramsArray["entry_credit"] = $entry->getCredit();
                 $paramsArray["entry_source_link"] = $entry->getSourceLink();
                 $paramsArray["entry_tags"] = $entry->getTags();
             } else {
                 $this->addError(APIErrors::UNKNOWN_MEDIA_SOURCE, $entry->getSource());
                 $insert = false;
             }
             if ($insert) {
                 KalturaLog::err("paramsArray" . print_r($paramsArray, true));
                 $insert_entry_helper = new myInsertEntryHelper($this, $kuser_id, $kshow_id, $paramsArray);
                 $insert_entry_helper->setPartnerId($partner_id, $subp_id);
                 $insert_entry_helper->insertEntry($token, $entry->getType(), $entry->getId(), $entry->getName(), $entry->getTags(), $entry);
                 $insert_entry_helper->getEntry();
                 $this->addDebug("added_entry{$i}", $entry->getName());
             }
         }
         // create_entry = true
         KalturaLog::err('id: ' . $entry->getId() . ' $quick_edit:' . $quick_edit);
         if ($quick_edit) {
             KalturaLog::info("quick edit with kshow_id [{$kshow_id}]");
             if (!$kshow) {
                 $kshow = kshowPeer::retrieveByPK($kshow_id);
             }
             // this i
             if (!$kshow) {
                 // BAD - this shount not be !
                 $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
                 return;
             }
             $metadata = $kshow->getMetadata();
             if ($metadata !== null) {
                 KalturaLog::info("Having metadata");
                 $relevant_kshow_version = 1 + $kshow->getVersion();
                 // the next metadata will be the first relevant version for this new entry
                 $version_info = array();
                 $version_info["KuserId"] = $puser_kuser->getKuserId();
                 $version_info["PuserId"] = $puser_id;
                 $version_info["ScreenName"] = $puser_kuser->getPuserName();
                 $new_metadata = myMetadataUtils::addEntryToMetadata($metadata, $entry, $relevant_kshow_version, $version_info);
                 $entry_modified = true;
                 if ($new_metadata) {
                     // TODO - add thumbnail only for entries that are worthy - check they are not moderated !
                     $thumb_modified = myKshowUtils::updateThumbnail($kshow, $entry, false);
                     if ($thumb_modified) {
                         $new_metadata = myMetadataUtils::updateThumbUrlFromMetadata($new_metadata, $entry->getThumbnailUrl());
                     }
                     // it is very important to increment the version count because even if the entry is deferred
                     // it will be added on the next version
                     if (!$kshow->getHasRoughcut()) {
                         // make sure the kshow now does have a roughcut
                         $kshow->setHasRoughcut(true);
                         $kshow->save();
                     }
                     $kshow->setMetadata($new_metadata, true);
                 }
                 // no need to save kshow - the modification of the metadata was done to the show_entry which will propagate any chages to the kshow in it's own save method
             }
         }
         if ($entry_modified) {
             $entry->save();
         }
         $not_id = null;
         // send a synch notification
         @(list($not_id, $not, $url, $params, $serialized_params) = myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $entry, null, null));
         if ($not_id) {
             $notification_ids[] = $not_id;
             $notifications[] = array("url" => $url, "params" => $serialized_params);
         }
         $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR);
         $entries[$prefix] = $wrapper;
         //$this->addMsg ( $prefix , $wrapper);
         // because the kshow's entrys field was changes do to this update, we have to remove object from cahce
         // TODO - think of some reverse way to automatically remove from the cache from within the wrapper
         // call some - update cache where the kshow_id plays a part in the update
         $wrapper->removeFromCache("kshow", $kshow_id, "entrys");
         $this->addDebug("added_fields", $fields_modified, $prefix);
     }
     $this->addMsg("entries", $entries);
     if (count($notification_ids) > 0) {
         $this->addMsg("notifications", $notifications);
     }
     if ($new_entry_count < 1) {
         $this->addError(APIErrors::NO_ENTRIES_ADDED);
         $this->addDebug("no_new_entries", "You have to have at least one new entry with a field called 'entry1_name'");
     }
     $this->addMsg("new_entry_count", $new_entry_count);
 }