GRAYBYTE WORDPRESS FILE MANAGER1905

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/nioscentre.in/wp-content/plugins/forminator/library/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/nioscentre.in/wp-content/plugins/forminator/library//class-captcha-verification.php
<?php
/**
 * Forminator Captcha Verification
 *
 * @package Forminator
 */

if ( ! defined( 'ABSPATH' ) ) {
	die();
}

/**
 * Class Forminator_Captcha_Verification
 *
 * Handle Captcha verification
 *
 * @since 1.15.5
 */
class Forminator_Captcha_Verification {

	/**
	 * Secred Key
	 *
	 * @var string
	 * @since 1.5.3
	 */
	private $secret_key = '';

	/**
	 * Provider
	 *
	 * @var string
	 * @since 1.15.5
	 */
	private $provider = '';

	/**
	 * Forminator_Captcha_Verification constructor.
	 *
	 * @since 1.5.3
	 *
	 * @param string $secret_key Secret Key.
	 * @param string $provider Provider - Added since 1.15.5.
	 */
	public function __construct( $secret_key, $provider ) {
		$this->secret_key = $secret_key;
		$this->provider   = $provider;
	}

	/**
	 * Verify captcha
	 *
	 * @since 1.5.3
	 *
	 * @param string      $user_response User response.
	 * @param null|string $remote_ip Remote IP.
	 * @param string      $score Score.
	 *
	 * @return bool|WP_Error (true on success, WP_Error on fail)
	 */
	public function verify( $user_response, $remote_ip = null, $score = '' ) {

		$provider = $this->provider;
		$url      = $this->get_verify_endpoint();

		$args = array(
			'method' => 'POST',
			'body'   => array(
				'secret'   => $this->secret_key,
				'response' => $user_response,
				'remoteip' => $remote_ip ? $remote_ip : Forminator_Geo::get_user_ip(),
			),
		);

		$res = wp_remote_request( $url, $args );

		if ( is_wp_error( $res ) ) {
			forminator_maybe_log( __METHOD__, $res );

			return $res;
		}

		$body = wp_remote_retrieve_body( $res );
		if ( empty( $body ) ) {
			$error = new WP_Error( $provider . '_empty_response', 'Empty response', array( $res ) );
			forminator_maybe_log( __METHOD__, $error );

			return $error;
		}

		$json = json_decode( $body, true );
		if ( empty( $json ) ) {
			$error = new WP_Error( $provider . '_failed_decode', 'Fail to decode', array( $body ) );
			forminator_maybe_log( __METHOD__, $error );

			return $error;
		}

		if ( 'recaptcha' === $provider ) {

			if ( ! empty( $score ) && ! empty( $json['score'] ) && floatval( $json['score'] ) < floatval( $score ) ) {
				$error = new WP_Error( 'recaptcha_failed_score', 'Score is lower than expected.', array( $body ) );
				forminator_maybe_log( __METHOD__, $error );

				return $error;
			}
		} elseif ( ! empty( $score ) && ! empty( $json['score'] ) && floatval( $json['score'] ) >= floatval( $score ) ) {

				$error = new WP_Error( 'hcaptcha_failed_score', 'Score is higher than expected.', array( $body ) );
				forminator_maybe_log( __METHOD__, $error );

				return $error;
		}

		// success verify.
		if ( isset( $json['success'] ) && true === $json['success'] ) {
			return true;
		}

		// read error.
		$error = new WP_Error( $provider . '_failed_verify', 'Fail to verify', array( $json ) );

		return $error;
	}

	/**
	 * Get Recaptcha endpoint to verify user response
	 *
	 * @since 1.5.3
	 * @since 1.15.5    Added hcaptcha endpoint
	 *
	 * @return string
	 */
	private function get_verify_endpoint() {
		$provider = $this->provider;

		if ( 'recaptcha' === $provider ) {
			$endpoint = 'https://www.google.com/recaptcha/api/siteverify';
		} elseif ( 'turnstile' === $provider ) {
			$endpoint = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
		} else {
			$endpoint = 'https://hcaptcha.com/siteverify';
		}

		/**
		 * Filter endpoint to be used for verify captcha
		 *
		 * @since 1.5.3     forminator_recaptcha_verify_endpoint
		 * @since 1.15.5    Added filter for hcaptcha: forminator_hcaptcha_verify_endpoint
		 *
		 * @param string $endpoint
		 *
		 * @return string
		 */
		$endpoint = apply_filters( 'forminator_' . $provider . '_verify_endpoint', $endpoint );

		return $endpoint;
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
abstracts
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
addon
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
calculator
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
external
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
field-autofill-providers
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
fields
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
gateways
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
helpers
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
lib
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
mixpanel
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
model
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
modules
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
protection
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
render
--
July 01 2025 09:31:58
giriqfky / giriqfky
0755
class-api.php
54.263 KB
March 03 2025 16:08:12
giriqfky / giriqfky
0644
class-autofill-loader.php
6.81 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-captcha-verification.php
3.651 KB
April 14 2025 14:55:34
giriqfky / giriqfky
0644
class-core.php
23.631 KB
May 19 2025 19:14:58
giriqfky / giriqfky
0644
class-database-tables.php
5.178 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-export-result.php
2.566 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-export.php
60.804 KB
March 17 2025 17:29:02
giriqfky / giriqfky
0644
class-form-fields.php
4.995 KB
February 03 2025 17:11:02
giriqfky / giriqfky
0644
class-forminator-hub-connector.php
7.856 KB
March 17 2025 17:29:02
giriqfky / giriqfky
0644
class-geo.php
4.382 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-integration-loader.php
19.328 KB
February 03 2025 17:11:02
giriqfky / giriqfky
0644
class-loader.php
2.536 KB
February 03 2025 17:11:02
giriqfky / giriqfky
0644
class-migration.php
28.507 KB
December 24 2024 20:31:58
giriqfky / giriqfky
0644
class-modules.php
1.98 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-page-cache.php
8.049 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-protection.php
1.034 KB
September 02 2024 15:32:28
giriqfky / giriqfky
0644
class-reports.php
7.193 KB
February 03 2025 17:11:02
giriqfky / giriqfky
0644
class-shortcode-generator.php
16.426 KB
November 25 2024 21:22:22
giriqfky / giriqfky
0644
class-template-api.php
7.535 KB
March 03 2025 16:08:12
giriqfky / giriqfky
0644
class-upgrade.php
1.499 KB
February 03 2025 17:11:02
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF