PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Frontend/Form/FrontendFormManager.php +108 -83 2.10.22.15.3 View file →
@@ -112,13 +112,16 @@
112 112 $msg = !empty($isRestricted) ? $isRestricted[0] : '';
113 113 return $formViewer->getConversationalView($hasFile, $msg);
114 114 }
115 115
116 - private function checkEmptySubmission($data, $file)
116 + public function checkEmptySubmission($data, $file)
117 117 {
118 118 $formFields = $this->getFields();
119 119 foreach ($formFields as $key => $field) {
120 120 $fieldType = $field['type'];
121 + if ('button' === $fieldType) {
122 + continue;
123 + }
121 124 $fileUploadFieldTypes = ['file-up', 'advanced-file-up'];
122 125 if ('decision-box' === $fieldType) {
123 126 continue;
124 127 }
@@ -201,13 +204,17 @@
201 204
202 205 if (true === $existAuthFilter) {
203 206 $result = apply_filters('bf_wp_user_auth', $existAuth[0], $_POST, $parameter);
204 207
208 + $result = apply_filters('bitform_filter_wp_user_auth_response', $result, $_POST, $parameter);
209 +
210 + do_action('bitform_wp_user_auth_response', $result, $_POST, $parameter);
211 +
205 212 if (isset($result['auth_type']) && 'register' === $result['auth_type']) {
206 213 if (!$result['success']) {
207 214 return new WP_Error('errors', __($result['message'], 'bit-form'));
208 215 } elseif (isset($result['success'])) {
209 - $redirectPage = $result['redirect_url'];
216 + $redirectPage = $result['redirectPage'];
210 217 $regSuccMsg = $result['message'];
211 218 $newNonce = wp_create_nonce('bitforms_' . $this->_form_id);
212 219 }
213 220 } else {
@@ -272,8 +279,9 @@
272 279 }
273 280 if (!empty($regSuccMsg) && isset($saveResponse['dflt_message'])) {
274 281 $saveResponse['message'] = $regSuccMsg;
275 282 }
283 +
276 284 $saveResponse = IntegrationHandler::maybeSetCronForIntegration($saveResponse, 'create');
277 285 $entryId = $saveResponse['entry_id'];
278 286
279 287 $responseMsg = is_array($saveResponse) && !empty($saveResponse) ? $saveResponse : __('Form Submitted Successfully', 'bit-form');
@@ -294,8 +302,9 @@
294 302 $validated = $this->beforeSubmittedValidate();
295 303 $validated = apply_filters('bitform_filter_form_validation', $validated, $this->_form_id);
296 304
297 305 $entryID = $_REQUEST['entryID'];
306 + $GLOBALS['bf_entry_id'] = $entryID;
298 307 if (is_null($entryID)) {
299 308 return new WP_Error('empty_form', __('Entries id is invalid', 'bit-form'));
300 309 }
301 310 if (true === $validated) {
@@ -316,9 +325,9 @@
316 325 if (isset($result['auth_type']) && 'register' === $result['auth_type']) {
317 326 if (!$result['success']) {
318 327 return new WP_Error('errors', __($result['message'], 'bit-form'));
319 328 } elseif (isset($result['success'])) {
320 - $redirectPage = $result['redirect_url'];
329 + $redirectPage = $result['redirectPage'];
321 330 $regSuccMsg = $result['message'];
322 331 $newNonce = wp_create_nonce('bitforms_' . $this->_form_id);
323 332 }
324 333 } else {
@@ -414,94 +423,20 @@
414 423 }
415 424 if ($this->isTrappedInHoneypot()) {
416 425 return new WP_Error('spam_detection', __('Token verification failed', 'bit-form'));
417 426 }
418 - $captchaSettings = $this->getCaptchaSettings();
419 - $captchaV3Settings = $this->getCaptchaV3Settings();
420 - if ($captchaSettings || $captchaV3Settings) {
421 - $token = $_POST['g-recaptcha-response'];
422 - if (!isset($_POST['g-recaptcha-response'])) {
423 - return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
424 - }
425 - $integrationHandler = new IntegrationHandler(0);
426 - $allFormIntegrations = $integrationHandler->getAllIntegration('app', $captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3');
427 - if (!is_wp_error($allFormIntegrations)) {
428 - foreach ($allFormIntegrations as $integration) {
429 - if (!is_null($integration->integration_type) && $integration->integration_type === ($captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3')) {
430 - $integrationDetails = json_decode($integration->integration_details);
431 - $integrationDetails->id = $integration->id;
432 - $reCAPTCHA = $integrationDetails;
433 - }
434 - }
435 - }
436 - if (!empty($reCAPTCHA->secretKey)) {
437 - $gRecaptchaResponse = HttpHelper::post(
438 - 'https://www.google.com/recaptcha/api/siteverify',
439 - ['secret' => $reCAPTCHA->secretKey, 'response' => $token]
440 - );
441 - $isgReCaptchaVerified = false;
442 - if (!is_wp_error($gRecaptchaResponse)) {
443 - if (
444 - $captchaV3Settings
445 - && !empty($gRecaptchaResponse->score)
446 - && ((float) $gRecaptchaResponse->score < (float) $captchaV3Settings->score)
447 - ) {
448 - wp_send_json_error(
449 - __(
450 - $captchaV3Settings->message,
451 - 'bit-form'
452 - )
453 - );
454 - }
427 + $formCurrentStep = isset($_POST['form-current-step']) ? $_POST['form-current-step'] : null;
455 428
456 - $isgReCaptchaVerified = $gRecaptchaResponse->success;
457 - }
458 - if (!$isgReCaptchaVerified) {
459 - return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
460 - }
461 - }
429 + if (is_wp_error($this->verifyGRecaptcha())) {
430 + return $this->verifyGRecaptcha();
462 431 }
463 432
464 433 /* Implement Turnstile Captcha start */
465 - $turnstileSetting = $this->getTurnstileSettings();
466 - if ($turnstileSetting) {
467 - if (!isset($_POST['cf-turnstile-response'])) {
468 - return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
469 - }
470 - $token = $_POST['cf-turnstile-response'];
471 - $turnstileCaptcha = null;
472 - $integrationHandler = new IntegrationHandler(0);
473 - $turnstileIntegration = $integrationHandler->getAllIntegration('app', 'turnstileCaptcha')[0];
474 - if (!is_wp_error($turnstileIntegration && !is_null($turnstileIntegration->integration_type))) {
475 - $turnstileCaptcha = json_decode($turnstileIntegration->integration_details);
476 - // $integrationDetails->id = $turnstileIntegration->id;
477 - // $turnstileCaptcha = $integrationDetails;
478 - }
479 - if (!is_null($turnstileCaptcha)) {
480 - $isTurnstileCaptchaVerified = false;
481 - $turnstileRecaptchaResponse = HttpHelper::post(
482 - 'https://challenges.cloudflare.com/turnstile/v0/siteverify',
483 - ['secret' => $turnstileCaptcha->secretKey, 'response' => $token]
484 - );
485 - if (!is_wp_error($turnstileRecaptchaResponse)) {
486 - if (!$turnstileRecaptchaResponse->success) {
487 - wp_send_json_error(
488 - __(
489 - 'Cloudflare Turnstile Validation Error: ' . implode(', ', $turnstileRecaptchaResponse->{'error-codes'}),
490 - 'bit-form'
491 - )
492 - );
493 - }
494 -
495 - $isTurnstileCaptchaVerified = $turnstileRecaptchaResponse->success;
496 - }
497 - if (!$isTurnstileCaptchaVerified) {
498 - return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
499 - }
500 - }
434 + if (is_wp_error($this->verifyTurnstileCaptcha())) {
435 + return $this->verifyTurnstileCaptcha();
501 436 }
437 + /* Implement Turnstile Captcha end */
502 438
503 - /* Implement Turnstile Captcha end */
504 439 $existAuth = (new IntegrationHandler($this->_form_id))->getAllIntegration('wp_user_auth', 'wp_auth', 1);
505 440
506 441 // check if user is already logged in and form has auth integration
507 442 do_action('bitform_checked_exist_auth', $this->_form_id, $existAuth);
@@ -568,8 +503,98 @@
568 503 }
569 504 return new WP_Error('unknown_form', __('Form does not exist', 'bit-form'));
570 505 } else {
571 506 return new WP_Error('token_expired', __('Token expired', 'bit-form'));
507 + }
508 + }
509 +
510 + private function verifyGRecaptcha()
511 + {
512 + $captchaSettings = $this->getCaptchaSettings();
513 + $captchaV3Settings = $this->getCaptchaV3Settings();
514 + if ($captchaSettings || $captchaV3Settings) {
515 + $token = $_POST['g-recaptcha-response'];
516 + if (!isset($_POST['g-recaptcha-response'])) {
517 + return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
518 + }
519 + $integrationHandler = new IntegrationHandler(0);
520 + $allFormIntegrations = $integrationHandler->getAllIntegration('app', $captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3');
521 + if (!is_wp_error($allFormIntegrations)) {
522 + foreach ($allFormIntegrations as $integration) {
523 + if (!is_null($integration->integration_type) && $integration->integration_type === ($captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3')) {
524 + $integrationDetails = json_decode($integration->integration_details);
525 + $integrationDetails->id = $integration->id;
526 + $reCAPTCHA = $integrationDetails;
527 + }
528 + }
529 + }
530 + if (!empty($reCAPTCHA->secretKey)) {
531 + $gRecaptchaResponse = HttpHelper::post(
532 + 'https://www.google.com/recaptcha/api/siteverify',
533 + ['secret' => $reCAPTCHA->secretKey, 'response' => $token]
534 + );
535 + $isgReCaptchaVerified = false;
536 + if (!is_wp_error($gRecaptchaResponse)) {
537 + if (
538 + $captchaV3Settings
539 + && !empty($gRecaptchaResponse->score)
540 + && ((float) $gRecaptchaResponse->score < (float) $captchaV3Settings->score)
541 + ) {
542 + wp_send_json_error(
543 + __(
544 + $captchaV3Settings->message,
545 + 'bit-form'
546 + )
547 + );
548 + }
549 +
550 + $isgReCaptchaVerified = $gRecaptchaResponse->success;
551 + }
552 + if (!$isgReCaptchaVerified) {
553 + return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
554 + }
555 + }
556 + }
557 + }
558 +
559 + private function verifyTurnstileCaptcha()
560 + {
561 + $turnstileSetting = $this->getTurnstileSettings();
562 + if ($turnstileSetting) {
563 + if (!isset($_POST['cf-turnstile-response'])) {
564 + return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
565 + }
566 + $token = $_POST['cf-turnstile-response'];
567 + $turnstileCaptcha = null;
568 + $integrationHandler = new IntegrationHandler(0);
569 + $turnstileIntegration = $integrationHandler->getAllIntegration('app', 'turnstileCaptcha')[0];
570 + if (!is_wp_error($turnstileIntegration && !is_null($turnstileIntegration->integration_type))) {
571 + $turnstileCaptcha = json_decode($turnstileIntegration->integration_details);
572 + // $integrationDetails->id = $turnstileIntegration->id;
573 + // $turnstileCaptcha = $integrationDetails;
574 + }
575 + if (!is_null($turnstileCaptcha)) {
576 + $isTurnstileCaptchaVerified = false;
577 + $turnstileRecaptchaResponse = HttpHelper::post(
578 + 'https://challenges.cloudflare.com/turnstile/v0/siteverify',
579 + ['secret' => $turnstileCaptcha->secretKey, 'response' => $token]
580 + );
581 + if (!is_wp_error($turnstileRecaptchaResponse)) {
582 + if (!$turnstileRecaptchaResponse->success) {
583 + wp_send_json_error(
584 + __(
585 + 'Cloudflare Turnstile Validation Error: ' . implode(', ', $turnstileRecaptchaResponse->{'error-codes'}),
586 + 'bit-form'
587 + )
588 + );
589 + }
590 +
591 + $isTurnstileCaptchaVerified = $turnstileRecaptchaResponse->success;
592 + }
593 + if (!$isTurnstileCaptchaVerified) {
594 + return new WP_Error('spam_detection', __('Please verify Cloudflare Turnstile Captcha', 'bit-form'));
595 + }
596 + }
572 597 }
573 598 }
574 599
575 600 public function verifySubmissionNonce()