Contact forms stopped working

12 replies · opened Mar 5, 2018

SSemicolon WebSTAFFMar 5, 2018

Hello,

Can you please disable the reCaptcha in the assets/include/sendemail.php File and get in touch with us again so that we can properly investigate the issue. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

NnikoslavsMar 5, 2018

I commented following lines in sendemail.php, so we don-t force recaptcha

		// if( !isset( $_POST['g-recaptcha-response'] ) ) {
		// 	echo '{ "alert": "error", "message": "Greška u Captcha verifikaciji! Molimo pokušajte ponovo." }';
		// 	die;
		// }

And this is alert I get from recaptcha admin:
We detected that your site is not verifying reCAPTCHA solutions. This is required for the proper use of reCAPTCHA on your site. Please see our developer site for more information.

Canvas version is 4.5.1

We currently can't migrate to newer version cause of time and resource limit

SSemicolon WebSTAFFMar 8, 2018

Hello,

According to the Error you have mentioned and since the Forms are working without reCaptcha, it appears that the allow_url_fopen is not enabled in your PHP Configuration on your Servers. Please contact your Web Hosting Providers to enable this for you and your Forms will start working fine again.

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

NnikoslavsMar 9, 2018

Dear, we checked with hosting provider, and they said that allow_url_fopen is enabled all the time

We need to be clear, these forms worked, but suddenly stopped working, should we try different recaptcha codes or something else?
Please advise

NnikoslavsMar 9, 2018

This is block of code that is not passing

			// Runs only when reCaptcha is present in the Contact Form
			if( isset( $_POST['g-recaptcha-response'] ) ) {
				$recaptcha_response = $_POST['g-recaptcha-response'];
				$response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response );

				$g_response = json_decode( $response );

				if ( $g_response->success !== true ) {
					echo '{ "alert": "error", "message": "Greška u ReCaptcha verifikaciji! Molimo pokušajte ponovo." }';
					die;
				}
			}
SSemicolon WebSTAFFMar 9, 2018

Hello,

According to your described issue, this can be a problem with the reCaptcha API keys, please consider using a fresh set of API Keys. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

NnikoslavsMar 12, 2018

We tried new set of keys, but no success

Please advise

NnikoslavsMar 15, 2018

Hello all,
this is code that I used for implementing Recaptcha, hope that will helps someone else struggling with this same issue.

			// Runs only when reCaptcha is present in the Contact Form
			if( isset( $_POST['g-recaptcha-response'] ) ) {
				$recaptcha_response = $_POST['g-recaptcha-response'];
				
				$data = array(
					'secret' => $recaptcha_secret,
        			'response' => $recaptcha_response
				);

				$verify = curl_init();
				curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
				curl_setopt($verify, CURLOPT_POST, true);
				curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
				curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
				curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
				$response = curl_exec($verify);
				curl_close($verify);
				
				$json = json_decode($response, true);
        		if($json["success"] !== true) { 
					echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
					die;
				}

			}

			// Uncomment the following Lines of Code if you want to Force reCaptcha Validation

			 if( !isset( $_POST['g-recaptcha-response'] ) ) {
			 	echo '{ "alert": "error", "message": "Captcha not Submitted! Please Try Again." }';
			 	die;
			}
SSemicolon WebSTAFFMar 19, 2018

Hello,

Thank You for your Patience. The modified code you are using uses PHP cURL Functionality which explains that the previous code using the file_get_contents PHP Functionality was not supported by your Servers.

We will surely try making the Codes more flexible in the Future Updates. Thanks for your Patience.

Do let us know if we can help you with anything else or if you find any further issues with Canvas.

NnikoslavsMar 20, 2018

It worked with file_get_contents but stopped due to ReCaptcha update and verifying over https

curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);

SSemicolon WebSTAFFMar 26, 2018

Hello,

Thank You so much for the elaborate explanation on this. We will surely take this into account and release an updated code.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard