ILIAS
release_8 Revision v8.23
◀ ilDoc Overview
xapiproxy.php
Go to the documentation of this file.
1
<?php
2
3
declare(strict_types=1);
4
21
// hardcoded namespace
22
// attention: maybe a problem with composer v2 / psr4 autoload requires exact matching of namespace and parent folder name?
23
24
namespace
XapiProxy
;
25
26
// hardcoded context for better performance
27
// $plugin = file_exists(__DIR__."/plugin.php"); // for testing
28
$plugin
=
false
;
29
33
if
(strtoupper(
$_SERVER
[
"REQUEST_METHOD"
]) ==
"OPTIONS"
) {
34
header(
'HTTP/1.1 204 No Content'
);
35
header(
'Access-Control-Allow-Origin: '
.
$_SERVER
[
"HTTP_ORIGIN"
]);
36
header(
'Access-Control-Allow-Credentials: true'
);
37
header(
'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'
);
38
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'
);
39
exit
;
40
}
41
45
if
(!empty(
$_SERVER
[
'PHP_AUTH_USER'
]) && !empty(
$_SERVER
[
'PHP_AUTH_PW'
])) {
46
$client
=
$_SERVER
[
'PHP_AUTH_USER'
];
47
$token
=
$_SERVER
[
'PHP_AUTH_PW'
];
48
} elseif (!empty(
$_SERVER
[
'HTTP_AUTHORIZATION'
])) {
49
$basicAuth = explode(
':'
, base64_decode(substr(
$_SERVER
[
'HTTP_AUTHORIZATION'
], 6)));
50
$client
= $basicAuth[0];
51
$token
= $basicAuth[1];
52
}
else
{
53
header(
'HTTP/1.1 401 Authorization Required'
);
54
header(
'Access-Control-Allow-Origin: '
.
$_SERVER
[
"HTTP_ORIGIN"
]);
55
header(
'Access-Control-Allow-Credentials: true'
);
56
header(
'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'
);
57
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'
);
58
exit
;
59
}
60
65
if
(
$plugin
) {
70
//require_once __DIR__.'/classes/XapiProxy/vendor/autoload.php';
71
72
chdir(
"../../../../../../../"
);
73
}
else
{
74
chdir(
"../../"
);
75
}
76
require_once(
"Services/Init/classes/class.ilInitialisation.php"
);
77
//instead of DataService
78
\ilContext::init
(\
ilContext::CONTEXT_SCORM
);
79
\ilInitialisation::initILIAS
();
80
// DataService::initIlias($client);
81
$dic
=
$GLOBALS
[
'DIC'
];
82
83
$xapiproxy
=
new
XapiProxy
(
$client
,
$token
,
$plugin
);
84
88
try
{
89
$xapiproxy
->initLrs();
90
}
catch
(\
Exception
$e
) {
91
$xapiproxy
->log()->error($e->getMessage());
92
}
93
$req
=
new
XapiProxyRequest
(
$xapiproxy
);
94
$resp
=
new
XapiProxyResponse
(
$xapiproxy
);
95
96
$xapiproxy
->setXapiProxyRequest(
$req
);
97
$xapiproxy
->setXapiProxyResponse(
$resp
);
98
99
$req
->handle();
XapiProxy\XapiProxyRequest
Definition:
XapiProxyRequest.php:30
XapiProxy\exit
exit
Definition:
xapiproxy.php:58
XapiProxy\XapiProxyResponse
Definition:
XapiProxyResponse.php:27
ilContext\CONTEXT_SCORM
const CONTEXT_SCORM
Definition:
class.ilContext.php:42
Vendor\Package\$e
$e
Definition:
example_cleaned.php:49
XapiProxy
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition:
DataService.php:21
XapiProxy\$xapiproxy
$xapiproxy
Definition:
xapiproxy.php:83
XapiProxy\$plugin
$plugin
Definition:
xapiproxy.php:28
XapiProxy\$req
catch(\Exception $e) $req
Definition:
xapiproxy.php:93
$client
$client
Definition:
dummy_client.php:43
ilInitialisation\initILIAS
static initILIAS()
ilias initialisation
Definition:
class.ilInitialisation.php:1225
$token
$token
Definition:
xapitoken.php:70
$_SERVER
$_SERVER['HTTP_HOST']
Definition:
raiseError.php:10
XapiProxy\$resp
$resp
Definition:
xapiproxy.php:94
$GLOBALS
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition:
PEAR.php:64
ilContext\init
static init(string $a_type)
Init context by type.
Definition:
class.ilContext.php:52
$dic
$dic
Definition:
result.php:32
Exception
Modules
CmiXapi
xapiproxy.php
Generated on Sun Aug 31 2025 22:01:20 for ILIAS by
1.8.13 (using
Doxyfile
)