Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/api_response_description.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## API Response description
API returns (`$api_result`) PHP object:
* allow (`bool/0|1`) – allow result to be published or not, in other words, spam(`0`) or ham(`1`).
* allow (`int: 0|1`) – allow result to be published or not, in other words, spam(`0`) or ham(`1`).
* comment (`string`) – server comment for requests.
* id (`MD5 hash hex string`) – unique MD5 hash used as request identifier.
* errno (`int`) - error number or `0` if the request is successful.
Expand Down
7 changes: 4 additions & 3 deletions lib/CleantalkAntispam.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ private function verifyData()
$this->checkAccessKey();
} catch (\Exception $e) {
$this->verdict->error = $e->getMessage();
$this->verdict->allow = true;
$this->verdict->allow = 1;
}

try {
$this->checkEventToken();
} catch (\Exception $e) {
if ($this->block_no_js_visitor) {
$this->verdict->error = $e->getMessage();
$this->verdict->allow = false;
$this->verdict->allow = 0;
$this->verdict->comment = 'Please, enable JavaScript to process the form.';
} else {
$this->verdict->allow = true;
$this->verdict->allow = 1;
}
}
}
Expand Down Expand Up @@ -335,6 +335,7 @@ private function checkEventToken()
*/
private function beforeReturnVerdict()
{
$this->verdict->allow = (int) (bool) $this->verdict->allow;
$this->setImprovementSuggestions();
return $this->verdict;
}
Expand Down
7 changes: 6 additions & 1 deletion lib/CleantalkVerdict.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

class CleantalkVerdict
{
public $allow = true;
/**
* Whether the request is allowed, 1|0.
*
* @var int
*/
public $allow = 1;
public $comment = '';
public $error = '';
public $request_link = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/HTTP/CleantalkResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function __construct($obj = null, $failed_urls = null)
$this->stop_words = isset($obj->stop_words) ? Helper::fromUTF8($obj->stop_words, 'ISO-8859-1') : null;
$this->comment = isset($obj->comment) ? strip_tags(Helper::fromUTF8($obj->comment, 'ISO-8859-1'), '<p><a><br>') : null;
$this->blacklisted = isset($obj->blacklisted) ? $obj->blacklisted : null;
$this->allow = isset($obj->allow) ? $obj->allow : 1;
$this->allow = isset($obj->allow) ? (int) (bool) $obj->allow : 1;
$this->id = isset($obj->id) ? $obj->id : null;
$this->fast_submit = isset($obj->fast_submit) ? $obj->fast_submit : 0;
$this->spam = isset($obj->spam) ? $obj->spam : 0;
Expand Down