This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Integration with reCAPTCHA v2


avatar
Sobiech 77
From: -
Is it possible to integrate Contentteller 2.1.18 with reCAPTCHA v2? If this is possible, how to do it?

I added the code <head>:
<script src = " https://www.google.com/recaptcha/api.js" async defer></ script>

And I swapped code:

<!-- Template: files_comment_form_recaptcha -->
<script type="text/javascript"
src="https://www.contentteller.com/ http://www.google.com/recaptcha/api/challenge?k={$insert['website_recaptcha_public_key']}">
</script>
<noscript>
<iframe src="https://www.contentteller.com/ http://www.google.com/recaptcha/api/noscript?k={$insert['website_recaptcha_public_key']}"
height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>

on

<div class="g-recaptcha" data-sitekey="my_key"></div>


but unfortunately in this way does not work.

Thanks!

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: Integration with reCAPTCHA v2
avatar
OP 77
From: -
Thank you, it works! Smiling Face
1 Re: Integration with reCAPTCHA v2
avatar
Administrator
1340
From: Vienna, Austria
There is also a PHP part. Here a possible solution but untested.

Replace the following in /classes/class_system.php:
  function dorecaptcha( $var, $var2, $var3, $var4 )
{
$error = 1;
if( function_exists( "curl_exec" ) )
{
$url = curl_init();
curl_setopt( $url, CURLOPT_URL, " http://api-verify.recaptcha.net/verify" );
curl_setopt( $url, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $url, CURLOPT_POSTFIELDS, "privatekey=" . $var . "&remoteip=" . $var2 . "&challenge=" . $var3 . "&response=" . $var4 );
curl_setopt( $url, CURLOPT_USERAGENT, "Esselbach Contentteller CMS" );
$recaptcha = curl_exec( $url );

if ( preg_match( "/true/i", $recaptcha ) )
{
$error = 0;
}

curl_close( $url );
}
return $error;
}


with:

function dorecaptcha( $var, $var2, $var3, $var4 )
{
$error = 1;
if( function_exists( "curl_exec" ) )
{
$url = curl_init();
curl_setopt( $url, CURLOPT_URL, " https://www.google.com/recaptcha/api/siteverify?secret=" . $var . "&remoteip=" . $var2 . "&response=" . $_POST['g-recaptcha-response'] );
curl_setopt( $url, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt( $url, CURLOPT_TIMEOUT, 15);
curl_setopt( $url, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt( $url, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt( $url, CURLOPT_USERAGENT, "Esselbach Contentteller CMS" );
$recaptcha = curl_exec( $url );
curl_close( $url );

$result = json_decode( $recaptcha, TRUE );
if( $result['success'] == "true")
{
$error = 0;
}
}
return $error;
}


and change the template to:

<!-- Template: files_comment_form_recaptcha -->
<script type="text/javascript"
src="https://www.contentteller.com/ https://www.google.com/recaptcha/api.js">
</script>
<div class="g-recaptcha" data-sitekey="{$insert['website_recaptcha_public_key']}"></div>

Let me know if this will work Winking Face

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.