40 Posts
yoyoxp
4 years ago
Topic

Hi all,


I decided to use the NoCaptcha ReCaptcha plugin on my site (https://www.seblod.com/store/extensions/48177). When I push the website to my webhosts server the captcha kept failing although it didn't in my development enviornment.

I debugged a bit and noticed the file_get_contents() method the plugin uses for Recaptcha response relies on the php.ini parameter allow_url_fopen to be set. My webhost controls the php.ini settings.

To fix the problem, I changed the plugin to use cURL instead.

If you encounter the same problem/this plugin not working it is probably the same issue, especially if you have allow_url_fopen unset.

To fix it open db_no_captcha.php (plugins/cck_field/db_no_captcha). Find line (around line #154):

$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$_POST['g-recaptcha-response']); 

Replace this line with:

$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$_POST['g-recaptcha-response']);
curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
$response =curl_exec($curlSession); curl_close($curlSession);

This fixed the problem for me!
Get a Book for SEBLOD
4229 Posts
Kadministrator
4 years ago
0
Level 1

thnx

Get a Book for SEBLOD