* @copyright 2017 Agence Bondaty and Co * @license single * Agence Bondaty and Co */ include('../../config/config.inc.php'); if (!defined('_PS_VERSION_')) { exit; } $tokenCheckage = Tools::getValue('token'); if (Tools::getToken(false) != $tokenCheckage) { die('No Valid Token'); } if (Tools::getValue('checkOK') && Tools::getValue('day') && Tools::getValue('month') && Tools::getValue('year')) { if (Validate::isInt(Tools::getValue('day')) || (Validate::isInt(Tools::getValue('month'))) || (Validate::isInt(Tools::getValue('year')))) { $context = Context::getContext(); $id_shop = (int)$context->shop->id; $sql = 'SELECT `age_restriction` FROM `'._DB_PREFIX_.'checkage` WHERE `id_shop` ="'.(int)$id_shop.'"'; $minAge = Db::getInstance()->getValue($sql); $instantMonth = date('n'); $instantDay = date('j'); $instantYear = date('Y'); $monthSubmit = (int)Tools::getValue('month'); $daySubmit = (int)Tools::getValue('day'); $yearSubmit = (int)Tools::getValue('year'); $ok = ''; $yearControl = $instantYear-$yearSubmit; if ($yearControl>$minAge) { $ok = '1'; } elseif ($yearControl==$minAge and $monthSubmit<$instantMonth) { $ok = '1'; } elseif ($yearControl==$minAge and $monthSubmit==$instantMonth and $daySubmit<=$instantDay) { $ok = '1'; } if (Tools::getValue("checkOK") == '1' && $ok == '1') { $context->cookie->checkOK = '1'; } else { $context->cookie->checkOK = '0'; } } }