/** * 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}"); }
/** * 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 return a JS library for integrating the KSR (similar to HTML5 in concept) * uiconfId specifies from which uiconf to fetch different settings that should be replaced in the JS */ public function execute() { // make sure output is not parsed as HTML header("Content-type: application/x-javascript"); $uiconfId = $this->getRequestParameter("uiconfId"); // replace all $_GET with $this->getRequestParameter() // load uiconf from DB. $this->uiconfObj = uiConfPeer::retrieveByPK($uiconfId); if (!$this->uiconfObj) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND); } $ui_conf_swf_url = $this->uiconfObj->getSwfUrl(); if (!$ui_conf_swf_url) { KExternalErrors::dieError(KExternalErrors::ILLEGAL_UI_CONF, "SWF URL not found in UI conf"); } @libxml_use_internal_errors(true); try { $this->uiconfXmlObj = new SimpleXMLElement(trim($this->uiconfObj->getConfFile())); } catch (Exception $e) { KalturaLog::debug("malformed uiconf XML - base64 encoded: [" . base64_encode(trim($this->uiconfObj->getConfFile())) . "]"); } if (!$this->uiconfXmlObj instanceof SimpleXMLElement) { // no xml or invalid XML, so throw exception throw new Exception('uiconf XML is invalid'); } // unsupress the xml errors @libxml_use_internal_errors(false); $this->_initReplacementTokens(); $this->_prepareLibJs(); $this->_prepareJs(); echo $this->jsResult; die; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $this->applyPartnerFilterForClass(new uiConfPeer(), $partner_id); $allow_empty = $this->getP("allow_empty_field", false); if ($allow_empty == "false" || $allow_empty === 0) { $allow_empty = false; } $prefix = $this->getObjectPrefix(); $uiconf_id = $this->getPM("{$prefix}_id"); $uiconf = uiConfPeer::retrieveByPK($uiconf_id); if (!$uiconf) { $this->addError(APIErrors::INVALID_UI_CONF_ID, $uiconf_id); return; } if ($uiconf && !$uiconf->isValid()) { $this->addError(APIErrors::INTERNAL_SERVERL_ERROR, "uiConf object [{$uiconf->getId()}] is not valid"); return; } // get the new properties for the uiconf from the request $uiconf_update_data = new uiConf(); $uiconf_update_data->setPartnerId($partner_id); // set this once before filling the object and once after $obj_wrapper = objectWrapperBase::getWrapperClass($uiconf_update_data, 0); $updateable_fields = $obj_wrapper->getUpdateableFields(); $fields_modified = baseObjectUtils::fillObjectFromMapOrderedByFields($this->getInputParams(), $uiconf_update_data, "{$prefix}_", $updateable_fields, BasePeer::TYPE_PHPNAME, $allow_empty); if (count($fields_modified) > 0) { if ($uiconf_update_data) { baseObjectUtils::fillObjectFromObject($updateable_fields, $uiconf_update_data, $uiconf, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, $allow_empty); } $uiconf->save(); } $wrapper = objectWrapperBase::getWrapperClass($uiconf, objectWrapperBase::DETAIL_LEVEL_REGULAR); $this->addMsg("{$prefix}", $wrapper); $this->addDebug("modified_fields", $fields_modified); }
/** * 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}"); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $this->applyPartnerFilterForClass(new uiConfPeer(), $partner_id); $ui_conf_id = $this->getPM("uiconf_id"); $detailed = $this->getP("detailed", false); $new_name = $this->getP("new_name"); if (!$new_name || $new_name == '') { $new_name = null; } $ui_conf = null; if ($ui_conf_id) { $ui_conf = uiConfPeer::retrieveByPK($ui_conf_id); } if (!$ui_conf) { $this->addError(APIErrors::INVALID_UI_CONF_ID, $ui_conf_id); } else { $ui_conf_verride_params = new uiConf(); $ui_conf_verride_params->setPartnerId($partner_id); $ui_conf_verride_params->setDisplayInSearch(1); // the cloned ui_conf should NOT be a template $new_ui_conf = $ui_conf->cloneToNew($ui_conf_verride_params, $new_name); if (!$new_ui_conf) { $this->addError(APIErrors::UI_CONF_CLONE_FAILED, $ui_conf_id); } else { $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($new_ui_conf, $level); // TODO - remove this code when cache works properly when saving objects (in their save method) // $wrapper->removeFromCache( "kshow" , $new_ui_conf->getId() ); $this->addMsg("uiconf", $wrapper); } } }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { // make sure output is not parsed as HTML header("Content-type: application/x-javascript"); $uiconfId = $this->getRequestParameter("uiconfId"); // replace all $_GET with $this->getRequestParameter() // load uiconf from DB. $this->uiconfObj = uiConfPeer::retrieveByPK($uiconfId); if (!$this->uiconfObj) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND); } @libxml_use_internal_errors(true); $this->uiconfXmlObj = new SimpleXMLElement($this->uiconfObj->getConfFile()); if (!$this->uiconfXmlObj instanceof SimpleXMLElement) { // no xml or invalid XML, so throw exception throw new Exception('uiconf XML is invalid'); } // unsupress the xml errors @libxml_use_internal_errors(false); $this->_initReplacementTokens(); $this->_prepareLibJs(); $this->_prepareJs(); echo $this->jsResult; die; }
/** * 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}"); }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $uiConfId = $this->getRequestParameter("id"); $uiConf = uiConfPeer::retrieveByPK($uiConfId); $subTypes = array(uiconf::FILE_SYNC_UICONF_SUB_TYPE_DATA, uiconf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); foreach ($subTypes as $subType) { if ($subType == uiconf::FILE_SYNC_UICONF_SUB_TYPE_DATA) { echo "Data:" . PHP_EOL; } else { if ($subType == uiconf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) { echo "Features:" . PHP_EOL; } } $syncKey = $uiConf->getSyncKey($subType); if (kFileSyncUtils::file_exists($syncKey)) { echo "File sync already exists." . PHP_EOL; } else { list($rootPath, $filePath) = $uiConf->generateFilePathArr($subType); $fullPath = $rootPath . $filePath; if (file_exists($fullPath)) { kFileSyncUtils::createSyncFileForKey($syncKey); echo "Created successfully." . PHP_EOL; } else { echo "File not found:" . PHP_EOL; echo $fullPath . PHP_EOL; echo "Not creating file sync." . PHP_EOL; } } echo PHP_EOL; } die; }
/** * 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; }
/** * * @param int $objectType * @param string $objectId * @return ISyncableFile */ public static function retrieveObject($objectType, $objectId) { $object = null; switch ($objectType) { case FileSyncObjectType::ENTRY: entryPeer::setUseCriteriaFilter(false); $object = entryPeer::retrieveByPK($objectId); entryPeer::setUseCriteriaFilter(true); break; case FileSyncObjectType::UICONF: uiConfPeer::setUseCriteriaFilter(false); $object = uiConfPeer::retrieveByPK($objectId); uiConfPeer::setUseCriteriaFilter(true); break; case FileSyncObjectType::BATCHJOB: BatchJobPeer::setUseCriteriaFilter(false); $object = BatchJobPeer::retrieveByPK($objectId); BatchJobPeer::setUseCriteriaFilter(true); break; case FileSyncObjectType::FLAVOR_ASSET: assetPeer::setUseCriteriaFilter(false); $object = assetPeer::retrieveById($objectId); assetPeer::setUseCriteriaFilter(true); break; case FileSyncObjectType::SYNDICATION_FEED: syndicationFeedPeer::setUseCriteriaFilter(false); $object = syndicationFeedPeer::retrieveByPK($objectId); syndicationFeedPeer::setUseCriteriaFilter(true); break; case FileSyncObjectType::CONVERSION_PROFILE: conversionProfile2Peer::setUseCriteriaFilter(false); $object = conversionProfile2Peer::retrieveByPK($objectId); conversionProfile2Peer::setUseCriteriaFilter(true); break; case FileSyncObjectType::FILE_ASSET: conversionProfile2Peer::setUseCriteriaFilter(false); $object = FileAssetPeer::retrieveByPK($objectId); conversionProfile2Peer::setUseCriteriaFilter(true); break; } if ($object == null) { $object = KalturaPluginManager::loadObject('ISyncableFile', $objectType, array('objectId' => $objectId)); } if ($object == null) { $error = __METHOD__ . " Cannot find object type [" . $objectType . "] with object_id [" . $objectId . "]"; KalturaLog::err($error); throw new kFileSyncException($error); } return $object; }
/** * Add new widget, can be attached to entry or kshow * SourceWidget is ignored. * * @action add * @param KalturaWidget $widget * @return KalturaWidget */ function addAction(KalturaWidget $widget) { if ($widget->sourceWidgetId === null && $widget->uiConfId === null) { throw new KalturaAPIException(KalturaErrors::SOURCE_WIDGET_OR_UICONF_REQUIRED); } if ($widget->sourceWidgetId !== null) { $sourceWidget = widgetPeer::retrieveByPK($widget->sourceWidgetId); if (!$sourceWidget) { throw new KalturaAPIException(KalturaErrors::SOURCE_WIDGET_NOT_FOUND, $widget->sourceWidgetId); } if ($widget->uiConfId === null) { $widget->uiConfId = $sourceWidget->getUiConfId(); } } if ($widget->uiConfId !== null) { $uiConf = uiConfPeer::retrieveByPK($widget->uiConfId); if (!$uiConf) { throw new KalturaAPIException(KalturaErrors::UICONF_ID_NOT_FOUND, $widget->uiConfId); } } if (!is_null($widget->enforceEntitlement) && $widget->enforceEntitlement == false && kEntitlementUtils::getEntitlementEnforcement()) { throw new KalturaAPIException(KalturaErrors::CANNOT_DISABLE_ENTITLEMENT_FOR_WIDGET_WHEN_ENTITLEMENT_ENFORCEMENT_ENABLE); } if ($widget->entryId !== null) { $entry = entryPeer::retrieveByPK($widget->entryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $widget->entryId); } } elseif ($widget->enforceEntitlement != null && $widget->enforceEntitlement == false) { throw new KalturaAPIException(KalturaErrors::CANNOT_DISABLE_ENTITLEMENT_WITH_NO_ENTRY_ID); } $dbWidget = $widget->toWidget(); $dbWidget->setPartnerId($this->getPartnerId()); $dbWidget->setSubpId($this->getPartnerId() * 100); $widgetId = $dbWidget->calculateId($dbWidget); $dbWidget->setId($widgetId); if ($entry && $entry->getType() == entryType::PLAYLIST) { $dbWidget->setIsPlayList(true); } $dbWidget->save(); $savedWidget = widgetPeer::retrieveByPK($widgetId); $widget = new KalturaWidget(); // start from blank $widget->fromObject($savedWidget, $this->getResponseProfile()); return $widget; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $this->applyPartnerFilterForClass('uiConf', $partner_id); $prefix = $this->getObjectPrefix(); $uiconf_id_to_delete = $this->getPM("{$prefix}_id"); $uiconf_to_delete = uiConfPeer::retrieveByPK($uiconf_id_to_delete); if ($uiconf_to_delete && !$uiconf_to_delete->isValid()) { $this->addError(APIErrors::INTERNAL_SERVERL_ERROR, "uiConf object [{$uiconf_to_delete->getId()}] is not valid"); return; } if (!$uiconf_to_delete) { $this->addError(APIErrors::INVALID_UI_CONF_ID, $prefix, $uiconf_id_to_delete); return; } $uiconf_to_delete->setStatus(uiConf::UI_CONF_STATUS_DELETED); $uiconf_to_delete->save(); // myNotificationMgr::createNotification( notification::NOTIFICATION_TYPE_ENTRY_DELETE , $entry_to_delete ); $this->addMsg("deleted_" . $prefix, objectWrapperBase::getWrapperClass($uiconf_to_delete, objectWrapperBase::DETAIL_LEVEL_REGULAR)); }
public function execute() { $this->uiconf_id = $this->getRequestParameter('uiconf_id'); if (!$this->uiconf_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id'); } $this->uiConf = uiConfPeer::retrieveByPK($this->uiconf_id); if (!$this->uiConf) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND); } $this->partner_id = $this->getRequestParameter('partner_id', $this->uiConf->getPartnerId()); if (!$this->partner_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id'); } // Single Player parameters $this->entry_id = $this->getRequestParameter('entry_id'); if ($this->entry_id) { $entry = entryPeer::retrieveByPK($this->entry_id); if ($entry) { $this->entry_name = $entry->getName(); $this->entry_description = $entry->getDescription(); $this->entry_thumbnail_url = $entry->getThumbnailUrl(); $flavor_tag = $this->getRequestParameter('flavor_tag', 'iphone'); $flavor_assets = assetPeer::retrieveReadyFlavorsByEntryIdAndTag($this->entry_id, $flavor_tag); $flavor_asset = reset($flavor_assets); /* @var $flavor_asset flavorAsset */ $this->flavor_asset_id = null; if ($flavor_asset) { $this->flavor_asset_id = $flavor_asset->getId(); } } else { $this->entry_id = null; } } $this->delivery_type = $this->getRequestParameter('delivery'); // Playlist Parameters $this->playlist_id = $this->getRequestParameter('playlist_id'); $this->playlist_name = $this->getRequestParameter('playlist_name'); $this->partner_host = myPartnerUtils::getHost($this->partner_id); $this->partner_cdnHost = myPartnerUtils::getCdnHost($this->partner_id); $this->secure_host = kConf::get('cdn_host_https'); }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $this->saved = false; $uiConfId = $this->getRequestParameter("id"); $this->uiConf = uiConfPeer::retrieveByPK($uiConfId); if ($this->uiConf->getObjType() != uiConf::UI_CONF_TYPE_CW) { die("Not a CW UIConf!"); } if ($this->uiConf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_ADVANCED) { die("Creation mode must be advanced!"); } if ($this->getRequest()->getMethodName() == "POST") { $this->uiConf->setConfFile($this->getRequestParameter("confFile")); $this->uiConf->save(); $this->redirect("system/editUiconf?id=" . $this->uiConf->getId()); } }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $this->applyPartnerFilterForClass('uiConf', $partner_id); $ui_conf_id = $this->getPM("ui_conf_id"); $detailed = $this->getP("detailed", false); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $ui_conf = uiConfPeer::retrieveByPK($ui_conf_id); if ($ui_conf && !$ui_conf->isValid()) { $this->addError(APIErrors::INTERNAL_SERVERL_ERROR, "uiConf object [{$ui_conf->getId()}] is not valid"); return; } if ($ui_conf) { $this->addMsg("ui_conf", objectWrapperBase::getWrapperClass($ui_conf, $level)); self::$escape_text = true; /* $service_provider_list = myPartnerUtils::getMediaServiceProviders ( $partner_id , $subp_id ); $this->addMsg( "config_" , $service_provider_list ); $ui = array ( "__0_moduleData" => array ( "moduleUrl" => "main" , "style" => "SearchView" , "locale" => "SearchView" ) , "__1_moduleData" => array ( "moduleUrl" => "SearchView.swf" , "style" => "SearchView" , "locale" => "SearchView" ) , "__2_moduleData" => array ( "moduleUrl" => "SearchView.swf" , "style" => "SearchView" , "locale" => "SearchView" ) , "__3_moduleData" => array ( "moduleUrl" => "SearchView.swf" , "style" => "SearchView" , "locale" => "SearchView" ) , ) ; $this->addMsg( "ui" , $ui ); */ } else { $this->addError(APIErrors::INVALID_UI_CONF_ID, $ui_conf_id); return; } }
/** * Add new widget, can be attached to entry or kshow * SourceWidget is ignored. * * @action add * @param KalturaWidget $widget * @return KalturaWidget */ function addAction(KalturaWidget $widget) { if ($widget->sourceWidgetId === null && $widget->uiConfId === null) { throw new KalturaAPIException(KalturaErrors::SOURCE_WIDGET_OR_UICONF_REQUIRED); } if ($widget->sourceWidgetId !== null) { $sourceWidget = widgetPeer::retrieveByPK($widget->sourceWidgetId); if (!$sourceWidget) { throw new KalturaAPIException(KalturaErrors::SOURCE_WIDGET_NOT_FOUND, $widget->sourceWidgetId); } if ($widget->uiConfId === null) { $widget->uiConfId = $sourceWidget->getUiConfId(); } } if ($widget->uiConfId !== null) { $uiConf = uiConfPeer::retrieveByPK($widget->uiConfId); if (!$uiConf) { throw new KalturaAPIException(KalturaErrors::UICONF_ID_NOT_FOUND, $widget->uiConfId); } } if ($widget->entryId !== null) { $entry = entryPeer::retrieveByPK($widget->entryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $widget->entryId); } } $dbWidget = $widget->toWidget(); $dbWidget->setPartnerId($this->getPartnerId()); $dbWidget->setSubpId($this->getPartnerId() * 100); $widgetId = $dbWidget->calculateId($dbWidget); $dbWidget->setId($widgetId); $dbWidget->save(); $savedWidget = widgetPeer::retrieveByPK($widgetId); $widget = new KalturaWidget(); // start from blank $widget->fromWidget($savedWidget); return $widget; }
/** * 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); $html5_version = kConf::get('html5_version'); $use_cdn = $uiConf->getUseCdn(); $host = $use_cdn ? $partner_cdnHost : $partner_host; $url = $host; $url .= "/html5/html5lib/v{$html5_version}/mwEmbedLoader.php"; $this->redirect($url); }
public function getRootObjects(IRelatedObject $object) { /* @var $object FileAsset */ $rootObjects = array(); $parentObject = null; switch ($object->getObjectType()) { case FileAssetObjectType::UI_CONF: $parentObject = uiConfPeer::retrieveByPK($object->getObjectId()); break; } if ($parentObject) { /* @var $parentObject IRelatedObjectPeer */ $peer = $parentObject->getPeer(); if ($peer instanceof IRelatedObjectPeer) { $parentRoots = $peer->getRootObjects($parentObject); if (count($parentRoots)) { $rootObjects = array_merge($rootObjects, $parentRoots); } } $rootObjects[] = $parentObject; } return $rootObjects; }
public function execute() { $this->html5_version = kConf::get('html5_version'); $this->uiconf_id = $this->getRequestParameter('uiconf_id'); if (!$this->uiconf_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'uiconf_id'); } $this->uiConf = uiConfPeer::retrieveByPK($this->uiconf_id); if (!$this->uiConf) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND); } $this->partner_id = $this->getRequestParameter('partner_id', $this->uiConf->getPartnerId()); if (!$this->partner_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'partner_id'); } $this->entry_id = $this->getRequestParameter('entry_id'); if (!$this->entry_id) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'entry_id'); } $this->delivery_type = $this->getRequestParameter('delivery'); $this->partner_host = myPartnerUtils::getHost($this->partner_id); $this->partner_cdnHost = myPartnerUtils::getCdnHost($this->partner_id); }
/** * Delete an existing UIConf with no partner limitation * * @action delete * @param int $id * * @throws APIErrors::INVALID_UI_CONF_ID */ function deleteAction($id) { $dbUiConf = uiConfPeer::retrieveByPK($id); if (!$dbUiConf) { throw new KalturaAPIException(APIErrors::INVALID_UI_CONF_ID, $id); } $dbUiConf->setStatus(uiConf::UI_CONF_STATUS_DELETED); $dbUiConf->save(); }
public static function getEmbedCode(entry $playlist, $wid, $ui_conf_id, $uid = null, $autoplay = null) { if ($playlist == null) { return ""; } if (!$uid) { $uid = "0"; } $partner_id = $playlist->getPartnerId(); $subp_id = $playlist->getSubpId(); $partner = PartnerPeer::retrieveByPK($partner_id); $host = myPartnerUtils::getHost($partner_id); $playlist_flashvars = self::toPlaylistUrl($playlist, $host); if ($wid == null) { $wid = $partner->getDefaultWidgetId(); } $widget = widgetPeer::retrieveByPK($wid); // use the ui_conf from the widget only if it was not explicitly set if ($ui_conf_id == null) { $ui_conf_id = $widget->getUiConfId(); } $ui_conf = uiConfPeer::retrieveByPK($ui_conf_id); if (!$ui_conf) { throw new kCoreException("Invalid uiconf id [{$ui_conf_id}] for widget [{$wid}]", APIErrors::INVALID_UI_CONF_ID); } // $autoplay_str = $autoplay ? "autoPlay=true" : "autoPlay=false" ; $autoplay_str = ""; $embed = <<<HTML <object height="{$ui_conf->getHeight()}" width="{$ui_conf->getWidth()}" type="application/x-shockwave-flash" data="{$host}/kwidget/wid/{$wid}/ui_conf_id/{$ui_conf_id}" id="kaltura_playlist" style="visibility: visible;">\t\t <param name="allowscriptaccess" value="always"/><param name="allownetworking" value="all"/><param name="bgcolor" value="#000000"/><param name="wmode" value="opaque"/><param name="allowfullscreen" value="true"/> <param name="movie" value="{$host}/kwidget/wid/{$wid}/ui_conf_id/{$ui_conf_id}"/> <param name="flashvars" value="layoutId=playlistLight&uid={$uid}&partner_id={$partner_id}&subp_id={$subp_id}&{$playlist_flashvars}"/></object> HTML; return array($embed, $ui_conf->getWidth(), $ui_conf->getHeight()); }
/** * Delete an existing UIConf with no partner limitation * * @action delete * @param int $id * * @throws APIErrors::INVALID_UI_CONF_ID */ function deleteAction($id) { $dbUiConf = uiConfPeer::retrieveByPK($id); if (!$dbUiConf) { throw new KalturaAPIException(APIErrors::INVALID_UI_CONF_ID, $id); } if ($dbUiConf->getPartnerId() == PartnerPeer::GLOBAL_PARTNER && !kPermissionManager::isPermitted(self::PERMISSION_GLOBAL_PARTNER_UI_CONF_UPDTAE)) { throw new KalturaAPIException(APIErrors::INVALID_UI_CONF_ID, $id); } $dbUiConf->setStatus(uiConf::UI_CONF_STATUS_DELETED); $dbUiConf->save(); }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $this->saved = false; $uiConfId = $this->getRequestParameter("id"); if ($uiConfId) { $uiConf = uiConfPeer::retrieveByPK($uiConfId); } else { $uiConf = new uiConf(); } if ($this->getRequest()->getMethodName() == "POST") { $uiConf->setPartnerId($this->getRequestParameter("partnerId")); $uiConf->setSubpId($uiConf->getPartnerId() * 100); $uiConf->setObjType($this->getRequestParameter("type")); $uiConf->setName($this->getRequestParameter("name")); $uiConf->setWidth($this->getRequestParameter("width")); $uiConf->setHeight($this->getRequestParameter("height")); $uiConf->setCreationMode($this->getRequestParameter("creationMode")); $uiConf->setSwfUrl($this->getRequestParameter("swfUrl")); $uiConf->setConfVars($this->getRequestParameter("confVars")); $useCdn = $this->getRequestParameter("useCdn"); $uiConf->setUseCdn($useCdn === "1" ? true : false); $uiConf->setDisplayInSearch($this->getRequestParameter("displayInSearch")); $uiConf->setConfVars($this->getRequestParameter("confVars")); $uiConf->setTags($this->getRequestParameter("tags")); /* files: */ if ($uiConf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_MANUAL) { $confFile = $this->getRequestParameter("uiconf_confFile"); $confFileFeatures = $this->getRequestParameter("uiconf_confFileFeatures"); if ($uiConf->getConfFile() != $confFile || $uiConf->getConfFileFeatures() != $confFileFeatures) { $uiConf->setConfFile($confFile); $uiConf->setConfFileFeatures($confFileFeatures); } } $uiConf->save(); $this->saved = true; } // so script won't die when uiconf is missing if (!$uiConf) { $uiConf = new uiConf(); } $partner = PartnerPeer::retrieveByPK($uiConf->getPartnerId()); $types = $uiConf->getUiConfTypeMap(); $c = new Criteria(); $c->add(widgetPeer::UI_CONF_ID, $uiConf->getId()); $c->setLimit(1000); $widgets = widgetPeer::doSelect($c); $widgetsPerPartner = array(); $this->tooMuchWidgets = false; if (count($widgets) == 1000) { $this->tooMuchWidgets = true; } else { if ($widgets) { foreach ($widgets as $widget) { if (!array_key_exists($widget->getPartnerId(), $widgetsPerPartner)) { $widgetsPerPartner[$widget->getPartnerId()] = 0; } $widgetsPerPartner[$widget->getPartnerId()]++; } } } // find the FileSync $fileSyncs = array(); $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA)); $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES)); foreach ($fileSyncs as &$fileSync) { $fileSync["fileSyncs"] = FileSyncPeer::retrieveAllByFileSyncKey($fileSync["key"]); } $this->fileSyncs = $fileSyncs; $this->widgetsPerPartner = $widgetsPerPartner; $this->directoryMap = $uiConf->getDirectoryMap(); $this->swfNames = $uiConf->getSwfNames(); $this->types = $types; $this->uiConf = $uiConf; $this->partner = $partner; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; // ajax stuff are here because there are too many actions in system module $ajax = $this->getRequestParameter("ajax", null); if ($ajax !== null) { switch ($ajax) { case "getPartnerName": $name = "Unknown Partner"; $partnerId = $this->getRequestParameter("id"); $partner = PartnerPeer::retrieveByPK($partnerId); if ($partner) { $name = $partner->getName(); } return $this->renderText(json_encode($name)); case "validateWidgetIds": $widgetIds = explode(",", $this->getRequestParameter("widgetIds")); $existingIds = array(); if (is_array($widgetIds)) { $widgets = widgetPeer::retrieveByPKs($widgetIds); if ($widgets) { foreach ($widgets as $widget) { $id = $widget->getId(); if (in_array($id, $widgetIds)) { $existingIds[] = $id; } } } } return $this->renderText(json_encode($existingIds)); } } // end of ajax stuff $uiConfId = $this->getRequestParameter("uiConfId"); $uiConf = uiConfPeer::retrieveByPK($uiConfId); if ($this->getRequest()->getMethodName() == "POST") { $numOfWidgets = (int) $this->getRequestParameter("numOfWidgets"); $startIndex = (int) $this->getRequestParameter("startIndex"); $partnerId = $this->getRequestParameter("partnerId"); $uiConfId = $this->getRequestParameter("uiConfId"); $entryId = $this->getRequestParameter("entryId"); $securityType = $this->getRequestParameter("securityType"); $securityPolicy = $this->getRequestParameter("securityPolicy"); $prefix = $this->getRequestParameter("prefix"); if ($prefix) { $prefix = "_"; } else { $prefix = ""; } for ($i = $startIndex; $i < $startIndex + $numOfWidgets; $i++) { $widget = new widget(); if (!$i) { $widget->setId($prefix . $partnerId . "_" . $uiConfId); } else { $widget->setId($prefix . $partnerId . "_" . $uiConfId . "_" . $i); } $widget->setUiConfId($uiConfId); $widget->setPartnerId($partnerId); $widget->setSubpId($partnerId * 100); $widget->setEntryId($entryId); $widget->setSecurityType($securityType); $widget->setSecurityPolicy($securityPolicy); $widget->save(); } $this->redirect("system/editUiconf?id=" . $uiConfId); } if ($uiConf) { $partner = PartnerPeer::retrieveByPK($uiConf->getPartnerId()); } else { $uiConf = new uiConf(); $partner = new Partner(); } $this->widget = new widget(); $this->uiConf = $uiConf; $this->partner = $partner; }
/** * 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) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, '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}"); die; } $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; $url = $host; $url .= "/html5/html5lib/v{$html5_version}/mwEmbedFrame.php"; $url .= "/entry_id/{$entry_id}/wid/{$widget_id}/uiconf_id/{$uiconf_id}"; if ($allowCache) { $cache->put($requestKey, $url); } $this->redirect($url); }
function cloneAction($id) { $dbUiConf = uiConfPeer::retrieveByPK($id); if (!$dbUiConf) { throw new KalturaAPIException(APIErrors::INVALID_UI_CONF_ID, $id); } $ui_conf_verride_params = new uiConf(); $ui_conf_verride_params->setPartnerId($this->getPartnerId()); $ui_conf_verride_params->setDisplayInSearch(1); // the cloned ui_conf should NOT be a template $uiConfClone = $dbUiConf->cloneToNew($ui_conf_verride_params); $uiConf = new KalturaUiConf(); $uiConf->fromUiConf($uiConfClone); return $uiConf; }
<?php require_once dirname(__FILE__) . '/../bootstrap.php'; if (!isset($argv[1])) { die('UI-Conf ID argument is required'); } $uiConfId = $argv[1]; $dryRun = !isset($argv[2]) || $argv[2] != 'realrun'; KalturaStatement::setDryRun($dryRun); KalturaLog::debug($dryRun ? "Dry Run" : "REAL RUN"); uiConfPeer::setUseCriteriaFilter(false); FileSyncPeer::setUseCriteriaFilter(false); $uiConf = uiConfPeer::retrieveByPK($uiConfId); if (!$uiConf) { die("UI-Conf ID [{$uiConfId}] not found"); } $fileSyncs = array(); $fileSync = kFileSyncUtils::getLocalFileSyncForKey($uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA), false); if ($fileSync) { $fileSyncs[] = $fileSync; } $fileSync = kFileSyncUtils::getLocalFileSyncForKey($uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_CONFIG), false); if ($fileSync) { $fileSyncs[] = $fileSync; } $fileSync = kFileSyncUtils::getLocalFileSyncForKey($uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES), false); if ($fileSync) { $fileSyncs[] = $fileSync; } if (empty($fileSyncs)) { die("No file_sync found for UI-Conf ID [" . $uiConfId . "]");
/** * 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); }
/** * 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(); }