You did not pass the validation check used to prevent spam submissions

In have enabled recaptcha from config.inc.php and getting this error “You did not pass the validation check used to prevent spam submissions.”

Please Guide …

@asmecher
Please guide
I followed the settings suggested by Jurnal_agrouqa in How to enable reCAPTCHA V2? - #4 by ctgraham

Hi @Haroon_Sattar,

What version of OJS are you using? (Please include this in your posts.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi,
I have the same problem. OJS version is 3.1.1.4
In config.inc.php the option allow_url_fopen = On

Thank you
sds, Nicolás.

Any help would be wellcome, configuration seems to be foolproof:

recaptcha = on
recaptcha_public_key = pubKeyFromWwwGoogleCom-recaptcha
recaptcha_private_key = privKeyFromWwwGoogleCom-recaptcha
captcha_on_register = on

but when I try to register, " You did not pass the validation check used to prevent spam submissions" error occurs.

I swear that I’m choosing only automobiles, or traffic signs as I’m asked to :stuck_out_tongue:

OJS is behind apache reverse-proxy, maybe some redirection is missing?

¿any log file I can read?

Saludos, Nicolás.

You may find helpful information in your server’s PHP error log. Check with your system administrator or hosting provider regarding how to access the PHP error log.

If your reverse proxy configuration requires a proxy for your server to reach out to other internet sites over HTTP, you need to configure that here:

Thanks for the answer.
I found in apache’s log PHP WARNINGS (last two warnings refer about recaptcha). I’ve changed my real OJS path to OJSPATH and my real site to mySite.edu for posting.

[from the last warning]
failed to open stream: No file or directory in FormValidatorReCaptcha.inc.php on line 85:

[FormValidatorReCaptcha.inc.php on line 85]
$response = file_get_contents(RECAPTCHA_HOST . RECAPTCHA_PATH, false, $requestContext);

[first lines of file FormValidatorReCaptcha.inc.php]
define(‘RECAPTCHA_RESPONSE_FIELD’, ‘g-recaptcha-response’);
define(‘RECAPTCHA_HOST’, ‘https://www.google.com’);
define(“RECAPTCHA_PATH”, “/recaptcha/api/siteverify”);

[Warnings in apache’s log]
PHP Warning: Declaration of AddThisPlugin::register($category, $path) should be compatible with LazyLoadPlugin::register($category, $path, $mainContextId = NULL) in /OJSPATH/plugins/generic/addThis/AddThisPlugin.inc.php on line 175, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of CustomBlockPlugin::getBlockContext() should be compatible with BlockPlugin::getBlockContext($contextId = NULL) in /OJSPATH/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 134, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of CustomBlockPlugin::getEnabled() should be compatible with BlockPlugin::getEnabled($contextId = NULL) in /OJSPATH/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 134, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of RegistrationHandler::validate($request) should be compatible with PKPHandler::validate($requiredContexts = NULL, $request = NULL) in /OJSPATH/lib/pkp/pages/user/RegistrationHandler.inc.php on line 19, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of RegistrationHandler::initialize($request, &$args) should be compatible with PKPHandler::initialize($request) in /OJSPATH/lib/pkp/pages/user/RegistrationHandler.inc.php on line 19, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of RegistrationForm::initData($request) should be compatible with Form::initData() in /OJSPATH/lib/pkp/classes/user/form/RegistrationForm.inc.php on line 21, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of RegistrationForm::validate() should be compatible with Form::validate($callHooks = true) in /OJSPATH/lib/pkp/classes/user/form/RegistrationForm.inc.php on line 21, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: Declaration of RegistrationForm::execute($request) should be compatible with Form::execute() in /OJSPATH/lib/pkp/classes/user/form/RegistrationForm.inc.php on line 21, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /OJSPATH/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 85, referer: https://mySite.edu/index.php/index/user/register

PHP Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: No existe el fichero o el directorio in /OJSPATH/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 85, referer: https://mySite.edu/index.php/index/user/register

My server can reach out others internet sites without any restrictions, no proxy configuration is needed.
I’m using apache-reverse-proxy in order to define multiple VirtualHosts.

The line with the error message is where OJS is trying to make an HTTP connection to https://www.google.com/recaptcha/api/siteverify. This appears to be failing.

If you server can successfully connect, it is possible that PHP is restricting remote fopen access. Check to see if your PHP install has the allow_url_fopen directive turned “off”.
http://php.net/manual/en/filesystem.configuration.php

Testing connection from OJS server

wget https://www.google.com/recaptcha/api/siteverify
–2019-02-08 12:04:12-- https://www.google.com/recaptcha/api/siteverify
Resolviendo www.google.com (www.google.com)… 64.233.186.105, 64.233.186.106, 64.233.186.147, …
Conectando con www.google.com (www.google.com)[64.233.186.105]:443… conectado.
Petición HTTP enviada, esperando respuesta… 200 OK
Longitud: no especificado [application/json]
Grabando a: “siteverify”

siteverify [ <=> ] 103 --.-KB/s en 0s

2019-02-08 12:04:13 (8,59 MB/s) - “siteverify” guardado [103]

I checked in /etc/php7/apache2/php.ini the option “allow_url_fopen = On” and in OJS’s config file is also On value… what else can I check

Oops. I missed the actual error you referenced above:

PHP Warning: file_get_contents(): Unable to find the wrapper “https” - did you forget to enable it when you configured PHP

Excelent!
I did’t know openssh module for PHP was requirement for enabling re-captcha!
unbelievable how installing one PHP module can make someone that happy! :slight_smile: :slight_smile:

thank you so much!
Saludos Nicolás.

Hi @ctgraham ,

I have the same trouble as @ojsfder:

[Wed Feb 19 11:22:16.682781 2020] [php7:warn] [pid 4316] [client x.x.x.x:59671] PHP Warning: Declaration of RegistrationHandler::validate($request) should be compatible with PKPHandler::validate($requiredContexts = NULL, $request = NULL) in /home/ojs/lib/pkp/pages/user/RegistrationHandler.inc.php on line 19, referer: https://x.x.x.x/index.php/Quodlibet/user/register
[Wed Feb 19 11:22:16.695492 2020] [php7:warn] [pid 4316] [client x.x.x.x:59671] PHP Warning: Declaration of RegistrationForm::validate() should be compatible with Form::validate($callHooks = true) in /home/ojs/lib/pkp/classes/user/form/RegistrationForm.inc.php on line 21, referer: https://x.x.x.x/index.php/Quodlibet/user/register
[Wed Feb 19 11:22:36.735885 2020] [php7:warn] [pid 4316] [client x.x.x.x:59671] PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/ojs/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 85, referer: https://x.x.x.x/index.php/Quodlibet/user/register
[Wed Feb 19 11:22:36.736027 2020] [php7:warn] [pid 4316] [client x.x.x.x:59671] PHP Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/ojs/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 85, referer: https://x.x.x.x/index.php/Quodlibet/user/register

I have done the following:

I have installed OJS 3.1.2 and php 7.3.

What else can I change?
Thanks a lot.
Regards.

It was a problem with the proxy configuration.
I disable allow_url_fopen in my config.inc.php and enable proxy. Then, recatpcha worked.
Cheers.

1 Like

Hi @ctgraham,

on one OJS 3.2.1.1 I had problem with validation check.

allow_url_fopen is off (with on is the same)
API key added

In error log have:
[16-Aug-2020 18:19:29 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /data04/c6410587/public_html/murmurations/ojs/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 89
[16-Aug-2020 18:19:29 UTC] PHP Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: no suitable wrapper could be found in /data04/c6410587/public_html/murmurations/ojs/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 89

On other sites works, but in this case… error with message:
[You did not pass the validation check used to prevent spam submissions.]

Is there problem with proxy server or?

Regards,
Lazar

In your PHP configuration (php.ini or equivalent) the directive allow_url_fopen has been turned off. For OJS to be able to verify the ReCAPTCHA response, it need to be able to make a direct connection to Google over HTTPS. This is implemented via an fopen call to a Google URL.

If your system administrator or hosting provide can enable the PHP setting allow_url_fopen, this may resolve your problem.

1 Like

Understand. In Config.ini.php and _php.ini have allow_url_fopen = On but still doesn`t work.

Did the error message in the log change? If not, the change doesn’t appear to be effective. If so, what is the new error message?

With ON option in both files, the errors in error.log are:

[17-Aug-2020 06:55:04 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /data04/c6410587/public_html/murmurations/ojs/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 89
[17-Aug-2020 06:55:04 UTC] PHP Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: no suitable wrapper could be found in /data04/c6410587/public_html/murmurations/ojs/lib/pkp/classes/form/validation/FormValidatorReCaptcha.inc.php on line 89