-
Notifications
You must be signed in to change notification settings - Fork 6
/
ajax-upgradetab.php
113 lines (90 loc) · 3.45 KB
/
ajax-upgradetab.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* Copyright (C) 2017-2019 thirty bees
* Copyright (C) 2007-2016 PrestaShop SA
*
* thirty bees is an extension to the PrestaShop software by PrestaShop SA.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author thirty bees <[email protected]>
* @author PrestaShop SA <[email protected]>
* @copyright 2017-2019 thirty bees
* @copyright 2007-2016 PrestaShop SA
* @license Academic Free License (AFL 3.0)
* PrestaShop is an internationally registered trademark of PrestaShop SA.
*/
use PsOneSixMigrator\Tools;
use PsOneSixMigrator\AjaxProcessor;
if (function_exists('opcache_reset')) {
opcache_reset();
}
if (function_exists('date_default_timezone_set')) {
// date_default_timezone_get calls date_default_timezone_set, which can provide warning
$timezone = @date_default_timezone_get();
date_default_timezone_set($timezone);
}
require_once __DIR__.'/../../config/settings.inc.php';
require_once __DIR__.'/../../modules/psonesixmigrator/classes/autoload.php';
if (!defined('_PS_MODULE_DIR_')) {
define('_PS_MODULE_DIR_', realpath(__DIR__.'/../../').'/modules/');
}
define('AUTOUPGRADE_MODULE_DIR', _PS_MODULE_DIR_.'psonesixmigrator/');
require_once(AUTOUPGRADE_MODULE_DIR.'functions.php');
$request = json_decode(file_get_contents('php://input'));
// the following test confirm the directory exists
if (!isset($request->dir)) {
die('no directory');
}
if (!defined('_PS_ROOT_DIR_')) {
define('_PS_ROOT_DIR_', realpath(__DIR__.'/../../'));
}
require_once __DIR__.'/../../config/defines.inc.php';
require_once(AUTOUPGRADE_MODULE_DIR.'alias.php');
$dir = Tools::safeOutput($request->dir);
if (realpath(__DIR__.'/../../').DIRECTORY_SEPARATOR.$dir !== realpath(realpath(__DIR__.'/../../').DIRECTORY_SEPARATOR.$dir)) {
die('wrong directory :'.(isset($_POST['dir']) ? $dir : ''));
}
define('_PS_ADMIN_DIR_', realpath(__DIR__.'/../../').DIRECTORY_SEPARATOR.$dir);
if (!defined('_MYSQL_ENGINE_')) {
define('_MYSQL_ENGINE_', 'MyISAM');
}
if (!defined('_PS_TOOL_DIR_')) {
define('_PS_TOOL_DIR_', _PS_ROOT_DIR_.'/tools/');
}
//require(_PS_ADMIN_DIR_.'/functions.php');
include(AUTOUPGRADE_MODULE_DIR.'init.php');
$ajaxUpgrader = AjaxProcessor::getInstance();
if (is_object($ajaxUpgrader) && $ajaxUpgrader->verifyToken()) {
$ajaxUpgrader->optionDisplayErrors();
$ajaxUpgrader->ajax = 1;
// the differences with index.php is here
$ajaxUpgrader->ajaxPreProcess();
$action = $request->action;
// no need to use displayConf() here
if (!empty($action) && method_exists($ajaxUpgrader, 'ajaxProcess'.$action)) {
$ajaxUpgrader->{'ajaxProcess'.$action}();
} else {
die(json_encode([
'error' => true,
'status' => 'Method not found',
], JSON_PRETTY_PRINT));
}
if (!empty($action) && method_exists($ajaxUpgrader, 'displayAjax'.$action)) {
$ajaxUpgrader->{'displayAjax'.$action}();
} else {
$ajaxUpgrader->displayAjax();
}
}
die(json_encode([
'error' => true,
'status' => 'Wrong token or request',
], JSON_PRETTY_PRINT));