- list($ret) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
- }
- return $ret;
-}
-
-// Remove a receiver's ID from $ARRAY and add a link for him to confirm
-function REMOVE_RECEIVER (&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=false)
-{
- $ret = "failed";
- if ($uid > 0)
- {
- // Remove entry from array
- unset($ARRAY[$key]);
-
- // Is there already a line for this user available?
- if ($stats_id > 0)
- {
- // Only when we got a real stats ID continue searching for the entry
- $type = "NORMAL"; $rowName = "stats_id";
- if ($bonus) { $type = "BONUS"; $rowName = "bonus_id"; }
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE %s='%s' AND userid=%s AND link_type='%s' LIMIT 1",
- array($rowName, $stats_id, bigintval($uid), $type), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0)
- {
- // No, so we add one!
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_links (%s, userid, link_type) VALUES ('%s','%s','%s')",
- array($rowName, $stats_id, bigintval($uid), $type), __FILE__, __LINE__);
- $ret = "done";
- }
- else
- {
- // Already found
- $ret = "already";
- }
-
- // Free memory
- SQL_FREERESULT($result);
- }
- }
- // Return status for sending routine
- return $ret;
-}
-
-// Calculate sum (default) or count records of given criteria
-function GET_TOTAL_DATA ($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false, $add="") {
- $ret = 0;
- //* DEBUG: */ echo $search."/".$tableName."/".$lookFor."/".$whereStatement."/".$add."<br />\n";
- if (($onlyRows) || ($lookFor == "userid")) {
- // Count rows
- //* DEBUG: */ echo "COUNT!<br />\n";
- $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'".$add,
- array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
- } else {
- // Add all rows
- //* DEBUG: */ echo "SUM!<br />\n";
- $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `"._MYSQL_PREFIX."_%s` WHERE `%s`='%s'".$add,
- array($lookFor, $tableName, $whereStatement, $search), __FILE__, __LINE__);
- }
-
- // Load row
- list($ret) = SQL_FETCHROW($result);
-
- // Free result
- SQL_FREERESULT($result);
-
- // Fix empty values
- if ((empty($ret)) && ($lookFor != "counter") && ($lookFor != "id") && ($lookFor != "userid")) {
- // Float number
- $ret = "0.00000";
- } elseif ("".$ret."" == "") {
- // Fix empty result
- $ret = "0";
- }
-
- // Return value
- return $ret;
-}
-// "Getter fro ref level percents
-function GET_REF_LEVEL_PERCENTS ($level) {
- global $cacheInstance, $_CONFIG, $cacheArray;
-
- // Default is zero
- $per = 0;
-
- // Do we have cache?
- if ((isset($cacheArray['ref_depths']['level'])) && (EXT_IS_ACTIVE("cache"))) {
- // First look for level
- $key = array_search($level, $cacheArray['ref_depths']['level']);
- if ($key !== false) {
- // Entry found!
- $per = $cacheArray['ref_depths']['percents'][$key];
-
- // Count cache hit
- if (getConfig('cache_hits') > 0) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
- }
- } elseif (!EXT_IS_ACTIVE("cache")) {
- // Get referal data
- $result_lvl = SQL_QUERY_ESC("SELECT percents FROM "._MYSQL_PREFIX."_refdepths WHERE level='%s' LIMIT 1",
- array(bigintval($level)), __FILE__, __LINE__);
-
- // Entry found?
- if (SQL_NUMROWS($result_lvl) == 1) {
- // Get percents
- list($per) = SQL_FETCHROW($result_lvl);
- } // END - if
-
- // Free result
- SQL_FREERESULT($result_lvl);
- }
-
- // Return percent
- return $per;
-}
-/**
- *
- * Dynamic referal system, can also send mails!
- *
- * subject = Subject line, write in lower-case letters and underscore is allowed
- * uid = Referal ID wich should receive...
- * points = ... xxx points
- * send_notify = shall I send the referal an email or not?
- * rid = inc/modules/guest/what-confirm.php need this (DEPRECATED???)
- * locked = Shall I pay it to normal (false) or locked (true) points ammount?
- * add_mode = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
- * 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;
-
- // Convert mode to lower-case
- $add_mode = strtolower($add_mode);
-
- // When $uid = 0 add points to jackpot
- if ($uid == "0") {
- // Add points to jackpot
- ADD_JACKPOT($points);
- return;
- } // END - if