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
Add two invites every month to registere
Controls ·  Search New posts · Mark unread

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

Unknown User
2019-07-12 08:12:46
im sure someone asked for this ? if not how well....
this hack wil hopefully add two invites to all registerd users every 31 days Untested please report findings

openup backend/cleanup.php before the last ?> add


///ADD TWO INVITES EVERY 31 DAYS
$date = get_date_time(gmtime() - 86400 * 31);
$dt = sqlesc(get_date_time());
$subject = sqlesc('Your Free Invites');
$query = SQL_Query_exec("SELECT `id`, `username`, `invites` FROM `users` WHERE `added` >= '{$date}' AND `enabled` = 'yes'");
while ($row = mysqli_fetch_array($query)) {
$msg = sqlesc($row['username'] . '  You have recieved 2 invites for being a registerd user for 31 days');  
SQL_Query_exec("UPDATE users SET invites = ($row[invites] +2 ) WHERE id = $row[id]");
SQL_Query_exec("INSERT INTO `messages` (`sender`, `receiver`, `added`, `msg`, `poster`, `subject`) VALUES (0, " . $row['id'] . ", $dt, $msg, 0, $subject)");
 }
Unknown User
2019-07-12 09:25:53
on further tests it seems to give invites everytime the cleanup is run needs further debuging
Unknown User
2019-07-12 10:49:05
"serph, post: 66904, member: 1398":

on further tests it seems to give invites everytime the cleanup is run needs further debuging

It doesn't check if invites are already added. added >= only checks when the user has registered date above or equal to the provided date.
Unknown User
2019-07-13 05:23:05
ok ive changed the code
but im unsure of how to add a check to see if users have recieved there two invites and dont add again and again

new code

$invitetime = gmtime() - $site_config["freeinvite"];
 $dt = sqlesc(get_date_time());
 $subject = sqlesc('Your Free Invites');
 $query = SQL_Query_exec("SELECT `id`, `username`, invites FROM `users` WHERE added < FROM_UNIXTIME($invitetime)");
 while ($row = mysqli_fetch_array($query)) {
 $msg = sqlesc($row['username'] . 'You have recieved 2 invites for being a registerd user for 31 days');
 SQL_Query_exec("UPDATE users SET invites = ($row[invites] +2 ) WHERE id = $row[id] AND added  < FROM_UNIXTIME($invitetime) ");
 SQL_Query_exec("INSERT INTO `messages` (`sender`, `receiver`, `added`, `msg`, `poster`, `subject`) VALUES (0, " . $row['id'] . ", $dt, $msg, 0, $subject)");
 }


add to backend config
[$site_config['freeinvites'] = 2678400; // defualt (31 Days)


i'll keep tinkering but if anyone comes up with a soulution awsome got a few projects going on at the same time so will get back to this if nobody sorts it before
Unknown User
2019-07-13 05:54:28
It needs a new sql column where youll update received and not received or just simply add invites only to those who have 0 every month.
Unknown User
2019-07-13 06:28:48
i was thinking of just adding it to a cron and giving users invites depending on last_accsess i havent worked with cleanup before i thourght it was similair to cron which in a way it is as it executes code on a timed basis but this code adds invites every x seconds my cleanup interval is set to 3600 so im not sure whats going on here ? been a few years since i played with TT
Unknown User
2019-07-13 06:30:37
Whole cleanup should be cronjob based because when site gets extra big, cleanup.php will timeout.
Unknown User
2019-07-13 06:37:26
im working on trying to intergrate an easycrontab in to the admin panel but its coded in smarty and its being a pain in the butt asking for missing tpls gahhh and i dont want to rip the whole code into admincp its over 4000 lines as it is  ill have to do a dirty iframe hack lol ill post it up later
Unknown User
2019-07-13 06:52:12
Isnt it easier just to use cli sceduled cron like **** /var/run/php /location/to/cleanup.php
Unknown User
2019-07-14 12:00:28
[USER=1398]@serph[/USER] -> Here's the SQL to make this better and limit the database so it doesn't timeout.

[color=rgb(65, 168, 95)]Tested and working as it supposes to work.[/color]

cleanup.php on top:
function autoinvites($interval, $invites, $maxinvites) {
   $time = gmtime() - ($interval*86400);
   $res = SQL_Query_exec("SELECT id, username, class, invites FROM users WHERE enabled = 'yes' AND warned = 'no' AND UNIX_TIMESTAMP(invitedate) IS NULL OR UNIX_TIMESTAMP(invitedate) <= $time");
   if (mysqli_num_rows($res) > 0) {
       while ($arr = mysqli_fetch_assoc($res)) {
           $maxninvites = $maxinvites[$arr['class']];
           if ($arr['invites'] >= $maxninvites)
               continue;
           if (($maxninvites-$arr['invites']) < $invites)
               $invites = $maxninvites - $arr['invites'];

           SQL_Query_exec("UPDATE users SET invites = invites+$invites, invitedate = NOW() WHERE last_access < NOW() - INTERVAL 2 DAY AND invites < 1 LIMIT 100");
       }
   }
}


Now on bottom:

// START INVITES UPDATE
   // SET INVITE AMOUNTS ACCORDING TO RATIO/GIGS ETC
   // autoinvites(interval to give invites (days), min downloaded GB, max downloaded GB, min ratio, invites to give, max invites allowed (array))
   // $maxinvites[CLASS ID] = max # of invites;
   $maxinvites[1] = 5;   //
   $maxinvites[2] = 5;  //
   $maxinvites[3] = 5;  //
   $maxinvites[4] = 5;  //
   $maxinvites[5] = 20; //
   $maxinvites[6] = 20; //
   $maxinvites[7] = 100; //

 // Give 2 invite every 30 days to users who logged in last 2 days.

   autoinvites(30, 2, $maxinvites);
Unknown User
2019-07-14 12:40:28
awsome well done [USER=20311]@shadows[/USER] (y)
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