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
Demote uploaders if not uploaded any torrents in x days
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2023-07-06 10:06:10
This is just an mod that auto demote uploaders if they didnt upload any torrents in 2 days

add in cleanup before last ?>
// Demote Uploaders if NO UPLOADS in 7 days
$maxdt = get_date_time(gmtime() - 86400 * 7);
$maxdt = sqlesc($maxdt);

$res = SQL_Query_exec("
   SELECT u.id, u.username, u.modcomment, COUNT(t.owner) AS upload_count
   FROM users u
   LEFT JOIN torrents t ON t.owner = u.id AND t.added > $maxdt
   WHERE u.class = 9
   GROUP BY u.id, u.username
", [$maxdt]);

if (mysqli_num_rows($res) > 0) {
   $dt = get_date_time();
   $msg = "Unfortunately, you have been demoted from UPLOADER to Flat Cested due to not uploading any torrents in the last 7 days.";
   $msg = sqlesc($msg);

   while ($arr = mysqli_fetch_assoc($res)) {
       $userId = $arr['id'];
       $username = $arr['username'];
       $modcomment = $arr['modcomment'];
       $uploadCount = $arr['upload_count'];

       if ($uploadCount == 0) {
           $modcomment = gmdate("Y-m-d") . " - Has been demoted from Uploader to Flat Cested. No uploads in 7 days\n " . $modcomment;
           $modcomment = sqlesc($modcomment);

           SQL_Query_exec("UPDATE users SET modcomment = modcomment, class = 1 WHERE id = $userId", [$modcomment, $userId]);
           SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES (0, $userId, $dt, $msg, 0)", [$userId, $dt, $msg]);

           write_log("User <a href=account-details.php?id=$userId>$username</a> was automatically demoted from Uploader to Flat Cested by the system. Reason: No uploads for 7 Days");
       }
   }
}


change u.class = 9 with your uploader class
change $maxdt = get_date_time(gmtime() - 86400*7); with how many days you want to give for uploaders .
You can add warn
Last edited by djlive on 2023-07-07 11:59:19
2023-07-06 16:02:41
Try this:


SELECT DISTINCT (SELECT COUNT(id) FROM torrents WHERE owner = u.id) AS total,
u.modcomment, u.username
FROM torrents t
LEFT JOIN users u ON u.id= t.owner
WHERE t.owner = u.id
AND t.added >= DATE_SUB(CURRENT_DATE, INTERVAL 2 DAY)


Sub-query, because you reduce your dataset if you call on a direct count statement. And use COUNT(id) to use a primary index, which is faster as the user table grows, includes correct calculation for determining the criteria against all users found. DISTINCT because we filter duplicate rows in absence of GROUP BY, just for demonstration.
Last edited by STorrents2020 on 2023-07-06 16:12:47
2023-07-06 16:05:35
It is working at least for me i have just shared the code thank you
2023-07-07 11:58:33
First post updated , there was some issues on it
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: 4
  • Members: 0
  • Guests online: 4
  • Comments: 3
  • Messages: 1,728