function proxy() { switch ($_SERVER['REQUEST_METHOD']) { case 'POST': $method = 'post'; $body = @file_get_contents('php://input'); break; case 'PUT': $method = 'put'; $body = @file_get_contents('php://input'); break; case 'DELETE': $method = 'delete'; $body = @file_get_contents('php://input'); break; case 'GET': default: $method = 'get'; break; } $request = Request::$method(PccConfig::getPasUrl() . $_SERVER['PATH_INFO'])->setQueryParams($_GET); // get and forward the request headers $headersObj = getallheaders(); $headersArr = array(); $forwardHeaderFound = false; foreach ($headersObj as $key => $value) { if (strtolower($key) == "x-forwarded-for") { $forwardHeaderFound = true; } array_push($headersArr, "{$key}: {$value}"); } // add an x-forwarded-for header if one did not exist if (!$forwardHeaderFound) { $remoteAddr = $_SERVER['REMOTE_ADDR']; array_push($headersArr, "X-Forwarded-For: {$remoteAddr}"); } $request->setHeaders($headersArr); // forward the request body if ($body) { $request->setBody($body); } $response = $request->send(); $response->send(); }
function getExternalDocId($session) { header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1 header("Pragma: no-cache"); //HTTP 1.0 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past $viewingSessionId = $session; // Call PCCIS // DocumentID query parameter already includes the "u" prefix so no need to add here $url = PccConfig::getImagingService() . "/ViewingSession/{$viewingSessionId}"; $acsApiKey = PccConfig::getApiKey(); $options = array('http' => array('method' => 'GET', 'header' => "Accept: application/json\r\n" . "Acs-Api-Key: {$acsApiKey}\r\n")); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); $response = json_decode($result); if (IsNullOrEmptyString($response->origin->documentMarkupId)) { throw new Exception('It appears that the demo is not configured to use PCCIS. Please check the config values in "full-viewer-sample/viewer-webtier/pcc.conifg" and try again.'); } return $response->origin->documentMarkupId; }