forked from fluxapps/OnlyOffice
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsave.php
More file actions
57 lines (42 loc) · 1.55 KB
/
save.php
File metadata and controls
57 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
use ILIAS\Plugin\OnlyOffice\CryptoService\JwtService;
use ILIAS\Plugin\OnlyOffice\Form\PluginConfigForm;
require_once dirname(__DIR__, 8) . '/vendor/composer/vendor/autoload.php';
initializeILIAS();
global $DIC;
if (($body_stream = file_get_contents("php://input")) === false) {
echo "Bad Request";
}
$encrypted = json_decode($body_stream, true);
$plugin = ilOnlyOfficePlugin::getInstance();
$secret = $plugin->settings->get(PluginConfigForm::KEY_ONLYOFFICE_SECRET, "");
$decrypted = JwtService::jwtDecode($encrypted['token'], $secret);
$data = json_decode($decrypted, true);
if ($data["status"] === 2) {
$DIC->logger()->root()->info("Save File");
$httpWrapper = $DIC->http()->wrapper();
$refinery = $DIC->refinery();
$uuid = $httpWrapper->query()->retrieve("uuid", $refinery->kindlyTo()->string());
$file_id = $httpWrapper->query()->retrieve("file_id", $refinery->kindlyTo()->int());
$file_ext = $httpWrapper->query()->retrieve("ext", $refinery->kindlyTo()->string());
try {
$callback_handler = new xonoCallbackHandler($DIC, $uuid, $file_id, $data);
$callback_handler->handleCallback();
} catch (Exception $e) {
echo $e->getMessage();
}
}
echo json_encode(["error" => 0], JSON_THROW_ON_ERROR);
exit;
//-------------------------------------------------------------------
function initializeILIAS(): void
{
try {
ilContext::init(ilContext::CONTEXT_SOAP_NO_AUTH);
ilInitialisation::initILIAS();
}
catch (Exception $exception) {
echo "Bad Request";
exit;
}
}