From d66d1abef9e16ff866dcebcbe44cb4f3b2a118ba Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 19 Oct 2015 23:33:15 -0400 Subject: [PATCH] Fix reCAPTCHA for some users --- inc/recaptcha/recaptchalib_v2.php | 33 ++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/inc/recaptcha/recaptchalib_v2.php b/inc/recaptcha/recaptchalib_v2.php index 4fdae35f..7cd9988c 100755 --- a/inc/recaptcha/recaptchalib_v2.php +++ b/inc/recaptcha/recaptchalib_v2.php @@ -91,27 +91,22 @@ class ReCaptcha private function _submitHTTPGet($path, $data) { $req = $this->_encodeQS($data); - // Try using cURL first. If that fails, fallback to file_get_contents - if (function_exists('curl_init')) { - $handle = curl_init($path); - $queryString = http_build_query($data, '', '&'); - $options = array( - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => $queryString, - CURLOPT_HTTPHEADER => array( - 'Content-Type: application/x-www-form-urlencoded' - ), - CURLINFO_HEADER_OUT => false, - CURLOPT_HEADER => false, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_SSL_VERIFYPEER => true - ); - curl_setopt_array($handle, $options); - $response = curl_exec($handle); - curl_close($handle); + + // Try using cURL + if ( function_exists('curl_init') ) + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $path); + curl_setopt($ch, CURLOPT_POST, count($data) ); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&') ); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + $response = curl_exec($ch); + curl_close($ch); return $response; } + // Default to file_get_contents $response = file_get_contents($path . $req); return $response; } @@ -157,5 +152,3 @@ class ReCaptcha return $recaptchaResponse; } } - -?>