mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Use new HTTP class to communicate with reCAPTCHA/Turnstile servers #2112
This commit is contained in:
parent
ef77af5a39
commit
4e3ffa6115
2 changed files with 16 additions and 20 deletions
|
|
@ -4,6 +4,7 @@ namespace Rhymix\Modules\Spamfilter\Captcha;
|
|||
|
||||
use Context;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\HTTP;
|
||||
|
||||
class reCAPTCHA
|
||||
{
|
||||
|
|
@ -27,20 +28,17 @@ class reCAPTCHA
|
|||
throw new Exception('msg_recaptcha_invalid_response');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$verify_request = \Requests::post(self::$verify_url, array(), array(
|
||||
'secret' => self::$config->secret_key,
|
||||
'response' => $response,
|
||||
'remoteip' => \RX_CLIENT_IP,
|
||||
));
|
||||
}
|
||||
catch (\Requests_Exception $e)
|
||||
$verify_request = HTTP::post(self::$verify_url, [
|
||||
'secret' => self::$config->secret_key,
|
||||
'response' => $response,
|
||||
'remoteip' => \RX_CLIENT_IP,
|
||||
]);
|
||||
if ($verify_request->getStatusCode() !== 200 || !$verify_request->getBody())
|
||||
{
|
||||
throw new Exception('msg_recaptcha_connection_error');
|
||||
}
|
||||
|
||||
$verify = @json_decode($verify_request->body, true);
|
||||
$verify = @json_decode($verify_request->getBody(), true);
|
||||
if (!$verify || !$verify['success'])
|
||||
{
|
||||
throw new Exception('msg_recaptcha_server_error');
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Rhymix\Modules\Spamfilter\Captcha;
|
|||
|
||||
use Context;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\HTTP;
|
||||
|
||||
class Turnstile
|
||||
{
|
||||
|
|
@ -27,20 +28,17 @@ class Turnstile
|
|||
throw new Exception('msg_recaptcha_invalid_response');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$verify_request = \Requests::post(self::$verify_url, array(), array(
|
||||
'secret' => self::$config->secret_key,
|
||||
'response' => $response,
|
||||
'remoteip' => \RX_CLIENT_IP,
|
||||
));
|
||||
}
|
||||
catch (\Requests_Exception $e)
|
||||
$verify_request = HTTP::post(self::$verify_url, [
|
||||
'secret' => self::$config->secret_key,
|
||||
'response' => $response,
|
||||
'remoteip' => \RX_CLIENT_IP,
|
||||
]);
|
||||
if ($verify_request->getStatusCode() !== 200 || !$verify_request->getBody())
|
||||
{
|
||||
throw new Exception('msg_recaptcha_connection_error');
|
||||
}
|
||||
|
||||
$verify = @json_decode($verify_request->body, true);
|
||||
$verify = @json_decode($verify_request->getBody(), true);
|
||||
if (!$verify || !$verify['success'])
|
||||
{
|
||||
throw new Exception('msg_recaptcha_server_error');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue