Add hidden field for spam

This commit is contained in:
Michael RICOIS 2017-12-13 11:34:56 +01:00
parent e5f83c46b4
commit f51bcf62c9
4 changed files with 17 additions and 2 deletions

View File

@ -17,4 +17,7 @@
height: 150px;
padding: 5px;
width: 700px;
}
input#email2 {
display: none;
}

View File

@ -52,7 +52,13 @@ if (Tools::isSubmit('submitMessage')) {
$fileAttachment['mime'] = $_FILES['fileUpload']['type'];
}
$message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
if (!($from = trim(Tools::getValue('from'))) OR !Validate::isEmail($from)){
if (Tools::getValue('email2') != '') {
$this->errors[] = Tools::displayError('Invalid');
}
elseif (preg_match("/\p{Han}+/u", $message)) {
$this->errors[] = Tools::displayError('Invalid message');
}
elseif (!($from = trim(Tools::getValue('from'))) OR !Validate::isEmail($from)){
$errors[] = Tools::displayError('Invalid e-mail address');
}
elseif ($alert_mode && Suspect::isBannished($from)){

View File

@ -34,8 +34,10 @@
<label for="email">{l s='E-mail address' mod='ant_support_form'}</label>
{if isset($customerThread.email)}
<input type="text" id="email" name="from" value="{$customerThread.email}" readonly="readonly" />
<input type="text" id="email2" name="email2" value="{$customerThread.email}" />
{else}
<input type="text" id="email" name="from" value="{$email}" />
<input type="text" id="email2" name="email2" value="{$email}" />
{/if}
</p>
{if !$PS_CATALOG_MODE}
@ -184,6 +186,7 @@
{literal}
<script>
$(function() {
$('input#email2').val('').hide();
if($('.cant-submit').length>0) {
$('#submitMessage').hide();
}

View File

@ -57,7 +57,10 @@ class ContactController extends ContactControllerCore {
}
$message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
if (Tools::getValue('email2') != '') {
$this->errors[] = Tools::displayError('Invalid e-mail address');
$this->errors[] = Tools::displayError('Invalid');
}
elseif (preg_match("/\p{Han}+/u", $message)) {
$this->errors[] = Tools::displayError('Invalid message');
}
elseif (!($from = trim(Tools::getValue('from'))) OR !Validate::isEmail($from)){
$this->errors[] = Tools::displayError('Invalid e-mail address');