首页 > 解决方案 > 数据库似乎有错误。reCaptch 不起作用

问题描述

我的支票 CAPTCHA 有问题。在我的本地机器上工作,但是当我在我的 cpnael 中放置或更改时不起作用。此验证重新验证适用于 v1(生命周期结束)

我放了v2 whit检查点。

我在本地和 cpanel 上有相同的 php 版本。

我在 cpanel 上收到此错误:

在此处输入图像描述

这是带有验证的recaptcha代码:

public function getTemplate()
{
    if ( ! $this->public_key )
    {
        return '';
    }

    if ($this->useSSL) 
    {
        $server = RECAPTCHA_API_SECURE_SERVER;
    } 
    else 
    {
        $server = RECAPTCHA_API_SERVER;
    }
    
    $html   = '';
    

    $html   .= '<head>
                    <title>reCAPTCHA</title>
                    <script src="https://www.google.com/recaptcha/api.js" async defer></script>
                </head>
                <body>
                    <form action="?" method="POST">
                    <div class="g-recaptcha" data-sitekey=  "></div>
                    <br/>
                    <input type="submit" value="Submit">
                    </form>
                </body>
                        <script type="text/javascript">
                        var onloadCallback = function() {
                        alert("grecaptcha is ready!");
                        };
                </script>
                    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
                    async defer>
                </script>';
                                                    
    //-----------------------------------------
    // Return Template Bit
    //-----------------------------------------
    
    return $this->registry->output->getTemplate('global_other')->captchaRecaptcha( $html );
}

/**
 * Validates the entered captcha code, returning true on success and false on failure
 *
 * @return  @e boolean
 *
 * <b>Example Usage:</b>
 * @code
 * $isValid = $this->validate();
 * @endcode
 */
public function validate()
{
    if ( !$this->private_key )
    {
        $this->error = 'no_private_key';
        return FALSE;
    }
    
    $captcha_unique_id  = $_REQUEST['recaptcha_challenge_field'];
    $captcha_input      = $_REQUEST['recaptcha_response_field'];
    
    //-----------------------------------------
    // Path disclosure prevention
    //-----------------------------------------
    if ( is_array( $captcha_input ) )
    {
        return false;
    }
    
    if ( $captcha_input == null || strlen($captcha_input) == 0 || $captcha_unique_id == null || strlen($captcha_unique_id) == 0) 
    {
        return false;
    }
    
    $classToLoad    = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
    $communication  = new $classToLoad();
    
    $response   = $communication->postFileContents( RECAPTCHA_VERIFY_SERVER . "/recaptcha/api/verify", array(
                                                                                                        'privatekey'    => $this->private_key,
                                                                                                        'remoteip'      => $this->member->ip_address,
                                                                                                        'challenge'     => $captcha_unique_id,
                                                                                                        'response'      => $captcha_input
                                                                                                    )   );

    $answers    = explode( "\n", $response );

    if ( trim($answers[0]) == 'true' ) 
    {
        return TRUE;
    }
    else
    {
        /**
         * It's an error
         */
        $this->error = $answers[1];
        return FALSE;
    }
}

这是我的功能

        {
            if ( $this->registry->getClass('class_captcha')->validate() !== TRUE )
            {
                return $this->_showForm('err_reg_code');
            }
        }

标签: phprecaptchaphp-5.6

解决方案


推荐阅读