ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
xapiproxy.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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');
59 }
60 
61 require_once '../vendor/composer/vendor/autoload.php';
62 //instead of DataService
65 // DataService::initIlias($client);
66 $dic = $GLOBALS['DIC'];
67 
69 
73 try {
74  $xapiproxy->initLrs();
75 } catch (\Exception $e) {
76  $xapiproxy->log()->error($e->getMessage());
77 }
80 
81 $xapiproxy->setXapiProxyRequest($req);
82 $xapiproxy->setXapiProxyResponse($resp);
83 
84 $req->handle();
const CONTEXT_SCORM
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: DataService.php:21
catch(\Exception $e) $req
Definition: xapiproxy.php:78
$client
static initILIAS()
ilias initialisation
$GLOBALS["DIC"]
Definition: wac.php:30
$token
Definition: xapitoken.php:67
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
static init(string $a_type)
Init context by type.
$dic
Definition: ltiresult.php:33
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:13