HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpicare/wp-content/updraft/plugins-old/metform/core/integrations/google-recaptcha.php
<?php
namespace MetForm\Core\Integrations;
defined( 'ABSPATH' ) || exit;

class Google_Recaptcha {

    use \MetForm\Traits\Singleton;

    private $return;

    public function verify_captcha_v2( $form_data, $form_settings ){

        $secretKey = ((isset($form_settings['mf_recaptcha_secret_key']) && ($form_settings['mf_recaptcha_secret_key'] != '')) ? $form_settings['mf_recaptcha_secret_key'] : '');
            
        $captcha = (isset($form_data['g-recaptcha-response']) ? $form_data['g-recaptcha-response'] : '');
        
        $data = array(
            'secret' => $secretKey,
            'response' => $captcha,
            'remoteip' => isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])):''
        );

        $endpoint = 'https://www.google.com/recaptcha/api/siteverify';
        $options = [
            'method'      => 'POST',
            'body'        => $data,
            'sslverify'   => false,
        ];

        $response = wp_remote_post( $endpoint, $options );
        $responseKeys = json_decode($response['body'],true);
        $this->return['responseKeys'] = $responseKeys;

        if($responseKeys["success"]) {
            $this->return['status'] = 1;
        } else {
            $this->return['status'] = 0;
            $this->return['error'] = esc_html__('Captcha is not verified.','metform');
        }

        return $this->return;
    }

    public function verify_captcha_v3( $form_data, $form_settings ){
        
        $secretKey = ((isset($form_settings['mf_recaptcha_secret_key_v3']) && ($form_settings['mf_recaptcha_secret_key_v3'] != '')) ? $form_settings['mf_recaptcha_secret_key_v3'] : '');
            
        $captcha = (isset($form_data['g-recaptcha-response-v3']) ? $form_data['g-recaptcha-response-v3'] : '');
        
        $data = array(
            'secret' => $secretKey,
            'response' => $captcha,
        );

        $endpoint = 'https://www.google.com/recaptcha/api/siteverify';
        $options = [
            'method'      => 'POST',
            'body'        => $data,
            'sslverify'   => false,
        ];

        $response = wp_remote_post( $endpoint, $options );

        $responseKeys = json_decode($response['body'],true);
        $this->return['responseKeys'] = $responseKeys;

        if($responseKeys["success"]) {
            $this->return['status'] = 1;
        } else {
            $this->return['status'] = 0;
            $this->return['error'] = esc_html__('Captcha is not verified.','metform');
        }

        return $this->return;
    }
}