name = 'cmsproducts';
$this->tab = 'front_office_features';
$this->author = 'MyPresta.eu';
$this->version = '1.5.5';
$this->bootstrap = 1;
$this->mypresta_link = 'https://mypresta.eu/modules/front-office-features/products-on-cms-pages.html';
parent::__construct();
$this->displayName = $this->getTranslator()->trans('Products on CMS pages', array(), 'Modules.CmsProducts.Admin');
$this->description = $this->getTranslator()->trans('Module allows to display lists of products on your shop CMS pages', array(), 'Modules.CmsProducts.Admin');
$this->checkforupdates();
}
public function checkforupdates($display_msg = 0, $form = 0)
{
// ---------- //
// ---------- //
// VERSION 13 //
// ---------- //
// ---------- //
$this->mkey = 'nolicense';
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') . '
' : '') . '
';
}
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 = cmsproductsUpdate::verify($this->name, (isset($this->mkey) ? $this->mkey : 'nokey'), $this->version);
}
if (cmsproductsUpdate::version($this->version) < cmsproductsUpdate::version(Configuration::get('updatev_' . $this->name)))
{
$this->warning = $this->l('New version available, check http://MyPresta.eu for more informations');
}
}
if ($display_msg == 1)
{
if (cmsproductsUpdate::version($this->version) < cmsproductsUpdate::version(cmsproductsUpdate::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 install()
{
if (parent::install())
{
Configuration::updateValue('mypresta_updates', 1);
return true;
}
}
public function getContent()
{
if (Tools::isSubmit('selecttab'))
{
Configuration::updateValue('cmsp_last_tab', Tools::getValue('selecttab'));
}
if (Tools::isSubmit('cmsproducts_hide'))
{
Configuration::updateValue('cmsproducts_hide', Tools::getValue('cmsproducts_hide'));
}
$output = "";
return $output . "".$this->displayForm()."
";
}
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];
}
}
public function displayForm()
{
$form = '';
if (Configuration::get('cmsp_last_tab') == 3)
{
$form .= '
';
}
elseif (Configuration::get('cmsp_last_tab') == 2)
{
$form = '
';
}
elseif (Configuration::get('cmsp_last_tab') == 4)
{
$form = '
';
}
else
{
$form = '
';
}
return '
';
}
}
class cmsproductsUpdate extends cmsproducts
{
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;
}
}
?>