Post by Gukkie » Mon Apr 25, 2016 9:37 pm

Hi, I enabled Google Re-Captcha but it does not seem to be working.

This is the error I get on the Contact Us page when I click the submit button.

"Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/spectretp/public_html/catalog/controller/captcha/google_captcha.php on line 26Warning: file_get_contents(https://www.google.com/recaptcha/api/si ... 147.84.198): failed to open stream: no suitable wrapper could be found in /home/spectretp/public_html/catalog/controller/captcha/google_captcha.php on line 26 "

Also, if I enable re-captcha on reviews, I cannot submit reviews.

Any ideas?

Newbie

Posts

Joined
Mon Apr 25, 2016 9:35 pm

Post by zlobec » Fri Jun 24, 2016 3:20 am

I get a similar problem.

Code: Select all

Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in D:\Wwwroot\artofmusic\trgovina\opencart-2.1.0.1\catalog\controller\captcha\google_captcha.php on line 30

Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify...): failed to open stream: Invalid argument in D:\Wwwroot\artofmusic\trgovina\opencart-2.1.0.1\catalog\controller\captcha\google_captcha.php on line 30 ­
The issue started recently... All was working about 2 months ago.. Server has not made any changes to configuration.

Edit:

The generated URL for ReCaptcha gets a successful response from Google... Looks like the file_get_contents needs attention.

Newbie

Posts

Joined
Tue Nov 17, 2015 11:52 pm

Post by ebuy » Sat Dec 03, 2016 11:33 pm

In my case there in no module or google button in settings but the files are in place.
How can i solve this ?
ubuntu 16.04 64-bit
Kernel Linux 4.4.0-51-generic x86_64
MATE 1.12.1 minimal
LEMP php7.0
opencart 2.3.0.2

Newbie

Posts

Joined
Sat Dec 03, 2016 10:15 pm

Post by misspiggy » Thu Feb 16, 2017 12:01 am

I get the exact same problem and warnings as the first poster.
I use the latest version of opencart Version 2.3.0.2

any idea how to solve this?

Newbie

Posts

Joined
Fri Nov 18, 2011 7:37 pm

Post by misspiggy » Thu Feb 16, 2017 11:36 am

After looking at some other topics.
I think the problem is maybe due to my server. I kn ow it's pretty strict and they don't allow much.

If this is the case and i cannot change things server side. Is there a work around to make recaptcha work?

Anyone any ideas?

Thanks in advance!

Newbie

Posts

Joined
Fri Nov 18, 2011 7:37 pm

Post by JDECLEMENTI » Sat Feb 18, 2017 4:11 am

Im in 2.0.2.0 But I was able to get mine working with a dirty work around by changing this code

Code: Select all

        if ($this->config->get('config_google_captcha_status')) {
            if (isset($this->request->post['g-recaptcha-response'])) {
                $recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);

                $recaptcha = json_decode($recaptcha, true);

                if (!$recaptcha['success']) {
                    $this->error['captcha'] = $this->language->get('error_captcha');
                }
            }
        }

To this code

Code: Select all

 if ($this->config->get('config_google_captcha_status')) {
            if (isset($this->request->post['g-recaptcha-response'])) {
              
                 $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR'];
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
if (curl_errno($ch)) {
  echo curl_error($ch);
  echo "\n<br />";
  $contents = '';
} else {
  curl_close($ch);
}

if (!is_string($contents) || !strlen($contents)) {
echo "Failed to get contents.";
$contents = '';
}

$contents = json_decode($contents, true);
              if (!$contents['success']) {
                    $this->error['captcha'] = $this->language->get('error_captcha');
                }
            }
        }


This is in my controller>information>contact.php Not sure why it stoped working all of a sudden but this saved my @$$

Newbie

Posts

Joined
Fri Jan 20, 2017 11:51 pm

Post by crosland » Sat Dec 07, 2019 12:51 am

A slightly different version also works in 3.0.3.2:

Code: Select all

			// Use curl instead https://forum.opencart.com/viewtopic.php?t=161727
			$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR'];
			$ch = curl_init();
			curl_setopt ($ch, CURLOPT_URL, $url);
			curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
			$contents = curl_exec($ch);
			if (curl_errno($ch)) {
				echo curl_error($ch);
				echo "\n<br />";
				$contents = '';
			} else {
				curl_close($ch);
			}

			if (!is_string($contents) || !strlen($contents)) {
				echo "Failed to get contents.";
				$contents = '';
			}

			$contents = json_decode($contents, true);
			if (!$contents['success']) {
				$this->session->data['gcapcha']	= true;
			} else {
				return $this->language->get('error_captcha');
			}

It's such a shame it was never fixed in a release :(

Active Member

Posts

Joined
Fri Sep 13, 2019 9:04 pm

Post by alber99 » Fri Jun 23, 2023 5:03 am

crosland wrote:
Sat Dec 07, 2019 12:51 am
A slightly different version also works in 3.0.3.2:

Code: Select all

			// Use curl instead https://forum.opencart.com/viewtopic.php?t=161727
			$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR'];
			$ch = curl_init();
			curl_setopt ($ch, CURLOPT_URL, $url);
			curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
			$contents = curl_exec($ch);
			if (curl_errno($ch)) {
				echo curl_error($ch);
				echo "\n<br />";
				$contents = '';
			} else {
				curl_close($ch);
			}

			if (!is_string($contents) || !strlen($contents)) {
				echo "Failed to get contents.";
				$contents = '';
			}

			$contents = json_decode($contents, true);
			if (!$contents['success']) {
				$this->session->data['gcapcha']	= true;
			} else {
				return $this->language->get('error_captcha');
			}

It's such a shame it was never fixed in a release :(
What code does this replace?

New member

Posts

Joined
Sun Apr 08, 2012 9:14 am

Post by paulfeakins » Fri Jun 23, 2023 7:09 pm

Gukkie wrote:
Mon Apr 25, 2016 9:37 pm
Hi, I enabled Google Re-Captcha but it does not seem to be working.
Just use our invisible one instead as it's miles better anyway: https://www.opencart.com/index.php?rout ... er=antropy

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by JNeuhoff » Fri Jun 23, 2023 8:12 pm

This forum thread is several years old! Anyway, we recommend using the SpamBot Buster, no need for cumbersome captchas, no need for calling 3rd party external URLs.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 19 guests