ILIAS
release_7 Revision v7.30-3-g800a261c036
◀ 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
if
(!empty(
$_SERVER
[
'PHP_AUTH_USER'
]) && !empty(
$_SERVER
[
'PHP_AUTH_PW'
])) {
26
$client
=
$_SERVER
[
'PHP_AUTH_USER'
];
27
$token
=
$_SERVER
[
'PHP_AUTH_PW'
];
28
} elseif (!empty(
$_SERVER
[
'HTTP_AUTHORIZATION'
])) {
29
$basicAuth = explode(
':'
, base64_decode(substr(
$_SERVER
[
'HTTP_AUTHORIZATION'
], 6)));
30
$client
= $basicAuth[0];
31
$token
= $basicAuth[1];
32
}
else
{
33
header(
'HTTP/1.1 401 Authorization Required'
);
34
exit
;
35
}
36
41
if
(
$plugin
) {
46
//require_once __DIR__.'/classes/XapiProxy/vendor/autoload.php';
47
48
chdir(
"../../../../../../../"
);
49
}
else
{
50
chdir(
"../../"
);
51
}
52
56
require_once __DIR__ .
'/classes/XapiProxy/DataService.php'
;
57
DataService::initIlias
(
$client
);
58
62
require_once __DIR__ .
'/classes/XapiProxy/XapiProxy.php'
;
63
$dic
=
$GLOBALS
[
'DIC'
];
64
65
$dic
[
'xapiproxy'
] =
function
(
$c
) use (
$client
,
$token
,
$plugin
) {
66
return
new
XapiProxy
(
$client
,
$token
,
$plugin
);
67
};
68
72
try
{
73
$dic
[
'xapiproxy'
]->initLrs();
74
}
catch
(\Exception
$e
) {
// ?
75
$dic
[
'xapiproxy'
]->log()->error(
$dic
[
'xapiproxy'
]->getLogMessage(
$e
->getMessage()));
76
}
77
78
require_once __DIR__ .
'/classes/XapiProxy/XapiProxyRequest.php'
;
79
require_once __DIR__ .
'/classes/XapiProxy/XapiProxyResponse.php'
;
80
$req
=
new
XapiProxyRequest
();
81
$resp
=
new
XapiProxyResponse
();
82
83
$dic
[
'xapiproxy'
]->setXapiProxyRequest(
$req
);
84
$dic
[
'xapiproxy'
]->setXapiProxyResponse(
$resp
);
85
86
$req
->handle();
$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:11
XapiProxy\XapiProxyResponse
Definition:
XapiProxyResponse.php:8
$c
$c
Definition:
cli.php:37
$client
if($_SERVER['argc']< 4) $client
Definition:
cron.php:12
Vendor\Package\$e
$e
Definition:
example_cleaned.php:31
XapiProxy
Definition:
DataService.php:3
XapiProxy\exit
exit
Definition:
xapiproxy.php:34
XapiProxy\$plugin
$plugin
Definition:
xapiproxy.php:8
XapiProxy\$resp
$resp
Definition:
xapiproxy.php:81
XapiProxy\$req
$req
Definition:
xapiproxy.php:80
$_SERVER
$_SERVER['HTTP_HOST']
Definition:
raiseError.php:10
$dic
$dic
Definition:
result.php:13
$token
$token
Definition:
xapitoken.php:52
Modules
CmiXapi
xapiproxy.php
Generated on Fri Oct 3 2025 21:00:43 for ILIAS by
1.9.4 (using
Doxyfile
)