-
Notifications
You must be signed in to change notification settings - Fork 18
/
esi.php
61 lines (47 loc) · 2.25 KB
/
esi.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
<?php
/***************************************************************************
* *
* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev *
* *
* This is commercial software, only users who have purchased a valid *
* license and accept to the terms of the License Agreement can install *
* and use this program. *
* *
****************************************************************************
* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *
****************************************************************************/
use Tygh\BlockManager\Block;
use Tygh\BlockManager\Grid;
use Tygh\BlockManager\RenderManager;
define('AREA', 'C');
// In case of this file is symlinked to the CS-Cart installation directory,
// there will be no 'init.php' file at the __DIR__ directory.
$root_dir = __DIR__;
if (isset($_SERVER['SCRIPT_FILENAME']) && dirname($_SERVER['SCRIPT_FILENAME']) != $root_dir) {
$root_dir = dirname($_SERVER['SCRIPT_FILENAME']);
}
if (isset($_REQUEST['block_id'],
$_REQUEST['snapping_id'],
$_REQUEST['lang_code'],
$_REQUEST['requested_uri']
)) {
$block_id = (int)$_REQUEST['block_id'];
$snapping_id = (int)$_REQUEST['snapping_id'];
$lang_code = $_REQUEST['lang_code'];
$requested_uri = rawurldecode($_REQUEST['requested_uri']);
$_SERVER['QUERY_STRING'] = parse_url($requested_uri, PHP_URL_QUERY);
$_SERVER['REQUEST_URI'] = $requested_uri;
require_once $root_dir . '/init.php';
$block = Block::instance()->getById($block_id, $snapping_id, array(), $lang_code);
$parent_grid = Grid::getById($block['grid_id'], $lang_code);
$content = RenderManager::renderBlock($block, $parent_grid, 'C', array(
'esi_enabled' => false,
'use_cache' => false,
'parse_js' => false,
));
header('Content-Type: text/html');
header('X-ESI-Response: true');
echo $content;
exit;
}