name = 'htmlbox'; $this->tab = 'front_office_features'; $this->author = 'MyPresta.eu'; $this->mypresta_link = 'https://mypresta.eu/modules/front-office-features/html-box.html'; $this->module_key = '44873542187effe440a9606087efd6e7'; $this->version = '1.7.1'; $this->dir = '/modules/htmlbox/'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('HTMLbox'); $this->description = $this->l('With this module you can put the HTML/JavaScript/CSS code anywhere you want'); $this->mkey = "freelicense"; $this->checkforupdates(); $this->modulehooks['header']['ps15'] = 1; $this->modulehooks['header']['ps16'] = 1; $this->modulehooks['header']['ps17'] = 1; $this->modulehooks['top']['ps15'] = 1; $this->modulehooks['top']['ps16'] = 1; $this->modulehooks['top']['ps17'] = 0; $this->modulehooks['displaytop']['ps15'] = 0; $this->modulehooks['displaytop']['ps16'] = 0; $this->modulehooks['displaytop']['ps17'] = 1; $this->modulehooks['topcolumn']['ps15'] = 0; $this->modulehooks['topcolumn']['ps16'] = 1; $this->modulehooks['topcolumn']['ps17'] = 0; $this->modulehooks['displaynav']['ps15'] = 0; $this->modulehooks['displaynav']['ps16'] = 1; $this->modulehooks['displaynav']['ps17'] = 0; $this->modulehooks['displaynav1']['ps15'] = 0; $this->modulehooks['displaynav1']['ps16'] = 0; $this->modulehooks['displaynav1']['ps17'] = 1; $this->modulehooks['displaynav2']['ps15'] = 0; $this->modulehooks['displaynav2']['ps16'] = 0; $this->modulehooks['displaynav2']['ps17'] = 1; $this->modulehooks['leftcolumn']['ps15'] = 1; $this->modulehooks['leftcolumn']['ps16'] = 1; $this->modulehooks['leftcolumn']['ps17'] = 1; $this->modulehooks['rightcolumn']['ps15'] = 1; $this->modulehooks['rightcolumn']['ps16'] = 1; $this->modulehooks['rightcolumn']['ps17'] = 1; $this->modulehooks['footer']['ps15'] = 1; $this->modulehooks['footer']['ps16'] = 1; $this->modulehooks['footer']['ps17'] = 1; $this->modulehooks['home']['ps15'] = 1; $this->modulehooks['home']['ps16'] = 1; $this->modulehooks['home']['ps17'] = 1; } public function inconsistency($return) { return true; } public function checkforupdates($display_msg = 0, $form = 0) { // ---------- // // ---------- // // VERSION 14 // // ---------- // // ---------- // $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 = htmlboxUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version); } if (htmlboxUpdate::version($this->version) < htmlboxUpdate::version(Configuration::get('updatev_' . $this->name))) { $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]; } } if ($display_msg == 1) { if (htmlboxUpdate::version($this->version) < htmlboxUpdate::version(htmlboxUpdate::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!') . ""; } } } } } static function remove_doublewhitespace($s = null) { return $ret = preg_replace('/([\s])\1+/', ' ', $s); } static function remove_whitespace($s = null) { $ret = preg_replace('/[\s]+/', '', $s); $ret = mysql_escape_string($ret); return $ret; } static function remove_whitespace_feed($s = null) { //$ret = preg_replace('/[\t\n\r\0\x0B]/', ' ', $s); $ret = str_replace("// ", "", $ret); return $ret; } static function smart_clean($s = null) { return $ret = trim(self::remove_doublewhitespace(self::remove_whitespace_feed($s))); } public function installModuleHooks() { foreach ($this->modulehooks AS $modulehook => $value) { if (($this->psversion() == 4 && $value['ps15'] == 1) || ($this->psversion() == 5 && $value['ps15'] == 1) || ($this->psversion() == 6 && $value['ps16'] == 1) || ($this->psversion() == 7 && $value['ps17'] == 1)) { if ($this->registerHook($modulehook) == false) { return false; } } } return true; } public function install() { if (parent::install() == false OR $this->installModuleHooks() == false OR Configuration::updateValue('update_' . $this->name, '0') == false OR Configuration::updateValue('htmlbox_header', '0') == false OR Configuration::updateValue('htmlbox_top', '0') == false OR Configuration::updateValue('htmlbox_leftcol', '0') == false OR Configuration::updateValue('htmlbox_rightcol', '1') == false OR Configuration::updateValue('htmlbox_footercol', '0') == false OR Configuration::updateValue('htmlbox_homecol', '0') == false OR Configuration::updateValue('htmlbox_body', 'enter the code here') == false OR Configuration::updateValue('htmlbox_ssl', '0') == false) { return false; } return true; } public function getContent() { $output = ""; if (Tools::isSubmit('submitSettingsHtmlbox')) { $v = trim($_POST['htmlbox_body']); $v = self::smart_clean($v); $body = $v; Configuration::updateValue('htmlbox_origtiny', Tools::getValue('htmlbox_origtiny')); Configuration::updateValue('htmlbox_disabletiny', Tools::getValue('htmlbox_disabletiny')); Configuration::updateValue('htmlbox_body', $body, true); Configuration::updateValue('htmlbox_ssl', Tools::getValue('htmlbox_ssl')); Configuration::updateValue('htmlbox_home', Tools::getValue('htmlbox_home')); Configuration::updateValue('htmlbox_hook', Tools::getValue('htmlbox_hook')); Configuration::updateValue('htmlbox_logged', Tools::getValue('htmlbox_logged')); Configuration::updateValue('htmlbox_unlogged', Tools::getValue('htmlbox_unlogged')); $output .= '
' . $this->l('Settings updated') . '
'; } $output .= ""; return $output . $this->displayForm(); } public function psversion() { $version = _PS_VERSION_; $exp = $explode = explode(".", $version); return $exp[1]; } public function displayForm() { $form = ''; if (Configuration::get('htmlbox_disabletiny') != 1) { $iso = Language::getIsoById((int)($this->context->language->id)); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'); $ad = dirname($_SERVER["PHP_SELF"]); if (Configuration::get('htmlbox_origtiny') == 1) { $form .= ''; } else { $form .= ''; } $form .= ' '; if (Configuration::get('htmlbox_origtiny') == 1) { $form .= ''; } } $select_options = ''; foreach ($this->modulehooks AS $modulehook => $value) { if ($value['ps17'] == 1) { $select_options .= ""; } } return $form . '

' . $this->l('Appearance of module') . '

'.$this->l('Use this option if you want to create own contents with default rich text editor.').' '.$this->l('Turn it on also if you use some module to extend rich text editor like: ').' TinyMCE pro.'.$this->l('Module will use this extended editor then').'


' . $this->l('JavaScrpt usage') . '

' . $this->l('if you want to use tags remember to disable html purifier') . '
' . $this->l('do the same if you want to use tags') . '
' . $this->l('How to disable HTML purifier') . '
' . $this->checkforupdates(0, 1) . '
' . $this->l('like us on Facebook') . '
' . '
' . $this->l('Proudly developed by') . ' MyPresta.eu
' . ""; } public function prepareBody($body) { $body = str_replace(array( "\rn", "\r", "\n" ), array( ' ', ' ', ' ' ), $body); $body = str_replace("// ", "", $body); return $body; } public function prepareDatas() { $this->context->smarty->assign('page_name', Tools::getValue('controller')); $this->context->smarty->assign('logged', $this->context->customer->isLogged()); $this->context->smarty->assign(array('htmlboxbody' => nl2br(stripslashes($this->prepareBody(Configuration::get('htmlbox_body')))))); $this->context->smarty->assign(array('is_https_htmlbox' => (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on" ? 1 : 0))); $this->context->smarty->assign(array('htmlbox_ssl' => Configuration::get('htmlbox_ssl'))); $this->context->smarty->assign(array('htmlbox_home' => Configuration::get('htmlbox_home'))); } function hookrightColumn($params) { if (Configuration::get('htmlbox_hook') == "rightcolumn") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } function hookleftColumn($params) { if (Configuration::get('htmlbox_hook') == "leftcolumn") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } function hookhome($params) { if (Configuration::get('htmlbox_hook') == "home") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } function hookfooter($params) { if (Configuration::get('htmlbox_hook') == "footer") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } function hookheader($params) { if (Configuration::get('htmlbox_hook') == "header") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } function hooktop($params) { if (Configuration::get('htmlbox_hook') == "top") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } function hookdisplayTop($params) { if (Configuration::get('htmlbox_hook') == "displaytop") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } public function hookdisplayTopColumn($params) { if (Configuration::get('htmlbox_hook') == "topcolumn") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } public function hookdisplayNav1($params) { if (Configuration::get('htmlbox_hook') == "displaynav1") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } public function hookdisplayNav2($params) { if (Configuration::get('htmlbox_hook') == "displaynav2") { $this->prepareDatas(); return $this->display(__FILE__, 'html.tpl'); } } } class htmlboxUpdate extends htmlbox { 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; } } ?>