define('SERVER_URL', "http://www.mxchange.org");
// This current patch level
-define('CURR_SVN_REVISION', "530");
+define('CURR_SVN_REVISION', "531");
// Take a prime number which is long (if you know a longer one please try it out!)
define('_PRIME', 591623);
if ($DOUBLER_POINTS == 0) {
// Exit here to prevent some SQL errors (SQL_QUERY_ESC doen't insert zeros! We need to fix this...)
return;
-}
+} // END - if
// If not currently doubled set it to zero
unset($_GET['DOUBLER_UID']);
ORDER BY d.timemark
LIMIT %d", array($DOUBLER_POINTS, $min, $_CONFIG['doubler_max_sent']), __FILE__, __LINE__);
+// Do we have entries found?
if (((SQL_NUMROWS($result_total) > 0) && ($_CONFIG['doubler_sent_all'] == "Y")) || ((SQL_NUMROWS($result_main) == $_CONFIG['doubler_group_sent']) && ($_CONFIG['doubler_sent_all'] == "N"))) {
// Switch to matching SQL resource
$result_load = $result_main;
if (!$OK) {
// Add points to used doubler points
UPDATE_CONFIG("doubler_used", $points, "+");
- }
+ } // END - if
// Update variables to prevent errors
$_CONFIG['doubler_used'] += $points;
// Load mail template and send mail away...
$msg = LOAD_EMAIL_TEMPLATE("member_doubler", $content, $uid);
SEND_EMAIL($uid, DOUBLER_MEMBER_SUBJECT, $msg);
- }
- }
-}
+ } // END - if
+ } // END - while
+} // END - if
// Free memory
SQL_FREERESULT($result_total);
$SQLs = array();
$test = false;
- // Backup language as well
- $LANG_BCK = $EXT_LANG_PREFIX;
- $EXT_ALWAYS_ACTIVE = "N";
-
// Load required extension also in update mode
$file = sprintf("%sinc/extensions/ext-%s.php", PATH, $EXT_UPDATE_DEPENDS);
// Check for required file
if (FILE_READABLE($file)) {
- // File exists so let's load it
+ // Bacup version number
$VER_BACKUP = $EXT_VERSION;
+
+ // Backup language as well
+ $LANG_BCK = $EXT_LANG_PREFIX;
+
+ // Save the Parrent $EXT_ALWAYS_ACTIVE for later!
+ $EXT_ALWAYS_ACTIVE_PARRENT = $EXT_ALWAYS_ACTIVE;
+
+ // Set EXT_ALWAYS_ACTIVE for update
$EXT_ALWAYS_ACTIVE = "N";
+
+ // File exists so let's load it
require($file);
- $EXT_VERSION = $VER_BACKUP;
// If versions mismatch update extension first
$ext_ver = GET_EXT_VERSION($EXT_UPDATE_DEPENDS);
// Nothing to register / update before...
$test = true;
}
+
+ // Restore version number
+ $EXT_VERSION = $VER_BACKUP;
+
+ // Restore language back
+ $EXT_LANG_PREFIX = $LANG_BCK;
+
+ // Restore $EXT_ALWAYS_ACTIVE with the value from parrent
+ $EXT_ALWAYS_ACTIVE = $EXT_ALWAYS_ACTIVE_PARRENT;
} else {
// Required file for update does not exists!
$test = true;
// Finally restore previous SQLs
$SQLs = $SQLs2; unset($SQLs2);
- $EXT_LANG_PREFIX = $LANG_BCK;
} else {
// Does not depend on an other extension
$test = true;
// Just count...
$TOTAL = 0;
- foreach($prices['uid'] as $key => $uid)
- {
+ foreach($prices['uid'] as $key => $uid) {
// Check status
// active = 1: account is still confirmed
// active = 0: account is deleted or locked
$prices['active'][$key] = $active;
// Allow valid and active users with at least one ref to get points
- if (($uid > 0) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0))
- {
+ if (($uid > 0) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
$TOTAL++;
- }
- }
+ } // END - if
+ } // END - foreach
if (($TOTAL < $min_prices) || ($TOTAL == 0)) {
// Do not end this rallye!
unset($DATA);
return;
- }
+ } // END - if
// Expire rallye
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_rallye_data SET expired='Y' WHERE id=%s LIMIT 1",
- array(bigintval($id)), __FILE__, __LINE__);
+ array(bigintval($id)), __FILE__, __LINE__);
// Run array through (by uid is the most important 2nd-level-array)
- foreach($prices['uid'] as $key => $uid)
- {
+ foreach($prices['uid'] as $key => $uid) {
// Allow valid and active users with at least one ref to get points
- if (($uid > 0) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0))
- {
+ if (($uid > 0) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) {
// Transfer data to array for the mail template
$DATA['level'] = $prices['level'][$key];
$DATA['points'] = $prices['points'][$key];
if ($DATA['points'] > 0) {
// Add points directly to user's account
ADD_POINTS_REFSYSTEM($uid, $DATA['points'], false, "0", false, "direct");
- }
+ } // END - if
if ($notify == "Y") {
// Prepare infos for the mail template
$cnt++;
$users['uid'][$uid] = $uid;
$users['poi'][$uid] = $DATA['infos'];
- }
- }
+ } // END - if
+ } // END - foreach
// Select template depending on notfication is switch on / off
if ($notify == "Y") {
}
// Send mail to admin
- die("OK!");
SEND_ADMIN_NOTIFICATION(RALLYE_ADMIN_EXPIRED.": ".$title, $templ, $cnt, 0);
// Add task
// Reset ref depths
$DEPTH = -1;
- // "Walk through all refids
+ // "Walk" through all refids
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},level={$level},points={$points}<br />\n";
foreach (GET_REFBACK_USERID_ARRAY($uid, $level) as $refid) {
// Skip level zero or if both are the same
// Some percents given?
if ($percents > 0) {
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):points={$points},perc={$perc},percents={$percents},level={$level}<br />\n";
- // Get points for refback
+ // Calculate points for refback
$refback = $points * ($perc / 100) * ($percents / 100);
// Update refback table ("refid" and "uid" must be exchanged!)
// Output link for manually removing stats entry
LOAD_TEMPLATE("admin_settings_saved", false, "<A href=\"".URL."/modules.php?module=admin&what=del_email&pid=".bigintval($_GET['mid'])."\">".ADMIN_REMOVE_STATS_ENTRY."</A>");
- }
+ } // END - if
// Free the result
SQL_FREERESULT($result_pool);
if ($_CONFIG['bonus_stats_yn'] == "Y") $ADD .= " + bonus_stats";
if ($_CONFIG['bonus_ref_yn'] == "Y") $ADD .= " + bonus_ref";
+ // Shall we add some entries?
if (!empty($ADD)) {
- $ADD .= " AND (0".$ADD.") > 0";
+ $whereStatement1 .= " AND (0".$ADD.") > 0";
} // END - if
- // SQL string to check for accounts
- $result_main = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, (turbo_bonus + login_bonus + bonus_order + bonus_stats + bonus_ref) AS points
+ // Run SQL string to check for accounts
+ $result_main = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, (0".$ADD.") AS points
FROM "._MYSQL_PREFIX."_user_data
".$whereStatement1."".$ADD."
ORDER BY active_bonus DESC, userid LIMIT %s",
- array($whereStatement2), __FILE__, __LINE__);
+ array($whereStatement2), __FILE__, __LINE__);
+ // Some entries were found?
if (SQL_NUMROWS($result_main) > 0) {
// Load our winners...
while ($content = SQL_FETCHARRAY($result_main)) {
// Get sender's data
$result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
- array(bigintval($DATA[1])), __FILE__, __LINE__);
+ array(bigintval($DATA[1])), __FILE__, __LINE__);
+
+ // Is the sender found?
if (SQL_NUMROWS($result_sender) == 1) {
// Load data and prepare mail
list($sname, $fname, $email) = SQL_FETCHROW($result_sender);
// Send it also waway
SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg);
- }
+ } // END - if
// Set status to SEND because we completely send it away
$result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1",
$cnt2 += $cnt;
// Update mediadata if version is 0.0.4 or higher
- if (GET_EXT_VERSION("mediadata") >= "0.0.4")
- {
+ if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
// Update entry (or add missing)
//* DEBUG: */ echo "*MEDIA/L:".__LINE__."*<br />";
MEDIA_UPDATE_ENTRY(array("total_orders", "normal_orders"), "add", 1);
- }
+ } // END - if
//* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$P."<br />";
break;
}
// Do we have send maximum mails?
- elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send']))
- {
+ elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send'])) {
// There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
$ADD = "";
if ($cnt <= $DATA[8]) $ADD = ", target_send=target_send-".$cnt;
//* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
break;
}
- }
- else
- {
+ } else {
// User does not exists so we have add the sender's points back to sender's account
- if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0])))
- {
+ if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0]))) {
// List was empty
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND' WHERE id=%s LIMIT 1",
array(bigintval($DATA[0])), __FILE__, __LINE__);
- }
- else
- {
- if ($uid > 0)
- {
+ } else {
+ // Is the userid set?
+ if ($uid > 0) {
// User does not exists, pay points back
$points = GET_PAY_POINTS($DATA[5]);
ADD_POINTS_REFSYSTEM($DATA[1], $points, false, "0", false, "direct");
// Add points together and remove user
$points_BACK[$DATA[1]] += $points;
- }
+ } // END - if
+
+ // Count up
$cnt_back[$DATA[1]]++;
}
+
// Remove entry from list
unset($dummy[$key]);
}
}
}
+
+ // Do we have points to "pay back"?
if ((sizeof($points_BACK) > 0) && (!empty($points_BACK[0]))) {
+ // Walk through all points
foreach ($points_BACK as $uid => $PB) {
// Add points only when we have points left to add and a valid user ID
if (($PB > 0) && ($uid > 0)) {
$result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
array(bigintval($uid)), __FILE__, __LINE__);
$DATA[10] = $PB; $DATA[11] = $cnt_back[$uid];
+
+ // User found?
if (SQL_NUMROWS($result) == 1) {
list($email) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Send mail out to admin
SEND_ADMIN_NOTIFICATION(ADMIN_BACK_JACKPOT." (".$uid.")", "back-admin", $content, "admin");
}
- }
- }
- }
+ } // END - if
+ } // END - foreach
+ } // END - if
}
// Free memory
SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET rand_confirmed=rand_confirmed + 1 WHERE userid=%s LIMIT 1",
array($url_uid), __FILE__, __LINE__);
} // END - if
- }
+ } // END - if
// Insert stats record
USER_STATS_INSERT_RECORD($url_uid, $type, $stats_data);
// Right code entered?
if (bigintval($_POST['gfx_check']) == $img_code) {
+ // Add points over referal system is the default
+ $locked = false;
+ $template = "mailid_points_done";
+
// Right code entered add points and remove entry
- if (($ref_pay > 0) && ($_CONFIG['allow_direct_pay'] == "N"))
- {
+ if (($ref_pay > 0) && ($_CONFIG['allow_direct_pay'] == "N")) {
// Don't add points over the referal system
$locked = true;
$template = "mailid_points_locked";
- }
- else
- {
- // Add points over referal system
- $locked = false;
- $template = "mailid_points_done";
- }
+ } // END - if
// Count down ref_payout value
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=ref_payout-1 WHERE userid=%s AND ref_payout > 0 LIMIT 1",
- array($url_uid), __FILE__, __LINE__);
+ array($url_uid), __FILE__, __LINE__);
// Add points
unset($DEPTH);
ADD_POINTS_REFSYSTEM($url_uid, $payment, false, "0", $locked);
// Shall I add bonus points for "turbo clickers" ?
- if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (function_exists('BONUS_ADD_TURBO_POINTS')))
- {
+ if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (function_exists('BONUS_ADD_TURBO_POINTS'))) {
// Is an active-rallye running and this is not a notification mail?
- if (($_CONFIG['bonus_active'] == "Y") && ($notify == "N"))
- {
+ if (($_CONFIG['bonus_active'] == "Y") && ($notify == "N")) {
// Shall I exclude the webmaster's own userid from the active-rallye?
- if (((($_CONFIG['bonus_uid'] == $url_uid) && ($_CONFIG['bonus_include_own'] == "Y")) || ($_CONFIG['bonus_uid'] != $url_uid)) && ($_CONFIG['def_refid'] != $url_uid))
- {
+ if (((($_CONFIG['bonus_uid'] == $url_uid) && ($_CONFIG['bonus_include_own'] == "Y")) || ($_CONFIG['bonus_uid'] != $url_uid)) && ($_CONFIG['def_refid'] != $url_uid)) {
// Add points and remember ranking are done in this function....
BONUS_ADD_TURBO_POINTS($DATA, $url_uid, $type);
define('_UID_VALUE' , $url_uid);
define('_TYPE_VALUE', $type);
define('_DATA_VALUE', TRANSLATE_COMMA($DATA));
- }
- }
- }
-
- // Remove link from table
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
- array(bigintval($lid)), __FILE__, __LINE__);
+ } // END - if
+ } // END - if
+ } // END - if
// Load total points
define('__TOTAL_POINTS', TRANSLATE_COMMA(
unset($DEPTH);
ADD_POINTS_REFSYSTEM($sender, $payment, false, 0, false, "direct");
- // Remove link from table
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
- array(bigintval($lid)), __FILE__, __LINE__);
-
// Load template
LOAD_TEMPLATE("mailid_points_failed");
}
+
+ // Remove link from table
+ $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
+ array(bigintval($lid)), __FILE__, __LINE__);
break;
case "img":