Skip to content

New. Integration. QuickCal integration protection implemented. #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions inc/cleantalk-integrations-by-hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@
'setting' => 'forms__registrations_test',
'ajax' => true
),
'QuickCal' => array(
'hook' => 'booked_add_appt',
'setting' => 'forms__contact_forms_test',
'ajax' => true
),
);

add_action('plugins_loaded', function () use ($apbct_active_integrations) {
Expand Down
8 changes: 8 additions & 0 deletions inc/cleantalk-pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,14 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
) {
return 'Login/Signup Popup';
}

// skip QuickCal - has direct integration
if (
apbct_is_plugin_active('quickcal/quickcal.php') &&
Request::getString('action') === 'booked_add_appt'
) {
return 'QuickCal';
}
} else {
/*****************************************/
/* Here is non-ajax requests skipping */
Expand Down
2 changes: 1 addition & 1 deletion js/apbct-public-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_comm-func.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_comm-func.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection_comm-func.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection_comm-func.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection_comm-func.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection_comm-func.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection_comm-func.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/cleantalk-admin-settings-page.min.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions js/src/apbct-public--2--public.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,15 +1136,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3080,15 +3080,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_comm-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -3521,15 +3521,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_ext-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3080,15 +3080,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_ext-protection_comm-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -3521,15 +3521,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_full-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3080,15 +3080,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_full-protection_comm-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -3521,15 +3521,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_int-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3080,15 +3080,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
9 changes: 7 additions & 2 deletions js/src/apbct-public-bundle_int-protection_comm-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -3521,15 +3521,20 @@ function ctAddWCMiddlewares() {
*/
function apbctCatchXmlHttpRequest() {
// 1) Check the page if it needed to catch XHR
if ( document.querySelector('div.wfu_container') !== null ) {
if (
document.querySelector('div.wfu_container') !== null ||
document.querySelector('#newAppointmentForm') !== null ||
document.querySelector('.booked-calendar-shortcode-wrap') !== null
) {
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
// 2) Check the caught request fi it needed to modify
if (
body &&
typeof body === 'string' &&
(
body.indexOf('action=wfu_ajax_action_ask_server') !== -1
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
body.indexOf('action=booked_add_appt') !== -1
)
) {
let addidionalCleantalkData = '';
Expand Down
40 changes: 40 additions & 0 deletions lib/Cleantalk/Antispam/Integrations/QuickCal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Cleantalk\Antispam\Integrations;

class QuickCal extends IntegrationBase
{
/**
* @inheritDoc
*/
public function getDataForChecking($argument)
{
$processed_post = apply_filters('apbct__filter_post', $_POST);
$name = esc_attr($processed_post['booked_appt_name']);
$surname = ( isset($processed_post['booked_appt_surname']) && $processed_post['booked_appt_surname'] ? esc_attr($processed_post['booked_appt_surname']) : false );
$fullname = ( $surname ? $name . ' ' . $surname : $name );
/** @psalm-suppress PossiblyUndefinedStringArrayOffset */
$email = $processed_post['booked_appt_email'];
$data = ct_gfa_dto($processed_post, $email, $fullname)->getArray();

if ( isset($_REQUEST['data']['ct_bot_detector_event_token']) ) {
$data['event_token'] = $_REQUEST['data']['ct_bot_detector_event_token'];
}
if ( isset($_REQUEST['data']['ct_no_cookie_hidden_field']) ) {
$data['ct_no_cookie_hidden_field'] = $_REQUEST['data']['ct_no_cookie_hidden_field'];
}

unset($_REQUEST['data']);

return $data;
}

/**
* @inheritDoc
*/
public function doBlock($message)
{
echo 'error###' . $message;
die();
}
}
Loading