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/Demote
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Mods Completed

Unknown User
2013-02-01 15:19:17
Promote Member to PU when :

- is not warned,

- added for more than x days,

- has minimum y GB uploaded,

- has ratio >= 1.00.

Demote PU to Member when :

- has ratio < 1.00.

cleanup.php

find



//OPTIMIZE TABLES




above add





//AUTO PROMOTE/DEMOTE



$gigs = 100*1073741824; // 100 GB

$delai = 28*86400; // 28 days

$date = get_date_time(gmtime() - $delai);

$time = get_date_time();



//Promote

$res = SQL_Query_exec("SELECT id FROM users WHERE class = '1' AND warned = 'no' AND added < '$date' AND uploaded >= $gigs AND (uploaded / downloaded) >= '1.0'");



while ($arr = mysql_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', 'Vous avez été promu Membre Elite, si votre ratio devient inférieur à 1.00, vous serez rétrogradé.', 'Vous avez été promu : Membre Elite')");



endwhile;



//Demote

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



while ($art = mysql_fetch_assoc($ret)) :



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

SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $art[id], '$time', 'Vous avez été rétrogradé Membre car votre ratio est inférieur à 1.0.', 'Vous avez été rétrogradé : Membre')");



endwhile;



// END AUTO PROMOTE/DEMOTE

Unknown User
2013-02-02 01:33:10
yesss thanx AzuriS :)
2013-02-02 01:51:36
Thanks!
Unknown User
2013-02-02 09:32:53
[size=18px]If you want that promotion and demotion to be recorded in the [/size][size=18px]log[/size][size=18px] and [/size][size=18px]modcomment[/size][size=18px]:[/size]



//===| Start Auto Promote/Demote Users |===//

//===| config

$gigs = 50*1073741824; # 50 GB / uploaded amount for promote as power user

$minratio = 0.95; # ratio for demotion to user

$delay = sqlesc(get_date_time(gmtime() - 86400*30)); # Joined > 1 month



//===| auto promote to power user

$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE class = 1 AND warned = 'no' AND added < $delay AND uploaded >= $gigs AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

$username = $arr[username];

$modcomment = $arr[modcomment];

$modcomment2 = gmdate("d-M-Y") . " - Has been promoted by System to Power User class n";

$modcomment = $modcomment2 . "" . $modcomment;

$modcom = sqlesc($modcomment);



SQL_Query_exec("UPDATE users SET class = 2, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");

SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'Congratulations, you were automatically promoted to Power User class. Please note that if your ratio drops below ".$minratio." at any time,  you will be demoted back to User', 'You have been promoted as Power User')");

write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been promoted by System to <b>Power User</b> class");

}

//===| auto demote to user

$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE class = 2 AND uploaded / downloaded < $minratio");

while ($arr = mysql_fetch_assoc($res)) {

$username = $arr[username];

$modcomment = $arr[modcomment];

$modcomment2 = gmdate("d-M-Y") . " - Has been demoted by System to User class n";

$modcomment = $modcomment2 . "" . $modcomment;

$modcom = sqlesc($modcomment);



SQL_Query_exec("UPDATE users SET class = 1, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");

SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You were automatically demoted as User. That happened because your ratio dropped below ".$minratio."', 'You have been demoted as User')");

write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been demoted by System to <b>User</b> class");

}

//===| End Auto Promote/Demote Users |===//

Unknown User
2013-02-02 13:34:58
do you have for more ranks?
Unknown User
2013-02-03 15:02:13
lets see if this post stays this time...................................

its not hard lol

use this and read read the comments in it........................



//===| Start Auto Promote/Demote Users |===//

//===| config

$minratio = 0.95; # ratio for demotion to user

$gigs2 = 50 * 1073741824; # 50 GB / uploaded amount for promote as power user

$delay2 = sqlesc(get_date_time(gmtime() - 86400 * 30)); # Joined > 1 month

$class2 = 2; // Power User Class

$gigs3 = 150 * 1073741824; # 150 GB / uploaded amount for promote as power user+

$delay3 = sqlesc(get_date_time(gmtime() - 86400 * 45)); # Joined > 1 month

$class3 = 3; // Power User Class+

//===| auto promote to power user

$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE class = 1 AND warned = 'no' AND (added < $delay2 AND uploaded >= $gigs2 AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

   $res_classname = SQL_Query_exec("SELECT level FROM groups WHERE group_id=$class2 LIMIT 1");

   if (mysql_num_rows($res_classname) == 1) {

       $arr_classname = mysql_fetch_assoc($res_classname);

       $new_classname = "$arr_classname[level]";

   }

   $username = $arr[username];

   $modcomment = $arr[modcomment];

   $modcomment2 = gmdate("d-M-Y") . " - Has been promoted by System to " . $new_classname . " class n";

   $modcomment = $modcomment2 . "" . $modcomment;

   $modcom = sqlesc($modcomment);



   SQL_Query_exec("UPDATE users SET class = $class2, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");

   SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'Congratulations, you were automatically promoted to Power User class. Please note that if your ratio drops below " . $minratio . " at any time,  you will be demoted back to User', 'You have been promoted as " . $new_classname . "')");

   write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been promoted by System to <b>" . $new_classname . "</b> class");

   unset($res, $arr, $res_classname, $arr_classname,$new_classname);

}

//===| auto promote to power user+

$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE class = $class2 AND warned = 'no' AND (added < $delay3 AND uploaded >= $gigs3 AND uploaded >= downloaded");

$time = get_date_time();

while ($arr = mysql_fetch_assoc($res)) {

   $res_classname = SQL_Query_exec("SELECT level FROM groups WHERE group_id=$class3 LIMIT 1");

   if (mysql_num_rows($res_classname) == 1) {

       $arr_classname = mysql_fetch_assoc($res_classname);

       $new_classname = "$arr_classname[level]";

   }

   $username = $arr[username];

   $modcomment = $arr[modcomment];

   $modcomment2 = gmdate("d-M-Y") . " - Has been promoted by System to Power User+ class n";

   $modcomment = $modcomment2 . "" . $modcomment;

   $modcom = sqlesc($modcomment);



   SQL_Query_exec("UPDATE users SET class = $class3, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");

   SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'Congratulations, you were automatically promoted to Power User class. Please note that if your ratio drops below " . $minratio . " at any time,  you will be demoted back to User', 'You have been promoted as " . $new_classname . "')");

   write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been promoted by System to <b>" . $new_classname . "</b> class");

}

//===| auto demote to user

$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE (class = $class2 || class = $class3) AND uploaded / downloaded < $minratio");

while ($arr = mysql_fetch_assoc($res)) {

   $username = $arr[username];

   $modcomment = $arr[modcomment];

   $modcomment2 = gmdate("d-M-Y") . " - Has been demoted by System to User class n";

   $modcomment = $modcomment2 . "" . $modcomment;

   $modcom = sqlesc($modcomment);



   SQL_Query_exec("UPDATE users SET class = 1, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");

   SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You were automatically demoted as User. That happened because your ratio dropped below " . $minratio . "', 'You have been demoted as User')");

   write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been demoted by System to <b>User</b> class");

}

//===| End Auto Promote/Demote Users |===//

Unknown User
2013-02-03 16:05:26
i have the below code for 2 ranks from Arcticwolf if i remember correct and its ok for 2.08+



// you might have to add this in your database

// ALTER TABLE `users` ADD `syscomment` TEXT NOT NULL AFTER `modcomment` ;

function do_cleanup_premotes()

{

       global $site_config;

       $pu_class = 2; // change this to well i dont know your power user class............

       $userclass = 1; // change this to well your user class........

       $pre_limit = 10 * 1024 * 1024 * 1024;

       $pre_minratio = 1.05;

       $dem_limit = 15 * 1024 * 1024 * 1024;

       $dem_minratio = .9;

       $premote_res = SQL_Query_exec("select level from groups where group_id = " . $pu_class . " order by group_id");

       $premote_arr = @mysql_fetch_row($premote_res);

       $premote_classname = $premote_arr["level"];

       $demote_res = SQL_Query_exec("select level from groups where group_id = " . $userclass . " order by group_id");

       $demote_arr = @mysql_fetch_row($demote_res);

       $demote_classname = $demote_arr["level"];



       $download_check = 'downloaded'; // dont change ....

       $upload_check = 'uploaded'; // dont change ....



       // promote users

       $premote_classname = $class["level"];

       $res = SQL_Query_exec("SELECT id,username,uploaded,downloaded,syscomment,class FROM users WHERE class = $userclass AND $upload_check >= $pre_limit AND uploaded / downloaded >= $pre_minratio AND enabled='yes' and added < DATE_SUB(NOW(), INTERVAL 28 DAY)");

       $msgs_buffer = $users_buffer = array();

       if (mysql_num_rows($res) > 0) {

                       $msg = "Congratulations, you have been auto-promoted to Power User. n";

                       while ($arr = mysql_fetch_assoc($res)) {

                                       $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3);

                                       ///---AUTOSYSTEM MODCOMMENT---//

                                       $syscomment = htmlspecialchars($arr["syscomment"]);

                                       $syscomment = gmdate("Y-m-d H:i") . " - Promoted to $premote_classname by System ( UL=" . mksize($arr['uploaded']) . ", DL=" . mksize($arr['downloaded']) . ", R=" . $ratio . " ) n" . $syscomment;

                                       $syscom = sqlesc($syscomment);

                                       SQL_Query_exec("UPDATE users SET syscomment = $syscom WHERE id = $arr[id]");

                                       ///---end

                                       $msgs_buffer[] = '(0,' . $arr['id'] . ',NOW(), ' . sqlesc($msg) . ', 'Promotion')';

                                       $users_buffer[] = '(' . $arr['id'] . ',' . $pu_class. ')';

                                       write_log("The account <b><a href=account-details.php?id=" . $arr['id'] . ">" . $arr['username'] . "</a></b> was Promoted to $premote_classname by System");

                       } //$arr = mysql_fetch_assoc($res)

                       if (sizeof($msgs_buffer) > 0) {

                                       SQL_Query_exec("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer));

                                       SQL_Query_exec("INSERT INTO users (id, class) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class)");

                                       write_log("Cleanup: Promoted " . mysql_affected_rows() / 2 . " from $demote_classname to $premote_classname");

                       } //sizeof($msgs_buffer) > 0

       } //mysql_num_rows($res) > 0

       unset($users_buffer, $msgs_buffer);



       // promote users

       $res_demotepu = SQL_Query_exec("SELECT id, username, class, syscomment, uploaded, downloaded FROM users WHERE class = $pu_class AND uploaded / downloaded <= $dem_minratio AND enabled='yes'");

       $msgs_buffer = $users_buffer2 = array();

       if (mysql_num_rows($res_demotepu) > 0) {

                       while ($arr_demotepu = mysql_fetch_assoc($res_demotepu)) {

                                       ///---AUTOSYSTEM MODCOMMENT---//

                                       $syscomment = htmlspecialchars($arr_demotepu["syscomment"]);

                                       $syscomment = gmdate("Y-m-d h:i:s A") . " - been auto-demoted from " . $premote_classname . " to " . $demote_classname . " because your share ratio has dropped below " . $dem_ratio . ". Ratio $ratio by -AutoSystem.n" . $syscomment;

                                       $syscom = sqlesc($syscomment);

                                       SQL_Query_exec("UPDATE users SET syscomment = $syscom WHERE id = $arr_demotepu[id]");

                                       ///---end

                                       $msg_demote = sqlesc($msg);

                                       $ratio = number_format($arr_demotepu['uploaded'] / $arr_demotepu['downloaded'], 3);

                                       $msg = "$arr_demotepu[username] You have been auto-demoted from " . $premote_classname . " to " . $demote_classname . " because your share ratio $ratio has dropped below " . $dem_ratio . ".";

                                       $msgs_buffer[] = '(0,' . $arr_demotepu['id'] . ',NOW(), ' . $msg_demote . ')';

                                       $users_buffer2[] = '(' . $arr_demotepu['id'] . ',' . $userclass . ')';

                                       write_log("The account <b><a href=account-details.php?id=" . $arr_demotepu['id'] . ">" . $arr_demotepu['username'] . "</a></b> was auto-demoted from <b>" . $premote_classname . "</b> to <b>" . $demote_classname . "</b> because your share ratio has dropped below " . $dem_minratio . ". Ratio $ratio by -AutoSystem");

                       } //$arr_demotepu = mysql_fetch_assoc($res_demotepu)

                       if (sizeof($msgs_buffer) > 0) {

                                       SQL_Query_exec("INSERT INTO messages (sender,receiver,added,msg) VALUES " . implode(', ', $msgs_buffer));

                                       SQL_Query_exec("INSERT INTO users (id, class) VALUES " . implode(', ', $users_buffer2) . " ON DUPLICATE key UPDATE class=values(class)");

                                       write_log("Cleanup: Demoted " . mysql_affected_rows() / 2 . " from $premote_classname to $demote_classname");

                       } //sizeof($msgs_buffer) > 0

       } //mysql_num_rows($res_demotepu) > 0

       unset($users_buffer2, $msgs_buffer);

}

[/code]
Unknown User
2013-02-03 17:04:42
that above is only 1 class aka power user.. if you want multi classes then you prob would need to use the info from my post above it..
Unknown User
2013-02-04 13:01:50
"Mythos, post: 88607":
do you have for more ranks?
add this to promote pu to upper class



$gigs2 = add here uploaded minimum to be promote

$ratio = add here ratio minimum to be promote

$res = SQL_Query_exec("SELECT id FROM users WHERE class = '2' AND warned = 'no' AND uploaded >= $gigs2 AND (uploaded / downloaded) >= $ratio");



while ($arr = mysql_fetch_assoc($res)) :



SQL_Query_exec("UPDATE users SET class = '3' WHERE id = $arr[id]");

SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'Vous avez été promu Membre Elite, si votre ratio devient inférieur à 1.00, vous serez rétrogradé.', 'Vous avez été promu : Membre Elite')");



endwhile;



and so on for each class promotion you want

read diff with first one i post and do demote same way

and change message!
Unknown User
2013-02-04 15:05:36
thanks to both
Unknown User
2013-06-10 20:41:24
There is a mistake somewhere but can not find...please help?

//===| Start Auto Promote/Demote Users |===//
//===| config
$minratio = 0.8; # ratio for demotion to user
$gigs2 = 25 * 26843545600; # 25 GB / uploaded amount for promote as Tegutsev Pump
$delay2 = sqlesc(get_date_time(gmtime() - 86400 * 30)); # Joined > 1 month
$class2 = 2; // Tegutsev Pump Class
$gigs3 = 950 * 1020054732800; # 950 GB / uploaded amount for promote as Tegija Pump
$delay3 = sqlesc(get_date_time(gmtime() - 86400 * 45)); # Joined > 1 month
$class3 = 3; // Tegija Pump Class+
//===| auto promote to power user
$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE class = 1 AND warned = 'no' AND (added < $delay2 AND uploaded >= $gigs2 AND uploaded >= downloaded");
$time = get_date_time();
while ($arr = mysql_fetch_assoc($res)) {
   $res_classname = SQL_Query_exec("SELECT level FROM groups WHERE group_id=$class2 LIMIT 1");
   if (mysql_num_rows($res_classname) == 1) {
       $arr_classname = mysql_fetch_assoc($res_classname);
       $new_classname = "$arr_classname[level]";
   }
   $username = $arr[username];
   $modcomment = $arr[modcomment];
   $modcomment2 = gmdate("d-M-Y") . " - Has been promoted by System to " . $new_classname . " class n";
   $modcomment = $modcomment2 . "" . $modcomment;
   $modcom = sqlesc($modcomment);

   SQL_Query_exec("UPDATE users SET class = $class2, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");
   SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'Congratulations, you were automatically promoted to Power User class. Please note that if your ratio drops below " . $minratio . " at any time,  you will be demoted back to User', 'You have been promoted as " . $new_classname . "')");
   write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been promoted by System to <b>" . $new_classname . "</b> class");
   unset($res, $arr, $res_classname, $arr_classname,$new_classname);
}
//===| auto promote to power user+
$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE class = $class2 AND warned = 'no' AND (added < $delay3 AND uploaded >= $gigs3 AND uploaded >= downloaded");
$time = get_date_time();
while ($arr = mysql_fetch_assoc($res)) {
   $res_classname = SQL_Query_exec("SELECT level FROM groups WHERE group_id=$class3 LIMIT 1");
   if (mysql_num_rows($res_classname) == 1) {
       $arr_classname = mysql_fetch_assoc($res_classname);
       $new_classname = "$arr_classname[level]";
   }
   $username = $arr[username];
   $modcomment = $arr[modcomment];
   $modcomment2 = gmdate("d-M-Y") . " - Has been promoted by System to Power User+ class n";
   $modcomment = $modcomment2 . "" . $modcomment;
   $modcom = sqlesc($modcomment);

   SQL_Query_exec("UPDATE users SET class = $class3, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");
   SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'Congratulations, you were automatically promoted to Power User class. Please note that if your ratio drops below " . $minratio . " at any time,  you will be demoted back to User', 'You have been promoted as " . $new_classname . "')");
   write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been promoted by System to <b>" . $new_classname . "</b> class");
}
//===| auto demote to user
$res = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE (class = $class2 || class = $class3) AND uploaded / downloaded < $minratio");
while ($arr = mysql_fetch_assoc($res)) {
   $username = $arr[username];
   $modcomment = $arr[modcomment];
   $modcomment2 = gmdate("d-M-Y") . " - Has been demoted by System to User class n";
   $modcomment = $modcomment2 . "" . $modcomment;
   $modcom = sqlesc($modcomment);

   SQL_Query_exec("UPDATE users SET class = 1, modcomment = CONCAT($modcom,modcomment) WHERE id = $arr[id]");
   SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, $arr[id], '$time', 'You were automatically demoted as User. That happened because your ratio dropped below " . $minratio . "', 'You have been demoted as User')");
   write_log("<a href=account-details.php?id=$arr[id]><b>$username</b></a> has been demoted by System to <b>User</b> class");
}
//===| End Auto Promote/Demote Users |===//

and see SQL error

Quote:
Database Error in backend/cleanup.php on line 313: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND uploaded >= 671088640000 AND uploaded >= downloaded' at line 1. Query was: SELECT id, username, modcomment FROM users WHERE class = 1 AND warned = 'no' AND (added < AND uploaded >= 671088640000 AND uploaded >= downloaded.
Unknown User
2013-06-10 22:58:05
It staring at you in the error

AND (added

should be


AND added
Unknown User
2013-06-11 15:18:23
Thanks kickass, now running without SQL errors  :)  

Now the next problem;

if the user has uploaded 25 + GB and ratio is 0.8 then nothing happens. However, should the user autopromote class 2

if the user has uploaded 950 + GB and ratio is 0.8 then he will be 2 classes of users. However, should go to class 3
Unknown User
2013-07-20 06:17:21
Salut

Somebody can give me this code
Unknown User
2013-07-20 06:57:24
Jesaie search in forum......
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