[USER=1398]@serph[/USER] -> Here's the SQL to make this better and limit the database so it doesn't timeout.
[color=rgb(65, 168, 95)]
Tested and working as it supposes to work.[/color]
cleanup.php on top:
function autoinvites($interval, $invites, $maxinvites) {
$time = gmtime() - ($interval*86400);
$res = SQL_Query_exec("SELECT id, username, class, invites FROM users WHERE enabled = 'yes' AND warned = 'no' AND UNIX_TIMESTAMP(invitedate) IS NULL OR UNIX_TIMESTAMP(invitedate) <= $time");
if (mysqli_num_rows($res) > 0) {
while ($arr = mysqli_fetch_assoc($res)) {
$maxninvites = $maxinvites[$arr['class']];
if ($arr['invites'] >= $maxninvites)
continue;
if (($maxninvites-$arr['invites']) < $invites)
$invites = $maxninvites - $arr['invites'];
SQL_Query_exec("UPDATE users SET invites = invites+$invites, invitedate = NOW() WHERE last_access < NOW() - INTERVAL 2 DAY AND invites < 1 LIMIT 100");
}
}
}
Now on bottom:
// START INVITES UPDATE
// SET INVITE AMOUNTS ACCORDING TO RATIO/GIGS ETC
// autoinvites(interval to give invites (days), min downloaded GB, max downloaded GB, min ratio, invites to give, max invites allowed (array))
// $maxinvites[CLASS ID] = max # of invites;
$maxinvites[1] = 5; //
$maxinvites[2] = 5; //
$maxinvites[3] = 5; //
$maxinvites[4] = 5; //
$maxinvites[5] = 20; //
$maxinvites[6] = 20; //
$maxinvites[7] = 100; //
// Give 2 invite every 30 days to users who logged in last 2 days.
autoinvites(30, 2, $maxinvites);