Skip to content

Commit

Permalink
fix submit_time
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovct committed Apr 16, 2018
1 parent 93dcfc5 commit 0f2041b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cleantalk/Antispam/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static function CheckSpam(&$arEntity, $bSendEmail = FALSE) {
$ct_request->agent = 'magento2-11';
$ct_request->js_on = $checkjs;
$ct_request->sender_info = $sender_info;
$ct_request->submit_time = isset($_COOKIE['apbct_timestamp']) ? time() - intval($_COOKIE['apbct_timestamp']) : 0;
$ct_request->submit_time = isset($_COOKIE['ct_ps_timestamp']) ? time() - intval($_COOKIE['ct_ps_timestamp']) : 0;

switch ($type) {
case 'comment':
Expand Down
10 changes: 1 addition & 9 deletions Cleantalk/Antispam/Observer/Predispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function process(){


public function execute(Observer $observer){

//Go out if CleanTalk disabled
if(!$this->getConfigValue('ct_enabled'))
return;
Expand Down Expand Up @@ -149,13 +148,6 @@ function CookieTest() {
'cookies_names' => array(),
'check_value' => $this->getConfigValue('ct_access_key'),
);

// Submit time
$apbct_timestamp = time();
setcookie('apbct_timestamp', $apbct_timestamp, 0, '/');
$cookie_test_value['cookies_names'][] = 'apbct_timestamp';
$cookie_test_value['check_value'] .= $apbct_timestamp;

// Pervious referer
if(!empty($_SERVER['HTTP_REFERER'])){
setcookie('apbct_prev_referer', $_SERVER['HTTP_REFERER'], 0, '/');
Expand Down Expand Up @@ -464,7 +456,7 @@ function CheckSpam($arEntity){
$ct_request->agent = 'magento2-11';
$ct_request->js_on = $checkjs;
$ct_request->sender_info = $sender_info;
$ct_request->submit_time = isset($_COOKIE['apbct_timestamp']) ? time() - intval($_COOKIE['apbct_timestamp']) : 0;
$ct_request->submit_time = isset($_COOKIE['ct_ps_timestamp']) ? time() - intval($_COOKIE['ct_ps_timestamp']) : 0;
switch ($type) {
case 'comment':
$timelabels_key = 'mail_error_comment';
Expand Down
5 changes: 3 additions & 2 deletions Cleantalk/Antispam/view/frontend/web/js/cleantalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ function ctSetCookie(c_name,value){

setTimeout(function(){
ctSetCookie("ct_checkjs", "777b374af06bbb4f6fdbda40727b5c3b");
ctSetCookie("ct_timezone", d.getTimezoneOffset()/60*(-1));
}, 1000);
}, 1000);
ctSetCookie("ct_ps_timestamp", Math.floor(new Date().getTime()/1000));
ctSetCookie("ct_timezone", d.getTimezoneOffset()/60*(-1));

0 comments on commit 0f2041b

Please sign in to comment.