Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Template Shares (http://www.bvlist.com/forumdisplay.php?f=26)
-   -   reCAPTCHA for tsue 2.2 (http://www.bvlist.com/showthread.php?t=11654)

outtyrox 2nd August 2018 00:32

has there been a solution for captcha v2 created yet? currently I've had to disable it in the admincp

dashboard> options> security> enable captcha for guests NO


doesn't look like it would be too difficult.

only difficult part is making it some its simple for users to enter their own private and public keys for the captcha v2 after the updates are made.


1. Mod /library/pages/signup.php
2. Mod /library/classes/class_recaptcha.php
3. Mod the default template for captcha

https://ibb.co/e4Nn6K

https://ibb.co/khPBYz

Bump: guess I should have checked all the pages.

I see joe roberts been working on it.

joeroberts 2nd August 2018 01:00

:clown: I posted a fix in here
http://www.bvlist.com/showthread.php?t=11654

outtyrox 2nd August 2018 01:09

Quote:

Originally Posted by joeroberts (Post 52327)
:clown: I posted a fix in here
http://www.bvlist.com/showthread.php?t=11654


I see the signup.php mod there. where is the mod for the class_recaptcha.php?

joeroberts 2nd August 2018 01:16

http://www.bvlist.com/showpost.php?p=52086&postcount=25

outtyrox 2nd August 2018 02:08

Quote:

Originally Posted by joeroberts (Post 52088)
You have made the edit in the templates?
Paste this snippet before the closing
Code:


tag on your HTML template:
Code:


Paste this snippet at the end of the
Code:


where you want the reCAPTCHA widget to appear:
Code:




joe which template(s) need this added? this is only part I'm not sure on. I have everything else updated.

joeroberts 2nd August 2018 02:35

going to have to say signup, lost password and login

outtyrox 2nd August 2018 02:47

suggestion:
seems like in the future it'd be a better option to make another file to import the recaptcha public and private keys from also. that way users dont mess up php files.

Bump:
----------------------------------------------------------------------------------------------------------------------------------------------------------------
got it to work after modifying the files joe said in his posts here. all credit goes to him for making this work.

first I made an account for google recaptcha and added my site url to get private and public key here:
Code:

https://www.google.com/recaptcha/admin


second i did the file edits joe posted here. (good idea to back these files up after for next time)

file edits:
http://www.bvlist.com/showpost.php?p=52086&postcount=25

template modes pictured below:
http://www.bvlist.com/showpost.php?p=52086&postcount=27



third in the template editor I modified the main template. sigup, and captcha template (good idea to backup the default template before you modify anything in here)

like so


main
https://s22.postimg.cc/okzto2y9d/Scr...2.13.14_PM.png


captcha (don't forget to put in your public key here)
https://s22.postimg.cc/ouet6nrmp/Scr...9.13.39_PM.png


sigup
https://s22.postimg.cc/ujdmygmep/Scr...1.50.30_PM.png



then put your private key in the updated /library/classes/class_captcha.php file

https://s22.postimg.cc/xpfnha3ld/Scr...9.08.04_PM.png

-------------------------

Bump: I have to do some more testing because confirmation working correctly.

- the new member signup to complete but I see this wierd confirmation. must be the captcha template mod i did.

wierd confirmation
https://s22.postimg.cc/uxeyy8e9t/Scr...1.54.13_PM.png

Bump: I fixed the weird error. It was a self inflected wound in class_captchA.php I added the ?> like PHP has and for some reason xam leaves out.


-----------------------------------------------------------


I'm having and issue getting class_captcha.php to return true. If I set it manually to true it works. I've tried making a new PHP using CURL instead the fileget method but same result.



TESTING CURL METHOD BUT SAME RESULT
Code:


class TSUE_captcha
{
    public function verifyCaptcha($recaptcha_challenge_field = "", $recaptcha_response_field = "")
    {
                //
                //PUT YOUR PRIVATE KEY HERE//
                $secret = "6LcsM2gUAAAAAAjbvuAs-YtADTLyAKkG96AX8nmK";
                //
                //
                //
                $remoteip = $_SERVER["REMOTE_ADDR"];
                $url = "https://www.google.com/recaptcha/api/siteverify";
                $response = $_POST["g-recaptcha-response"];
       
                // Curl Request
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, array(
                    'secret' => $secret,
                    'response' => $response,
                    'remoteip' => $remoteip
                    ));
                $curlData = curl_exec($curl);
                curl_close($curl);
       
                // Parse data
                $jsonResponse = json_decode($curlData);
                if ($jsonResponse->success === true)
                    return true;
                else
                    return false;
    }

}


MasterMan 4th August 2018 16:22

edit these:


1. main template of your all styles and add


Quote:



before the closing of


2. go to your captcha template and add to all styles the following on the top;



Quote:



change the xxxxxxxxxxxxxxxxxxxx with your site key where you registered with google recaptcha!


that's it ...! this works :)

joeroberts 4th August 2018 17:02

OMG masterman your brilliant!!!
Now why didn’t I think of that???
Just make sure you turn off recaptcha in the tracker so that it won’t get checked on submit because it well never F**cking pass this way!!!

outtyrox 4th August 2018 17:28

yes works until google flags your key for the callback not being implemented correctly.

this is the part that needs fixed so the update to v2 keeps working

Code:

https://developers.google.com/recaptcha/docs/verify#api-request
Bump:
Quote:

Originally Posted by MasterMan (Post 52342)
edit these:


1. main template of your all styles and add





before the closing of


2. go to your captcha template and add to all styles the following on the top;






change the xxxxxxxxxxxxxxxxxxxx with your site key where you registered with google recaptcha!


that's it ...! this works :)


same thing i posted above.

you didn't mention you still have to update the other files with joe's edits or it's not going to work.

the recaptcha option in settings has to stay on also or the recaptcha wont appear or run neither.

then after a day or two google will stop the recaptcha from working for the call back not working correctly.

joeroberts 5th August 2018 17:15

Quote:

Originally Posted by outtyrox (Post 52332)
Code:


class TSUE_captcha
{
    public function verifyCaptcha($recaptcha_challenge_field = "", $recaptcha_response_field = "")
    {
                //
                //PUT YOUR PRIVATE KEY HERE//
                $secret = "6LcsM2gUAAAAAAjbvuAs-YtADTLyAKkG96AX8nmK";
                //
                //
                //
                $remoteip = $_SERVER["REMOTE_ADDR"];
                $url = "https://www.google.com/recaptcha/api/siteverify";
                $response = $_POST["g-recaptcha-response"];
       
                // Curl Request
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, array(
                    'secret' => $secret,
                    'response' => $response,
                    'remoteip' => $remoteip
                    ));
                $curlData = curl_exec($curl);
                curl_close($curl);
       
                // Parse data
                $jsonResponse = json_decode($curlData);
                if ($jsonResponse->success === true)
                    return true;
                else
                    return false;
    }

}


problem here is
Code:

$response = $_POST["g-recaptcha-response"];
becuase you well not get that $_POST
you well need to use the
Code:

$recaptcha_response_field

outtyrox 5th August 2018 19:22

Quote:

Originally Posted by joeroberts (Post 52353)
problem here is
Code:

$response = $_POST["g-recaptcha-response"];
becuase you well not get that $_POST
you well need to use the
Code:

$recaptcha_response_field

correct because not part the form so the js has to do it from my understanding which it does but somewhere there's still an issue I cannot resolve.

I've added the following to debug it but I'm not understanding the issue yet.

//echo "
";
//print_r($_POST);

and

//testing to see if response working. comment out once working
echo "
";
print_r($response);



I thought I just use the $recaptcha_response_field for the response varible but even that doesn't produce a success for the response


here's what i see from the class_captcha.php response



//echo "
";
//print_r($_POST);
https://s22.postimg.cc/wo0r7fmpd/Scr...1.09.36_PM.png



CAPTCHA success failing
https://s22.postimg.cc/3lmh4xddt/Scr...1.12.29_PM.png


//testing to see if response working. comment out once working
echo "
";
print_r($response);
https://s22.postimg.cc/7ur7756dd/Scr...1.12.56_PM.png

Bump: I have fixed this and here's how.

the _POST of the variables to the response was not being assigned for some reason when calling ajax/signup.php at sigup and running the library/class_captcha.php

I simply made a variable in ajax/signup.php to assign the response to and that got ride the response not assigned error


edited working class_captcha.php

Code:


class TSUE_captcha
{
    public function verifyCaptcha($recaptcha_challenge_field, $recaptcha_response_field)
    {
               
                //
                //PUT YOUR PRIVATE KEY HERE//
                $secret = "6LcsM2gUAAAAAAjbvuAs-YtADTLyAKkG96AX8nmK";
                //
                //
                //
                global $_POST;
                $remoteip = $_SERVER["REMOTE_ADDR"];
                $url = "https://www.google.com/recaptcha/api/siteverify";
       
                // Curl Request
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, array(
                    'secret' => $secret,
                    'response' => $recaptcha_response_field,
                    'remoteip' => $remoteip
                    ));
                $result = curl_exec($curl);
                curl_close($curl);
       
                $result = json_decode($result);
               
               
                //echo "
";
                //echo print_r($recaptcha_response_field);
                //echo print_r($result);
                //echo "
";
               
               
                if ($result -> success) {
                    return true;
                }
                else
                {
                    return false;
                }
    }

}
?>



edited ajax/signup.php


- search for $_POST["g-recaptcha-response"]; in ajax/signup.php
- created a variable $recaptcha_response_field = $_POST["g-recaptcha-response"];
- edit if( !$verifyCaptcha->verifyCaptcha($recaptcha_challenge_field, $_POST["g-recaptcha-response"];))

and make it

- if( !$verifyCaptcha->verifyCaptcha($recaptcha_challenge_field, $recaptcha_response_field))


https://s22.postimg.cc/ysqoipi75/Scr...1.37.47_AM.png

Bump: Here's the updated TSUE v2.2 source code with Recaptcha v2 working

- Complete with files updated included that joe made with one minor edit to /ajax/signup.php
- Updated default database with template edits already done so you dont have to do them. only the public key entry in captcha template

1. Extract and upload directory to your domain web host
2. Create a database in CPANEL
3. Use MyPHPAdmin and Import default database file to your newly created database
4. Run installer: https://yourdomainnamehere.com/tsue_install/install.php

5. Make a Google Recaptcha key pair for your domain

- Edit template named captcha and put in your and public captcha key
- Edit /library/classes/class_captcha.php and put in your private captcha key

6. Proceed as normal

Credits to joe roberts for file updates and Napon for his work.


Code:

https://my.pcloud.com/publink/show?code=XZVvdW7ZO707LfnGq6L3cvv6lbVjN7gc9Sak
Bump: ========================================
use this to resize the captcha.

note: this is the catpcha part edited in the template. don't forget to enter your site key of course.


Code:




All times are GMT +2. The time now is 09:57.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.