Fix reCAPTCHA for some users

merge-requests/2/head 2.5.0
Mike Koch 9 years ago
parent 7fa8a83015
commit d66d1abef9

@ -91,27 +91,22 @@ class ReCaptcha
private function _submitHTTPGet($path, $data) private function _submitHTTPGet($path, $data)
{ {
$req = $this->_encodeQS($data); $req = $this->_encodeQS($data);
// Try using cURL first. If that fails, fallback to file_get_contents
if (function_exists('curl_init')) { // Try using cURL
$handle = curl_init($path); if ( function_exists('curl_init') )
$queryString = http_build_query($data, '', '&'); {
$options = array( $ch = curl_init();
CURLOPT_POST => true, curl_setopt($ch, CURLOPT_URL, $path);
CURLOPT_POSTFIELDS => $queryString, curl_setopt($ch, CURLOPT_POST, count($data) );
CURLOPT_HTTPHEADER => array( curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&') );
'Content-Type: application/x-www-form-urlencoded' curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
), curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
CURLINFO_HEADER_OUT => false, $response = curl_exec($ch);
CURLOPT_HEADER => false, curl_close($ch);
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true
);
curl_setopt_array($handle, $options);
$response = curl_exec($handle);
curl_close($handle);
return $response; return $response;
} }
// Default to file_get_contents
$response = file_get_contents($path . $req); $response = file_get_contents($path . $req);
return $response; return $response;
} }
@ -157,5 +152,3 @@ class ReCaptcha
return $recaptchaResponse; return $recaptchaResponse;
} }
} }
?>

Loading…
Cancel
Save