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.