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
Auto-Promote Users
Controls ·  Search New posts · Mark unread

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

2020-09-22 06:03:36
This mod will auto promote users to the class you choose. It works well for me and is ported from another project.

Open backend/cleanup.php and find

//DELETE PENDING USER ACCOUNTS OVER TIMOUT AGE

Add right before // line

// Auto promote users
$regular     = 1; // Regular class ID
$promotclass = 3; // Promoted class ID
$limit       = 25 * 1024 * 1024 * 1024;
$minratio    = 1.05;
$maxdt       = get_date_time(time() - 86400 * 28);
$res         = SQL_Query_exec("SELECT id, username FROM users WHERE class = $regular AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt");
if ($res) {
   $dt  = get_date_time();
   $msg = "Congratulations, you have been automatically promoted to Power User. You can now do more stuff.";
   while ($arr = mysql_fetch_assoc($res)) {
       SQL_Query_exec("UPDATE users SET class = $promotclass WHERE id = $arr[id]");
       $txt   = "You have been promoted to Power User!";
       $event = "$arr[username] has been promoted Power User";
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
       SQL_Query_exec("INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, $arr[username], $event, $dt, 0)");
       write_log("The user <a href=\"/user/?id=$arr[id]\">$arr[username]</a> was automatically promoted to power user.");
   }
}

// Auto demote users
$minratio = 0.95;
$res      = SQL_Query_exec("SELECT id, username FROM users WHERE class = $promotclass AND uploaded / downloaded < $minratio");
if ($res) {
   $dt  = get_date_time();
   $msg = "You were automatically demoted from Power User to Regular because your share ratio fell below $minratio.";
   while ($arr = $res->fetch()) {
       SQL_Query_exec("UPDATE users SET class = $regular WHERE id = $arr[id]");
       $txt   = "You have been demoted to Regular!";
       $event = "$arr[username] has been demoted Regular";
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
       SQL_Query_exec("INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, $arr[username], $event, $dt, 0)");
       write_log("The user <a href=\"/user/?id=$arr[id]\">$arr[username]</a> was automatically demoted to regular.");
   }
}

[ATTACH type="full" alt="auto-promoted.png"]5901[/ATTACH]
auto-promoted.png
auto-promoted.png
2020-09-22 19:00:57
hello, my vip id group is 3 in the BDD can you tell me what id group I have to put on this piece of code for the member to switch to vip; thanks in advance.

SQL_Query_exec("UPDATE users SET class = 3 WHERE id = $arr[id]");
2020-09-23 18:30:52
Hello and sorry but the account does not update automatically here is my code below :rolleyes:

// Auto promote VIP
   $limit = 25 * 1024 * 1024 * 1024;
   $minratio = 3.00;
   $maxdt = get_date_time(time() - 86400 * 28);
   $res = SQL_Query_exec("SELECT id, username FROM users WHERE class = 1 AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt");
   if ($res) {
       $dt = get_date_time();
       $msg = "Félicitations, suite a votre bon ratio de partage de 3.00 ou plus vous avez été automatiquement promu VIP. Vous pouvez maintenant faire plus de choses.";
       while ($arr = mysql_fetch_assoc($res)) {
           SQL_Query_exec("UPDATE users SET class = 3 WHERE id = $arr[id]");
           $txt = "Vous avez été promu VIP!";
           $event = "$arr[username] a été promu VIP";
           SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[user_id], NOW(), $txt, 0)");
           SQL_Query_exec("INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, $arr[username], $event, NOW(), 0)");
           write_log("The user <a href=\"/user/?id=$arr[user_id]\">$arr[username]</a> A atteint un bon ratio de partage de 3.00 ou plus et a été automatiquement promu au rang VIP - Bravo !!!.");
       }
   }





// Auto demote vip
   $minratio = 1.80;
   $res = $db->query_params("SELECT user_id, username FROM users WHERE class = 3 AND uploaded / downloaded < :minratio", array('minratio' => $minratio));
   if ($res) {
       $dt = get_date_time();
       $msg = "Vous avez été automatiquement rétrogradé de vip a Membre parce que votre ratio de partage est tombé en dessous de.";
       while ($arr = $res->fetch()) {
           $db->query_params('UPDATE users SET class = 1 WHERE user_id = :user_id', array('user_id' => $arr['user_id']));
           $txt = "Vous avez été rétrogradé au rang de membre.";
           $event = "$arr[username] a été rétrogradé à Membre";
           $db->query_params('INSERT INTO messages (sender, receiver, added, msg, poster, subject) VALUES(0, :user_id, NOW(), :message, 0, :subject)', array('user_id' => $arr['user_id'], 'message' => $txt, 'subject' => 'Demoted!'));
           $db->query_params('INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, :receiver, :event, NOW(), 0)', array('receiver' => $arr['username'], 'event' => $event));
           write_log("The user <a href=\"/user/?id=$arr[user_id]\">$arr[username]</a> a été automatiquement promu au rang d'utilisateur vip.");
       }
   }
2020-09-23 19:27:02
Hi Niki, I will tackle this when I’m home today ?
You can change both queries to class 1 (all) and see it work on next cleanup, or I fix later today
2020-09-23 19:34:35
hi and thanks I'll wait for your return for corrections (y):D
2020-09-24 00:56:11
Hi ;)
Erro sql
#89
$res = SQL_Query_exec("SELECT id, username FROM users WHERE class = 1 AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt");



Database Error in backend/cleanup.php on line 89: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '01:54:06' at line 1. Query was: SELECT id, username FROM users WHERE class = 1 AND uploaded >= 26843545600 AND uploaded / downloaded >= 3 AND added < 2020-08-27 01:54:06.[/TD]


Thanks you!
2020-09-24 03:31:14
Be right there guys
2020-09-24 16:44:46
that should work for any User that has uploaded 25+GBs and has a ratio over 1


Hello I found this code below that works and change the class member to power user automatically with 25 go upload and a ratio of 1.00

but it doesn't downgrade the class power user to class  member  when the ratio is below 1.00 so there may be an error in the downgrade code and I can't find it. :rolleyes:




//AUTO PROMOTE USER

       $gigs = 25*1073741824; // 25 GB
       $res = SQL_Query_exec("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND uploaded >= downloaded");
       $time = get_date_time();
       while ($arr = mysqli_fetch_assoc($res)) {
               SQL_Query_exec("UPDATE users SET class = 2 WHERE id = $arr[id]");
               SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically promoted from User to Power User, If your ratio drops below 1.00 you will be demoted.', 'You have been promoted to: Power User')");
       }


       $res = SQL_Query_exec("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND uploaded < downloaded");
       while ($arr = mysqli_fetch_assoc($res)) {
               SQL_Query_exec("UPDATE users SET class = 1 WHERE id = $arr[id]");
               SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You have been automatically demoted from Power User to User.', 'You have been demoted to User')");
       }

//AUTO PROMOTE USER END
2020-09-27 21:15:35
*** Post updated for both promoting/demoting with:

- Easier IDs for managing promoting/demoting by class
- Corrected datetime entry
2020-11-11 23:52:11
"STorrents2020, post: 69413, member: 20382":

*** Post updated for both promoting/demoting with:

- Easier IDs for managing promoting/demoting by class
- Corrected datetime entry


yo" ;)

error..
Database Error in backend/cleanup.php on line 429: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '00:48:17' at line 1. Query was: SELECT id, username FROM users WHERE class = 1 AND uploaded >= 26843545600 AND uploaded / downloaded >= 1.05 AND added < 2020-10-15 00:48:17. 



Error lign 229#
$res22       = SQL_Query_exec("SELECT id, username FROM users WHERE class=$regular AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt");




// Auto promote users
$regular     = 1; // Regular class ID
$promotclass = 2; // Promoted class ID
$limit       = 25 * 1024 * 1024 * 1024;
$minratio    = 1.05;
$maxdt       = get_date_time(time() - 86400 * 28);
$res22       = SQL_Query_exec("SELECT id, username FROM users WHERE class=$regular AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt");
if ($res22) {
   $dt  = get_date_time();
   $msg = "Félicitations, vous avez été automatiquement promu Super Membre. \rVous pouvez maintenant faire plus de choses. ";
   while ($arr = mysqli_fetch_assoc($res22)) {
       SQL_Query_exec("UPDATE users SET class = $promotclass WHERE id = $arr[id]");
       $txt   = "Vous avez été promu utilisateur avancé!";
       $event = "$arr[username] a été promu Super Membre";
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
       SQL_Query_exec("INSERT INTO ajshoutbox (uid, date, name, text) VALUES (NULL, $arr[username], $event, $dt, 0)");
       write_log("L utilisateur <a href=\"/user/?id=$arr[id]\">$arr[username]</a> a été automatiquement promu Super Membre.");
   }
}

// Auto demote users
$minratio = 0.95;
$res22   = SQL_Query_exec("SELECT id, username FROM users WHERE class=$promotclass AND uploaded / downloaded < $minratio");
if ($res22) {
   $dt  = get_date_time();
   $msg = "Vous avez été automatiquement rétrogradé de Super Mmebre à Membre parce que votre ratio de partage est tombé en dessous de $minratio.";
   while ($arr = $res22->fetch()) {
       SQL_Query_exec("UPDATE users SET class = $regular WHERE id = $arr[id]");
       $txt   = "Vous avez été rétrogradé au statut régulier!";
       $event = "$arr[username] a été rétrogradé Membre";
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
       SQL_Query_exec("INSERT INTO ajshoutbox (uid, date, name, text) VALUES (NULL, $arr[username], $event, $dt, 0)");
       write_log("L utilisateur <a href=\"/user/?id=$arr[id]\">$arr[username]</a> a été automatiquement rétrogradé au statut normal.");
   }
}
// End auto promote users

thanks in advance for help ;)
2020-11-12 07:30:40
Those variables in the query may need double quotes to be valid, I prepare these in a array usually so may of missed legacy approach
2020-11-12 17:03:12
Bonjour spiriteblue test celui ci-dessous et devrais fonctionner




####################################

# AUTO PROMOTE SUPER MEMBRES #

####################################

$gigs = 25*1073741824; // 25 GB

   $res_premote = SQL_Query_exec("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND (uploaded / downloaded) >= 1.0");

   $time = get_date_time();

   while ($arr_premote = mysqli_fetch_assoc($res_premote)) {

       SQL_Query_exec("UPDATE users SET class = 2 WHERE id = $arr_premote[id]");

       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr_premote[id], '$time', '

Félicitations, vous avez été automatiquement promu Membre pour Super Membre vous pouvez maintenant faire plus de choses.

, Si votre ratio tombe en dessous de 1,00, vous serez rétrogradé.', 'Vous avez été promu à: Super Membre')");

   }

               unset($res_premote,$arr_premote);

   $res_demote = SQL_Query_exec("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND (uploaded / downloaded) <= 1.0");

   while ($arr_demote = mysqli_fetch_assoc($res_demote)) {

       SQL_Query_exec("UPDATE users SET class = 1 WHERE id = $arr_demote[id]");

       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr_demote[id], '$time', 'Vous avez été automatiquement rétrogradé deSuper Membre pourMembre.', 'Vous avez été rétrogradé au rang d'utilisateur')");

   }

               unset($res_demote,$arr_demote);

##########################

# END AUTO PROMOTE SUPEER MEMBRES#

##########################
2020-11-12 22:41:02
I can’t confirm this code, but thanks Nikki. Typically, a foreach loop will need to be unset() if exiting out of an array outside of the loop in older versions of PHP. This has since been declared unnecessary since 7+ to my knowledge.

As it stands, it’s useful for destroying variables, not sure about objects though.
2020-11-12 23:36:15
"niki, post: 69540, member: 20338":

Bonjour spiriteblue test celui ci-dessous et devrais fonctionner




####################################

# AUTO PROMOTE SUPER MEMBRES #

####################################

$gigs = 25*1073741824; // 25 GB

   $res_premote = SQL_Query_exec("SELECT id FROM users WHERE class = 1 AND uploaded >= $gigs AND (uploaded / downloaded) >= 1.0");

   $time = get_date_time();

   while ($arr_premote = mysqli_fetch_assoc($res_premote)) {

       SQL_Query_exec("UPDATE users SET class = 2 WHERE id = $arr_premote[id]");

       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr_premote[id], '$time', '

Félicitations, vous avez été automatiquement promu Membre pour Super Membre vous pouvez maintenant faire plus de choses.

, Si votre ratio tombe en dessous de 1,00, vous serez rétrogradé.', 'Vous avez été promu à: Super Membre')");

   }

               unset($res_premote,$arr_premote);

   $res_demote = SQL_Query_exec("SELECT id FROM users WHERE class = 2 AND uploaded >= $gigs AND (uploaded / downloaded) <= 1.0");

   while ($arr_demote = mysqli_fetch_assoc($res_demote)) {

       SQL_Query_exec("UPDATE users SET class = 1 WHERE id = $arr_demote[id]");

       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr_demote[id], '$time', 'Vous avez été automatiquement rétrogradé deSuper Membre pourMembre.', 'Vous avez été rétrogradé au rang d'utilisateur')");

   }

               unset($res_demote,$arr_demote);

##########################

# END AUTO PROMOTE SUPEER MEMBRES#

##########################


yo niki ;)
Mais STorrents2020 a raison et j'y est pensé aussi a utiliser les vieux code en sachant qui fonctionne mais peux de cassure des objets
===============//
but STorrents2020 is right and I also thought about using the old code knowing which works but can break objects
2020-11-13 00:21:54
"STorrents2020, post: 69538, member: 20382":

Those variables in the query may need double quotes to be valid, I prepare these in a array usually so may of missed legacy approach


Error:
Database Error in backend/cleanup.php on line 429: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2020-10-16 01:16:06' at line 1. Query was: SELECT `id`, `username` FROM `users` WHERE class = 1 AND `uploaded` = 26843545600 AND `uploaded` / `downloaded` = 1.05 AND `added`  2020-10-16 01:16:06.

$res22       = SQL_Query_exec("SELECT `id`, `username` FROM `users` WHERE class = $regular AND `uploaded` > = $limit AND `uploaded/downloaded` > = $minratio AND `added` < $maxdt");


almost to the truth :ROFLMAO:
if another test I am ready to solve the problem ;)


// Auto promote users
$regular     = 1; // Regular class ID
$promotclass = 2; // Promoted class ID
$limit       = 25 * 1024 * 1024 * 1024;
$minratio    = 1.05;
$maxdt       = get_date_time(time() - 86400 * 28);
$res22       = SQL_Query_exec("SELECT `id`, `username` FROM `users` WHERE class = $regular AND `uploaded` > = $limit AND `uploaded/downloaded` > = $minratio AND `added` < $maxdt");
if ($res22) {
   $dt  = get_date_time();
   $msg = "Félicitations, vous avez été automatiquement promu Super Membre. \rVous pouvez maintenant faire plus de choses. ";
   while ($arr = mysqli_fetch_assoc($res22)) {
       SQL_Query_exec("UPDATE users SET class = $promotclass WHERE id = $arr[id]");
       $txt   = "Vous avez été promu utilisateur avancé!";
       $event = "$arr[username] a été promu Super Membre";
       SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $txt, 0)");
       SQL_Query_exec("INSERT INTO ajshoutbox (uid, date, name, text) VALUES (NULL, $arr[username], $event, $dt, 0)");
       write_log("L utilisateur <a href=\"/user/?id=$arr[id]\">$arr[username]</a> a été automatiquement promu Super Membre.");
   }
}

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