-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
cookie.php
64 lines (51 loc) · 1.88 KB
/
cookie.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
namespace Opencart\Catalog\Controller\Common;
/**
* Class Cookie
*
* @package Opencart\Catalog\Controller\Common
*/
class Cookie extends \Opencart\System\Engine\Controller {
/**
* @return string
*/
public function index(): string {
if ($this->config->get('config_cookie_id') && !isset($this->request->cookie['policy'])) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation((int)$this->config->get('config_cookie_id'));
if ($information_info) {
$this->load->language('common/cookie');
$data['text_cookie'] = sprintf($this->language->get('text_cookie'), $this->url->link('information/information.info', 'language=' . $this->config->get('config_language') . '&information_id=' . $information_info['information_id']));
$data['agree'] = $this->url->link('common/cookie.confirm', 'language=' . $this->config->get('config_language') . '&agree=1');
$data['disagree'] = $this->url->link('common/cookie.confirm', 'language=' . $this->config->get('config_language') . '&agree=0');
return $this->load->view('common/cookie', $data);
}
}
return '';
}
/**
* Confirm
*
* @return void
*/
public function confirm(): void {
$json = [];
if (isset($this->request->get['agree'])) {
$agree = $this->request->get['agree'];
} else {
$agree = '0';
}
if ($this->config->get('config_cookie_id') && !isset($this->request->cookie['policy'])) {
$this->load->language('common/cookie');
$option = [
'expires' => time() + 60 * 60 * 24 * 365,
'path' => $this->config->get('session_path'),
'SameSite' => $this->config->get('config_session_samesite')
];
setcookie('policy', $agree, $option);
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}