Skip to content

Commit

Permalink
Fix. CleantalkAntispam handler class fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Apr 27, 2023
1 parent b7547f1 commit 82dbb89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use Cleantalk\CleantalkAntispam;
//require_once "lib/cleantalk-php-patch.php"; -- PHP-FPM

$cleantalk_antispam = new CleantalkAntispam($apikey, $email_field, $user_name_field, $message_field, $type_form);
$cleantalk_antispam->handle();
$api_result = $cleantalk_antispam->handle();
?>

<form method="post">
Expand All @@ -67,7 +67,7 @@ $cleantalk_antispam->handle();
```

## API Response description
API returns PHP object:
API returns (`$api_result`) PHP object:
* allow (0|1) - allow to publish or not, in other words spam or ham
* comment (string) - server comment for requests.
* id (string MD5 HEX hash) - unique request idenifier.
Expand Down
17 changes: 1 addition & 16 deletions lib/CleantalkAntispam.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,7 @@ public function handle()
$ct_result = $ct->isAllowMessage($ct_request);
}

if ($ct_result->allow == 1) {
if ($this->type_form === 'signup') {
echo 'User allowed. Reason ' . $ct_result->comment;
}
if ($this->type_form === 'contact') {
echo 'Message allowed. Reason ' . $ct_result->comment;
}
} else {
if ($this->type_form === 'signup') {
echo 'User forbidden. Reason ' . $ct_result->comment;
}
if ($this->type_form === 'contact') {
echo 'Message forbidden. Reason ' . $ct_result->comment;
}
}
echo '<br /><br />';
return $ct_result;
}

public function frontendScript()
Expand Down

0 comments on commit 82dbb89

Please sign in to comment.