Skip to content

Commit

Permalink
Added check for honeypot field being unset, version 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ImpressionEngineering committed Oct 12, 2021
1 parent dc5e3c6 commit cd6907f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion perch/addons/apps/impeng_cleantalk/admin.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

if ($CurrentUser->logged_in()) {
$this->register_app('impeng_cleantalk', 'CleanTalk Anti Spam', 50, 'CleanTalk anti spam for Perch Forms', '0.3', true);
$this->register_app('impeng_cleantalk', 'CleanTalk Anti Spam', 50, 'CleanTalk anti spam for Perch Forms', '0.4', true);
$this->require_version('impeng_cleantalk', '3.0');

$API = new PerchAPI(1.0, 'impeng_cleantalk');
Expand Down
10 changes: 7 additions & 3 deletions perch/addons/apps/impeng_cleantalk/runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ function impeng_cleantalk_form_handler($SubmittedForm) {
$configFilePath = __DIR__.'/config/config.'.$formKey.'.php';
if(file_exists($configFilePath)) {
include ($configFilePath);
error_log("Config file is:");
error_log( print_r( $configFilePath, true ) );
// error_log("Config file is: ".print_r( $configFilePath, true )) ;
}
else {
include(__DIR__.'/config/config.default.php');
Expand All @@ -39,7 +38,9 @@ function impeng_cleantalk_form_handler($SubmittedForm) {

// check that honeypot field is present
if (!isset($SubmittedForm->data[$honeypotFieldID])) {
error_log("impeng_cleantalk - A submitted form does not have a honneypot field ".print_r($data, true));
// error_log("impeng_cleantalk - A submitted form does not have a honneypot field ".print_r($data, true));
// Honeypot field is not set so this is SPAM, set the honeypot field so Perch processes as spam.
$SubmittedForm->data[$honeypotFieldID] = "Honeypot field is missing, this must be spam";
}

if (isset($SubmittedForm->data[$honeypotFieldID]) && $SubmittedForm->data[$honeypotFieldID] === "") {
Expand Down Expand Up @@ -116,6 +117,9 @@ function impeng_cleantalk_form_handler($SubmittedForm) {
}

}
// Debugging form redispatch issues
// error_log("about to redispatch form: ".print_r($SubmittedForm->data, true));

// prevent passing on js_on field
unset($SubmittedForm->data['js_on']);
//Redispatch all submitted forms to Perch forms regardless of enabled/disabled and CleanTalk result
Expand Down

0 comments on commit cd6907f

Please sign in to comment.