storage.php
1.98 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
use Bitrix\Main\Application;
use Bitrix\Main\Config\Configuration;
use Bitrix\Main\Diag\ExceptionHandlerFormatter;
use Bitrix\Main\Engine\Response\AjaxJson;
use Bitrix\Main\Error;
use Bitrix\Main\ErrorCollection;
try
{
require($_SERVER["DOCUMENT_ROOT"]."/desktop_app/headers.php");
if (!defined("BX_FORCE_DISABLE_SEPARATED_SESSION_MODE"))
{
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('%Bitrix24.Disk/([0-9.]+)%i', $_SERVER['HTTP_USER_AGENT']))
{
define("BX_FORCE_DISABLE_SEPARATED_SESSION_MODE", true);
}
}
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
/** @var CAllMain $APPLICATION */
$diskEnabled = false;
if(IsModuleInstalled('disk'))
{
$diskEnabled =
\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) &&
CModule::includeModule('disk');
if($diskEnabled && \Bitrix\Disk\Configuration::REVISION_API >= 5)
{
$storageController = new Bitrix\Disk\Bitrix24Disk\Legacy\StorageController();
$storageController
->setActionName($_REQUEST['action'])
->exec();
}
else
{
$diskEnabled = false;
}
}
if(!$diskEnabled)
{
$APPLICATION->IncludeComponent('bitrix:webdav.disk', '', array('VISUAL' => false));
CMain::FinalActions();
die();
}
}
catch (\Throwable $e)
{
$errorCollection = new ErrorCollection();
$exceptionHandling = Configuration::getValue('exception_handling');
if (!empty($exceptionHandling['debug']))
{
$errorCollection[] = new Error(ExceptionHandlerFormatter::format($e));
if ($e->getPrevious())
{
$errorCollection[] = new Error(ExceptionHandlerFormatter::format($e->getPrevious()));
}
}
if ($e instanceof \Exception || $e instanceof \Error)
{
$exceptionHandler = Application::getInstance()->getExceptionHandler();
$exceptionHandler->writeToLog($e);
}
/** @global \CMain $APPLICATION */
global $APPLICATION;
$APPLICATION->RestartBuffer();
while(ob_end_clean());
Application::getInstance()->end(0, AjaxJson::createError($errorCollection));
}