ILIAS
release_6 Revision v6.24-5-g0c8bfefb3b8
◀ ilDoc Overview
xapiproxy.php
Go to the documentation of this file.
1
<?
php
2
// hardcoded namespace
3
// attention: maybe a problem with composer v2 / psr4 autoload requires exact matching of namespace and parent folder name?
4
namespace
XapiProxy
;
5
6
// hardcoded context for better performance
7
// $plugin = file_exists(__DIR__."/plugin.php"); // for testing
8
$plugin
=
false
;
9
13
if
(strtoupper(
$_SERVER
[
"REQUEST_METHOD"
]) ==
"OPTIONS"
) {
14
header(
'HTTP/1.1 204 No Content'
);
15
header(
'Access-Control-Allow-Origin: '
.
$_SERVER
[
"HTTP_ORIGIN"
]);
16
header(
'Access-Control-Allow-Credentials: true'
);
17
header(
'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'
);
18
header(
'Access-Control-Allow-Headers: X-Experience-API-Version,Accept,Authorization,Etag,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'
);
19
exit
;
20
}
21
25
// file_put_contents("log.txt",var_export($_SERVER,true),8);
26
27
if
( !empty(
$_SERVER
[
'PHP_AUTH_USER'
]) && !empty(
$_SERVER
[
'PHP_AUTH_PW'
]) )
28
{
29
$client
=
$_SERVER
[
'PHP_AUTH_USER'
];
30
$token
=
$_SERVER
[
'PHP_AUTH_PW'
];
31
}
32
elseif( !empty(
$_SERVER
[
'HTTP_AUTHORIZATION'
]) )
33
{
34
$basicAuth = explode(
':'
, base64_decode(substr(
$_SERVER
[
'HTTP_AUTHORIZATION'
], 6)));
35
$client
= $basicAuth[0];
36
$token
= $basicAuth[1];
37
}
38
else
39
{
40
header(
'HTTP/1.1 401 Authorization Required'
);
41
exit
;
42
}
43
48
if
(
$plugin
) {
53
//require_once __DIR__.'/classes/XapiProxy/vendor/autoload.php';
54
55
chdir(
"../../../../../../../"
);
56
}
57
else
{
58
chdir(
"../../"
);
59
}
60
64
require_once __DIR__.
'/classes/XapiProxy/DataService.php'
;
65
DataService::initIlias
(
$client
);
66
70
require_once __DIR__.
'/classes/XapiProxy/XapiProxy.php'
;
71
$dic
=
$GLOBALS
[
'DIC'
];
72
73
$dic
[
'xapiproxy'
] =
function
(
$c
) use (
$client
,
$token
,
$plugin
) {
74
return
new
XapiProxy
(
$client
,
$token
,
$plugin
);
75
};
76
80
try
{
81
$dic
[
'xapiproxy'
]->initLrs();
82
}
83
catch
(\Exception
$e
) {
// ?
84
$dic
[
'xapiproxy'
]->log()->error(
$dic
[
'xapiproxy'
]->getLogMessage(
$e
->getMessage()));
85
}
86
87
require_once __DIR__.
'/classes/XapiProxy/XapiProxyRequest.php'
;
88
require_once __DIR__.
'/classes/XapiProxy/XapiProxyResponse.php'
;
89
$req
=
new
XapiProxyRequest
();
90
$resp
=
new
XapiProxyResponse
();
91
92
$dic
[
'xapiproxy'
]->setXapiProxyRequest(
$req
);
93
$dic
[
'xapiproxy'
]->setXapiProxyResponse(
$resp
);
94
95
$req
->handle();
96
?>
$GLOBALS
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition:
PEAR.php:64
php
An exception for terminatinating execution or to throw for unit testing.
XapiProxy\DataService\initIlias
static initIlias($client_id)
Definition:
DataService.php:7
XapiProxy\XapiProxyRequest
Definition:
XapiProxyRequest.php:10
XapiProxy\XapiProxyResponse
Definition:
XapiProxyResponse.php:7
$client
if($_SERVER['argc']< 4) $client
Definition:
cron.php:12
Vendor\Package\$c
$c
Definition:
example_cleaned.php:31
Vendor\Package\$e
$e
Definition:
example_cleaned.php:31
XapiProxy
Definition:
DataService.php:3
XapiProxy\exit
exit
Definition:
xapiproxy.php:41
XapiProxy\$plugin
$plugin
Definition:
xapiproxy.php:8
XapiProxy\$resp
$resp
Definition:
xapiproxy.php:90
XapiProxy\$req
$req
Definition:
xapiproxy.php:89
$_SERVER
$_SERVER['HTTP_HOST']
Definition:
raiseError.php:10
$dic
$dic
Definition:
result.php:13
$token
$token
Definition:
xapitoken.php:57
Modules
CmiXapi
xapiproxy.php
Generated on Fri Oct 3 2025 20:00:48 for ILIAS by
1.9.4 (using
Doxyfile
)