if (($data['ref_payout'] > 0) && (getConfig('allow_direct_pay') == "N")) $locked = true;
// Add points to account
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
ADD_POINTS_REFSYSTEM("birthday_confirm", $uid, $data['points'], false, "0", $locked, strtolower(getConfig('birthday_mode')));
// Remove entry from table
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_birthday WHERE userid=%s AND chk_value='%s' LIMIT 1",
- array($uid, $chk), __FILE__, __LINE__);
+ array($uid, $chk), __FILE__, __LINE__);
// Update mediadata if version is 0.0.4 or newer
if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
define('SERVER_URL', "http://www.mxchange.org");
// Current SVN revision
-define('CURR_SVN_REVISION', "662");
+define('CURR_SVN_REVISION', "663");
// Take a prime number which is long (if you know a longer one please try it out!)
define('_PRIME', 591623);
array($points, $uid), __FILE__, __LINE__);
} else {
// Add points to account
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
ADD_POINTS_REFSYSTEM("beg", $uid, $points, false, "0", $locked, strtolower(getConfig('beg_mode')));
}
// Payback refback for refid and reduce it for current user
function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
//* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
- global $DEPTH, $cacheArray;
+ global $cacheArray;
// Back ref depths
- $cacheArray['depth'][$uid][$ref] = $DEPTH;
+ $cacheArray['depth'][$uid][$ref] = $GLOBALS['ref_level'];
// Init points
$return = $points;
// "Walk" through all level
while (list($level, $perc) = SQL_FETCHROW($result_refs)) {
// Reset ref depths
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
// "Walk" through all refids
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},level={$level},points={$points}<br />\n";
SQL_FREERESULT($result_refs);
// Restore ref depth
- $DEPTH = $cacheArray['depth'][$uid][$ref];
+ $GLOBALS['ref_level'] = $cacheArray['depth'][$uid][$ref];
// Return them
//* DEBUG: */ print "</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />\n";
//
function ADMIN_DO_ACTION($wht) {
- global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $DATA, $DEPTH;
+ global $menuDesription, $menuTitle, $_CONFIG, $cacheArray, $DATA;
//* DEBUG: */ echo __LINE__."*".$wht."/".$GLOBALS['module']."/".$GLOBALS['action']."/".$GLOBALS['what']."*<br />\n";
if (EXT_IS_ACTIVE("cache")) {
define('__POINTS_VALUE', $_POST['points']);
$result_main = SQL_QUERY("SELECT userid FROM `"._MYSQL_PREFIX."_user_data` WHERE status='CONFIRMED' ORDER BY userid", __FILE__, __LINE__);
while (list($uid) = SQL_FETCHROW($result_main)) {
- // User ID found in URL so we use this give him some credits
- $result = SQL_QUERY_ESC("SELECT surname, family, email FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
- // Selected user does exist
- list($sname, $fname, $email) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
-
- if ((isset($_POST['ok'])) && (!empty($_POST['points']))) {
- global $DEPTH;
- // Remove depth to prevent booking errors. This is a bad coding
- // practice, thats also why we need to write this project from
- // scratch...
- unset($DEPTH);
+ // Remove depth to prevent booking errors. This is a bad coding
+ // practice, thats also why we need to write this project from
+ // scratch...
+ $GLOBALS['ref_level'] = -1;
- // Ok, add points and send an email to him...
- ADD_POINTS_REFSYSTEM("admin_all", $uid, bigintval($_POST['points']), false, "0", false, "direct");
+ // Ok, add points and send an email to him...
+ ADD_POINTS_REFSYSTEM("admin_all", $uid, bigintval($_POST['points']), false, "0", false, "direct");
- // Prepare content
- $content = array(
- 'text' => SQL_ESCAPE($_POST['reason']),
- 'points' => bigintval($_POST['points'])
- );
+ // Prepare content
+ $content = array(
+ 'text' => SQL_ESCAPE($_POST['reason']),
+ 'points' => bigintval($_POST['points'])
+ );
- // Load email template and send email away
- $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval($uid));
- SEND_EMAIL(bigintval($uid), ADMIN_ADD_SUBJ, $msg);
- }
- }
- }
+ // Load email template and send email away
+ $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval($uid));
+ SEND_EMAIL(bigintval($uid), ADMIN_ADD_SUBJ, $msg);
+ } // END - while
// Free memory
SQL_FREERESULT($result_main);
SQL_FREERESULT($result);
if ((isset($_POST['ok'])) && (!empty($_POST['points']))) {
- global $DEPTH;
// Remove depth to prevent booking errors. This is a bad coding
// practice, thats also why we need to write this project from
// scratch...
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
// Ok, add points and send an email to him...
ADD_POINTS_REFSYSTEM("admin_single", bigintval($_GET['u_id']), bigintval($_POST['points']), false, "0", false, "direct");
UPDATE_REF_COUNTER($rid);
// Ok, write the ref-points to this user and his parent-ref
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
// Shall I "pay" the referal points imidiately?
if (getConfig('ref_payout') == "0") {
} // END - if
// Add one-time referal bonus over referal system or directly
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
ADD_POINTS_REFSYSTEM("referal_bonus", $rid, getConfig('points_ref'), true, bigintval($uid), $locked, getConfig('reg_points_mode'));
} // END - if
} // END - if
$success = WERNIS_EXECUTE_WITHDRAW($_POST['wds66_id'], md5($_POST['wds66_password']), $_POST['amount']);
if ($success) {
// Add it to this amount
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
ADD_POINTS_REFSYSTEM("wernis_withdraw", $GLOBALS['userid'], bigintval($_POST['amount']), false, 0, false, "direct");
// Update the user data as well..
* for default value will cause no referal will get points ever!!!)
*/
function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
- //* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
- global $DEPTH, $_CONFIG, $DATA, $cacheArray;
+ /* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
+ global $_CONFIG, $DATA, $cacheArray;
// Convert mode to lower-case
$add_mode = strtolower($add_mode);
} // END - if
// Count up referal depth
- if (!isset($DEPTH)) {
+ if (!isset($GLOBALS['ref_level'])) {
// Initialialize referal system
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />\n";
- $DEPTH = 0;
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />\n";
+ $GLOBALS['ref_level'] = 0;
} else {
// Increase referal level
- $DEPTH++;
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$DEPTH}<br />\n";
+ $GLOBALS['ref_level']++;
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$GLOBALS['ref_level']}<br />\n";
}
// Default is "normal" points
$result_user = SQL_QUERY_ESC("SELECT refid, email FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
array(bigintval($uid)), __FILE__, __LINE__);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},numRows=".SQL_NUMROWS($result_user).",points={$points}<br />\n";
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},numRows=".SQL_NUMROWS($result_user).",points={$points}<br />\n";
if (SQL_NUMROWS($result_user) == 1) {
// This is the user and his ref
list($ref, $email) = SQL_FETCHROW($result_user);
$cacheArray['add_uid'][$ref] = $uid;
// Get percents
- $per = GET_REF_LEVEL_PERCENTS($DEPTH);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},depth={$DEPTH},per={$per},mode={$add_mode}<br />\n";
+ $per = GET_REF_LEVEL_PERCENTS($GLOBALS['ref_level']);
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},depth={$GLOBALS['ref_level']},per={$per},mode={$add_mode}<br />\n";
// Some percents found?
if ($per > 0) {
// Calculate new points
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},per={$per},depth={$DEPTH}<br />\n";
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},per={$per},depth={$GLOBALS['ref_level']}<br />\n";
$ref_points = $points * $per / 100;
// Pay refback here if level > 0 and in ref-mode
- if ((EXT_IS_ACTIVE("refback")) && ($DEPTH > 0) && ($per < 100) && ($add_mode == "ref") && (isset($cacheArray['add_uid'][$uid]))) {
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$DEPTH} - BEFORE!<br />\n";
+ if ((EXT_IS_ACTIVE("refback")) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($add_mode == "ref") && (isset($cacheArray['add_uid'][$uid]))) {
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - BEFORE!<br />\n";
$ref_points = ADD_REFBACK_POINTS($cacheArray['add_uid'][$uid], $uid, $points, $ref_points);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$DEPTH} - AFTER!<br />\n";
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - AFTER!<br />\n";
} // END - if
// Update points...
SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET %s=%s+%s WHERE userid=%s AND ref_depth='%s' LIMIT 1",
- array($data, $data, $ref_points, bigintval($uid), bigintval($DEPTH)), __FILE__, __LINE__);
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},uid={$uid},depth={$DEPTH},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />\n";
+ array($data, $data, $ref_points, bigintval($uid), bigintval($GLOBALS['ref_level'])), __FILE__, __LINE__);
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},uid={$uid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />\n";
// No entry updated?
if (SQL_AFFECTEDROWS() < 1) {
// First ref in this level! :-)
$result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_points (userid,ref_depth,%s) VALUES (%s,%s,%s)",
- array($data, bigintval($uid), bigintval($DEPTH), $ref_points), __FILE__, __LINE__);
+ array($data, bigintval($uid), bigintval($GLOBALS['ref_level']), $ref_points), __FILE__, __LINE__);
} // END - if
// Update mediadata as well
// Prepare content
$content = array(
'percent' => $per,
- 'level' => bigintval($DEPTH),
+ 'level' => bigintval($GLOBALS['ref_level']),
'points' => $ref_points,
'refid' => bigintval($ref)
);
// Maybe there's another ref?
if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) {
// Then let's credit him here...
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},points={$points} - ADVANCE!<br />\n";
- ADD_POINTS_REFSYSTEM(sprintf("%s_ref:%s", $subject, $DEPTH), $ref, $points, $send_notify, $ref, $locked);
+ /* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},points={$points} - ADVANCE!<br />\n";
+ ADD_POINTS_REFSYSTEM(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), $ref, $points, $send_notify, $ref, $locked);
} // END - if
} // END - if
} // END - if
// Free result
SQL_FREERESULT($result_user);
- //* DEBUG: */ print "</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />\n";
+ /* DEBUG: */ print "</li></ul>----------------------- <font color=\"#aa0000\">".__FUNCTION__." - EXIT</font> ------------------------<br />\n";
}
//
function UPDATE_REF_COUNTER ($uid) {
}
//
function META_DESCRIPTION ($mod, $wht) {
- global $_CONFIG, $DEPTH;
+ global $_CONFIG;
// Exclude admin and member's area
if (($mod != "admin") && ($mod != "login")) {
} // END - if
// Remove depth
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
}
//
function ADD_JACKPOT($points) {
array($url_uid), __FILE__, __LINE__);
// Add points
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
ADD_POINTS_REFSYSTEM("mailid_okay", $url_uid, $payment, false, "0", $locked);
// Shall I add bonus points for "turbo clickers" ?
LOAD_TEMPLATE($template);
} else {
// Wrong image code! So add points to sender's account
- unset($DEPTH);
+ unset($GLOBALS['ref_level']);
ADD_POINTS_REFSYSTEM("mailid_payback", $sender, $payment, false, 0, false, "direct");
// Load template