function RALLYE_ADD_TOPUSERS($rallye,$default=0)
{
global $_CONFIG;
- $since = (time() - $_CONFIG['ap_inactive_since']);
+ // Init variable
+ $since = 0;
+ if (EXT_IS_ACTIVE("autopurge")) {
+ $since = $_CONFIG['ap_inactive_since'];
+ } // END - if
// First check how many prices are set
$result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%s ORDER BY price_level",
$result_ref = SQL_QUERY_ESC("SELECT DISTINCT p.points FROM "._MYSQL_PREFIX."_user_points AS p
LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
ON p.userid=d.userid
-WHERE d.userid=%s AND d.status='CONFIRMED' AND p.ref_depth=1 AND d.max_mails > 0 AND d.mails_confirmed >= %s AND d.last_online >= %s
+WHERE d.userid=%s AND d.status='CONFIRMED' AND p.ref_depth=1 AND d.max_mails > 0 AND d.mails_confirmed >= %s AND d.last_online >= (UNIX_TIMESTAMP() - %s)
LIMIT 1", array(bigintval($uid), $_CONFIG['ref_payout'], $since), __FILE__, __LINE__);
list($refpoints) = SQL_FETCHROW($result_ref);
SQL_FREERESULT($result_ref);
global $DATA, $_CONFIG;
// Latest online time
- $since = (time() - $_CONFIG['ap_inactive_since']);
+ $since = 0;
+ if (EXT_IS_ACTIVE("autopurge")) {
+ $since = $_CONFIG['ap_inactive_since'];
+ } // END - if
// Load rallye data
list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
// active = 0: account is deleted or locked
$result = SQL_QUERY_ESC("SELECT COUNT(userid) AS active
FROM "._MYSQL_PREFIX."_user_data
-WHERE userid=%s AND status='CONFIRMED' AND last_online >= %s
+WHERE userid=%s AND status='CONFIRMED' AND last_online >= (UNIX_TIMESTAMP() - %s)
LIMIT 1", array(bigintval($uid), $since), __FILE__, __LINE__);
list($active) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
{
global $DATA, $_CONFIG;
// Check for expired rallyes
- $EXPIRE = time() - ONE_DAY * 3; // The hard-coded value...
- $result_rallye = SQL_QUERY_ESC("SELECT id, title, start_time, end_time FROM "._MYSQL_PREFIX."_rallye_data WHERE end_time <= %s AND expired='Y'",
- array($EXPIRE), __FILE__, __LINE__);
+ $EXPIRE = ONE_DAY * 3; // @TODO The hard-coded value...
+ $result_rallye = SQL_QUERY_ESC("SELECT id, title, start_time, end_time
+FROM "._MYSQL_PREFIX."_rallye_data
+WHERE end_time <= (UNIX_TIMESTAMP() - %s) AND expired='Y'",
+ array($EXPIRE), __FILE__, __LINE__);
if (SQL_NUMROWS($result_rallye) > 0)
{