public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { // it is very common to expect an updated ui_conf object objectWrapperBase::useCache(false); $widget_id = $this->getPM("widget_id"); $detailed = $this->getP("detailed", false); $uiconf_id = $this->getP("uiconf_id", $this->getP("ui_conf_id", null)); self::$escape_text = true; //$widget = widgetPeer::retrieveByHashedId( $widget_id ); $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { $this->addError(APIErrors::INVALID_WIDGET_ID, $widget_id); } else { // check if this widget is public - if so , create a ks for viewing the related kshow if ($uiconf_id) { $widget->overrideUiConfId($uiconf_id); } // make sure the validation is done before leaving the action - // because the getWidgetHtml might throw an exception - it's better to envke it here rather than tht UI $widget->getWidgetHtml(); // TODO - call //$result = kSessionUtils::startKSession ( $partner_id , $this->getP ( "secret" ) , $puser_id , $ks , $expiry , $admin , "" , $privileges ); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $this->addMsg("widget", objectWrapperBase::getWrapperClass($widget, $level)); } }
public function execute() { $widgetId = $this->getRequestParameter("wid"); $widget = widgetPeer::retrieveByPK($widgetId); if (!$widget) { KalturaLog::err("Widget id [{$widgetId}] not found"); die; } $entry = $widget->getentry(); $entryId = $widget->getEntryId(); if (!$entry) { KalturaLog::err("Entry id [{$entryId}] not found"); die; } $uiConf = $widget->getuiConf(); $uiConfId = $widget->getUiConfId(); if (!$uiConf) { KalturaLog::err("UI Conf id [{$uiConfId}] not found"); die; } $widgetPath = "/kwidget/wid/{$widgetId}/entry_id/{$entryId}/ui_conf/{$uiConfId}"; $this->widget = $widget; $this->entry = $entry; $this->uiConf = $uiConf; $this->entryThumbUrl = $entry->getThumbnailUrl(); $this->entryThumbSecureUrl = $entry->getThumbnailUrl(null, 'https'); $this->widgetUrl = 'http://' . kConf::get('www_host') . $widgetPath; $this->widgetSecureUrl = 'https://' . kConf::get('www_host') . $widgetPath; }
public function execute() { $widgetId = $this->getRequestParameter("wid"); $widget = widgetPeer::retrieveByPK($widgetId); if (!$widget) { KalturaLog::err("Widget id [{$widgetId}] not found"); die; } $entry = $widget->getentry(); $entryId = $widget->getEntryId(); if (!$entry) { KalturaLog::err("Entry id [{$entryId}] not found"); die; } $uiConf = $widget->getuiConf(); $uiConfId = $widget->getUiConfId(); if (!$uiConf) { KalturaLog::err("UI Conf id [{$uiConfId}] not found"); die; } $this->entry_name = $entry->getName(); $this->entry_description = $entry->getDescription(); $this->entry_thumbnail_url = $entry->getThumbnailUrl(); $this->entry_thumbnail_secure_url = $entry->getThumbnailUrl(null, 'https'); $this->entry_duration = $entry->getDuration(); $flavor_tag = $this->getRequestParameter('flavor_tag', 'iphone'); $flavor_assets = assetPeer::retrieveReadyFlavorsByEntryIdAndTag($entryId, $flavor_tag); $flavor_asset = reset($flavor_assets); $flavorId = null; if ($flavor_asset) { $flavorId = $flavor_asset->getId(); } $embed_host = kConf::hasParam('cdn_api_host') ? kConf::get('cdn_api_host') : kConf::get('www_host'); $embed_host_https = kConf::hasParam('cdn_api_host_https') ? kConf::get('cdn_api_host_https') : kConf::get('www_host'); $https_enabled = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; $protocol = $https_enabled ? 'https' : 'http'; $port = $_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : ''; $partnerId = $widget->getPartnerId(); $this->widget = $widget; $this->entry = $entry; $this->uiConf = $uiConf; // Build SWF Path $swfPath = "/index.php/kwidget/wid/" . $widgetId . "/uiconf_id/" . $uiConfId . "/entry_id/" . $entryId; // Set SWF URLs $this->swfUrl = 'http://' . $embed_host . $swfPath; $this->swfSecureUrl = 'https://' . $embed_host_https . $swfPath; // set player url $this->playerUrl = 'https://' . $embed_host_https . '/p/' . $this->partner_id . '/sp/' . $this->partner_id . '00/embedIframeJs/uiconf_id/' . $this->uiconf_id . '/partner_id/' . $this->partner_id . '?iframeembed=true&entry_id=' . $this->entry_id . '&flashvars[streamerType]=auto'; $host = $https_enabled ? $embed_host_https : $embed_host; $this->html5Url = $protocol . "://" . $host . "/p/" . $partnerId . "/sp/" . $partnerId . "00/embedIframeJs/uiconf_id/" . $uiConfId . "/partner_id/" . $partnerId; $this->pageURL = $protocol . '://' . $_SERVER["SERVER_NAME"] . $port . $_SERVER["REQUEST_URI"]; $this->flavorUrl = null; if (isset($flavorId)) { $this->flavorUrl = 'https://' . $embed_host_https . '/p/' . $partnerId . '/sp/' . $partnerId . '00/playManifest/entryId/' . $entryId . '/flavorId/' . $flavorId . '/format/url/protocol/' . $protocol . '/a.mp4'; } }
/** * Will forward to the the thumbnail of the kshows using the widget id */ public function execute() { $widget_id = $this->getRequestParameter("wid"); $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(); if ($kshow_id) { $kshow = kshowPeer::retrieveByPK($kshow_id); if ($kshow->getShowEntry()) { $this->redirect($kshow->getShowEntry()->getBigThumbnailUrl()); } } }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { // make sure the secret fits the one in the partner's table $ks_str = ""; $expiry = $this->getP("expiry", 86400); $widget_id = $this->getPM("widget_id"); $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { $this->addError(APIErrors::INVALID_WIDGET_ID, $widget_id); return; } $partner_id = $widget->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partner_id); // TODO - see how to decide if the partner has a URL to redirect to // according to the partner's policy and the widget's policy - define the privileges of the ks // TODO - decide !! - for now only view - any kshow $privileges = "view:*,widget:1"; if ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_FORCE_KS) { if (!$this->ks) { // the one from the defPartnerservices2Action $this->addException(APIErrors::MISSING_KS); } $ks_str = $this->getP("ks"); $widget_partner_id = $widget->getPartnerId(); $res = kSessionUtils::validateKSession2(1, $widget_partner_id, $puser_id, $ks_str, $this->ks); if (0 >= $res) { // chaned this to be an exception rather than an error $this->addException(APIErrors::INVALID_KS, $ks_str, $res, ks::getErrorStr($res)); } } else { // the session will be for NON admins and privileges of view only $puser_id = 0; $result = kSessionUtils::createKSessionNoValidations($partner_id, $puser_id, $ks_str, $expiry, false, "", $privileges); } if ($result >= 0) { $this->addMsg("ks", $ks_str); $this->addMsg("partner_id", $partner_id); $this->addMsg("subp_id", $widget->getSubpId()); $this->addMsg("uid", "0"); } else { // TODO - see that there is a good error for when the invalid login count exceed s the max $this->addError(APIErrors::START_WIDGET_SESSION_ERROR, $widget_id); } }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { // get the new properties for the kuser from the request $widget = new widget(); $obj_wrapper = objectWrapperBase::getWrapperClass($widget, 0); $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $widget, "widget_", $obj_wrapper->getUpdateableFields()); // check that mandatory fields were set // TODO $new_widget = null; if (count($fields_modified) > 0) { // see if to create a widget from a widget or from a kshow if ($widget->getSourceWidgetId()) { $widget_from_db = widgetPeer::retrieveByPK($widget->getSourceWidgetId()); $new_widget = widget::createWidgetFromWidget($widget_from_db, $widget->getKshowId(), $widget->getEntryId(), $widget->getUiConfId(), $widget->getCustomData(), $widget->getPartnerData(), $widget->getSecurityType()); if (!$new_widget) { $this->addError(APIErrors::INVALID_KSHOW_AND_ENTRY_PAIR, $widget->getKshowId(), $widget->getEntryId()); return; } } else { $kshow_id = $widget->getKshowId(); if ($kshow_id) { $kshow = kshowPeer::retrieveByPK($kshow_id); if (!$kshow) { $this->addError(APIErrors::KSHOW_DOES_NOT_EXISTS); // This field in unique. Please change "); return; } } else { $kshow = new kshow(); $kshow->setId(0); $kshow->setPartnerId($partner_id); $kshow->setSubpId($subp_id); } $new_widget = widget::createWidget($kshow, $widget->getEntryId(), null, $widget->getUiConfId(), $widget->getCustomData(), $widget->getPartnerData(), $widget->getSecurityType()); } $this->addMsg("widget", objectWrapperBase::getWrapperClass($new_widget, objectWrapperBase::DETAIL_LEVEL_DETAILED)); $this->addDebug("added_fields", $fields_modified); } else { $this->addError(APIErrors::NO_FIELDS_SET_FOR_WIDGET); } }
public static function getWidgetKshowEntryFromGenericId($generic_id) { if ($generic_id == null) { return null; } $prefix = substr($generic_id, 0, 2); if ($prefix == "w-") { $id = substr($generic_id, 2); // the rest of the string $widget = widgetPeer::retrieveByPK($id, null, widgetPeer::WIDGET_PEER_JOIN_ENTRY + widgetPeer::WIDGET_PEER_JOIN_KSHOW); if (!$widget) { return null; } $kshow = $widget->getKshow(); $entry = $widget->getEntry(); return array($widget, $kshow, $entry); } elseif ($prefix == "k-") { $id = substr($generic_id, 2); // the rest of the string list($kshow, $entry, $error) = self::getKshowAndEntry($id, -1); if ($error) { return null; } return array(null, $kshow, $entry); } elseif ($prefix == "e-") { $id = substr($generic_id, 2); // the rest of the string list($kshow, $entry, $error) = self::getKshowAndEntry(-1, $id); if ($error) { return null; } return array(null, $kshow, $entry); } else { // not a good prefix - why guess ??? return null; } }
/** * Add widget based on existing widget. * Must provide valid sourceWidgetId * * @action clone * @paran KalturaWidget $widget * @return KalturaWidget */ function cloneAction(KalturaWidget $widget) { $dbWidget = widgetPeer::retrieveByPK($widget->sourceWidgetId); if (!$dbWidget) { throw new KalturaAPIException(APIErrors::INVALID_WIDGET_ID, $widget->sourceWidgetId); } $newWidget = widget::createWidgetFromWidget($dbWidget, $widget->kshowId, $widget->entryId, $widget->uiConfId, null, $widget->partnerData, $widget->securityType); if (!$newWidget) { throw new KalturaAPIException(APIErrors::INVALID_KSHOW_AND_ENTRY_PAIR, $widget->kshowId, $widget->entryId); } $widget = new KalturaWidget(); $widget->fromWidget($newWidget); return $widget; }
/** * 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); }
public function execute() { sfView::SUCCESS; $this->partner_id = $this->getP("pid"); $this->subp_id = $this->getP("subpid", (int) $this->partner_id * 100); $this->uid = $this->getP("uid"); $this->ks = $this->getP("kmcks"); if (!$this->ks) { // if kmcks from cookie doesn't exist, try ks from REQUEST $this->ks = $this->getP('ks'); } $this->screen_name = $this->getP("screen_name"); $this->email = $this->getP("email"); $this->allow_reports = false; if (!$this->ks) { $this->redirect("kmc/kmc"); die; } // $this->beta = $this->getRequestParameter( "beta" ); $this->embed_code = ""; $this->ui_conf_width = ""; $this->ui_conf_height = ""; if ($this->partner_id !== null) { $widget = widgetPeer::retrieveByPK("_" . $this->partner_id); if ($widget) { $this->embed_code = $widget->getWidgetHtml("kaltura_player"); $ui_conf = $widget->getuiConf(); // $this->ui_conf_width = 0; // $ui_conf->getWidth(); // $this->ui_conf_height = 0 ; // $ui_conf->getHeight(); } } $this->partner = $partner = null; $this->templatePartnerId = 0; if ($this->partner_id !== NULL) { $this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id); kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, $this->uid, $this->screen_name, $this->email, 2); $this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : 0; } $this->payingPartner = 'false'; if ($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE) { $this->payingPartner = 'true'; } $this->enable_live_streaming = 'false'; if (kConf::get('kmc_content_enable_live_streaming') && $partner) { if ($partner->getLiveStreamEnabled() && $partner->getKmcVersion() == 3) { $this->enable_live_streaming = 'true'; } } // this is Andromeda kmc2Action - following are irrelevant so we set them to false & empty // just to make sure they don't get a black-eye value $this->enable_live_streaming = 'false'; $this->silverLightPlayerUiConfs = array(); $this->silverLightPlaylistUiConfs = array(); /* // remarked - no silverlight players in Andromeda if($partner->getKmcVersion() == 3) { $this->silverLightPlayerUiConfs = kmcUtils::getSilverLightPlayerUiConfs('slp'); $this->silverLightPlaylistUiConfs = kmcUtils::getSilverLightPlayerUiConfs('sll'); } */ // 2009-08-27 is the date we added ON2 to KMC trial account // TODO - should be depracated if ($partner) { if (strtotime($partner->getCreatedAt()) >= strtotime('2009-08-27') || $partner->getEnableAnalyticsTab()) { $this->allow_reports = true; } if ($partner->getEnableAnalyticsTab()) { $this->allow_reports = true; } } // set content kdp version according to partner id $moderated_partners = array(31079, 28575, 32774); $this->content_kdp_version = 'v2.7.0'; if (in_array($this->partner_id, $moderated_partners)) { $this->content_kdp_version = 'v2.1.2.29057'; } $this->playlist_uiconf_list = $this->getUiconfList('playlist'); $this->player_uiconf_list = $this->getUiconfList('player'); $this->first_login = false; if ($partner) { $this->first_login = $partner->getIsFirstLogin(); if ($this->first_login === true) { $partner->setIsFirstLogin(false); $partner->save(); } $this->jw_license = $partner->getLicensedJWPlayer(); } // if the email is empty - it is an indication that the kaltura super user is logged in if (!$this->email) { $this->allow_reports = true; } /* applications versioning */ $this->kmc_content_version = 'v2.1.6.1'; $this->kmc_account_version = 'v2.1.2.3'; $this->kmc_appstudio_version = 'v2.0.4'; $this->kmc_rna_version = 'v1.1.3'; $this->kmc_dashboard_version = 'v1.0.10'; $this->jw_uiconfs_array = kmcUtils::getJWPlayerUIConfs(); $this->jw_uiconf_playlist = kmcUtils::getJWPlaylistUIConfs(); $this->advanced_editor = $this->getAdvancedEditorUiConf(); $this->simple_editor = $this->getSimpleEditorUiConf(); }
public function execute() { sfView::SUCCESS; /** check parameters and verify user is logged-in **/ $this->partner_id = $this->getP("pid"); $this->subp_id = $this->getP("subpid", (int) $this->partner_id * 100); $this->uid = $this->getP("uid"); $this->ks = $this->getP("kmcks"); if (!$this->ks) { // if kmcks from cookie doesn't exist, try ks from REQUEST $this->ks = $this->getP('ks'); } $this->screen_name = $this->getP("screen_name"); $this->email = $this->getP("email"); /** if no KS found, redirect to login page **/ if (!$this->ks) { $this->redirect("kmc/kmc"); die; } /** END - check parameters and verify user is logged-in **/ /** load partner from DB, and set templatePartnerId **/ $this->partner = $partner = null; $this->templatePartnerId = self::SYSTEM_DEFAULT_PARTNER; if ($this->partner_id !== NULL) { $this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id); kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, $this->uid, $this->screen_name, $this->email, self::CURRENT_KMC_VERSION); $this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : self::SYSTEM_DEFAULT_PARTNER; } /** END - load partner from DB, and set templatePartnerId **/ /** set default flags **/ $this->allow_reports = false; $this->payingPartner = 'false'; $this->embed_code = ""; $this->enable_live_streaming = 'false'; $this->kmc_enable_custom_data = 'false'; $this->kdp508_players = array(); $this->first_login = false; $this->enable_vast = 'false'; /** END - set default flags **/ /** set values for template **/ $this->service_url = myPartnerUtils::getHost($this->partner_id); $this->host = str_replace("http://", "", $this->service_url); $this->cdn_url = myPartnerUtils::getCdnHost($this->partner_id); $this->cdn_host = str_replace("http://", "", $this->cdn_url); $this->rtmp_host = myPartnerUtils::getRtmpUrl($this->partner_id); $this->flash_dir = $this->cdn_url . myContentStorage::getFSFlashRootPath(); /** set embed_code value **/ if ($this->partner_id !== null) { $widget = widgetPeer::retrieveByPK("_" . $this->partner_id); if ($widget) { $this->embed_code = $widget->getWidgetHtml("kaltura_player"); $ui_conf = $widget->getuiConf(); } } /** END - set embed_code value **/ /** set payingPartner flag **/ if ($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE) { $this->payingPartner = 'true'; } /** END - set payingPartner flag **/ /** set enable_live_streaming flag **/ if (kConf::get('kmc_content_enable_live_streaming') && $partner) { if ($partner->getLiveStreamEnabled()) { $this->enable_live_streaming = 'true'; } } /** END - set enable_live_streaming flag **/ /** set enable_live_streaming flag **/ if ($partner && $partner->getEnableVast()) { $this->enable_vast = 'true'; } /** END - set enable_live_streaming flag **/ /** set kmc_enable_custom_data flag **/ $defaultPlugins = kConf::get('default_plugins'); if (is_array($defaultPlugins) && in_array('MetadataPlugin', $defaultPlugins) && $partner) { if ($partner->getPluginEnabled(MetadataPlugin::PLUGIN_NAME) && $partner->getKmcVersion() == self::CURRENT_KMC_VERSION) { $this->kmc_enable_custom_data = 'true'; } } /** END - set kmc_enable_custom_data flag **/ /** set allow_reports flag **/ // 2009-08-27 is the date we added ON2 to KMC trial account // TODO - should be depracated if (strtotime($partner->getCreatedAt()) >= strtotime('2009-08-27') || $partner->getEnableAnalyticsTab()) { $this->allow_reports = true; } if ($partner->getEnableAnalyticsTab()) { $this->allow_reports = true; } // if the email is empty - it is an indication that the kaltura super user is logged in if (!$this->email) { $this->allow_reports = true; } /** END - set allow_reports flag **/ /** set first_login and jw_license flags **/ if ($partner) { $this->first_login = $partner->getIsFirstLogin(); if ($this->first_login === true) { $partner->setIsFirstLogin(false); $partner->save(); } $this->jw_license = $partner->getLicensedJWPlayer(); } /** END - set first_login and jw_license flags **/ /** partner-specific: change KDP version for partners working with auto-moderaion **/ // set content kdp version according to partner id $moderated_partners = array(31079, 28575, 32774); $this->content_kdp_version = 'v2.7.0'; if (in_array($this->partner_id, $moderated_partners)) { $this->content_kdp_version = 'v2.1.2.29057'; } /** END - partner-specific: change KDP version for partners working with auto-moderaion **/ /** applications versioning **/ $this->kmc_content_version = kConf::get('kmc_content_version'); $this->kmc_account_version = kConf::get('kmc_account_version'); $this->kmc_appstudio_version = kConf::get('kmc_appstudio_version'); $this->kmc_rna_version = kConf::get('kmc_rna_version'); $this->kmc_dashboard_version = kConf::get('kmc_dashboard_version'); /** END - applications versioning **/ /** uiconf listing work **/ /** fill $this->confs with all uiconf objects for all modules **/ $contentSystemUiConfs = kmcUtils::getAllKMCUiconfs('content', $this->kmc_content_version, self::SYSTEM_DEFAULT_PARTNER); $contentTemplateUiConfs = kmcUtils::getAllKMCUiconfs('content', $this->kmc_content_version, $this->templatePartnerId); //$this->confs = kmcUtils::getAllKMCUiconfs('content', $this->kmc_content_version, $this->templatePartnerId); $appstudioSystemUiConfs = kmcUtils::getAllKMCUiconfs('appstudio', $this->kmc_appstudio_version, self::SYSTEM_DEFAULT_PARTNER); $appstudioTemplateUiConfs = kmcUtils::getAllKMCUiconfs('appstudio', $this->kmc_appstudio_version, $this->templatePartnerId); //$this->confs = array_merge($this->confs, kmcUtils::getAllKMCUiconfs('appstudio', $this->kmc_appstudio_version, $this->templatePartnerId)); $reportsSystemUiConfs = kmcUtils::getAllKMCUiconfs('reports', $this->kmc_rna_version, self::SYSTEM_DEFAULT_PARTNER); $reportsTemplateUiConfs = kmcUtils::getAllKMCUiconfs('reports', $this->kmc_rna_version, $this->templatePartnerId); //$this->confs = array_merge($this->confs, kmcUtils::getAllKMCUiconfs('reports', $this->kmc_rna_version, $this->templatePartnerId)); /** for each module, create separated lists of its uiconf, for each need **/ /** content players: **/ $this->content_uiconfs_previewembed = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_previewembed", true, $contentSystemUiConfs); $this->content_uiconfs_previewembed_list = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_previewembed_list", true, $contentSystemUiConfs); $this->content_uiconfs_moderation = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_moderation", false, $contentSystemUiConfs); $this->content_uiconfs_drilldown = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_drilldown", false, $contentSystemUiConfs); $this->content_uiconfs_flavorpreview = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_flavorpreview", false, $contentSystemUiConfs); $this->content_uiconfs_metadataview = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_metadataview", false, $contentSystemUiConfs); /** content KCW,KSE,KAE **/ $this->content_uiconfs_upload = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_upload", false, $contentSystemUiConfs); $this->simple_editor = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_simpleedit", false, $contentSystemUiConfs); $this->advanced_editor = kmcUtils::find_confs_by_usage_tag($contentTemplateUiConfs, "content_advanceedit", false, $contentSystemUiConfs); /** appStudio templates uiconf **/ $this->appstudio_uiconfs_templates = kmcUtils::find_confs_by_usage_tag($appstudioTemplateUiConfs, "appstudio_templates", false, $appstudioSystemUiConfs); /** reports drill-down player **/ $this->reports_uiconfs_drilldown = kmcUtils::find_confs_by_usage_tag($reportsTemplateUiConfs, "reports_drilldown", false, $reportsSystemUiConfs); /** silverlight uiconfs **/ $this->silverLightPlayerUiConfs = array(); $this->silverLightPlaylistUiConfs = array(); if ($partner->getKmcVersion() == self::CURRENT_KMC_VERSION && $partner->getEnableSilverLight()) { $this->silverLightPlayerUiConfs = kmcUtils::getSilverLightPlayerUiConfs('slp'); $this->silverLightPlaylistUiConfs = kmcUtils::getSilverLightPlayerUiConfs('sll'); } /** jw uiconfs **/ $this->jw_uiconfs_array = kmcUtils::getJWPlayerUIConfs(); $this->jw_uiconf_playlist = kmcUtils::getJWPlaylistUIConfs(); /** 508 uicinfs **/ if ($partner->getKmcVersion() == self::CURRENT_KMC_VERSION && $partner->getEnable508Players()) { $this->kdp508_players = kmcUtils::getKdp508PlayerUiconfs(); } /** partner's preview&embed uiconfs **/ $this->content_pne_partners_player = kmcUtils::getPartnersUiconfs($this->partner_id, 'player'); $this->content_pne_partners_playlist = kmcUtils::getPartnersUiconfs($this->partner_id, 'playlist'); /** appstudio: default entry and playlists **/ $this->appStudioExampleEntry = $partner->getAppStudioExampleEntry(); $appStudioExampleEntry = entryPeer::retrieveByPK($this->appStudioExampleEntry); if (!($appStudioExampleEntry && $appStudioExampleEntry->getDisplayInSearch() == mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK && $appStudioExampleEntry->getStatus() == entryStatus::READY && $appStudioExampleEntry->getType() == entryType::MEDIA_CLIP)) { $this->appStudioExampleEntry = "_KMCLOGO1"; } $this->appStudioExamplePlayList0 = $partner->getAppStudioExamplePlayList0(); $appStudioExamplePlayList0 = entryPeer::retrieveByPK($this->appStudioExamplePlayList0); if (!($appStudioExamplePlayList0 && $appStudioExamplePlayList0->getStatus() == entryStatus::READY && $appStudioExamplePlayList0->getType() == entryType::PLAYLIST)) { $this->appStudioExamplePlayList0 = "_KMCSPL1"; } $this->appStudioExamplePlayList1 = $partner->getAppStudioExamplePlayList1(); $appStudioExamplePlayList1 = entryPeer::retrieveByPK($this->appStudioExamplePlayList1); if (!($appStudioExamplePlayList1 && $appStudioExamplePlayList1->getStatus() == entryStatus::READY && $appStudioExamplePlayList1->getType() == entryType::PLAYLIST)) { $this->appStudioExamplePlayList1 = "_KMCSPL2"; } /** END - appstudio: default entry and playlists **/ /** END - uiconf listing work **/ /** get templateXmlUrl for whitelabeled partners **/ $this->appstudio_templatesXmlUrl = $this->getAppStudioTemplatePath(); }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; requestUtils::handleConditionalGet(); ignore_user_abort(); $entry_id = $this->getRequestParameter("entry_id"); $widget_id = $this->getRequestParameter("widget_id", 0); $upload_token_id = $this->getRequestParameter("upload_token_id"); $version = $this->getIntRequestParameter("version", null, 0, 10000000); $type = $this->getIntRequestParameter("type", 1, 1, 5); //Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5. $width = $this->getRequestParameter("width", -1); $height = $this->getRequestParameter("height", -1); if (strpos($width, "!") || strpos($height, "!")) { $type = 5; } $width = $this->getFloatRequestParameter("width", -1, -1, 10000); $height = $this->getFloatRequestParameter("height", -1, -1, 10000); $crop_provider = $this->getRequestParameter("crop_provider", null); $quality = $this->getIntRequestParameter("quality", 0, 0, 100); $src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000); $src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000); $src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000); $src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000); $vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1); $vid_slice = $this->getRequestParameter("vid_slice", -1); $vid_slices = $this->getRequestParameter("vid_slices", -1); $density = $this->getFloatRequestParameter("density", 0, 0); $stripProfiles = $this->getRequestParameter("strip", null); $flavor_id = $this->getRequestParameter("flavor_id", null); $file_name = $this->getRequestParameter("file_name", null); $file_name = basename($file_name); // actual width and height of image from which the src_* values were taken. // these will be used to multiply the src_* parameters to make them relate to the original image size. $rel_width = $this->getFloatRequestParameter("rel_width", -1, -1, 10000); $rel_height = $this->getFloatRequestParameter("rel_height", -1, -1, 10000); if ($width == -1 && $height == -1) { $width = 120; $height = 90; } else { if ($width == -1) { // if only either width or height is missing reset them to zero, and convertImage will handle them $width = 0; } else { if ($height == -1) { $height = 0; } } } $bgcolor = $this->getRequestParameter("bgcolor", "ffffff"); $partner = null; // validating the inputs if (!is_numeric($quality) || $quality < 0 || $quality > 100) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'quality must be between 20 and 100'); } if (!is_numeric($src_x) || $src_x < 0 || $src_x > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_x must be between 0 and 10000'); } if (!is_numeric($src_y) || $src_y < 0 || $src_y > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_y must be between 0 and 10000'); } if (!is_numeric($src_w) || $src_w < 0 || $src_w > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_w must be between 0 and 10000'); } if (!is_numeric($src_h) || $src_h < 0 || $src_h > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_h must be between 0 and 10000'); } if (!is_numeric($width) || $width < 0 || $width > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'width must be between 0 and 10000'); } if (!is_numeric($height) || $height < 0 || $height > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000'); } if (!is_numeric($density) || $density < 0) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive'); } if (!is_numeric($vid_sec) || $vid_sec < -1) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive'); } if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters'); } if ($upload_token_id) { $upload_token = UploadTokenPeer::retrieveByPK($upload_token_id); if ($upload_token) { $partnerId = $upload_token->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); if ($density == 0) { $density = $partner->getDefThumbDensity(); } if (is_null($stripProfiles)) { $stripProfiles = $partner->getStripThumbProfile(); } $thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg"); kFile::fullMkdir($thumb_full_path); if (file_exists($upload_token->getUploadTempPath())) { $src_full_path = $upload_token->getUploadTempPath(); $valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP); $image_type = exif_imagetype($src_full_path); if (!in_array($image_type, $valid_image_types)) { // capture full frame myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3); if (!file_exists($thumb_full_path)) { myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0); } $src_full_path = $thumb_full_path; } // and resize it myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles); kFile::dumpFile($thumb_full_path); } else { KalturaLog::debug("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC"); $remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI']; kFile::dumpUrl($remoteUrl); } } } if ($entry_id) { $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { // problem could be due to replication lag kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId())); } } else { // get the widget $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND); } // get the kshow $kshow_id = $widget->getKshowId(); $kshow = kshowPeer::retrieveByPK($kshow_id); if ($kshow) { $entry_id = $kshow->getShowEntryId(); } else { $entry_id = $widget->getEntryId(); } $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } } $partner = $entry->getPartner(); if ($density == 0) { $density = $partner->getDefThumbDensity(); } $thumbParams = new kThumbnailParameters(); $thumbParams->setSupportAnimatedThumbnail($partner->getSupportAnimatedThumbnails()); if (is_null($stripProfiles)) { $stripProfiles = $partner->getStripThumbProfile(); } //checks whether the thumbnail display should be restricted by KS $base64Referrer = $this->getRequestParameter("referrer"); $referrer = base64_decode($base64Referrer); if (!is_string($referrer)) { $referrer = ""; } // base64_decode can return binary data if (!$referrer) { $referrer = kApiCache::getHttpReferrer(); } $ksStr = $this->getRequestParameter("ks"); $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, accessControlContextType::THUMBNAIL); $securyEntryHelper->validateForPlay(); // multiply the passed $src_* values so that they will relate to the original image size, according to $src_display_* if ($rel_width != -1) { $widthRatio = $entry->getWidth() / $rel_width; $src_x = $src_x * $widthRatio; $src_w = $src_w * $widthRatio; } if ($rel_height != -1) { $heightRatio = $entry->getHeight() / $rel_height; $src_y = $src_y * $heightRatio; $src_h = $src_h * $heightRatio; } $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB; if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA; } KalturaLog::debug("get thumbnail filesyncs"); $dataKey = $entry->getSyncKey($subType); list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($dataKey, true, false); $tempThumbPath = null; $entry_status = $entry->getStatus(); // both 640x480 and 0x0 requests are probably coming from the kdp // 640x480 - old kdp version requesting thumbnail // 0x0 - new kdp version requesting the thumbnail of an unready entry // we need to distinguish between calls from the kdp and calls from a browser: <img src=...> // that can't handle swf input if (($width == 640 && $height == 480 || $width == 0 && $height == 0) && ($entry_status == entryStatus::PRECONVERT || $entry_status == entryStatus::IMPORT || $entry_status == entryStatus::ERROR_CONVERTING || $entry_status == entryStatus::DELETED)) { $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/bigthumbnail/"; if ($entry_status == entryStatus::DELETED) { $msgPath .= $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK ? "entry_blocked.swf" : "entry_deleted.swf"; } else { $msgPath .= $entry_status == entryStatus::ERROR_CONVERTING ? "entry_error.swf" : "entry_converting.swf"; } kFile::dumpFile($msgPath, null, 0); } if (!$file_sync) { $tempThumbPath = $entry->getLocalThumbFilePath($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $density, $stripProfiles, $flavor_id, $file_name); if (!$tempThumbPath) { KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } } if (!$local && !$tempThumbPath && $file_sync) { if (!in_array($file_sync->getDc(), kDataCenterMgr::getDcIds())) { $remoteUrl = $file_sync->getExternalUrl($entry->getId()); header("Location: {$remoteUrl}"); die; } $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']); kFile::dumpUrl($remoteUrl); } // if we didnt return a template for the player die and dont return the original deleted thumb if ($entry_status == entryStatus::DELETED) { KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } if (!$tempThumbPath) { try { $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, null, $density, $stripProfiles, $thumbParams); } catch (Exception $ex) { if ($ex->getCode() != kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) { KalturaLog::log("Error - resize image failed"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } // get original flavor asset $origFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id); if (!$origFlavorAsset) { KalturaLog::log("Error - no original flavor for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false); if (!$remoteFileSync) { // file does not exist on any DC - die KalturaLog::log("Error - no FileSync for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) { KalturaLog::log("ERROR - Trying to redirect to myself - stop here."); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) { KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync); kFile::dumpUrl($remoteUrl); } } $nocache = strpos($tempThumbPath, "_NOCACHE_") !== false; if ($securyEntryHelper->shouldDisableCache() || kApiCache::hasExtraFields() || !$securyEntryHelper->isKsWidget() && $securyEntryHelper->hasRules()) { $nocache = true; } // notify external proxy, so it'll cache this url if (!$nocache && requestUtils::getHost() == kConf::get("apphome_url") && file_exists($tempThumbPath)) { self::notifyProxy($_SERVER["REQUEST_URI"]); } // cache result if (!$nocache) { $requestKey = $_SERVER["REQUEST_URI"]; $cache = new myCache("thumb", 86400 * 30); // 30 days $cache->put($requestKey, $tempThumbPath); } kFile::dumpFile($tempThumbPath, null, $nocache ? 0 : null); // TODO - can delete from disk assuming we caneasily recreate it and it will anyway be cached in the CDN // however dumpfile dies at the end so we cant just write it here (maybe register a shutdown callback) }
/** * Start a session for Kaltura's flash widgets * * @action startWidgetSession * @param string $widgetId * @param int $expiry * * @throws APIErrors::INVALID_WIDGET_ID * @throws APIErrors::MISSING_KS * @throws APIErrors::INVALID_KS * @throws APIErrors::START_WIDGET_SESSION_ERROR * @return KalturaStartWidgetSessionResponse */ function startWidgetSession($widgetId, $expiry = 86400) { // make sure the secret fits the one in the partner's table $ksStr = ""; $widget = widgetPeer::retrieveByPK($widgetId); if (!$widget) { throw new KalturaAPIException(APIErrors::INVALID_WIDGET_ID, $widgetId); } $partnerId = $widget->getPartnerId(); //$partner = PartnerPeer::retrieveByPK( $partner_id ); // TODO - see how to decide if the partner has a URL to redirect to // according to the partner's policy and the widget's policy - define the privileges of the ks // TODO - decide !! - for now only view - any kshow $privileges = "view:*,widget:1"; if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $partnerId) && !$widget->getEnforceEntitlement() && $widget->getEntryId()) { $privileges .= ',' . kSessionBase::PRIVILEGE_DISABLE_ENTITLEMENT_FOR_ENTRY . ':' . $widget->getEntryId(); } if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $partnerId) && !is_null($widget->getPrivacyContext()) && $widget->getPrivacyContext() != '') { $privileges .= ',' . kSessionBase::PRIVILEGE_PRIVACY_CONTEXT . ':' . $widget->getPrivacyContext(); } $userId = 0; /*if ( $widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_FORCE_KS ) { $user = $this->getKuser(); if ( ! $this->getKS() )// the one from the base class throw new KalturaAPIException ( APIErrors::MISSING_KS ); $widget_partner_id = $widget->getPartnerId(); $res = kSessionUtils::validateKSession2 ( 1 ,$widget_partner_id , $user->getId() , $ks_str , $this->ks ); if ( 0 >= $res ) { // chaned this to be an exception rather than an error throw new KalturaAPIException ( APIErrors::INVALID_KS , $ks_str , $res , ks::getErrorStr( $res )); } } else {*/ // the session will be for NON admins and privileges of view only $result = kSessionUtils::createKSessionNoValidations($partnerId, $userId, $ksStr, $expiry, false, "", $privileges); //} if ($result >= 0) { $response = new KalturaStartWidgetSessionResponse(); $response->partnerId = $partnerId; $response->ks = $ksStr; $response->userId = $userId; return $response; } else { // TODO - see that there is a good error for when the invalid login count exceed s the max throw new KalturaAPIException(APIErrors::START_WIDGET_SESSION_ERROR, $widgetId); } }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { KExternalErrors::setResponseErrorCode(KExternalErrors::HTTP_STATUS_NOT_FOUND); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; requestUtils::handleConditionalGet(); ignore_user_abort(); $entry_id = $this->getRequestParameter("entry_id"); $widget_id = $this->getRequestParameter("widget_id", 0); $upload_token_id = $this->getRequestParameter("upload_token_id"); $version = $this->getIntRequestParameter("version", null, 0, 10000000); $type = $this->getIntRequestParameter("type", 1, 1, 5); //Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5. $width = $this->getRequestParameter("width", -1); $height = $this->getRequestParameter("height", -1); if (strpos($width, "!") || strpos($height, "!")) { $type = 5; } $width = $this->getFloatRequestParameter("width", -1, -1, 10000); $height = $this->getFloatRequestParameter("height", -1, -1, 10000); $nearest_aspect_ratio = $this->getIntRequestParameter("nearest_aspect_ratio", 0, 0, 1); $imageFilePath = null; $crop_provider = $this->getRequestParameter("crop_provider", null); $quality = $this->getIntRequestParameter("quality", 0, 0, 100); $src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000); $src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000); $src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000); $src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000); $vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1); $vid_slice = $this->getRequestParameter("vid_slice", -1); $vid_slices = $this->getRequestParameter("vid_slices", -1); $density = $this->getFloatRequestParameter("density", 0, 0); $stripProfiles = $this->getRequestParameter("strip", null); $flavor_id = $this->getRequestParameter("flavor_id", null); $file_name = $this->getRequestParameter("file_name", null); $file_name = basename($file_name); // actual width and height of image from which the src_* values were taken. // these will be used to multiply the src_* parameters to make them relate to the original image size. $rel_width = $this->getFloatRequestParameter("rel_width", -1, -1, 10000); $rel_height = $this->getFloatRequestParameter("rel_height", -1, -1, 10000); $def_width = $this->getFloatRequestParameter("def_width", -1, -1, 10000); $def_height = $this->getFloatRequestParameter("def_height", -1, -1, 10000); if ($width == -1 && $height == -1) { if ($def_width == -1) { $width = 120; } else { $width = $def_width; } if ($def_height == -1) { $height = 90; } else { $height = $def_height; } } else { if ($width == -1) { $width = 0; } else { if ($height == -1) { $height = 0; } } } $bgcolor = $this->getRequestParameter("bgcolor", "ffffff"); $partner = null; $format = $this->getRequestParameter("format", null); // validating the inputs if (!is_numeric($quality) || $quality < 0 || $quality > 100) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'quality must be between 20 and 100'); } if (!is_numeric($src_x) || $src_x < 0 || $src_x > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_x must be between 0 and 10000'); } if (!is_numeric($src_y) || $src_y < 0 || $src_y > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_y must be between 0 and 10000'); } if (!is_numeric($src_w) || $src_w < 0 || $src_w > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_w must be between 0 and 10000'); } if (!is_numeric($src_h) || $src_h < 0 || $src_h > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_h must be between 0 and 10000'); } if (!is_numeric($width) || $width < 0 || $width > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'width must be between 0 and 10000'); } if (!is_numeric($height) || $height < 0 || $height > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000'); } if (!is_numeric($density) || $density < 0) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive'); } if (!is_numeric($vid_sec) || $vid_sec < -1) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive'); } if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters'); } if ($vid_slices != -1 && $vid_slices <= 0 || !is_numeric($vid_slices)) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_slices must be positive'); } if ($upload_token_id) { $upload_token = UploadTokenPeer::retrieveByPK($upload_token_id); if ($upload_token) { $partnerId = $upload_token->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); if ($partner) { KalturaMonitorClient::initApiMonitor(false, 'extwidget.thumbnail', $partner->getId()); if ($quality == 0) { $quality = $partner->getDefThumbQuality(); } if ($density == 0) { $density = $partner->getDefThumbDensity(); } if (is_null($stripProfiles)) { $stripProfiles = $partner->getStripThumbProfile(); } } $thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg"); kFile::fullMkdir($thumb_full_path); if (file_exists($upload_token->getUploadTempPath())) { $src_full_path = $upload_token->getUploadTempPath(); $valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP); $image_type = exif_imagetype($src_full_path); if (!in_array($image_type, $valid_image_types)) { // capture full frame myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3); if (!file_exists($thumb_full_path)) { myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0); } $src_full_path = $thumb_full_path; } // and resize it myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles, null, $format); kFileUtils::dumpFile($thumb_full_path); } else { KalturaLog::info("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC"); $remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI']; kFileUtils::dumpUrl($remoteUrl); } } } if ($entry_id) { $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { // problem could be due to replication lag kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId())); } } else { // get the widget $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND); } // get the kshow $kshow_id = $widget->getKshowId(); $kshow = kshowPeer::retrieveByPK($kshow_id); if ($kshow) { $entry_id = $kshow->getShowEntryId(); } else { $entry_id = $widget->getEntryId(); } $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } } KalturaMonitorClient::initApiMonitor(false, 'extwidget.thumbnail', $entry->getPartnerId()); if ($nearest_aspect_ratio) { // Get the entry's default thumbnail path (if any) $defaultThumbnailPath = myEntryUtils::getLocalImageFilePathByEntry($entry, $version); // Get the file path of the thumbnail with the nearest $selectedThumbnailDescriptor = kThumbnailUtils::getNearestAspectRatioThumbnailDescriptorByEntryId($entry_id, $width, $height, $defaultThumbnailPath); if ($selectedThumbnailDescriptor) { $imageFilePath = $selectedThumbnailDescriptor->getImageFilePath(); $thumbWidth = $selectedThumbnailDescriptor->getWidth(); $thumbHeight = $selectedThumbnailDescriptor->getHeight(); // The required width and height will serve as the final crop values $src_w = $width; $src_h = $height; // Base on the thumbnail's dimensions kThumbnailUtils::scaleDimensions($thumbWidth, $thumbHeight, $width, $height, kThumbnailUtils::SCALE_UNIFORM_SMALLER_DIM, $width, $height); // Set crop type $type = KImageMagickCropper::CROP_AFTER_RESIZE; } } $partner = $entry->getPartner(); // not allow capturing frames if the partner has FEATURE_DISALLOW_FRAME_CAPTURE permission if ($vid_sec != -1 || $vid_slice != -1 || $vid_slices != -1) { if ($partner->getEnabledService(PermissionName::FEATURE_BLOCK_THUMBNAIL_CAPTURE)) { KExternalErrors::dieError(KExternalErrors::NOT_ALLOWED_PARAMETER); } } if ($partner) { if ($quality == 0) { $quality = $partner->getDefThumbQuality(); } if ($density == 0) { $density = $partner->getDefThumbDensity(); } } $thumbParams = new kThumbnailParameters(); $thumbParams->setSupportAnimatedThumbnail($partner->getSupportAnimatedThumbnails()); if (is_null($stripProfiles)) { $stripProfiles = $partner->getStripThumbProfile(); } //checks whether the thumbnail display should be restricted by KS $base64Referrer = $this->getRequestParameter("referrer"); $referrer = base64_decode($base64Referrer); if (!is_string($referrer)) { $referrer = ""; } // base64_decode can return binary data if (!$referrer) { $referrer = kApiCache::getHttpReferrer(); } $ksStr = $this->getRequestParameter("ks"); $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, ContextType::THUMBNAIL); $securyEntryHelper->validateForPlay(); // multiply the passed $src_* values so that they will relate to the original image size, according to $src_display_* if ($rel_width != -1 && $rel_width) { $widthRatio = $entry->getWidth() / $rel_width; $src_x = $src_x * $widthRatio; $src_w = $src_w * $widthRatio; } if ($rel_height != -1 && $rel_height) { $heightRatio = $entry->getHeight() / $rel_height; $src_y = $src_y * $heightRatio; $src_h = $src_h * $heightRatio; } $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB; if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA; } $dataKey = $entry->getSyncKey($subType); list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($dataKey, true, false); $tempThumbPath = null; $entry_status = $entry->getStatus(); // both 640x480 and 0x0 requests are probably coming from the kdp // 640x480 - old kdp version requesting thumbnail // 0x0 - new kdp version requesting the thumbnail of an unready entry // we need to distinguish between calls from the kdp and calls from a browser: <img src=...> // that can't handle swf input if (($width == 640 && $height == 480 || $width == 0 && $height == 0) && ($entry_status == entryStatus::PRECONVERT || $entry_status == entryStatus::IMPORT || $entry_status == entryStatus::ERROR_CONVERTING || $entry_status == entryStatus::DELETED)) { $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/bigthumbnail/"; if ($entry_status == entryStatus::DELETED) { $msgPath .= $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK ? "entry_blocked.swf" : "entry_deleted.swf"; } else { $msgPath .= $entry_status == entryStatus::ERROR_CONVERTING ? "entry_error.swf" : "entry_converting.swf"; } kFileUtils::dumpFile($msgPath, null, 0); } if (!$file_sync) { $tempThumbPath = $entry->getLocalThumbFilePath($version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $density, $stripProfiles, $flavor_id, $file_name); if (!$tempThumbPath) { KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } } if (!$local && !$tempThumbPath && $file_sync) { if (!in_array($file_sync->getDc(), kDataCenterMgr::getDcIds())) { $remoteUrl = $file_sync->getExternalUrl($entry->getId()); header("Location: {$remoteUrl}"); KExternalErrors::dieGracefully(); } $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']); kFileUtils::dumpUrl($remoteUrl); } // if we didnt return a template for the player die and dont return the original deleted thumb if ($entry_status == entryStatus::DELETED) { KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } if (!$tempThumbPath) { try { $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $imageFilePath, $density, $stripProfiles, $thumbParams, $format); } catch (Exception $ex) { if ($ex->getCode() != kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) { KalturaLog::err("Resize image failed"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } // get original flavor asset $origFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id); if (!$origFlavorAsset) { KalturaLog::err("No original flavor for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false); if (!$remoteFileSync) { // file does not exist on any DC - die KalturaLog::log("Error - no FileSync for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) { KalturaLog::err("Trying to redirect to myself - stop here."); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) { KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync); kFileUtils::dumpUrl($remoteUrl); } } $nocache = false; if ($securyEntryHelper->shouldDisableCache() || kApiCache::hasExtraFields() || !$securyEntryHelper->isKsWidget() && $securyEntryHelper->hasRules(ContextType::THUMBNAIL)) { $nocache = true; } $cache = null; if (!is_null($entry->getPartner())) { $partnerCacheAge = $entry->getPartner()->getThumbnailCacheAge(); } if ($nocache) { $cacheAge = 0; } else { if ($partnerCacheAge) { $cacheAge = $partnerCacheAge; } else { if (strpos($tempThumbPath, "_NOCACHE_") !== false) { $cacheAge = 60; } else { $cacheAge = 3600; $cache = new myCache("thumb", 2592000); // 30 days, the max memcache allows } } } $lastModified = $entry->getAssetCacheTime(); $renderer = kFileUtils::getDumpFileRenderer($tempThumbPath, null, $cacheAge, 0, $lastModified); $renderer->partnerId = $entry->getPartnerId(); if ($cache) { $invalidationKey = $entry->getCacheInvalidationKeys(); $invalidationKey = kQueryCache::CACHE_PREFIX_INVALIDATION_KEY . $invalidationKey[0]; $cacheTime = time() - kQueryCache::CLOCK_SYNC_TIME_MARGIN_SEC; $cachedResponse = array($renderer, $invalidationKey, $cacheTime); $cache->put($_SERVER["REQUEST_URI"], $cachedResponse); } $renderer->output(); KExternalErrors::dieGracefully(); // TODO - can delete from disk assuming we caneasily recreate it and it will anyway be cached in the CDN // however dumpfile dies at the end so we cant just write it here (maybe register a shutdown callback) }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; requestUtils::handleConditionalGet(); ignore_user_abort(); $entry_id = $this->getRequestParameter("entry_id"); $widget_id = $this->getRequestParameter("widget_id", 0); $upload_token_id = $this->getRequestParameter("upload_token_id"); $version = $this->getRequestParameter("version", null); $width = $this->getRequestParameter("width", -1); $height = $this->getRequestParameter("height", -1); $type = $this->getRequestParameter("type", 1); $crop_provider = $this->getRequestParameter("crop_provider", null); $quality = $this->getRequestParameter("quality", 0); $src_x = $this->getRequestParameter("src_x", 0); $src_y = $this->getRequestParameter("src_y", 0); $src_w = $this->getRequestParameter("src_w", 0); $src_h = $this->getRequestParameter("src_h", 0); $vid_sec = $this->getRequestParameter("vid_sec", -1); $vid_slice = $this->getRequestParameter("vid_slice", -1); $vid_slices = $this->getRequestParameter("vid_slices", -1); // actual width and height of image from which the src_* values were taken. // these will be used to multiply the src_* parameters to make them relate to the original image size. $rel_width = $this->getRequestParameter("rel_width", -1); $rel_height = $this->getRequestParameter("rel_height", -1); if ($width == -1 && $height == -1) { $width = 120; $height = 90; } else { if ($width == -1) { // if only either width or height is missing reset them to zero, and convertImage will handle them $width = 0; } else { if ($height == -1) { $height = 0; } } } $bgcolor = $this->getRequestParameter("bgcolor", "ffffff"); if ($upload_token_id) { $upload_token = UploadTokenPeer::retrieveByPK($upload_token_id); if ($upload_token) { $thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg"); kFile::fullMkdir($thumb_full_path); if (file_exists($upload_token->getUploadTempPath())) { $src_full_path = $upload_token->getUploadTempPath(); $valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP); $image_type = exif_imagetype($src_full_path); if (!in_array($image_type, $valid_image_types)) { // capture full frame myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3); if (!file_exists($thumb_full_path)) { myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0); } $src_full_path = $thumb_full_path; } // and resize it myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h); kFile::dumpFile($thumb_full_path); } } } $entry = entryPeer::retrieveByPKNoFilter($entry_id); // multiply the passed $src_* values so that they will relate to the original image size, according to $src_display_* if ($rel_width != -1) { $widthRatio = $entry->getWidth() / $rel_width; $src_x = $src_x * $widthRatio; $src_w = $src_w * $widthRatio; } if ($rel_height != -1) { $heightRatio = $entry->getHeight() / $rel_height; $src_y = $src_y * $heightRatio; $src_h = $src_h * $heightRatio; } if (!$entry) { // get the widget $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND); } // get the kshow $kshow_id = $widget->getKshowId(); $kshow = kshowPeer::retrieveByPK($kshow_id); if ($kshow) { $entry_id = $kshow->getShowEntryId(); } else { $entry_id = $widget->getEntryId(); } $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } } $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB; if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA; } $dataKey = $entry->getSyncKey($subType); list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($dataKey, true, false); $tempThumbPath = null; $entry_status = $entry->getStatus(); // both 640x480 and 0x0 requests are probably coming from the kdp // 640x480 - old kdp version requesting thumbnail // 0x0 - new kdp version requesting the thumbnail of an unready entry // we need to distinguish between calls from the kdp and calls from a browser: <img src=...> // that can't handle swf input if (($width == 640 && $height == 480 || $width == 0 && $height == 0) && ($entry_status == entryStatus::PRECONVERT || $entry_status == entryStatus::IMPORT || $entry_status == entryStatus::ERROR_CONVERTING || $entry_status == entryStatus::DELETED)) { $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/bigthumbnail/"; if ($entry_status == entryStatus::DELETED) { $msgPath .= $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK ? "entry_blocked.swf" : "entry_deleted.swf"; } else { $msgPath .= $entry_status == entryStatus::ERROR_CONVERTING ? "entry_error.swf" : "entry_converting.swf"; } kFile::dumpFile($msgPath, null, 0); } if (!$file_sync) { // if entry type is audio - serve generic thumb: if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) { if ($entry->getStatus() == entryStatus::DELETED && $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) { KalturaLog::log("rejected audio entry - not serving thumbnail"); KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/thumbnail/audio_thumb.jpg"; $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath); //kFile::dumpFile($tempThumbPath, null, 0); } elseif ($entry->getType() == entryType::LIVE_STREAM) { if ($entry->getStatus() == entryStatus::DELETED && $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) { KalturaLog::log("rejected live stream entry - not serving thumbnail"); KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg"; $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath); } elseif ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) { $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.jpg"; $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath); //kFile::dumpFile($tempThumbPath, null, 0); } elseif ($entry->getType() == entryType::MEDIA_CLIP) { // commenting out the new behavior, in this case the thumbnail will be created in resizeEntryImage //$contentPath = myContentStorage::getFSContentRootPath(); //$msgPath = $contentPath."content/templates/entry/thumbnail/broken_thumb.jpg"; //header("Xkaltura-app: entry [$entry_id] in conversion, returning template broken thumb"); //KalturaLog::log( "Entry in conversion, no thumbnail yet [$entry_id], created dynamic 1x1 jpg"); //kFile::dumpFile($msgPath, null, 0); try { $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices); } catch (Exception $ex) { if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) { // get original flavor asset $origFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id); if ($origFlavorAsset) { $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false); if (!$remoteFileSync) { // file does not exist on any DC - die KalturaLog::log("Error - no FileSync for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) { KalturaLog::log("ERROR - Trying to redirect to myself - stop here."); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } $remote_url = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync, $_SERVER['REQUEST_URI']); KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]"); $this->redirect($remote_url); } } } } else { // file does not exist on any DC - die KalturaLog::log("Error - no FileSync for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } } if (!$local && !$tempThumbPath) { $remote_url = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']); KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]"); $this->redirect($remote_url); } // if we didnt return a template for the player die and dont return the original deleted thumb if ($entry_status == entryStatus::DELETED) { KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } if (!$tempThumbPath) { try { $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices); } catch (Exception $ex) { if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) { // get original flavor asset $origFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id); if ($origFlavorAsset) { $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false); if (!$remoteFileSync) { // file does not exist on any DC - die KalturaLog::log("Error - no FileSync for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) { KalturaLog::log("ERROR - Trying to redirect to myself - stop here."); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } $remote_url = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync, $_SERVER['REQUEST_URI']); KalturaLog::log(__METHOD__ . ": redirecting to [{$remote_url}]"); $this->redirect($remote_url); } } } } $nocache = strpos($tempThumbPath, "_NOCACHE_") !== false; // notify external proxy, so it'll cache this url if (!$nocache && requestUtils::getHost() == kConf::get("apphome_url") && file_exists($tempThumbPath)) { self::notifyProxy($_SERVER["REQUEST_URI"]); } // cache result if (!$nocache) { $requestKey = $_SERVER["REQUEST_URI"]; $cache = new myCache("thumb", 86400 * 30); // 30 days $cache->put($requestKey, $tempThumbPath); } kFile::dumpFile($tempThumbPath, null, $nocache ? 0 : null); // TODO - can delete from disk assuming we caneasily recreate it and it will anyway be cached in the CDN // however dumpfile dies at the end so we cant just write it here (maybe register a shutdown callback) }
private function createGenericWidgetHtml2($partner_id, $subp_id, $puser_id) { $widget_id = $this->getP("widget_id"); $kshow_id = $this->getP("kshow_id"); $entry_id = $this->getP("entry_id"); $widget_type = $this->getP("widget_type", 1); // TODO -decide on a good default; $host = $this->getP("host", null); $WIDGET_HOST = requestUtils::getHost(); // add the version as an additional parameter $domain = $host ? "http://" . $host : $WIDGET_HOST; $swf_url = "/index.php/extwidget/kwidget/wid/{$widget_id}/kid/{$kshow_id}"; $height = 0; $width = 0; $widget = widgetPeer::retrieveByPK($widget_id); if ($widget) { $ui_conf = $widget->getUiConf(); if ($ui_conf) { $height = $ui_conf->getHeight(); $width = $ui_conf->getWidth(); } } if (!$height) { $height = 300 + 105 + 20; } if (!$width) { $width = 400; } $params = array(); if ($kshow_id) { $params[] = "kshowId={$kshow_id}"; } if ($entry_id) { $params[] = "entryId={$entry_id}"; } $flash_vars = implode("&", $params); $widget = '<object id="kaltura_player_' . (int) microtime(true) . '" type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all" allowFullScreen="true" height="' . $height . '" width="' . $width . '" data="' . $domain . $swf_url . '">' . '<param name="allowScriptAccess" value="always" />' . '<param name="allowNetworking" value="all" />' . '<param name="allowFullScreen" value="true" />' . '<param name="bgcolor" value=#000000 />' . '<param name="movie" value="' . $domain . $swf_url . '"/>' . '<param name="flashVars" value="' . $flash_vars . '"/>' . '<param name="wmode" value="opaque"/>' . "<a href='http://www.kaltura.com' style='color:#bcff63; text-decoration:none; '>Kaltura</a>" . '</object>'; $html = "<div>{$widget}</div><br><div><code>" . htmlentities($widget) . "</code>"; return $html; }
public static function createWidget($kshow, $entry_id = null, $parent_widget_obj_or_id = null, $ui_conf_id = 1, $custom_data = null, $partner_data = null, $security_type = null) { $widget = new widget(); $widget->setKshowId($kshow->getId()); $widget->setEntryId($entry_id); $widget->setPartnerId($kshow->getPartnerId()); $widget->setSubpId($kshow->getSubpId()); $source_widget = null; if ($parent_widget_obj_or_id != null) { if ($parent_widget_obj_or_id instanceof widget) { $source_widget = $parent_widget_obj_or_id; $widget->setSourceWidgetId($parent_widget_obj_or_id->getId()); } else { // assume its an id $source_widget = widgetPeer::retrieveByPK($parent_widget_obj_or_id); $widget->setSourceWidgetId($parent_widget_obj_or_id); } } $widget->setUiConfId($ui_conf_id); if ($source_widget) { $widget->setRootWidgetId($source_widget->getRootWidgetId()); if ($ui_conf_id == null) { // if none was explicitly set - use the parent_widget's ui_conf $widget->setUiConfId($source_widget->getUiConfId()); } } $widget->setCustomData($custom_data); $widget->setPartnerData($partner_data); $widget->setSecurityType($security_type); $widget->setId(self::calculateId($widget)); if ($widget->getUiConfId() == null) { // set the default to be 1 $widget->setUiConfId(1); } if ($widget->getRootWidgetId() == null) { // set the root to be self - $widget->setRootWidgetId($widget->getId()); } $widget->save(); return $widget; }
/** * 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); }
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()); }
public function execute() { sfView::SUCCESS; $this->module = $this->getP("module", "dashboard"); $this->partner_id = $this->getP("partner_id"); $this->subp_id = $this->getP("subp_id"); $this->uid = $this->getP("uid"); $this->ks = $this->getP("ks"); $this->screen_name = $this->getP("screen_name"); $this->email = $this->getP("email"); $this->allow_reports = false; $this->beta = $this->getRequestParameter("beta"); $this->embed_code = ""; $this->ui_conf_width = ""; $this->ui_conf_height = ""; if ($this->partner_id !== null) { $widget = widgetPeer::retrieveByPK("_" . $this->partner_id); if ($widget) { $this->embed_code = $widget->getWidgetHtml("kaltura_player"); $ui_conf = $widget->getuiConf(); // $this->ui_conf_width = 0; // $ui_conf->getWidth(); // $this->ui_conf_height = 0 ; // $ui_conf->getHeight(); } } $this->partner = $partner = null; $this->templatePartnerId = 0; if ($this->partner_id !== NULL) { $this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id); kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, $this->uid, $this->screen_name, $this->email, 1); $this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : 0; } $this->payingPartner = 'false'; if ($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE) { $this->payingPartner = 'true'; } $this->visibleCT = 'false'; if (kConf::get('kmc_content_enable_commercial_transcoding') && $partner) { // 2009-08-27 is the date we added ON2 to KMC trial account if ($partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE || $partner->getType() == 1 && strtotime($partner->getCreatedAt()) >= strtotime('2009-08-27')) { $this->visibleCT = 'true'; } } // 2009-08-27 is the date we added ON2 to KMC trial account // TODO - should be depracated if (strtotime($partner->getCreatedAt()) >= strtotime('2009-08-27') || $partner->getEnableAnalyticsTab()) { $this->allow_reports = true; } if ($partner->getEnableAnalyticsTab()) { $this->allow_reports = true; } // set content kdp version according to partner id $moderated_partners = array(31079, 28575, 32774); $this->content_kdp_version = 'v2.7.0'; if (in_array($this->partner_id, $moderated_partners)) { $this->content_kdp_version = 'v2.1.2.29057'; } /* $c = $this->getCritria(); $c->addAnd ( uiConfPeer::TAGS, "%playlist%" , Criteria::LIKE ); // $c->addAnd ( uiConfPeer::TAGS, "%jwplaylist%" , Criteria::NOT_LIKE ); // */ $this->playlist_uiconf_list = $this->getUiconfList('playlist'); /* $c = $this->getCritria(); $c->addAnd ( uiConfPeer::TAGS, "%player%" , Criteria::LIKE ); // $c->addAnd ( uiConfPeer::TAGS, "%jwplayer%" , Criteria::NOT_LIKE ); // */ $this->player_uiconf_list = $this->getUiconfList('player'); $this->first_login = false; if ($partner) { $this->first_login = $partner->getIsFirstLogin(); if ($this->first_login === true) { $partner->setIsFirstLogin(false); $partner->save(); } $this->jw_license = $partner->getLicensedJWPlayer(); } // if the email is empty - it is an indication that the kaltura super user is logged in if (!$this->email) { $this->allow_reports = true; } /* applications versioning */ $this->kmc_content_version = 'v1.1.11'; $this->kmc_account_version = 'v1.1.7'; $this->kmc_appstudio_version = 'v1.2.4'; $this->kmc_rna_version = 'v1.0.5'; $this->kmc_dashboard_version = 'v1.0.1'; $this->jw_uiconfs_array = $this->getJWPlayerUIConfs(); $this->jw_uiconf_playlist = $this->getJWPlaylistUIConfs(); if (!$this->module) { $this->redirect("kmc/kmc"); die; } }