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
AJAX Check Username on Signup
Controls ·  Search New posts · Mark unread

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

2020-02-12 22:43:59
Here I compiled and tested this using several variations of ajax scripts, and this is the best by far in many ways. PDO in its purest.

Upload ajax_checkusername.php to main directory.

Open account-signup.php and find:

<tr>
   <td><?php echo T_("USERNAME"); ?>: <font class="required">*</font></td>
    <td><input type="text" size="40" name="wantusername" /></td>
</tr>


And replace with this:

<tr>
   <td><?php echo T_("USERNAME"); ?>: <font class="required">*</font></td>
    <td><input type="text" size="40" name="wantusername" id="validate" /></td>
    <!-- Response -->
    <div id="uname_response" ></div>
<script type="text/javascript">
$(document).ready(function() {
   $("#validate").keyup(function() {
       var a = $(this).val().trim();
       if ("" != a) {
           $("#uname_response").show();
           $.ajax({
               url: "ajax_checkusername.php", /* Use absolute url if you are using rewritten urls */
               type: "post",
               data: {
                   username: a
               },
               success: function(a) {
                   $("#uname_response").html(a);
               }
           });
       } else $("#uname_response").hide();
   });
});
</script>
</tr>


Be sure to update the database details in ajax_checkusername.php to match yours. Enjoy.
ajax_checkusername.zip
Download
2020-05-03 19:22:49
hi STorrents2020

first a big thank you for this hack and you can see the result on an image?

Thanks you!
2020-05-04 06:31:35
"spiritblue, post: 68499, member: 401":

hi STorrents2020

first a big thank you for this hack and you can see the result on an image?

Thanks you!


No worries! It was a quick put together and did the job well. You can update it to retrieve the matched row data for which user exists already in db, is that what you need? :alien:
2020-05-04 08:26:59
I wanted a picture of the result
2020-05-04 10:20:24
"spiritblue, post: 68504, member: 401":

I wanted a picture of the result


/PM
2020-05-05 08:28:00
ok thanks,
[ATTACH type="full" alt="Capture.PNG"]5498[/ATTACH]

[ATTACH type="full" alt="Capture2.PNG"]5497[/ATTACH]

first PDO that works for me with this config (y) ? ?

Version Mysql: 10.3.22-MariaDB-log-cll-lve
Version PHP: 7.3.17
Capture.PNG
Capture.PNG
Capture2.PNG
Capture2.PNG
Capture.PNG
Capture.PNG

2020-05-05 08:38:55
Question:
why your page entry is not in ?
Example(ajax_checkusername.php):  <? php
2020-05-05 09:23:25
"spiritblue, post: 68512, member: 401":

Question:
why your page entry is not in ?
Example(ajax_checkusername.php):  <? php


On live site?
2020-05-05 19:40:36
no,  the beginning of your page with <? is written without php
for the file of the name of ajax_checkusername.php :)
[ATTACH type="full"]5499[/ATTACH]
Capture.PNG
Capture.PNG

2020-05-05 21:25:16
"spiritblue, post: 68515, member: 401":

no,  the beginning of your page with <? is written without php
for the file of the name of ajax_checkusername.php :)
[ATTACH=full]5499[/ATTACH]


just personal preference, the last mod I posted I’ve corrected all tags before post
2020-05-05 23:51:17
"STorrents2020, post: 68518, member: 20382":

just personal preference, the last mod I posted I’ve corrected all tags before post

ha ok! (y) ;)
2020-05-08 23:42:15
I have a question. I fiddled about with this for a minute and got nowhere. Im a bit rusty lately and probably smoke too much weed, but im having fun ;) . I am using a php/html page for the account-signup just cuz it looked cool. Where would I place this code? If it dont work for me, thats fine. Im just having some fun and playing around
<?php
require_once("backend/functions.php");
dbconn();
session_start();
$site_config["LEFTNAV"] = $site_config["MIDDLENAV"] = $site_config["RIGHTNAV"] = false;
$username_length = 15; // Max username length. You shouldn't set this higher without editing the database first
$password_minlength = 6;
$password_maxlength = 40;

// Disable checks if we're signing up with an invite
if (!is_valid_id($_REQUEST["invite"]) || strlen($_REQUEST["secret"]) != 32) {
   //invite only check
   if ($site_config["INVITEONLY"]) {
       echo '<script>alert("This site is invite only")</script>';
       stdfoot();
       die();
//        show_error_msg(T_("INVITE_ONLY"), "<br /><br /><center>".T_("INVITE_ONLY_MSG")."<br /><br /></center>",1);
   }

   //get max members, and check how many users there is
   $numsitemembers = get_row_count("users");
   if ($numsitemembers >= $site_config["maxusers"])
       show_error_msg(T_("SORRY")."...", T_("SITE_FULL_LIMIT_MSG") . number_format($site_config["maxusers"])." ".T_("SITE_FULL_LIMIT_REACHED_MSG")." ".number_format($numsitemembers)." members",1);
} else {
   $res = SQL_Query_exec("SELECT id FROM users WHERE id = $_REQUEST[invite] AND MD5(secret) = ".sqlesc($_REQUEST["secret"]));
   $invite_row = mysqli_fetch_assoc($res);
   if (!$invite_row) {
       show_error_msg(T_("ERROR"), T_("INVITE_ONLY_NOT_FOUND")." ".($site_config['signup_timeout']/86400)." days.", 1);
   }
}

if ($_GET["takesignup"] == "1") {

$message == "";

function validusername($username) {
       $allowedchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
       for ($i = 0; $i < strlen($username); ++$i)
           if (strpos($allowedchars, $username[$i]) === false)
           return false;
       return true;
}

   $wantusername = $_POST["wantusername"];
   $email = $_POST["email"];
   $wantpassword = $_POST["wantpassword"];
   $passagain = $_POST["passagain"];
   $country = $_POST["country"];
   $gender = $_POST["gender"];
   $client = $_POST["client"];
   $age = (int) $_POST["age"];

 if (empty($wantpassword) || (empty($email) && !$invite_row) || empty($wantusername))
   $message = T_("DONT_LEAVE_ANY_FIELD_BLANK");
 elseif (strlen($wantusername) > $username_length)
   $message = sprintf(T_("USERNAME_TOO_LONG"), $username_length);
 elseif ($wantpassword != $passagain)
   $message = T_("PASSWORDS_NOT_MATCH");
 elseif (strlen($wantpassword) < $password_minlength)
   $message = sprintf(T_("PASS_TOO_SHORT"), $password_minlength);
 elseif (strlen($wantpassword) > $password_maxlength)
   $message = sprintf(T_("PASS_TOO_LONG"), $password_maxlength);
 elseif ($wantpassword == $wantusername)
    $message = T_("PASS_CANT_MATCH_USERNAME");
 elseif (!validusername($wantusername))
   $message = "Invalid username.";
 elseif (!$invite_row && !validemail($email))
       $message = "That doesn't look like a valid email address.";

///captcha shit. Delete if not working////////
$QaptChaInput = $_SESSION['qaptcha_key'];
   if (!isset($_POST[$QaptChaInput]))
       $message = 'Captcha failure.';
       unset($_SESSION['qaptcha_key']);
///end captcha shit//////

   if ($message == "") {
       // Certain checks must be skipped for invites
       if (!$invite_row) {
           //check email isnt banned
           $maildomain = (substr($email, strpos($email, "@") + 1));
           $a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from email_bans where mail_domain='$email'")));
           if ($a[0] != 0)
               $message = sprintf(T_("EMAIL_ADDRESS_BANNED_S"), $email);

           $a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from email_bans where mail_domain LIKE '%$maildomain%'")));
           if ($a[0] != 0)
               $message = sprintf(T_("EMAIL_ADDRESS_BANNED_S"), $email);

         // check if email addy is already in use
         $a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from users where email='$email'")));
         if ($a[0] != 0)
           $message = sprintf(T_("EMAIL_ADDRESS_INUSE_S"), $email);
       }

      //check username isnt in use
     $a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from users where username='$wantusername'")));
     if ($a[0] != 0)
       $message = sprintf(T_("USERNAME_INUSE_S"), $wantusername);

//      $secret = mksecret(); //generate secret field //commented due to IP check also using same vars below
//
//      $wantpassword = passhash($wantpassword);// hash the password //commented due to IP check also using same vars below
   }

   if ($message != "")
       show_error_msg(T_("SIGNUP_FAILED"), $message, 1);

           //check if IP is already a peer
           if ($site_config["ipcheck"] && $site_config["accountmax"] >= "1") {
           $ip = $_SERVER['REMOTE_ADDR'];
           $ipq = get_row_count("users", "WHERE ip = '$ip'");
           if ($ipq >= $site_config["accountmax"])
           $message = $site_config["SITENAME"]." only allows " . $site_config["accountmax"] . " user account per IP address. <br> If you want to create a new account, please contact an administrator.<br /><br /><font color=red> The limit for ip : $ip has been reached.</font><br /><br />Registration failed. <br /><a style='cursor: pointer;cursor:hand;' href='account-login.php'><font color=red>Click here to return to the login page.</font></a>";
   }
           $secret = mksecret(); //generate secret field

           $wantpassword = passhash($wantpassword);// hash the password


   if ($message != "")
       show_error_msg(T_("SIGNUP_FAILED"), $message, 1);

 if ($message == "") {
       if ($invite_row) {
           SQL_Query_exec("UPDATE users SET username=".sqlesc($wantusername).", password=".sqlesc($wantpassword).", secret=".sqlesc($secret).", status='confirmed', added='".get_date_time()."' WHERE id=$invite_row[id]");
           //send pm to new user
           if ($site_config["WELCOMEPMON"]){
               $dt = sqlesc(get_date_time());
               $msg = sqlesc($site_config["WELCOMEPMMSG"]);
               SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $invite_row[id], $dt, $msg, 0)");
           }
           header("Refresh: 0; url=account-confirm-ok.php?type=confirm");
           die;
       }

   if ($site_config["CONFIRMEMAIL"]) { //req confirm email true/false
       $status = "pending";
   }else{
       $status = "confirmed";
   }

   //make first member admin
   if ($numsitemembers == '0')
       $signupclass = '8';
   else
       $signupclass = '1';

    SQL_Query_exec("INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, uploaded, downloaded, language, invites, class, ip) VALUES (" .
    implode(",", array_map("sqlesc", array($wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), $age, $country, $gender, $client, $site_config["default_theme"], $site_config["new_member_upload_ratio"], 0, $site_config["default_language"], $site_config["new_member_invites"], $signupclass, getip()))).")");

   $id = mysqli_insert_id($GLOBALS["DBconnector"]);

   $psecret = md5($secret);
   $thishost = $_SERVER["HTTP_HOST"];
   $thisdomain = preg_replace('/^www\./is', "", $thishost);

   //ADMIN CONFIRM
   if ($site_config["ACONFIRM"]) {
       $body = T_("YOUR_ACCOUNT_AT")." ".$site_config['SITENAME']." ".T_("HAS_BEEN_CREATED_YOU_WILL_HAVE_TO_WAIT")."\n\n".$site_config['SITENAME']." ".T_("ADMIN");
   }else{//NO ADMIN CONFIRM, BUT EMAIL CONFIRM
       $body = T_("YOUR_ACCOUNT_AT")." ".$site_config['SITENAME']." ".T_("HAS_BEEN_APPROVED_EMAIL")."\n\n    ".$site_config['SITEURL']."/account-confirm.php?id=$id&secret=$psecret\n\n".T_("HAS_BEEN_APPROVED_EMAIL_AFTER")."\n\n    ".T_("HAS_BEEN_APPROVED_EMAIL_DELETED")."\n\n".$site_config['SITENAME']." ".T_("ADMIN");
   }

   if ($site_config["CONFIRMEMAIL"]){ //email confirmation is on
       sendmail($email, "Your $site_config[SITENAME] User Account", $body, "", "-f$site_config[SITEEMAIL]");
       header("Refresh: 0; url=account-confirm-ok.php?type=signup&email=" . urlencode($email));
   }else{ //email confirmation is off
       header("Refresh: 0; url=account-confirm-ok.php?type=noconf");
   }
   //send pm to new user
   if ($site_config["WELCOMEPMON"]){
       $dt = sqlesc(get_date_time());
       $msg = sqlesc($site_config["WELCOMEPMMSG"]);
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $id, $dt, $msg, 0)");
   }

   die;
 }

}//end takesignup



//stdhead(T_("SIGNUP"));
//begin_frame(T_("SIGNUP"));
?>
<form method="post" action="account-signup.php?takesignup=1">
   <?php if ($invite_row) { ?>
   <input type="hidden" name="invite" value="<?php echo $_GET["invite"]; ?>" />
   <input type="hidden" name="secret" value="<?php echo htmlspecialchars($_GET["secret"]); ?>" />
   <?php } ?>
   <table cellspacing="0" cellpadding="2" border="0">
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title><?php $site_config["SITENAME"] ?></title>
   <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
   <link rel="stylesheet" type="text/css" href="css/fontawesome-all.min.css">
   <link rel="stylesheet" type="text/css" href="css/iofrm-style.css">
   <link rel="stylesheet" type="text/css" href="css/iofrm-theme14.css">
</head>
<body>
   <div class="form-body" class="container-fluid">
       <div class="row">
           <div class="form-holder">
               <div class="form-content">
                   <div class="form-items">
                       <div class="website-logo-inside">
                           <a href="index.html">
                           </a>
                       </div>
                       <h3>Use the form below to sign up.</h3>
                       <p>Name, Password and E-mail are required.</p>
                       <div class="page-links">
                           <a href="account-login.php">Login</a><a href="account-signup.php" class="active">Register</a><a href="account-recover.php">Recover Account</a>
                       </div>
                       <form>
                           <input class="form-control" autocomplete="off" type="text" name="wantusername" placeholder="Username" required>                          
                           <input class="form-control" autocomplete="off" type="password" name="wantpassword" placeholder="Password" required>        
                           <input class="form-control" autocomplete="off" type="password" name="passagain" placeholder="Confim Password" required>
                           <input class="form-control" autocomplete="off" type="text" name="email" placeholder="E-mail Address" required>
                           <input class="form-control" autocomplete="off" type="text" name="age" placeholder="Age" maxlength="3">
                           <input class="form-control" autocomplete="off" list="country" name="country" placeholder="Country. Click for options">
                           <datalist id="country">
                           <?php
                           $countries = "<option value=\"0\">---- ".T_("NONE_SELECTED")." ----</option>\n";
                           $ct_r = SQL_Query_exec("SELECT id,name,domain from countries ORDER BY name");
                           while ($ct_a = mysqli_fetch_assoc($ct_r)) {
                           $countries .= "<option value=\"$ct_a[id]\">$ct_a[name]</option>\n";
                           }
                           ?>
                           <?php echo $countries; ?>
                           </datalist>
                           <input class="form-control" list="client" type="text" name="client" placeholder="Torrent Client Used. Click for options" autocomplete="off">
                       
<datalist id="client">
<option value= "ABC">
<option value= "Acquisition">
<option value= "Anatomic P2P">
<option value= "Arctic Torrent">
<option value= "aria2">
<option value= "Azureus">
<option value= "BiglyBT">
<option value= "BitComet">
<option value= "BitFlu">
<option value= "BitLet">
<option value= "BitPump">
<option value= "BitTorrent 5 / Mainline">
<option value= "BitSpirit">
<option value= "BitTyrant">
<option value= "Blizzard Downloader">
<option value= "Blog Torrent">
<option value= "BTPD">
<option value= "BTSharp (library)">
<option value= "burst!">
<option value= "CTorrent">
<option value= "Deluge">
<option value= "FlashGet">
<option value= "Folx">
<option value= "freeloader">
<option value= "G3 Torrent">
<option value= "Gnome BitTorrent">
<option value= "Halite">
<option value= "KTorrent">
<option value= "MLDonkey">
<option value= "MonoTorrent (client library)">
<option value= "MooPolice">
<option value= "Opera">
<option value= "QTorrent">
<option value= "Qbittorrent">
<option value= "rTorrent">
<option value= "Rufus">
<option value= "Shareaza">
<option value= "sharktorrent">
<option value= "SymTorrent">
<option value= "Torrent Swapper">
<option value= "TorrentVolve">
<option value= "Transmission">
<option value= "Turbo Torrent">
<option value= "TorrentSpy Rufus">
<option value= "µTorrent">
<option value= "XTorrent">
<option value= "ZipTorrent">
 </datalist>
                           <div class="form-button">
                               <div class="QapTcha"></div>
                               <button id="submit" type="submit" class="ibtn">Register</button>
                           </div>
                       </form>
                   </div>
               </div>
           </div>
       </div>
   </div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
   </table>
</form>

<!--captcha shit. Delete if not working-->
<link rel="stylesheet" href="jquery/QapTcha.jquery.css" type="text/css" />
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.js"></script>
<script type="text/javascript" src="jquery/jquery.ui.touch.js"></script>
<script type="text/javascript" src="jquery/QapTcha.jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
   $('.QapTcha').QapTcha({disabledSubmit:true,autoRevert:true});
   });
</script>
<!--end captcha shit -->

<?php
//end_frame();
?>

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)
2020-05-09 02:08:36
You had a lot of time to waste! ?
2020-05-10 00:15:59
Do you want me to merge into a new file using that code you posted? As you are custom HTML as myself
2020-05-10 10:36:23
Yes. I must be doing something wrong.
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)
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: 8
  • Members: 0
  • Guests online: 8
  • Comments: 3
  • Messages: 1,728