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)
{
if (EXT_IS_ACTIVE("autopurge")) {
// Start finding them...
- $since = (time() - $_CONFIG['ap_inactive_since']);
+ $since = $_CONFIG['ap_inactive_since'];
$EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
// Check for more extensions
// Check for all accounts
$SQLs[] = "SELECT DISTINCT d.userid, d.email, d.last_online
FROM "._MYSQL_PREFIX."_user_data AS d
-WHERE d.status='CONFIRMED' AND d.joined < ".$since." AND d.last_online < ".$since." AND d.ap_notified < ".$since."
+WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - ".$since.") AND d.last_online < ".$since." AND d.ap_notified < ".$since."
".$EXCLUDE_LIST."
ORDER BY d.userid";
$WHATs[] = "list_autopurge";
}
// Autopurge installed?
- $LAST = ""; $ONLINE = "";
+ $LAST = "";
if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
// Use last online timestamp to keep inactive members away from here
- $LAST = " AND last_online >= ";
- $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
+ $LAST = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
}
$SQLs[] = "SELECT ".$USE." AS active_bonus FROM "._MYSQL_PREFIX."_user_data
-WHERE status='CONFIRMED' AND ".$USE.">0".$LAST."".$ONLINE."
+WHERE status='CONFIRMED' AND ".$USE.">0".$LAST."
ORDER BY active_bonus DESC, userid";
$WHATs[] = "list_bonus";
$DESCRs[] = TASK_ADMIN_LIST_BONUS;
// Begging rallye
// Autopurge installed?
- $LAST = ""; $ONLINE = "";
+ $LAST = "";
if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
// Use last online timestamp to keep inactive members away from here
- $LAST = " AND last_online >= ";
- $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
+ $LAST = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
}
$SQLs[] = "SELECT userid FROM "._MYSQL_PREFIX."_user_data
-WHERE status='CONFIRMED' AND beg_points>0".$LAST."".$ONLINE."
+WHERE status='CONFIRMED' AND beg_points>0".$LAST."
ORDER BY beg_points DESC, userid";
$WHATs[] = "list_beg";
$DESCRs[] = TASK_ADMIN_LIST_BEG;
// Add description as navigation point
ADD_DESCR("admin", basename(__FILE__));
-// Ok, let's have a look...
-$since = bigintval(time() - $_CONFIG['ap_inactive_since']);
-$EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
+// Exclude default referal id if set
+$EXCLUDE_LIST = "";
+if ($_CONFIG['def_refid'] > 0) {
+ $EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
+} // END - if
// Check for more extensions
if (EXT_IS_ACTIVE("beg")) $EXCLUDE_LIST .= " AND d.userid != c.beg_uid";
// Check for all accounts
$result = SQL_QUERY_ESC("SELECT DISTINCT d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
FROM "._MYSQL_PREFIX."_user_data AS d
-WHERE d.status='CONFIRMED' AND d.joined < %s AND d.last_online < %s AND d.ap_notified < %s
+WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - %s) AND d.last_online < (UNIX_TIMESTAMP() - %s) AND d.ap_notified < (UNIX_TIMESTAMP() - %s)
".$EXCLUDE_LIST."
-ORDER BY d.userid", array($since, $since, $since), __FILE__, __LINE__);
+ORDER BY d.userid", array($_CONFIG['ap_inactive_since'], $_CONFIG['ap_inactive_since'], $_CONFIG['ap_inactive_since']), __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0)
{
if (EXT_IS_ACTIVE("autopurge"))
{
// Use last online timestamp to keep inactive members away from here
- $LAST = " AND last_online >= %s";
- $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
+ $LAST = " AND last_online >= (UNIX_TIMESTAMP() - %s)";
+ $ONLINE = $_CONFIG['ap_inactive_since'];
}
// Check if at least one is in the active rallye
}
// Prepare constant for timemark
- define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_inactive_since'], "2"));
+ if (EXT_IS_ACTIVE("autopurge")) {
+ define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_inactive_since'], "2"));
+ } else {
+ define('__AUTOPURGE_TIMEOUT', sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "autopurge"));
+ }
// Load final template
LOAD_TEMPLATE("admin_list_beg");
$LAST = "%s"; $ONLINE = "";
if (EXT_IS_ACTIVE("autopurge")) {
// Use last online timestamp to keep inactive members away from here
- $LAST = " AND last_online >= %s";
- $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
+ $LAST = " AND last_online >= (UNIX_TIMESTAMP() - %s)";
+ $ONLINE = $_CONFIG['ap_inactive_since'];
}
// Check if at least one is in the active rallye
}
// Prepare constant for timemark
- define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_inactive_since'], "2"));
+ if (EXT_IS_ACTIVE("autopurge")) {
+ define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_inactive_since'], "2"));
+ } else {
+ define('__AUTOPURGE_TIMEOUT', sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "autopurge"));
+ }
// Load final template
LOAD_TEMPLATE("admin_list_bonus");
}
// Check his IP number
- $to = bigintval(time() - $_CONFIG['ip_timeout']);
- $result = SQL_QUERY_ESC("SELECT joined, last_update FROM "._MYSQL_PREFIX."_user_data WHERE REMOTE_ADDR='%s' AND (joined > %s OR last_update > %s) LIMIT 1",
- array(getenv('REMOTE_ADDR'), $to, $to), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT joined, last_update FROM "._MYSQL_PREFIX."_user_data WHERE REMOTE_ADDR='%s' AND (joined > (UNIX_TIMESTAMP() - %s) OR last_update > (UNIX_TIMESTAMP() - %s)) LIMIT 1",
+ array(getenv('REMOTE_ADDR'), $_CONFIG['ip_timeout'], $_CONFIG['ip_timeout']), __FILE__, __LINE__);
if ((SQL_NUMROWS($result) == 1) && (!IS_ADMIN()))
{
// Same IP in timeout range and different email address entered... Eat this, faker! ;-)
// Test the refid (because some strange hackers... :-P)
$result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0)
- {
+ if (SQL_NUMROWS($result) == 0) {
// Not found so we set your refid!
$_POST['refid'] = $_CONFIG['def_refid'];
set_session("refid", $_CONFIG['def_refid']);
// Autopurge installed?
$LAST = "%s"; $ONLINE = "";
-if (EXT_IS_ACTIVE("autopurge"))
-{
+if (EXT_IS_ACTIVE("autopurge")) {
// Use last online timestamp to keep inactive members away from here
- $LAST = " AND last_online >= %s";
- $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
+ $LAST = " AND last_online >= (UNIX_TIMESTAMP() - %s)";
+ $ONLINE = $_CONFIG['ap_inactive_since'];
}
// Let's check if there are some points left we can "pay"...
// Autopurge installed?
$LAST = "%s"; $ONLINE = "";
-if (EXT_IS_ACTIVE("autopurge"))
-{
+if (EXT_IS_ACTIVE("autopurge")) {
// Use last online timestamp to keep inactive members away from here
- $LAST = " AND last_online >= %s";
- $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
+ $LAST = " AND last_online >= (UNIX_TIMESTAMP() - %s)";
+ $ONLINE = $_CONFIG['ap_inactive_since'];
}
// Let's check if there are some points left we can "pay"...
// Continue with the frametester, we first need to store the data temporary in the pool
//
// First we would like to store the data and get it's pool position back...
- $result = SQL_QUERY_ESC("SELECT id, data_type FROM "._MYSQL_PREFIX."_pool WHERE sender=%s AND url='%s' AND timestamp > %s LIMIT 1",
- array($GLOBALS['userid'], $_POST['url'], bigintval(time() - $_CONFIG['url_tlock'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT id, data_type
+FROM "._MYSQL_PREFIX."_pool
+WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
+ array($GLOBALS['userid'], $_POST['url'], $_CONFIG['url_tlock']), __FILE__, __LINE__);
$type = "TEMP"; $id = 0;
if (SQL_NUMROWS($result) == 1)
{
// Extension "autopurge" is inactive or purging of inactive accounts is deactivated
$whereStatement1 = "WHERE status='CONFIRMED'";
- $whereStatement2 = 0;
- $whereStatement3 = bigintval($_CONFIG['bonus_ranks']);
+ $whereStatement2 = bigintval($_CONFIG['bonus_ranks']);
// Shall I keep inactive members away from here? (mostly wanted in an "active-rallye" ...)
if (EXT_IS_ACTIVE("autopurge"))
if ($_CONFIG['ap_inactive_since'] > 0)
{
// Okay, include last online timestamp
- $whereStatement1 = "WHERE status='CONFIRMED' AND last_online >=";
- $whereStatement2 = bigintval(time() - $_CONFIG['ap_inactive_since']);
- $whereStatement3 = bigintval($_CONFIG['bonus_ranks']);
+ $whereStatement1 = sprintf("WHERE status='CONFIRMED' AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
+ $whereStatement2 = bigintval($_CONFIG['bonus_ranks']);
}
}
// Add more bonus points here
- $ADD = " AND (0";
+ $ADD = "";
if ($_CONFIG['bonus_click_yn'] == "Y") $ADD .= " + turbo_bonus";
if ($_CONFIG['bonus_login_yn'] == "Y") $ADD .= " + login_bonus";
if ($_CONFIG['bonus_order_yn'] == "Y") $ADD .= " + bonus_order";
if ($_CONFIG['bonus_stats_yn'] == "Y") $ADD .= " + bonus_stats";
if ($_CONFIG['bonus_ref_yn'] == "Y") $ADD .= " + bonus_ref";
- $ADD .= ") > 0";
+
+ if (!empty($ADD)) {
+ $ADD .= "AND (0".$ADD.") > 0";
+ } // END - if
// SQL string to check for accounts
$result_main = SQL_QUERY_ESC("SELECT userid, email, (turbo_bonus + login_bonus + bonus_order + bonus_stats + bonus_ref) AS active_bonus
FROM "._MYSQL_PREFIX."_user_data
".$whereStatement1." %s".$ADD."
ORDER BY active_bonus DESC, userid LIMIT %s",
- array($whereStatement2, $whereStatement3), __FILE__, __LINE__);
+ array($whereStatement2), __FILE__, __LINE__);
if (SQL_NUMROWS($result_main) > 0)
{
require($INC);
}
-if (($_CONFIG['send_prof_update'] == "Y") && ($_CONFIG['profile_update'] > 0) && ($_CONFIG['resend_profile_update']))
-{
- // Ok, we shall send update notifications...
- $TIMEOUT = bigintval(time() - $_CONFIG['profile_update']);
- $TIMEOUT2 = bigintval(time() - $_CONFIG['resend_profile_update']);
-
+if (($_CONFIG['send_prof_update'] == "Y") && ($_CONFIG['profile_update'] > 0) && ($_CONFIG['resend_profile_update'])) {
// Load personal data 0 1 2 3 4 5 6
$result = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, last_update, joined
- FROM "._MYSQL_PREFIX."_user_data
- WHERE (last_update < %s AND last_update != '0' AND last_profile_sent < %s) OR (last_update='0' AND last_profile_sent='0' AND joined < %s)
- ORDER BY userid", array($TIMEOUT, $TIMEOUT2, $TIMEOUT), __FILE__, __LINE__);
+FROM
+ "._MYSQL_PREFIX."_user_data
+WHERE
+ (last_update < (UNIX_TIMESTAMP() - %s) AND last_update != 0 AND last_profile_sent < (UNIX_TIMESTAMP() - %s))
+OR
+ (last_update=0 AND last_profile_sent=0 AND joined < (UNIX_TIMESTAMP() - %s))
+ORDER BY userid", array($_CONFIG['profile_update'], $_CONFIG['resend_profile_update'], $_CONFIG['profile_update']), __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0)
{
// We need to send-out notifications...