Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Template Shares
Reply
  #51  
Old 5th August 2018, 17:15
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
Quote:
Originally Posted by outtyrox View Post
Code:
<?php 

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
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #52  
Old 5th August 2018, 19:22
outtyrox outtyrox is offline
Senior Member
 
Join Date: Apr 2015
Posts: 59
Default
Quote:
Originally Posted by joeroberts View Post
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 "<pre>";
//print_r($_POST);

and

//testing to see if response working. comment out once working
echo "<pre>";
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 "<pre>";
//print_r($_POST);
Click the image to open in full size.



CAPTCHA success failing
Click the image to open in full size.


//testing to see if response working. comment out once working
echo "<pre>";
print_r($response);
Click the image to open in full size.

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:
<?php 

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 "<pre>";
                //echo print_r($recaptcha_response_field);
                //echo print_r($result);
                //echo "<pre>";
                
                
                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))


Click the image to open in full size.

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:
 <div class="g-recaptcha" data-theme="light" data-sitekey="XXXXXXXXXXXXX" style="transform:scale(0.77);-webkit-transform:scale(0.77);transform-origin:0 0;-webkit-transform-origin:0 0;"></div>
Reply With Quote
Reply

Tags
22 , recaptcha , tsue

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 16:50. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.