Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabea David committed Sep 26, 2017
2 parents cf654e7 + ab772b4 commit f6c248c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

### 1.0.5 (2017-09-26)

- exclude checkbox fields (if unchecked) from spam count
- because it's a standard browser behaviour that the value of a checkbox is only sent if the checkbox was checked
- this leads to a mismatch while counting fields
- the number of submitted fields does not match the number of fields which are present in the form

### 1.0.4 (2017-09-14)

- extend option `classes`
Expand Down
15 changes: 8 additions & 7 deletions SimpleContactForm.module
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use \Jos\Mailer;
* See README.md for usage instructions.
*
* @author Tabea David <[email protected]>
* @version 1.0.4
* @version 1.0.5
* @copyright Copyright (c) 2017
* @see https://github.com/justonestep/processwire-simplecontactform
* @see http://www.processwire.com
Expand All @@ -30,7 +30,7 @@ class SimpleContactForm extends WireData implements Module {
return array(
'title' => 'Simple Contact Form',
'summary' => 'Just a simple contact form.',
'version' => 103,
'version' => 105,
'href' => 'https://github.com/justonestep/processwire-simplecontactform',
'singular' => true,
'autoload' => true,
Expand Down Expand Up @@ -194,17 +194,18 @@ class SimpleContactForm extends WireData implements Module {
$spamProtector = new SpamProtection();

// exclude markup fields from spam count
$markupFields = 0;
// AND exclude checkbox fields (if unchecked) from spam count
// BECAUSE it's a standard browser behaviour that the value of a checkbox is only sent if the checkbox was checked
$excludeFields = 0;
foreach ($this->allFields as $inputfield) {
if ($field = $this->fields->get($inputfield)) {
if ($field->type instanceof FieldtypeFieldsetOpen || $field->type instanceof FieldtypeFieldsetTabOpen) {
$markupFields++;
}
if ($field->type instanceof FieldtypeFieldsetOpen || $field->type instanceof FieldtypeFieldsetTabOpen) $excludeFields++;
if ($field->type instanceof FieldtypeCheckbox && !$this->input->post->{$field->name}) $excludeFields++;
}
}

$spamProtector
->setCount(count($this->allFields) - $markupFields + count(self::$spamFields))
->setCount(count($this->allFields) - $excludeFields + count(self::$spamFields))
->setTimeRange($this->antiSpamTimeMin, $this->antiSpamTimeMax)
->setSaveMessages($this->saveMessages)
->setExcludeIpAdresses($this->antiSpamExcludeIps)
Expand Down

0 comments on commit f6c248c

Please sign in to comment.