-
Notifications
You must be signed in to change notification settings - Fork 0
/
seers.php
151 lines (133 loc) · 4.7 KB
/
seers.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* 2007-2020 PrestaShop
*
* 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.txt.
* 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 license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class Seers extends Module
{
public $apisecrekkey = '--------------secretkey---------------';
public function __construct()
{
$this->module_key = 'bf95963c818431a4778551a826a12f86';
$this->name = 'seers';
$this->tab = 'analytics_stats';
$this->author = 'Nick Spencer';
$this->version='1.0.0';
$this->bootstrap=true;
$this->ps_versions_compliancy = array('min' => '1.6.0.0', 'max' => '1.7.99.99');
parent::__construct();
$this->displayName = $this->l('Seers Cookie Consent Banner and Privacy Policy');
$this->description= $this->l('Seers cookie consent management platform is trusted by thousands of businesses. Become GDPR, CCPA, ePrivacy and LGPD compliant in three clicks.');
$this->confirmUninstall = $this->l('Are you sure you want to delete these details?');
}
public function install()
{
$this->plugin_active_inactive(1);
return parent::install() && $this->registerHook('displayHeader');
}
public function disable()
{
$this->plugin_active_inactive(0);
return true;
}
public function uninstall()
{
if (! parent::uninstall()) {
return false;
}
$this->plugin_active_inactive(0);
return true;
}
public function hookDisplayHeader()
{
//adding css
/*
$this->context->controller->addCSS(array(
$this->_path.'views/css/seers.css'
));
// adding JS
$this->context->controller->addJS(array(
$this->_path.'views/js/seers.js'
));
*/
$ID = Configuration::get('SEERSGROUPID');
if ($ID !== '') {
return '<script data-key=
"' . $ID . '" data-name="CookieXray" src="https://seersco.com/script/cb.js" type="text/javascript">
</script>';
}
return $ID;
}
public function getContent()
{
$output = '';
if (Tools::isSubmit('saveseers')) {
$name = strval(Tools::getValue('print'));
if (!empty($name)) {
Configuration::updateValue('SEERSGROUPID', $name);
$output .= $this->displayConfirmation( $this->l('SEERS Group ID updated successfully'));
} else {
$output .= $this->displayError( $this->l('SEERS Group ID update unsuccessful'));
}
}
$this->context->smarty->assign(array('SEERSGROUPID' => Configuration::get('SEERSGROUPID')));
return $output . $this->display(__FILE__, 'views/templates/admin/configure.tpl');
}
public function plugin_active_inactive($isative = 0){
$postData = array(
'domain' => ((Configuration::get('PS_SSL_ENABLED')) ? Configuration::get('PS_SHOP_DOMAIN_SSL') : Configuration::get('PS_SHOP_DOMAIN') ),
'isactive' => $isative,
'secret' => $this->apisecrekkey,
'platform' => 'prestashop',
'pluginname' => $this->displayName
);
$request_headers = array(
'Content-Type' => 'application/json',
'Referer' => ((Configuration::get('PS_SSL_ENABLED')) ? Configuration::get('PS_SHOP_DOMAIN_SSL') : Configuration::get('PS_SHOP_DOMAIN') ),
);
//$url = "https://seersco.backend/api/plugin-domain";
$url = "https://cmp.seersco.com/api/plugin-domain";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => $request_headers,
CURLOPT_POSTFIELDS => $postData
));
$response = curl_exec($curl);
$error_number = curl_errno($curl);
$error_message = curl_error($curl);
curl_close($curl);
$response =json_decode($response, TRUE);
return $response;
}
}