little class i made using this https://torrenttrader.uk/topic?topicid=9935#post67759
first in config the keys you get from here https://www.google.com/recaptcha/about/
in account login find
add below
find
below add
find in backend / function.php
add under
make file called Captcha.php add in backend folder
first in config the keys you get from here https://www.google.com/recaptcha/about/
// Captcha use google api
$site_config['CAPTCHA_ON'] =true;
$site_config['CAPTCHA_KEY'] = 'googlecaptchakey';
$site_config['CAPTCHA_SECRET'] = 'googlecaptchasecret'; in account login find
if ($_POST["username"] && $_POST["password"]) {add below
(new Captcha)->response($_POST['g-recaptcha-response']);find
<tr><td align="center"><b><?php echo T_("PASSWORD"); ?>:</b> <input type="password" size="40" name="password" /></td></tr>below add
<?php (new Captcha)->html(); ?>find in backend / function.php
require_once(BACKEND."/languages.php");add under
require_once(BACKEND."/Captcha.php");make file called Captcha.php add in backend folder
<?php
class Captcha
{
private $key;
private $secret;
public function __construct()
{
global $site_config;
$this->key = $site_config['CAPTCHA_KEY'];
$this->secret = $site_config['CAPTCHA_SECRET'];
}
public function response($captcha)
{
global $site_config;
if ($site_config['CAPTCHA_ON']) {
if (!$captcha) {
autolink(T_('<b>Please check the the captcha form.</b>'), "account-login.php");
}
$secret = $site_config['CAPTCHA_SECRET'];
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $this->secret . '&response=' . $captcha);
$responseData = json_decode($verifyResponse);
if ($responseData->success) {
// its successfull so let it go
} else {
autolink(T_('<b>Please check the the captcha form.</b>'), "account-login.php");
}
}
}
public function html()
{
global $site_config;
if ($site_config['CAPTCHA_ON']) {
return print("<div class='g-recaptcha' data-theme='light' data-sitekey='" . $this->key . "'></div>");
}
}
}
Last edited by M-jay
on 2021-09-08 17:39:27
on 2021-09-08 17:39:27
