Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Google reCAPTCHA [TTv3]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2019-04-30 23:07:43
Figured I would post this.

Go to google and get your keys https://www.google.com/recaptcha/intro/v3.html

in the default theme (whichever theme you have set as theme id 1) header.php, at the bottom, put
<script src="https://www.google.com/recaptcha/api.js" async defer></script>


enter your keys below and replace your account-login.php, or pull code from below and add it to your own custom login
<?php
require_once("backend/functions.php");
dbconn();

///Enter google keys below
$siteKey = 'key_here';
$secret = 'secretkey_here';
///end google reCAPTCHA

session_start();
$site_config["LEFTNAV"] = $site_config["MIDDLENAV"] = $site_config["RIGHTNAV"] = false;

///WARNING COMMENTED IF YOU HAVE A FULL PAGE LOGIN. OTHERWISE UNCOMMENT.
//if (!empty($_REQUEST["returnto"])) {
//   if (!$_GET["nowarn"]) {
//       $nowarn = T_("MEMBERS_ONLY");
//   }
//}
// END WARNING COMMENT

if ($_POST["username"] && $_POST["password"]) {
  $password = passhash($_POST["password"]);

  if (!empty($_POST["username"]) && !empty($_POST["password"])) {
     $res = SQL_Query_exec("SELECT id, password, secret, status, enabled FROM users WHERE username = " . sqlesc($_POST["username"]) . "");
     $row = mysqli_fetch_assoc($res);
     $captcha;
     if(isset($_POST['g-recaptcha-response'])){
         $captcha=$_POST['g-recaptcha-response'];
       }
       if(!$captcha){
         $message = '<h2>Please check the the captcha form.</h2>';
         header("Refresh: 1; url= account-login.php");
       }
       $secretKey = "<?php echo $secret;?>";
       $ip = $_SERVER['REMOTE_ADDR'];
       $response="file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip.")";

     if ( ! $row || $row["password"] != $password )
        $message = T_("LOGIN_INCORRECT");
     elseif ($row["status"] == "pending")
        $message = T_("ACCOUNT_PENDING");
     elseif ($row["enabled"] == "no")
        $message = T_("ACCOUNT_DISABLED");
  } else
     $message = T_("NO_EMPTY_FIELDS");

  if (!$message){
     logincookie($row["id"], $row["password"], $row["secret"]);
     if (!empty($_POST["returnto"])) {
        header("Refresh: 0; url=" . $_POST["returnto"]);
        die();
     }
     else {
        header("Refresh: 0; url=index.php");
        die();
     }
  }else{
     show_error_msg(T_("ACCESS_DENIED"), $message, 1);
  }
}
unset($_POST['g-recaptcha-response']);
logoutcookie();

stdhead(T_("LOGIN"));

if ($nowarn)
     show_error_msg(T_("ERROR"), $nowarn, 0);

begin_frame(T_("LOGIN"));
?>
<form method="post" action="account-login.php">
 <table border="0" cellpadding="2" align="center">
     <tr><td align="center"><b><?php echo T_("USERNAME"); ?>:</b> <input type="text" size="40" name="username" /></td></tr>
     <tr><td align="center"><b><?php echo T_("PASSWORD"); ?>:</b> <input type="password" size="40" name="password" /></td></tr>
       <tr><td align="center"><div class="g-recaptcha" data-theme="light" data-sitekey="<?php echo $siteKey; ?>"></div></td></tr>
     <tr><td colspan="2" align="center"><input type="submit" value="<?php echo T_("LOGIN"); ?>" /><br /><br /><i><?php echo T_("COOKIES");?></i></td></tr>
  </table>
<?php

if ( ! empty($_REQUEST["returnto"]) )
{
     print("<input type=\"hidden\" name=\"returnto\" value=\"" . cleanstr($_REQUEST["returnto"]) . "\" />\n");
}
?>
</form>
<p align="center"><a href="account-signup.php"><?php echo T_("SIGNUP"); ?></a> | <a href="account-recover.php"><?php echo T_("RECOVER_ACCOUNT"); ?></a></p>
<?php
end_frame();
stdfoot();
?>

Alter this portion of the code to set a light or dark background for the re-captcha to fit your theme

data-theme="light"

[ATTACH type="full"]5036[/ATTACH]
Capture.PNG
Capture.PNG

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2019-05-17 22:48:33
Thanks you ! M8
2019-05-17 22:50:15
mini error
<script src="https://www.google.com/recaptcha/api.js" [color=rgb(184, 49, 47)]async defer[/color]></script>
;)

<script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>
Unknown User
2019-05-18 08:35:00
Not error. Async defer means that it will prioritize async loading and if not supported then it will be defer. It is a modern way of handling javascript.
"spiritblue, post: 66590, member: 401":

mini error
<script src="https://www.google.com/recaptcha/api.js" [color=rgb(184, 49, 47)]async defer[/color]></script>
;)

<script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>
2019-05-18 20:35:35
ok(y), but on my side I remove "async defer" and it does not change anything :rolleyes:
Unknown User
2019-05-18 20:55:21
"spiritblue, post: 66595, member: 401":

ok(y), but on my side I remove "async defer" and it does not change anything :rolleyes:

it doesn't suppose to change anything.

  • Async scripts are executed as soon as the script is loaded, so it doesn't guarantee the order of execution (a script you included at the end may execute before the first script file )
  • Defer scripts guarantees the order of execution in which they appear in the page.
2019-05-18 21:11:27
"shadows, post: 66596, member: 20311":

it doesn't suppose to change anything.

  • Async scripts are executed as soon as the script is loaded, so it doesn't guarantee the order of execution (a script you included at the end may execute before the first script file )
  • Defer scripts guarantees the order of execution in which they appear in the page.


after updating my page, you're right I had to give it back, thank you (y)
Unknown User
2019-05-24 19:50:20
[USER=311]@MicroMonkey[/USER] there is a brute-force here with this captcha. The form is checking if password or username is correct before asking for captcha so attacker can run brute-force until they find a right password.

Fix:
in the code find and delete

  if(!$captcha){
         $message = '<h2>Please check the the captcha form.</h2>';
         header("Refresh: 1; url= account-login.php");
       }


Now above
if ( ! $row || $row["password"] != $password )

Add the code which you deleted:
 if(!$captcha){

         $message = '<h2>Please check the the captcha form.</h2>';

         header("Refresh: 1; url= account-login.php");

       }


And this will solve brute-force attacks :)
2019-05-25 12:54:51
thank you very much. I didnt know this
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2026-11-08 12:24:50
signup captcha??
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728