Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=93)
-   -   Auto Promote/Demote user (http://www.bvlist.com/showthread.php?t=4272)

joeroberts 17th January 2010 08:51

Auto Promote/Demote user
 
these functions well auto promote and demote users By upload and ratio
Open include/cleanup.php

add to before
Code:

function getscrapedata($url) {
Code:

/*Auto Prommote system By joeroberts
To Use call to function in clean up You Must use a new call for each level you want to Promote
autopromote(10,2,1.1,"Power User","user");
autpromote(
$upload = user with upload equle or greater then
$bite = Type of byte Meg Gig Tera
$ratio = user with ratio equle or better then
$new_level = New level to promote to
$old_level = select from user in this level
)
*/
function autopromote($upload, $bite="1", $ratio, $new_level, $old_level){
      global $db, $db_prefix;
$mb = 1024*1024;
$gb = 1024*1024*1024;
$tb = 1024*1024*1024*1024;
if ($bite == '1')
    $upload = $mb*$upload;
elseif ($bite == '2')
    $upload = $gb*$upload;
elseif ($bite == '3')
    $upload = $tb*$upload;
else return;
    $res1 ="SELECT id FROM ".$db_prefix."_users WHERE  can_do = '".$old_level."' AND active = 1 AND uploaded >= $upload AND uploaded / downloaded >= $ratio AND warned = '0'" ;
$res =$db->sql_query($res1)or btsqlerror($res1);
    $prouser = array();
      while ($arr = $db->sql_fetchrow($res))
      {
        $prouser[] = $arr['id'];
}
$db->sql_freeresult($res);
if(count($prouser) > 0)
  $db->sql_query("UPDATE ".$db_prefix."_users SET  can_do ='".$new_level."' WHERE id IN ( '".implode("','",$prouser)."')") or btsqlerror("UPDATE ".$db_prefix."_users SET  can_do ='".$level."' WHERE id IN ( '".implode("','",$prouser)."')");
}
/*Auto Demotion system By joeroberts
To Use call to function in clean up You Must use a new call for each level you want to demote
autodemote(1.0, "user", "Power User");
autodemote(
$ratio = user with ratio less then
$new_level New Level for user
$old_level Level From sich to demote from
)
*/
function autodemote($ratio, $new_level, $old_level){
      global $db, $db_prefix;
    $res1 ="SELECT id FROM ".$db_prefix."_users WHERE  can_do = '".$old_level."' AND active = 1 AND uploaded / downloaded < $ratio AND warned = '0'" ;
$res =$db->sql_query($res1)or btsqlerror($res1);
    $prouser = array();
      while ($arr = $db->sql_fetchrow($res))
      {
        $prouser[] = $arr['id'];
}
$db->sql_freeresult($res);
if(count($prouser) > 0)
  $db->sql_query("UPDATE ".$db_prefix."_users SET  can_do ='".$new_level."' WHERE id IN ( '".implode("','",$prouser)."')") or btsqlerror("UPDATE ".$db_prefix."_users SET  can_do ='".$level."' WHERE id IN ( '".implode("','",$prouser)."')");
}

To activate this find in same file
Code:

autoclean();
and add before something like this
Code:

autopromote(10,2,1.1,"Power User","user");
autodemote(1.0, "user", "Power User");


cop1976 7th February 2010 13:55

With all respect, but it does not work for me.

joeroberts 7th February 2010 14:31

please give me example

cop1976 7th February 2010 17:35

I add this code before function getscrapedata

Code:

/*Auto Prommote system By joeroberts
To Use call to function in clean up You Must use a new call for each level you want to Promote
autopromote(10,2,1.1,"Power User","user");
autpromote(
$upload = user with upload equle or greater then
$bite = Type of byte Meg Gig Tera
$ratio = user with ratio equle or better then
$new_level = New level to promote to
$old_level = select from user in this level
)
*/
function autopromote($upload, $bite="1", $ratio, $new_level, $old_level){
      global $db, $db_prefix;
$mb = 1024*1024;
$gb = 1024*1024*1024;
$tb = 1024*1024*1024*1024;
if ($bite == '1')
    $upload = $mb*$upload;
elseif ($bite == '2')
    $upload = $gb*$upload;
elseif ($bite == '3')
    $upload = $tb*$upload;
else return;
    $res1 ="SELECT id FROM ".$db_prefix."_users WHERE  can_do = '".$old_level."' AND active = 1 AND uploaded >= $upload AND uploaded / downloaded >= $ratio AND warned = '0'" ;
$res =$db->sql_query($res1)or btsqlerror($res1);
    $prouser = array();
      while ($arr = $db->sql_fetchrow($res))
      {
        $prouser[] = $arr['id'];
}
$db->sql_freeresult($res);
if(count($prouser) > 0)
  $db->sql_query("UPDATE ".$db_prefix."_users SET  can_do ='".$new_level."' WHERE id IN ( '".implode("','",$prouser)."')") or btsqlerror("UPDATE ".$db_prefix."_users SET  can_do ='".$level."' WHERE id IN ( '".implode("','",$prouser)."')");
}
/*Auto Demotion system By joeroberts
To Use call to function in clean up You Must use a new call for each level you want to demote
autodemote(1.0, "user", "Power User");
autodemote(
$ratio = user with ratio less then
$new_level New Level for user
$old_level Level From sich to demote from
)
*/
function autodemote($ratio, $new_level, $old_level){
      global $db, $db_prefix;
    $res1 ="SELECT id FROM ".$db_prefix."_users WHERE  can_do = '".$old_level."' AND active = 1 AND uploaded / downloaded < $ratio AND warned = '0'" ;
$res =$db->sql_query($res1)or btsqlerror($res1);
    $prouser = array();
      while ($arr = $db->sql_fetchrow($res))
      {
        $prouser[] = $arr['id'];
}
$db->sql_freeresult($res);
if(count($prouser) > 0)
  $db->sql_query("UPDATE ".$db_prefix."_users SET  can_do ='".$new_level."' WHERE id IN ( '".implode("','",$prouser)."')") or btsqlerror("UPDATE ".$db_prefix."_users SET  can_do ='".$level."' WHERE id IN ( '".implode("','",$prouser)."')");
}

and before autoclean i add

Code:

autopromote(25,2,1.0,"power_user","user");
autodemote(0.9, "user", "power_user");
autopromote(100,2,2.0,"super_user","power_user");
autodemote(1.9, "power_user", "super_user");
autopromote(500,2,3.0,"elite_user","super_user");
autodemote(2.9, "super_user", "elite_user");

I promote manualy user to power user who had only 10 GB upload, and system don't demote him.

joeroberts 7th February 2010 17:44

what was your ratio?

cop1976 7th February 2010 18:05

More than 1.0, but upload was only 10 gb.

joeroberts 7th February 2010 18:19

well only demote By ratio as it takes into mind if you had the uploads to get to that level then that should not change

cop1976 7th February 2010 18:37

Why the code does not pay attention to upload, only the ratio? For what is the number of upload in this code?
Thx for answer, but autopromote and demote users would be very helpful.
Is there any possibility to make it work properly?

joeroberts 7th February 2010 18:42

it pays attention in the promote part not the demote part it is easy to make it to so though give me a day as I got something else going now.

cop1976 7th February 2010 18:45

Ok thx and btw great job ;)

Bump: Is it possible that the system sends a message to the user about the promotion or degradation, and to add an entry in the mod comment with the exact date when it was done?


All times are GMT +2. The time now is 13:16.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.