first commit
This commit is contained in:
123
modules/ets_cfultimate/controllers/front/captcha.php
Normal file
123
modules/ets_cfultimate/controllers/front/captcha.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* 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 contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
class Ets_CfUltimateCaptchaModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->create_image();
|
||||
die;
|
||||
}
|
||||
|
||||
public function create_image()
|
||||
{
|
||||
$security_code = Tools::substr(sha1(mt_rand()), 17, 6);
|
||||
$context = Context::getContext();
|
||||
$captcha_name = Tools::getValue('captcha_name');
|
||||
if (Tools::getValue('page') == 'contact')
|
||||
$context->cookie->$captcha_name = $security_code;
|
||||
else
|
||||
$context->cookie->$captcha_name = $security_code;
|
||||
$context->cookie->write();
|
||||
if (Tools::getValue('theme') == 'colorful') {
|
||||
|
||||
$image = imagecreatetruecolor(150, 35);
|
||||
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$white = imagecolorallocate($image, 255, 255, 255);
|
||||
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
|
||||
$green = imagecolorallocatealpha($image, 0, 255, 0, 75);
|
||||
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
|
||||
|
||||
imagefilledrectangle($image, 0, 0, $width, $height, $white);
|
||||
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
|
||||
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
|
||||
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);
|
||||
imagefilledrectangle($image, 0, 0, $width, 0, $black);
|
||||
imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
|
||||
imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
|
||||
imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);
|
||||
|
||||
imagestring($image, 10, (int)(($width - (Tools::strlen($security_code) * 9)) / 2), (int)(($height - 15) / 2), $security_code, $black);
|
||||
} else {
|
||||
$width = 100;
|
||||
$height = 30;
|
||||
$image = ImageCreate($width, $height);
|
||||
$white = ImageColorAllocate($image, 255, 255, 255);
|
||||
$black = ImageColorAllocate($image, 27, 79, 166);
|
||||
$noise_color = imagecolorallocate($image, 172, 211, 255);
|
||||
$background_color = imagecolorallocate($image, 255, 255, 255);
|
||||
//$text_color = imagecolorallocate($image, 20, 40, 100);
|
||||
ImageFill($image, 0, 0, $background_color);
|
||||
for ($i = 0; $i < ($width * $height) / 3; $i++) {
|
||||
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
|
||||
}
|
||||
for ($i = 0; $i < ($width * $height) / 150; $i++) {
|
||||
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
|
||||
}
|
||||
imagestring($image, 10, 30, 6, $security_code, $black);
|
||||
}
|
||||
header("Content-Type: image/jpeg");
|
||||
ImageJpeg($image);
|
||||
ImageDestroy($image);
|
||||
exit();
|
||||
}
|
||||
|
||||
/*function to convert hex value to rgb array*/
|
||||
protected function hexToRGB($colour)
|
||||
{
|
||||
if ($colour[0] == '#') {
|
||||
$colour = Tools::substr($colour, 1);
|
||||
}
|
||||
if (Tools::strlen($colour) == 6) {
|
||||
list($r, $g, $b) = array($colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5]);
|
||||
} elseif (Tools::strlen($colour) == 3) {
|
||||
list($r, $g, $b) = array($colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$r = hexdec($r);
|
||||
$g = hexdec($g);
|
||||
$b = hexdec($b);
|
||||
return array('r' => $r, 'g' => $g, 'b' => $b);
|
||||
}
|
||||
|
||||
|
||||
/*function to get center position on image*/
|
||||
protected function ImageTTFCenter($image, $text, $font, $size, $angle = 8)
|
||||
{
|
||||
$xi = imagesx($image);
|
||||
$yi = imagesy($image);
|
||||
$box = imagettfbbox($size, $angle, $font, $text);
|
||||
$xr = abs(max($box[2], $box[4])) + 5;
|
||||
$yr = abs(max($box[5], $box[7]));
|
||||
$x = (int)(($xi - $xr) / 2);
|
||||
$y = (int)(($yi + $yr) / 2);
|
||||
return array($x, $y);
|
||||
}
|
||||
}
|
||||
91
modules/ets_cfultimate/controllers/front/contact.php
Normal file
91
modules/ets_cfultimate/controllers/front/contact.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* 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 contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class Ets_CfUltimateContactModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias);
|
||||
}
|
||||
|
||||
if ( Configuration::get('PS_REWRITING_SETTINGS') && $id_contact && (Tools::strpos($_SERVER['REQUEST_URI'],'url_alias')!==false || Tools::strpos($_SERVER['REQUEST_URI'],'id_contact')!==false)){
|
||||
$url = $this->module->getLinkContactForm($id_contact,$this->context->language->id);
|
||||
Tools::redirect($url);
|
||||
}
|
||||
|
||||
$this->module->setMetas($id_contact);
|
||||
|
||||
$ip = Tools::getRemoteAddr();
|
||||
$browser = $this->module->getDevice();
|
||||
if (!Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_log WHERE ip="' . pSQL($ip) . '" AND DAY(datetime_added) ="' . pSQL(date('d')) . '" AND MONTH(datetime_added) ="' . pSQL(date('m')) . '" AND YEAR(datetime_added) ="' . pSQL(date('Y')) . '" AND id_contact=' . (int)$id_contact)) {
|
||||
Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'ets_cfu_log(ip,id_contact,browser,id_customer,datetime_added) VALUES ("' . pSQL($ip) . '","' . (int)$id_contact . '","' . pSQL($browser) . '","' . (int)Context::getContext()->customer->id . '","' . pSQL(date('Y-m-d h:i:s')) . '")');
|
||||
}
|
||||
if (Tools::getValue('action') == 'etsCfuAddLogger') {
|
||||
die(Tools::jsonEncode(array(
|
||||
'sus' => true
|
||||
)));
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
if ($contact->id && $contact->active && $contact->enable_form_page && $this->module->existContact($id_contact) && ($this->context->customer->logged || !$contact->only_customer )) {
|
||||
$contact_form = $this->module->ets_cfu_contact_form($contact->id);
|
||||
$this->context->smarty->assign(array(
|
||||
'form_html' => $this->module->form_html($contact_form),
|
||||
'contact' => $contact,
|
||||
'link_contact' => $this->module->getLinkContactForm($id_contact),
|
||||
));
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('contactform16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/contactform.tpl');
|
||||
}
|
||||
} elseif (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('not-found16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/not-found.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function getBreadcrumbLinks()
|
||||
{
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<'))
|
||||
return;
|
||||
$breadcrumb = parent::getBreadcrumbLinks();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias);
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
$breadcrumb['links'][] = array(
|
||||
'title' => $contact->title,
|
||||
'url' => $this->module->getLinkContactForm($id_contact),
|
||||
);
|
||||
return $breadcrumb;
|
||||
}
|
||||
}
|
||||
31
modules/ets_cfultimate/controllers/front/index.php
Normal file
31
modules/ets_cfultimate/controllers/front/index.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* 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 contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
56
modules/ets_cfultimate/controllers/front/submit.php
Normal file
56
modules/ets_cfultimate/controllers/front/submit.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* 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 contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class Ets_CfUltimateSubmitModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
if ($id = (int)Tools::getValue('_ets_cfu_container_post')) {
|
||||
$item = ets_cfu_contact_form($id);
|
||||
$result = $item->submit();
|
||||
$unit_tag = Tools::getValue('_ets_cfu_unit_tag');
|
||||
$response = array(
|
||||
'into' => '#' . ets_cfu_sanitize_unit_tag($unit_tag),
|
||||
'status' => $result['status'],
|
||||
'message' => $result['message'],
|
||||
);
|
||||
if ('validation_failed' == $result['status']) {
|
||||
$invalid_fields = array();
|
||||
foreach ((array)$result['invalid_fields'] as $name => $field) {
|
||||
$invalid_fields[] = array(
|
||||
'into' => 'span.ets_cfu_form-control-wrap.' . ets_cfu_sanitize_html_class($name),
|
||||
'message' => $field['reason'],
|
||||
'idref' => $field['idref'],
|
||||
);
|
||||
}
|
||||
|
||||
$response['invalidFields'] = $invalid_fields;
|
||||
}
|
||||
die(
|
||||
Tools::jsonEncode($response)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
95
modules/ets_cfultimate/controllers/front/thank.php
Normal file
95
modules/ets_cfultimate/controllers/front/thank.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 ETS-Soft
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
|
||||
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
|
||||
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
|
||||
*
|
||||
* 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 contact us for extra customization service at an affordable price
|
||||
*
|
||||
* @author ETS-Soft <etssoft.jsc@gmail.com>
|
||||
* @copyright 2007-2021 ETS-Soft
|
||||
* @license Valid for 1 website (or project) for each purchase of license
|
||||
* International Registered Trademark & Property of ETS-Soft
|
||||
*/
|
||||
|
||||
class Ets_CfUltimateThankModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias,null,true);
|
||||
}
|
||||
|
||||
if ( Configuration::get('PS_REWRITING_SETTINGS') && $id_contact && (Tools::strpos($_SERVER['REQUEST_URI'],'url_alias')!==false || Tools::strpos($_SERVER['REQUEST_URI'],'id_contact')!==false)){
|
||||
$url = $this->module->getLinkContactForm($id_contact,$this->context->language->id);
|
||||
Tools::redirect($url);
|
||||
}
|
||||
|
||||
$this->module->setMetas($id_contact,true);
|
||||
$ip = Tools::getRemoteAddr();
|
||||
$browser = $this->module->getDevice();
|
||||
if (!Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'ets_cfu_log WHERE ip="' . pSQL($ip) . '" AND DAY(datetime_added) ="' . pSQL(date('d')) . '" AND MONTH(datetime_added) ="' . pSQL(date('m')) . '" AND YEAR(datetime_added) ="' . pSQL(date('Y')) . '" AND id_contact=' . (int)$id_contact)) {
|
||||
Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'ets_cfu_log(ip,id_contact,browser,id_customer,datetime_added) VALUES ("' . pSQL($ip) . '","' . (int)$id_contact . '","' . pSQL($browser) . '","' . (int)Context::getContext()->customer->id . '","' . pSQL(date('Y-m-d h:i:s')) . '")');
|
||||
}
|
||||
if (Tools::getValue('action') == 'etsCfuAddLogger') {
|
||||
die(Tools::jsonEncode(array(
|
||||
'sus' => true
|
||||
)));
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
if ($contact->id && $contact->active && $this->module->existContact($id_contact)) {
|
||||
$contact_form = $this->module->ets_cfu_contact_form($contact->id);
|
||||
$base_url = Ets_CfUltimate::getLinkContactForm($id_contact,(int)Context::getContext()->language->id,'thank');
|
||||
$base_url .=$contact->thank_you_alias;
|
||||
$this->context->smarty->assign(array(
|
||||
'contact' => $contact,
|
||||
'link_contact' => $base_url,
|
||||
'thank_you_page_title' => $contact_form->thank_you_page_title,
|
||||
'thank_you_message' => $contact_form->thank_you_message
|
||||
));
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('thank-page16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/thank-page.tpl');
|
||||
}
|
||||
} elseif (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$this->setTemplate('not-found16.tpl');
|
||||
} else {
|
||||
$this->setTemplate('module:ets_cfultimate/views/templates/front/not-found.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getBreadcrumbLinks()
|
||||
{
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<'))
|
||||
return;
|
||||
$breadcrumb = parent::getBreadcrumbLinks();
|
||||
$id_contact = Tools::getValue('id_contact');
|
||||
if (!$id_contact && ($alias = Tools::getValue('url_alias'))) {
|
||||
$id_contact = ETS_CFU_Contact::getIdContactByAlias($alias,null, true);
|
||||
}
|
||||
$contact = new ETS_CFU_Contact($id_contact, $this->context->language->id);
|
||||
$base_url = Ets_CfUltimate::getLinkContactForm($id_contact,(int)Context::getContext()->language->id,'thank');
|
||||
$breadcrumb['links'][] = array(
|
||||
'title' => $contact->thank_you_page_title,
|
||||
'url' => $base_url,
|
||||
);
|
||||
return $breadcrumb;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user