php - 数据库似乎有错误。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');
}
}
解决方案
推荐阅读
- tomcat - 配置 Tomcat 以记录启动时加载的所有 Jar 文件和/或类
- android - 调试 Android 应用程序:安装 apk 给出“未安装应用程序”
- scala - 当类型是协变的时,为什么我们不能提供隐式类型类?
- html - 如何在选定的导航项下方对齐引导下拉菜单
- c# - VSTO 功能区:如何使文本“自定义工具栏”从功能区左侧消失?
- netcdf - Xarray - 连接来自多个文件的切片
- google-apps-script - 通常如何从 Google Apps 脚本访问 BigQuery
- angular - 运行没有实体的基本 JHipster monilithic 应用程序会返回一个空白页面
- perl - perl 提取字符串和科学数字
- python - 如何在python中提取包含嵌套字典的嵌套列表中的项目