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
Invite By Code V3
Controls ·  Search New posts · Mark unread

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

2022-04-29 16:39:26
In Progress but should work fully - needs some testing before live site.

1) If user has invite - user can make code
2) user sends code to friend by email
3) friend inputs code
4) if code ok - signup - include admin confirm, welcome message etc etc

Works same as invites except user NOT created unless code excepted

SQL
CREATE TABLE `invites` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`inviter` int(10) unsigned NOT NULL DEFAULT '0',
`inviteid` int(10) NOT NULL DEFAULT '0',
`invite` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`time_invited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`confirmed` char(3) COLLATE utf8_bin NOT NULL DEFAULT 'no',
PRIMARY KEY (`id`),
KEY `inviter` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=182 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


create file invitecode.php
<?php
// Get File
require_once "backend/functions.php";
require_once "backend/config.php";

// Get Functions
dbconn();
loggedinonly();

// Count Max Users
$users = get_row_count("users", "WHERE enabled = 'yes'");
if ($users >= $site_config["maxusers_invites"]) {
show_error_msg(T_("ERROR"), "Sorry, The current user account limit (" . number_format($site_config["maxusers_invites"]) . ") has been reached. Inactive accounts are pruned all the time, please check back again later...", 1);
}

// Form Submitted
$mail = $_POST['email'];
$code = $_POST['secretcode'];
$specailcode = $_POST['specialcode'];
$type = $_GET['type'];

// Delete Code
if ($type == 'del') {
SQL_Query_exec("DELETE FROM invites WHERE invite = '$_GET[invite]'");
SQL_Query_exec("UPDATE users SET invites = ($CURUSER[invites] +1 ) WHERE id = $CURUSER[id]");
autolink("invitecode.php", "deleted invite code");
   die();
}

// Create Code
if (!empty($code)) {
   // Get User ID
   $id = 0 + $_GET["id"];
   if ($id == 0) {
       $id = $CURUSER["id"];
   }
   if (get_user_class() <= 6)
       $id = $CURUSER["id"];

   SQL_Query_exec("INSERT INTO invites (inviter, invite, time_invited) VALUES ('$id', '$code', '" . get_date_time() . "')");
   SQL_Query_exec("UPDATE users SET invites = invites - 1 WHERE id = $id");
   header("Refresh: 0; url=invitecode.php");
}

// Count Invites
$count = get_row_count("users", "WHERE invites > 0 AND id = $CURUSER[id]");
if ($count <= 0) {
   show_error_msg(T_("ERROR"), "Vous avez aucune invitation!");
}

// create secret
$secret = mksecret();
$psecret = md5($secret);

// show page
stdhead("Invite");
begin_frame("Invites");
echo "<center>This is last code $psecret</center>";
print("<br /><center><a class=stylebouton href=invitetree.php>".T_("INVITE_TREE")."</a></center>"); //one small space here!
?>
<form method="post" action="invitecode.php">
   <input type="hidden" name="secretcode" value="<?php echo $psecret ?>">
   <input type="submit" value="Create Code">
</form>
<?php
$rul = get_row_count("invites", "WHERE inviter = $CURUSER[id]");
$rer = SQL_Query_exec("SELECT inviteid, invite, time_invited FROM invites WHERE inviter = $CURUSER[id] AND confirmed='no'");
$num1 = mysqli_num_rows($rer);
print("<table border=0 width=750 cellspacing=0 cellpadding=5>".
"<tr class=tabletitle><td class=table_head colspan=6><b>Statut actuel des codes créés</b> ($rul) <br/><font color=#B0FF30><b>NB</b></font>: <i>Signalez à vos invités que le code est valide pour 5 jours.</i></td></tr>");
if(!$num1){
print("<tr class=ttable_col1><td colspan=6><i><b>...Aucun code d'invitation créé pour le moment !</b></i></tr>");
} else {
print("<tr class=tableb><td class=table_head><b>".T_("CODE_INVITE_")."</b></td><td class=table_head><b>".T_("CREATED_DATE")."</b></td><td class=table_head><b>".T_("DELETE_INVITE")."</td></tr>");
for ($i = 0; $i < $num1; ++$i)
{
$arr1 = mysqli_fetch_assoc($rer);
print("<tr><td class=table_col1 align=center>$arr1[invite]</td><td class=table_col1 align=center>$arr1[time_invited]</td>");
//print("<td><input type=\"checkbox\" name=\"conusr[]\" value=\"" . $arr['id'] . "\" /></td></tr>");
print ("<td class=table_col2 align=center><a href=\"invitecode.php?invite=$arr1[invite]&type=del\"><img src='images/delete.png' alt='".T_("DELETE_INVITE")."' width='17' height='17' border='0' /></a></td></tr>");
}
}
print("</table><br/>");
end_frame();
stdfoot();


Create file activatecode.php
<?php
require_once("backend/functions.php");
dbconn();
loggedinonly();

// FORM SUBMITTED
if ($_GET["take"]) {
   $code = $_POST['secret'];
$secret = mksecret(20);

// Create User
$ret = SQL_Query_exec("INSERT INTO users (username, secret, email, status, invited_by, added, stylesheet, language) VALUES (".
implode(",", array_map("sqlesc", array($code, $code, $email, 'pending', $CURUSER["id"]))) . ",'" . get_date_time() . "', $site_config[default_theme], $site_config[default_language])");

// Update Inviter
$last_id =  mysqli_insert_id($GLOBALS["DBconnector"]);
$invitees = "$id $CURUSER[invitees]";
SQL_Query_exec("UPDATE users SET invites = invites - 1, invitees='$invitees' WHERE id = $CURUSER[id]");

// Delete Invite
//SQL_Query_exec("DELETE FROM invites WHERE invite = $code");

autolink("account-signup.php?invite=$last_id&secret=$code", "Now Signup");
die;
}

// Show Page
stdhead(T_("activate"));
begin_frame(T_("activate"));
?>
<form method="post" action="activatecode.php?take=1">
 <label for="secret">PLACE CODE:</label>
 <input type="text" id="secret" name="secret">
 <input type="submit">
</form>
<?php
end_frame();
stdfoot();


account-signup.php find
		$res = SQL_Query_exec("SELECT id FROM users WHERE id = $_REQUEST[invite] AND MD5(secret) = ".sqlesc($_REQUEST["secret"]));

replace with
		$cutsecret = substr($_REQUEST["secret"], 0, 20);	
$res = SQL_Query_exec("SELECT id FROM users WHERE id = $_REQUEST[invite] AND secret = ".sqlesc($cutsecret));

find
		if (!$invite_row) {
show_error_msg(T_("ERROR"), T_("INVITE_ONLY_NOT_FOUND")." ".($site_config['signup_timeout']/86400)." days.", 1);
}

below add
		$res = SQL_Query_exec("SELECT * FROM invites WHERE invite = ".sqlesc($_REQUEST["secret"]));	
$invite_code = mysqli_fetch_assoc($res);
if (!$invite_code) {
show_error_msg(T_("ERROR"), T_("strange code are you sure"));
} else {
$invite_code = true;
}

find
<?php if (!$invite_row) {?>

replace with
<?php if (!$invite_row || $invite_code) {?>


1) visit yoursiteaddresscom/invitecode.php
2) make code
3) visit yoursiteaddresscom/activatecode.php
4) enter code
5) signup

any ideas let me know
😀  👍
Last edited by M-jay warn on 2022-04-29 20:09:52
2022-05-01 19:22:59
I'll give it a try. thanks. I am gunna try this for utf8mb4
CREATE TABLE `invites` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`inviter` int(10) unsigned NOT NULL DEFAULT '0',
`inviteid` int(10) NOT NULL DEFAULT '0',
`invite` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`time_invited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`confirmed` char(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'no',
PRIMARY KEY (`id`),
KEY `inviter` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=182 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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)
2022-05-02 21:26:56
hello M-jay sorry for waiting for reply lol

I had to do my inpot and format my pc, lol

good... first of all, I don't have the lines to ask to search on signup, but I tried to install it anyway and it didn't work, it gave me the error "strange code are you sure"

but if you could just give me a line of code to add for the validation to the email of my validation of the new subscriber who draws him! to have confirmation that I have validated them, it would be easier than to mess up the invitation system by code which works well, but which does not send confirmation to the guest as said above.
 here is the error image of your new invitation mode
I give you the files and the _block I made to send by email the invitation
Capture d’écran 2022-05-02 171947.png
File missing
account-signup.zip
File missing
Bureau.zip
File missing
invite_block.zip
File missing

Last edited by spiritblue on 2023-07-30 17:38:06
2022-05-03 15:26:06
try this https://torrenttrader.uk/topic?topicid=10451&page=last#post71417
Last edited by M-jay warn on 2022-05-03 15:26:48
2022-05-26 16:42:46
Every variable in this code in loosely defined and open to all kinds of issues.

Wrap your expected numbers with intval(), which defaults to 0 if not > 0 (prevents a fatal error), filter inputs (filter_var() is good to use), etc etc.

I would not use this code at this time. At best, implement rate limiting with a die() approach on excessive requests. That’s just the beginning lol..
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: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728