Exemplo n.º 1
0
 public function dispatch($service, $action, $params = array())
 {
     KalturaLog::debug("Dispatching service [" . $service . "], action [" . $action . "] with params " . print_r($params, true));
     $start = microtime(true);
     // prevent impersonate to partner zero
     $p = isset($params["p"]) && $params["p"] ? $params["p"] : null;
     if (!$p) {
         $p = isset($params["partnerId"]) && $params["partnerId"] ? $params["partnerId"] : null;
     }
     $GLOBALS["partnerId"] = $p;
     // set for logger
     $userId = "";
     $ksStr = isset($params["ks"]) ? $params["ks"] : null;
     if (!$service) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_NOT_SPECIFIED);
     }
     try {
         // load the service reflector
         $reflector = new KalturaServiceReflector($service);
     } catch (Exception $ex) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_DOES_NOT_EXISTS, $service);
     }
     // check if action exists
     if (!$action) {
         throw new KalturaAPIException(KalturaErrors::ACTION_NOT_SPECIFIED, $service);
     }
     if (!$reflector->isActionExists($action)) {
         throw new KalturaAPIException(KalturaErrors::ACTION_DOES_NOT_EXISTS, $action, $service);
     }
     $actionParams = $reflector->getActionParams($action);
     // services.ct - check if partner is allowed to access service ...
     // validate it's ok to access this service
     $deserializer = new KalturaRequestDeserializer($params);
     $arguments = $deserializer->buildActionArguments($actionParams);
     $serviceInstance = $reflector->getServiceInstance();
     kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : null;
     kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
     kCurrentContext::$ps_vesion = "ps3";
     kCurrentContext::$service = $reflector->getServiceName();
     kCurrentContext::$action = $action;
     kCurrentContext::$client_lang = isset($params['clientTag']) ? $params['clientTag'] : null;
     kCurrentContext::initKsPartnerUser($ksStr, $p, $userId);
     kPermissionManager::init(kConf::get('enable_cache'));
     // initialize the service before invoking the action on it
     $serviceInstance->initService($reflector->getServiceId(), $reflector->getServiceName(), $action);
     $invokeStart = microtime(true);
     KalturaLog::debug("Invoke start");
     $res = $reflector->invoke($action, $arguments);
     KalturaLog::debug("Invoke took - " . (microtime(true) - $invokeStart) . " seconds");
     KalturaLog::debug("Disptach took - " . (microtime(true) - $start) . " seconds");
     $this->clearMemory();
     return $res;
 }
Exemplo n.º 2
0
// needed for testmeDoc
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*"));
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "generator"));
// needed for testmeDoc
KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/plugins/' . basename(__FILE__) . '.cache');
//KAutoloader::dumpExtra();
KAutoloader::register();
// Timezone
date_default_timezone_set(kConf::get("date_default_timezone"));
// America/New_York
error_reporting(E_ALL);
KalturaLog::setLogger(new KalturaStdoutLogger());
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
kCurrentContext::$ps_vesion = 'ps3';
$entryId = '0_bs1fapzx';
/*$matches = null;
if (preg_match ( "/x0y.*.err/" , '/pub/in/x0y.title.err' , $matches))
{
	print_r($matches);
	print_r(preg_split ("/\./", $matches[0]));
}
else
{
 echo 'non';
}
return;
if(isset($argv[1]))
	$entryId = $argv[1];
 private function setServiceConfigFromPartner($partner)
 {
     $service_name = str_replace("Action", "", get_class($this));
     // service name is the class name without the word Action
     if ($partner && $partner->getStatus() == Partner::PARTNER_STATUS_CONTENT_BLOCK) {
         $partner_services_config = $partner->getServiceConfigId();
         $partner->setServiceConfigId(Partner::CONTENT_BLOCK_SERVICE_CONFIG_ID);
         $this->service_config = myPartnerUtils::getServiceConfig($partner);
         $partner->setServiceConfigId($partner_services_config);
     } elseif ($partner && $partner->getStatus() == Partner::PARTNER_STATUS_FULL_BLOCK) {
         $partner_services_config = $partner->getServiceConfigId();
         $partner->setServiceConfigId(Partner::FULL_BLOCK_SERVICE_CONFIG_ID);
         $this->service_config = myPartnerUtils::getServiceConfig($partner);
         $partner->setServiceConfigId($partner_services_config);
     } else {
         $this->service_config = myPartnerUtils::getServiceConfig($partner);
     }
     kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : gethostname();
     kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
     kCurrentContext::$ps_vesion = "ps2";
     kCurrentContext::$service = "partnerservices2";
     kCurrentContext::$action = $service_name;
     $this->service_config->setServiceName($service_name);
 }
Exemplo n.º 4
0
 public function dispatch($service, $action, $params = array())
 {
     $start = microtime(true);
     // prevent impersonate to partner zero
     $p = isset($params["p"]) && $params["p"] ? $params["p"] : null;
     if (!$p) {
         $p = isset($params["partnerId"]) && $params["partnerId"] ? $params["partnerId"] : null;
     }
     $GLOBALS["partnerId"] = $p;
     // set for logger
     $userId = "";
     $ksStr = isset($params["ks"]) ? $params["ks"] : null;
     if (!$service) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_NOT_SPECIFIED);
     }
     //strtolower on service - map is indexed according to lower-case service IDs
     $service = strtolower($service);
     $serviceActionItem = KalturaServicesMap::retrieveServiceActionItem($service, $action);
     $action = strtolower($action);
     if (!isset($serviceActionItem->actionMap[$action])) {
         KalturaLog::crit("Action does not exist!");
         throw new KalturaAPIException(KalturaErrors::ACTION_DOES_NOT_EXISTS, $action, $service);
     }
     try {
         $actionReflector = new KalturaActionReflector($service, $action, $serviceActionItem->actionMap[$action]);
     } catch (Exception $e) {
         throw new Exception("Could not create action reflector for service [{$service}], action [{$action}]. Received error: " . $e->getMessage());
     }
     $actionParams = $actionReflector->getActionParams();
     $actionInfo = $actionReflector->getActionInfo();
     // services.ct - check if partner is allowed to access service ...
     kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : gethostname();
     kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
     kCurrentContext::$ps_vesion = "ps3";
     kCurrentContext::$service = $serviceActionItem->serviceInfo->serviceName;
     kCurrentContext::$action = $action;
     kCurrentContext::$client_lang = isset($params['clientTag']) ? $params['clientTag'] : null;
     kCurrentContext::initKsPartnerUser($ksStr, $p, $userId);
     // validate it's ok to access this service
     $deserializer = new KalturaRequestDeserializer($params);
     $this->arguments = $deserializer->buildActionArguments($actionParams);
     KalturaLog::debug("Dispatching service [" . $service . "], action [" . $action . "], reqIndex [" . kCurrentContext::$multiRequest_index . "] with params " . print_r($this->arguments, true));
     $responseProfile = $deserializer->getResponseProfile();
     if ($responseProfile) {
         KalturaLog::debug("Response profile: " . print_r($responseProfile, true));
     }
     kPermissionManager::init(kConf::get('enable_cache'));
     kEntitlementUtils::initEntitlementEnforcement();
     $disableTags = $actionInfo->disableTags;
     if ($disableTags && is_array($disableTags) && count($disableTags)) {
         foreach ($disableTags as $disableTag) {
             KalturaCriterion::disableTag($disableTag);
         }
     }
     if ($actionInfo->validateUserObjectClass && $actionInfo->validateUserIdParamName && isset($actionParams[$actionInfo->validateUserIdParamName])) {
         //			// TODO maybe if missing should throw something, maybe a bone?
         //			if(!isset($actionParams[$actionInfo->validateUserIdParamName]))
         //				throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, $actionInfo->validateUserIdParamName);
         KalturaLog::debug("validateUserIdParamName: " . $actionInfo->validateUserIdParamName);
         $objectId = $params[$actionInfo->validateUserIdParamName];
         $this->validateUser($actionInfo->validateUserObjectClass, $objectId, $actionInfo->validateUserPrivilege, $actionInfo->validateOptions);
     }
     // initialize the service before invoking the action on it
     // action reflector will init the service to maintain the pluginable action transparency
     $actionReflector->initService($responseProfile);
     $invokeStart = microtime(true);
     KalturaLog::debug("Invoke start");
     try {
         $res = $actionReflector->invoke($this->arguments);
     } catch (KalturaAPIException $e) {
         if ($actionInfo->returnType != 'file') {
             throw $e;
         }
         KalturaResponseCacher::adjustApiCacheForException($e);
         $res = new kRendererDieError($e->getCode(), $e->getMessage());
     }
     kEventsManager::flushEvents();
     KalturaLog::debug("Invoke took - " . (microtime(true) - $invokeStart) . " seconds");
     KalturaLog::debug("Dispatch took - " . (microtime(true) - $start) . " seconds, memory: " . memory_get_peak_usage(true));
     return $res;
 }
Exemplo n.º 5
0
set_time_limit(0);
// check cache before loading anything
require_once __DIR__ . "/../lib/KalturaResponseCacher.php";
$expiry = kConf::hasParam("v3cache_getfeed_default_expiry") ? kConf::get("v3cache_getfeed_default_expiry") : 86400;
$cache = new KalturaResponseCacher(null, kCacheManager::CACHE_TYPE_API_V3_FEED, $expiry);
$cache->checkOrStart();
ob_start();
// Database
DbManager::setConfig(kConf::getDB());
DbManager::initialize();
KalturaLog::debug(">------------------------------------- syndicationFeedRenderer -------------------------------------");
KalturaLog::info("syndicationFeedRenderer-start ");
KalturaLog::debug("getFeed Params [" . print_r(requestUtils::getRequestParams(), true) . "]");
kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : null;
kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
kCurrentContext::$ps_vesion = "ps3";
$feedId = getRequestParameter('feedId');
$entryId = getRequestParameter('entryId');
$limit = getRequestParameter('limit');
$ks = getRequestParameter('ks');
$feedProcessingKey = "feedProcessing_{$feedId}_{$entryId}_{$limit}";
if (function_exists('apc_fetch')) {
    if (apc_fetch($feedProcessingKey)) {
        KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST);
    }
}
try {
    $syndicationFeedRenderer = new KalturaSyndicationFeedRenderer($feedId, $feedProcessingKey, $ks);
    $syndicationFeedRenderer->addFlavorParamsAttachedFilter();
    kCurrentContext::$partner_id = $syndicationFeedRenderer->syndicationFeed->partnerId;
    if (isset($entryId)) {