Issues (165)

src/scripts/dicom_web.php (6 issues)

1
<?php 
2
/**
3
 Copyright (C) 2018-2020 KANOUN Salim
4
 This program is free software; you can redistribute it and/or modify
5
 it under the terms of the Affero GNU General Public v.3 License as published by
6
 the Free Software Foundation;
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
 Affero GNU General Public Public for more details.
11
 You should have received a copy of the Affero GNU General Public Public along
12
 with this program; if not, write to the Free Software Foundation, Inc.,
13
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14
 */
15
16
/**
17
 * Proxy sending OHIF Ajax's queries to Orthanc PACS
18
 * Pass only GET request on the /dicom-web/ API
19
 * Check Access grant to user using the Dicom_Web_Access Class
20
 */
21
22
use Proxy\Proxy;
0 ignored issues
show
The type Proxy\Proxy was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use Proxy\Adapter\Guzzle\GuzzleAdapter;
0 ignored issues
show
The type Proxy\Adapter\Guzzle\GuzzleAdapter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use Proxy\Filter\RemoveEncodingFilter;
0 ignored issues
show
The type Proxy\Filter\RemoveEncodingFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use Laminas\Diactoros\Request;
0 ignored issues
show
The type Laminas\Diactoros\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
Session::checkSession(false);
28
$linkpdo=Session::getLinkpdo();
29
30
$userObject=new User($_SESSION['username'], $linkpdo);
31
$permissionDicomWebObject=new Dicom_Web_Access($_SERVER['REQUEST_URI'], $userObject, $_SESSION['role'], $linkpdo);
32
try {
33
	$permissionDicomWeb=$permissionDicomWebObject->getDecision();
34
}catch (Exception $e) {
35
	header('HTTP/1.0 403 Forbidden');
36
	exit();
37
}
38
39
if ($permissionDicomWeb) {   
40
	unset($_GET['page']);
41
    
42
	$calledURL=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
43
    
44
	$finalURI=str_replace("orthanc/", "", $_SERVER['REQUEST_URI']);
45
    
46
	$request=new Request($finalURI, 'GET', 'php://temp', array('Authorization' => "Basic ".base64_encode('dicomWeb:dicomWeb')));
47
    
48
	// Create a guzzle client
49
	$guzzle=new GuzzleHttp\Client();
0 ignored issues
show
The type GuzzleHttp\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
50
    
51
	// Create the proxy instance
52
	$proxy=new Proxy(new GuzzleAdapter($guzzle));
53
    
54
	// Add a response filter that removes the encoding headers.
55
	$proxy->filter(new RemoveEncodingFilter());
56
    
57
	// Forward the request and get the response.
58
	$response=$proxy -> forward($request) -> filter(function($request, $response, $next) {
59
		// Manipulate the request object.
60
		$url = getenv("HOST_URL");
61
		$port = getenv("HOST_PORT");
62
		$protocol = getenv("HOST_PROTOCOL");
63
		$request=$request->withHeader('Forwarded', 'by=localhost;for=localhost;host='.$url.':'.$port.'/orthanc'.';proto='.$protocol);
64
65
		$response=$next($request, $response);
66
        
67
		return $response;
68
	}) -> to($calledURL);
69
    
70
	// Output response to the browser.
71
	(new Narrowspark\HttpEmitter\SapiEmitter)->emit($response);
0 ignored issues
show
The type Narrowspark\HttpEmitter\SapiEmitter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
72
73
}else {
74
	header('HTTP/1.0 403 Forbidden');
75
}
76