Пример #1
0
 public function getRequestParameter($name, $default = null)
 {
     $requestParams = infraRequestUtils::getRequestParams();
     if (array_key_exists($name, $requestParams)) {
         return $requestParams[$name];
     }
     if (isset(self::$shortNames[$name])) {
         $shortName = self::$shortNames[$name];
         if (array_key_exists($shortName, $requestParams)) {
             return $requestParams[$shortName];
         }
     }
     return $default;
 }
Пример #2
0
 protected function __construct($cacheType, $params = null)
 {
     $this->_cacheStoreTypes = kCacheManager::getCacheSectionNames($cacheType);
     if ($params) {
         $this->_params = $params;
     } else {
         $this->_params = infraRequestUtils::getRequestParams();
     }
     parent::__construct();
 }
Пример #3
0
 public static function dumpApiRequest($host, $onlyIfAvailable = false)
 {
     if ($onlyIfAvailable) {
         //validate that the other DC is available before dumping the request
         if (kConf::hasParam('disable_dump_api_request') && kConf::get('disable_dump_api_request')) {
             KalturaLog::info('dumpApiRequest is disabled');
             return;
         }
     }
     if (kCurrentContext::$multiRequest_index > 1) {
         KExternalErrors::dieError(KExternalErrors::MULTIREQUEST_PROXY_FAILED);
     }
     self::closeDbConnections();
     // prevent loop back of the proxied request by detecting the "X-Kaltura-Proxy header
     if (isset($_SERVER["HTTP_X_KALTURA_PROXY"])) {
         KExternalErrors::dieError(KExternalErrors::PROXY_LOOPBACK);
     }
     $get_params = $post_params = array();
     // pass uploaded files by adding them as post data with curl @ prefix
     // signifying a file. the $_FILES[xxx][tmp_name] points to the location
     // of the uploaded file.
     // we preserve the original file name by passing the extra ;filename=$_FILES[xxx][name]
     foreach ($_FILES as $key => $value) {
         $post_params[$key] = "@" . $value['tmp_name'] . ";filename=" . $value['name'];
         if (!is_uploaded_file($value['tmp_name'])) {
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
     }
     foreach ($_POST as $key => $value) {
         $post_params[$key] = $value;
     }
     $url = $_SERVER['REQUEST_URI'];
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' && kConf::hasParam('https_param_salt')) {
         $post_params['apiProtocol'] = 'https_' . kConf::get('https_param_salt');
     }
     if (isset($_SERVER['CONTENT_TYPE'])) {
         if (strtolower($_SERVER['CONTENT_TYPE']) == 'application/json' || strpos(strtolower($_SERVER['CONTENT_TYPE']), 'multipart/form-data') === 0 && isset($_POST['json'])) {
             $post_params = array_merge($post_params, infraRequestUtils::getRequestParams());
         }
     }
     $httpHeader = array("X-Kaltura-Proxy: dumpApiRequest");
     $ipHeader = infraRequestUtils::getSignedIpAddressHeader();
     if ($ipHeader) {
         list($headerName, $headerValue) = $ipHeader;
         $httpHeader[] = $headerName . ": " . $headerValue;
     }
     $ch = curl_init();
     // set URL and other appropriate options
     curl_setopt($ch, CURLOPT_URL, $host . $url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
     curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.11.1");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ch, CURLOPT_POST, TRUE);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
     // Set callback function for body
     curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'kFileUtils::read_body');
     // Set callback function for headers
     curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'kFileUtils::read_header');
     header("X-Kaltura:dumpApiRequest " . kDataCenterMgr::getCurrentDcId());
     // grab URL and pass it to the browser
     $content = curl_exec($ch);
     // close curl resource, and free up system resources
     curl_close($ch);
     KExternalErrors::dieGracefully();
 }