Hello I've tested this code but it doesn't work, can you help me to make it work, thanks in advance. (y):D
add to cleanup.php
add near the end
//heres another take on demote/promote auto
//promote member to power user
//Demote power-users to members and disable account
add to cleanup.php
add near the end
//heres another take on demote/promote auto
//promote member to power user
$limit = 25*1024*1024*1024;
$minratio = 1.05;
$maxdt = sqlesc(get_date_time(gmtime() - 86400*28));
$res = mysqli_query("SELECT id, username FROM users WHERE class = 1 AND uploaded >= $limit AND uploaded / downloaded >= $minratio AND added < $maxdt") or sqlerr(__FILE__, __LINE__);
if (mysqli_num_rows($res) > 0)
{
$dt = sqlesc(get_date_time());
$msg = sqlesc("Congratulations, you have been auto-promoted to Power User by SYSTEM.");
while ($arr = mysqli_fetch_assoc($res))
{
mysqli_query("UPDATE users SET class = 2 WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);
mysqli_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES (0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__);
write_log("User <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a> Was automatically promoted to POWERUSER by SYSTEM.");
}
}
//Demote power-users to members and disable account
$limit = 25*1024*1024*1024;
$minratio = 0.75;
$maxdt = sqlesc(get_date_time(gmtime() - 86400*28));
$res = mysqli_query("SELECT id, username FROM users WHERE class = 2 AND uploaded <= $limit AND uploaded / downloaded <= $minratio AND added < $maxdt") or sqlerr(__FILE__, __LINE__);
if (mysqli_num_rows($res) > 0)
{
$dt = sqlesc(get_date_time());
//$msg = sqlesc("Congratulations, you have been auto-demoted to Member and account disabled by SYSTEM. Probably due to low ratio or account inactivity.");
while ($arr = mysqli_fetch_assoc($res))
{
mysqli_query("UPDATE users SET class = 1, enabled = 'No' WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);
//mysqli_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES (0, $arr[id], $dt, $msg, 0)")or sqlerr(__FILE__, __LINE__);
write_log("User <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a> Was automatically demoted to member and disabled by SYSTEM. Messages purged.");
//remove any records belonging to this user in messages
mysqli_query("DELETE FROM messages WHERE receiver = $arr[id]")or sqlerr(__FILE__, __LINE__);
}
}
