-
Notifications
You must be signed in to change notification settings - Fork 6
/
landing.php
64 lines (54 loc) · 1.87 KB
/
landing.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
<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author Doofinder
* @copyright Doofinder
* @license GPLv3
*/
use PrestaShop\Module\Doofinder\Src\Entity\DoofinderConfig;
use PrestaShop\Module\Doofinder\Src\Entity\DoofinderConstants;
use PrestaShop\Module\Doofinder\Src\Entity\LanguageManager;
$rootPath = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
$configFilePath = $rootPath . '/config/config.inc.php';
if (@file_exists($configFilePath)) {
require_once $configFilePath;
} else {
require_once dirname(__FILE__) . '/../../config/config.inc.php';
}
require_once 'autoloader.php';
if (!defined('_PS_VERSION_')) {
exit;
}
if (!Module::isInstalled('doofinder') || !Module::isEnabled('doofinder')) {
DoofinderConfig::debug('[Landing][Warning] Doofinder module is not installed or is not enabled');
Tools::redirect('index.php?controller=404');
exit;
}
$hashid = Tools::getValue('hashid');
$slug = Tools::getValue('slug');
if (!$hashid || !$slug) {
DoofinderConfig::debug('[Landing][Warning] Hashid and/or slug could not be retrieved: ' . PHP_EOL . '- slug: ' . DoofinderConfig::dump($slug) . '- hashid: ' . DoofinderConfig::dump($hashid));
Tools::redirect('index.php?controller=404');
exit;
}
$idLang = LanguageManager::getLanguageByHashid($hashid);
if (!$idLang) {
DoofinderConfig::debug('[Landing][Warning] Invalid Language ID: ' . DoofinderConfig::dump($idLang));
Tools::redirect('index.php?controller=404');
exit;
}
$link = Context::getContext()->link->getModuleLink(
DoofinderConstants::NAME,
'landing',
['landing_name' => $slug],
null,
$idLang
);
Tools::redirect($link);