logo
Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
bart  
#1 Posted : Wednesday, August 15, 2012 2:48:55 PM(UTC)
bart

Rank: Administration

Reputation:

Groups: Administration
Joined: 10/8/2008(UTC)
Posts: 188
Man

Was thanked: 1 time(s) in 1 post(s)
UPDATE Erwin 2018-11-06: go to here: Recaptcha 2018
Recaptcha 2018


Hi There,

A lot of times I get the question from customers to include captcha on their contact form or somewhere else in their site.

That's why I decided to create a manual for this so other people can use this knowledge as well.
This manual is for including reCAPTCHA in Sienn, and really, If you know how, It's really easy to implement.

At first we need a public and a private key for the site,
You can get this from here: https://www.google.com/recaptcha/admin/create
You can also recieve global key's so you can use the same key's for multiple sites but that is up to you.

Now we have to download the reCAPTCHA dll from here: http://code.google.com/p/recaptcha/downloads/list?q=label:aspnetlib-Latest
and copy it to the sites bin directory.

Now we have to create an open control like this:
Code:
d:\inetpub\wwwroot\<site dir>\bin\Recaptcha.dll
==>END SYSTEMREFERENCE
Imports recaptcha
==>END IMPORTS

Dim recaptcha as new RecaptchaControl
recaptcha.Id="recaptcha"
recaptcha.PublicKey="<My public key>"
recaptcha.PrivateKey="<My private key>"
Controlplace.controls.add(recaptcha)

replace the key's and dir of the site or also copy the dll in the SiennCMS.

And put this control somewhere in the form. ({!$Control.36.<constrol number>$!})
If we load the form now, we should already see the capcha.

UserPostedImage

We can also renew this captcha, but still we have to finish the check for the submitbutton.
We can do this in "UserEscape formulier datacheck"
here we can place the following code:
Code:
select Case FormId
  Case 1
    If not MyForm.IsValid Then
      return "Wrong Captcha"
    End If
end Select

Of cource we need to check the formId
And we are done.

For more information about customizing this captcah you can look here:
https://developers.google.com/recaptcha/docs/aspnet?hl=nl

Edited by moderator Tuesday, November 6, 2018 9:41:33 AM(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your Sienn Forum forum account. New Registrations are disabled.

Erwin  
#2 Posted : Monday, November 26, 2012 10:24:56 AM(UTC)
Erwin

Rank: Administration

Reputation:

Groups: Moderators, Administration, Member
Joined: 10/8/2008(UTC)
Posts: 44

To theme it, don't add the script as described in Google, but change you variables in the control:

Code:
recaptcha.theme = "clean"


so you get something like this:
Code:
Dim recaptcha as new RecaptchaControl
recaptcha.theme = "clean"
recaptcha.Id="recaptcha"
recaptcha.PublicKey="xxx"
recaptcha.PrivateKey="yyy"
Controlplace.controls.add(recaptcha)


styles can be found here: https://developers.google.com/recaptcha/docs/customization?hl=nl
bart  
#3 Posted : Wednesday, August 17, 2016 2:22:48 PM(UTC)
bart

Rank: Administration

Reputation:

Groups: Administration
Joined: 10/8/2008(UTC)
Posts: 188
Man

Was thanked: 1 time(s) in 1 post(s)
Recaptcha V2 and sienn ML

Hi Guys,

the implementation of reCaptcha V2 is a little bit different then for v1
see also the documentatation
https://developers.google.com/recaptcha/intro
having the captcha appear on the site is the easy past.
you just include a javascript (always https)
and then Add a div for the captcha
Code:
<script src="https://www.google.com/recaptcha/api.js?hl=nl" async defer></script>
<div class="g-recaptcha" data-sitekey="<Site key>" data-theme="dark"></div>

you can give paramaters for theme and language of course.
see configuration: https://developers.googl...tcha/docs/display#config

now the recaptcha is there still we have to validate this.
this we still do in "UserEscape formulier datacheck (Global)"
we can retrieve the captcha value the following way
Code:
Dim ReCaptchavalue as string = Request.form("g-Recaptcha-Response")


we have to create a functions which calls the google API for validation like this
Code:
Public Function Validate(EncodedResponse As String) As boolean
	Dim client = New System.Net.WebClient()

	Dim PrivateKey As String = "<Private Key......>"

	Dim GoogleReply as string= client.DownloadString(String.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", PrivateKey, EncodedResponse))

' 	Dim captchaResponse = Newtonsoft.Json.JsonConvert.DeserializeObject()(GoogleReply)

' 	Return captchaResponse.Success
    Return GoogleReply.contains("""success"": true")
End Function


now we still only have to check the key from the form request.
In siennML this looks like this, in Sienn4 we just return the error as string.
Code:
Select Case FormId
    Case 4
        Dim ReCaptchavalue as string = Request.form("g-Recaptcha-Response")
        If Not Validate(ReCaptchavalue) Then
            Dim errorItem As SError.SErrorItem = New SiennDataObject.SError.SErrorItem(SiennDataObject.SEnum.SErrorTypes.Error_FieldCheck_NotDateTime,"ReCaptchavalue", 0, 0, 0, "U heeft de Captcha verkeerd ingevuld")
            SError.Add(errorItem)
            Return False
        End If 
End Select


Thats's it.

see http://stackoverflow.com...-in-asp-nets-server-side for more solutions
Erwin  
#4 Posted : Tuesday, November 6, 2018 9:39:23 AM(UTC)
Erwin

Rank: Administration

Reputation:

Groups: Moderators, Administration, Member
Joined: 10/8/2008(UTC)
Posts: 44

1. Get or create a recaptcha secret key and private key at: https://www.google.com/recaptcha/admin#list (easiest to use the MCC-account of SIENN)
2a. Add to code UserEscape formulier datacheck

Code:

Select Case FormId
    Case 3 ' <-- change id to your form of course...
        Dim ReCaptchavalue as string = Request.form("g-Recaptcha-Response")
        If Not Validate(ReCaptchavalue) Then
            
            Return "Your Recaptcha is invalid"
        End If 
End Select

2b. Add to the function of UserEscape formulier datacheck
Code:

Public Function Validate(EncodedResponse As String) As boolean
	Dim client = New System.Net.WebClient()
	Dim PrivateKey As String = "aaaabbbcccddeeeeefff" ' <-- change PrivateKey with your private key from step 1
  	Dim GoogleReply as string= client.DownloadString(String.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", PrivateKey, EncodedResponse))
    Return GoogleReply.contains("""success"": true")
End Function


2c. error check the build/compile the UserEscape formulier datacheck

3. add to your form these 2 lines before the send-button:
Code:

<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="111122223333344444"></div> <!-- <-- change data-sitekey with the public key from step 1 -->
{!!Button_bevestig!!}


4. test it on the live website, inform the customer.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.