-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathajax-upgradetab.php
More file actions
executable file
·69 lines (53 loc) · 2.04 KB
/
Copy pathajax-upgradetab.php
File metadata and controls
executable file
·69 lines (53 loc) · 2.04 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
<?php
/**
* For the full copyright and license information, please view the
* LICENSE.md file that was distributed with this source code.
*/
use PrestaShop\Module\AutoUpgrade\Router\Router;
use PrestaShop\Module\AutoUpgrade\Task\Runner\SingleTask;
use Symfony\Component\HttpFoundation\Request;
/*
* This file is the entrypoint for all ajax requests during a upgrade, rollback or configuration.
* In order to get the admin context, this file is copied to the admin/autoupgrade folder of your shop when the module configuration is reached.
*
* Calling it from the module/autoupgrade folder will have unwanted consequences on the upgrade and your shop.
*/
ini_set('display_errors', '0');
ob_start();
require_once realpath(dirname(__FILE__) . '/../../modules/autoupgrade') . '/ajax-upgradetabconfig.php';
autoupgrade_require_autoload(dirname(__FILE__));
$request = Request::createFromGlobals();
$container = autoupgrade_init_container($request);
(new \PrestaShop\Module\AutoUpgrade\ErrorHandler($container->getLogger()))->enable();
if (!$container->getCookie()->check($_COOKIE)) {
// If this is an XSS attempt, then we should only display a simple, secure page
if (ob_get_level() && ob_get_length() > 0) {
ob_clean();
}
echo '{wrong token}';
http_response_code(401);
exit(1);
}
$container->loadNecessaryClasses();
$action = $request->get('action');
if (!empty($action)) {
$controller = new SingleTask($container);
$controller->setOptions(['action' => $action]);
$controller->run();
// Clear previous output to ensure the response is a valid JSON
if (ob_get_level() && ob_get_length() > 0) {
ob_clean();
}
echo $controller->getJsonResponse();
} else {
$response = (new Router($container))->handle($request);
// Clear previous output to ensure the response is a valid JSON
if (ob_get_level() && ob_get_length() > 0) {
ob_clean();
}
if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
$response->send();
} else {
echo $response;
}
}