name = 'uecookie'; $this->tab = 'Blocks'; $this->author = 'MyPresta.eu'; $this->version = '1.7.8'; $this->module_key = '98954d996259885532adabb50f129a9d'; $this->mypresta_link = 'https://mypresta.eu/modules/front-office-features/european-union-cookie-law.html'; $this->dir = '/modules/uecookie/'; $this->setup = $this->getconf(); $this->psver = $this->psversion(); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('European Union Cookies Law'); $this->description = $this->l('This module displays a nice information about Cookies in your shop'); $this->checkforupdates(); } public function checkforupdates($display_msg = 0, $form = 0) { // ---------- // // ---------- // // VERSION 16 // // ---------- // // ---------- // $this->mkey = "nlc"; if (@file_exists('../modules/' . $this->name . '/key.php')) { @require_once('../modules/' . $this->name . '/key.php'); } else { if (@file_exists(dirname(__FILE__) . $this->name . '/key.php')) { @require_once(dirname(__FILE__) . $this->name . '/key.php'); } else { if (@file_exists('modules/' . $this->name . '/key.php')) { @require_once('modules/' . $this->name . '/key.php'); } } } if ($form == 1) { return '
' . ($this->psversion() == 6 || $this->psversion() == 7 ? '
' . $this->l('MyPresta updates') . '
' : '') . '
' . ($this->psversion() == 5 ? '' . $this->l('MyPresta updates') . '' : '') . '
' . (Tools::isSubmit('submit_settings_updates_now') ? ($this->inconsistency(0) ? '' : '') . $this->checkforupdates(1) : '') . '

' . $this->l('Turn this option on if you want to check MyPresta.eu for module updates automatically. This option will display notification about new versions of this addon.') . '

' . $this->displayName . '

' . $this->l('This is direct link to official addon page, where you can read about changes in the module (changelog)') . '

'; } else { if (defined('_PS_ADMIN_DIR_')) { if (Tools::isSubmit('submit_settings_updates')) { Configuration::updateValue('mypresta_updates', Tools::getValue('mypresta_updates')); } if (Configuration::get('mypresta_updates') != 0 || (bool)Configuration::get('mypresta_updates') != false) { if (Configuration::get('update_' . $this->name) < (date("U") - 259200)) { $actual_version = uecookieUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version); } if (uecookieUpdate::version($this->version) < uecookieUpdate::version(Configuration::get('updatev_' . $this->name)) && Tools::getValue('ajax', 'false') == 'false') { $this->context->controller->warnings[] = '' . $this->displayName . ': ' . $this->l('New version available, check http://MyPresta.eu for more informations') . ' ' . $this->l('More details in changelog') . ''; $this->warning = $this->context->controller->warnings[0]; } } else { if (Configuration::get('update_' . $this->name) < (date("U") - 259200)) { $actual_version = uecookieUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version); } } if ($display_msg == 1) { if (uecookieUpdate::version($this->version) < uecookieUpdate::version(uecookieUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version))) { return "" . $this->l('New version available!') . ""; } else { return "" . $this->l('Module is up to date!') . ""; } } } } } public function inconsistency() { return true; } function install() { if ($this->psversion() == 7) { if (parent::install() == false OR ! $this->registerhook('header') OR ! $this->registerHook('footer') OR ! $this->registerHook('top') OR ! Configuration::updateValue('update_' . $this->name, '0') OR ! Configuration::updateValue('uecookie_opacity', '0.5') OR ! Configuration::updateValue('uecookie_position', '1') OR ! Configuration::updateValue('uecookie_bg', '000000') OR ! Configuration::updateValue('uecookie_shadow', 'FFFFFF') OR ! Configuration::updateValue('uecookie_text', array($this->context->language->id => $this->l('This shop uses cookies and other technologies so that we can improve your experience on our sites.')))) { return false; } else { return true; } } else { if (parent::install() == false OR ! $this->registerHook('footer') OR ! $this->registerHook('top')) { return false; } else { return true; } } } public function psversion($part = 1) { $version = _PS_VERSION_; $exp = $explode = explode(".", $version); if ($part == 1) { return $exp[1]; } if ($part == 2) { return $exp[2]; } if ($part == 3) { return $exp[3]; } if ($part == 4) { return $exp[3]; } } public function getconf() { $var = new stdClass(); $var->uecookie_position = Configuration::get('uecookie_position'); $var->uecookie_bg = Configuration::get('uecookie_bg'); $var->uecookie_shadow = Configuration::get('uecookie_shadow'); $var->uecookie_opacity = Configuration::get('uecookie_opacity'); $var->uecookie_closex = Configuration::get('uecookie_closex'); $var->uecookie_close_txt = Configuration::get('uecookie_close_txt'); $var->uecookie_close_bg = Configuration::get('uecookie_close_bg'); return $var; } public function return_dir() { return _MODULE_DIR_; } public function getContent() { $output = ""; if (Tools::isSubmit('module_settings')) { if (Tools::getValue('uecookie_cleanup') == 1) { Configuration::deleteByName('uecookie_text'); } Configuration::updateValue('uecookie_text', $_POST['uecookie_text'], true); Configuration::updateValue('ueTiny', Tools::getValue('ueTiny', 0)); Configuration::updateValue('uecookie_bg', $_POST['uecookie_bg'], true); Configuration::updateValue('uecookie_closex', $_POST['uecookie_closex']); Configuration::updateValue('uecookie_usex', $_POST['uecookie_usex']); Configuration::updateValue('uecookie_close_bg', $_POST['uecookie_close_bg']); Configuration::updateValue('uecookie_close_txt', $_POST['uecookie_close_txt']); Configuration::updateValue('uecookie_shadow', $_POST['uecookie_shadow'], true); Configuration::updateValue('uecookie_position', Tools::getValue('uecookie_position'), true); Configuration::updateValue('uecookie_opacity', $_POST['uecookie_opacity'], true); Configuration::updateValue('uecookie_lib', Tools::getValue('uecookie_lib', 0), true); Configuration::updateValue('uecookie_x_where', Tools::getValue('uecookie_x_where', 1)); Configuration::updateValue('uecookie_x_fa', Tools::getValue('uecookie_x_fa', 0)); Configuration::updateValue('uecookie_close_anim', Tools::getValue('uecookie_close_anim', 0)); Configuration::updateValue('uecookie_padding', Tools::getValue('uecookie_padding', '')); } return $output . $this->displayForm(); } public function displayForm() { $languages = Language::getLanguages(false); $id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT'); $var = $this->getconf(); global $cookie; $iso = Language::getIsoById((int)($cookie->id_lang)); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'); $ad = dirname($_SERVER["PHP_SELF"]); if ($this->psversion() == 7) { $form = ' '; if (Configuration::get('ueTiny') == 1) { $form .= ''; } else { $form .= ''; $form .= ''; } } $position_top = ""; $position_bottom = ""; if (Configuration::get('uecookie_position') == 1) { $position_top = "checked=\"yes\""; } if (Configuration::get('uecookie_position') == 2) { $position_bottom = "checked=\"yes\""; } $values = Configuration::getInt('uecookie_text'); $content = ""; foreach ($languages as $language) { $content .= '

' . $language['name'] . '

'; } $form .= '

'.$this->l('I am developing this module for free - if you want').' '.$this->l('send me a donation').'

' . $this->l('UE cookie law') . '

' . $content . '
' . $this->l('top') . ' ' . $this->l('bottom') . '
px
' . $this->l('No') . ' ' . $this->l('Yes') . '
' . $this->l('If you are on PrestaShop 1.7 or if your theme does not support font awesome - to use [x] button you have to include font awesome library. Use this option only if you use [x] button and if your website does not use Font Awesome.') . '
' . $this->l('for example: 0.5') . '
' . $this->l('footer') . ' ' . $this->l('header') . '
' . $this->l('Some templates uses own hook to build footer section. In cases like this please use "header" option to include ue notification to front office') . '
' . $this->l('Remove stored configuration before save new settings') . '
' . $this->l('If you will activate this option module will remove existing configuration and then save current configuration to avoid problems with save process of translations. Use this option when you will add new languages to your shop.') . '
'; $form .= $this->checkforupdates(0, 1); return '' . "" . $form; } public function hookFooter($params) { if (Configuration::get('uecookie_lib') != 1) { if ( ! isset($_COOKIE['cookie_ue'])) { $var = $this->getconf(); global $smarty; $smarty->assign('vareu', $var); if ($this->psversion() == 7) { $smarty->assign(array('uecookie' => $message = Configuration::get('uecookie_text', $this->context->language->id))); } else { global $cookie; $smarty->assign(array('uecookie' => $message = Configuration::get('uecookie_text', $cookie->id_lang))); } return $this->display(__file__, 'top.tpl'); } } } public function hookHeader($params) { if (Configuration::get('uecookie_lib') == 1) { if ( ! isset($_COOKIE['cookie_ue'])) { $var = $this->getconf(); global $smarty; $smarty->assign('vareu', $var); if ($this->psversion() == 7) { $smarty->assign(array('uecookie' => $message = Configuration::get('uecookie_text', $this->context->language->id))); } else { global $cookie; $smarty->assign(array('uecookie' => $message = Configuration::get('uecookie_text', $cookie->id_lang))); } return $this->display(__file__, 'top.tpl'); } } } } class uecookieUpdate extends uecookie { public static function version($version) { $version = (int)str_replace(".", "", $version); if (strlen($version) == 3) { $version = (int)$version . "0"; } if (strlen($version) == 2) { $version = (int)$version . "00"; } if (strlen($version) == 1) { $version = (int)$version . "000"; } if (strlen($version) == 0) { $version = (int)$version . "0000"; } return (int)$version; } public static function encrypt($string) { return base64_encode($string); } public static function verify($module, $key, $version) { if (ini_get("allow_url_fopen")) { if (function_exists("file_get_contents")) { $actual_version = @file_get_contents('http://dev.mypresta.eu/update/get.php?module=' . $module . "&version=" . self::encrypt($version) . "&lic=$key&u=" . self::encrypt(_PS_BASE_URL_ . __PS_BASE_URI__)); } } Configuration::updateValue("update_" . $module, date("U")); Configuration::updateValue("updatev_" . $module, $actual_version); return $actual_version; } } ?>