unset($GLOBALS['ref_level']);
}
-// Adds points to the jackpot
-function ADD_JACKPOT ($points) {
- $result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FUNCTION__, __LINE__);
+function GET_JACKPOT_POINTS () {
+ // Default is zero
+ $jackpot = '0.00000';
+
+ // Read them
+ $result = SQL_QUERY("SELECT `points` FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE `ok`='ok' LIMIT 1", __FUNCTION__, __LINE__);
+
+ // Do we have an entry?
if (SQL_NUMROWS($result) == 0) {
- // Create line
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_jackpot` (ok, points) VALUES ('ok','%s')", array($points), __FUNCTION__, __LINE__);
+ // No, so create line
+ SQL_QUERY("INSERT INTO `{!_MYSQL_PREFIX!}_jackpot` (`ok`, `points`) VALUES ('ok','0.00000')", __FUNCTION__, __LINE__);
} else {
- // Free memory
- SQL_FREERESULT($result);
+ // Read the line
+ list($jackpot) = SQL_FETCHROW($result);
+ }
- // Update points
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_jackpot` SET points=points+%s WHERE ok='ok' LIMIT 1",
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return them
+ return $jackpot;
+}
+
+// Adds points to the jackpot
+function ADD_JACKPOT ($points) {
+ // Get jackpot points for dummy
+ $jackpot = GET_JACKPOT_POINTS();
+
+ // Update points
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_jackpot` SET `points`=`points`+%s WHERE `ok`='ok' LIMIT 1",
array($points), __FUNCTION__, __LINE__);
- }
}
// Subtracts points from the jackpot
// First failed
$ret = '-1';
- // Get current points
- $result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 0) {
- // Create line
- SQL_QUERY("INSERT INTO `{!_MYSQL_PREFIX!}_jackpot` (ok, points) VALUES ('ok', 0.00000)", __FUNCTION__, __LINE__);
- } else {
- // Read points
- list($jackpot) = SQL_FETCHROW($result);
- if ($jackpot >= $points) {
- // Update points when there are enougth points in jackpot
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_jackpot` SET points=points-%s WHERE ok='ok' LIMIT 1",
+ // Get jackpot points for dummy
+ $jackpot = GET_JACKPOT_POINTS();
+
+ // Enougth points i jackpot?
+ if ($jackpot >= $points) {
+ // Update points when there are enougth points in jackpot
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_jackpot` SET `points`=`points`-%s WHERE `ok`='ok' LIMIT 1",
array($points), __FUNCTION__, __LINE__);
- $ret = $jackpot - $points;
- } // END - if
- }
+ $ret = $jackpot - $points;
+ } // END - if
// Free memory
SQL_FREERESULT($result);
+
+ // Return the result
+ return $ret;
}
// Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
// Run database update
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "entries={$entries}");
- SQL_QUERY("UPDATE `{!_MYSQL_PREFIX!}_config` SET ".$entries." WHERE config=0 LIMIT 1", __FUNCTION__, __LINE__);
+ SQL_QUERY("UPDATE `{!_MYSQL_PREFIX!}_config` SET ".$entries." WHERE `config`=0 LIMIT 1", __FUNCTION__, __LINE__);
// Get affected rows
$affectedRows = SQL_AFFECTEDROWS();
// "Getter" for total available receivers
function getTotalReceivers ($mode='normal') {
// Query database
- $result_all = SQL_QUERY("SELECT userid
-FROM `{!_MYSQL_PREFIX!}_user_data`
-WHERE `status`='CONFIRMED' AND receive_mails > 0 ".PREPARE_SQL_HTML_HOLIDAY($mode),
+ $result_all = SQL_QUERY("SELECT
+ `userid`
+FROM
+ `{!_MYSQL_PREFIX!}_user_data`
+WHERE
+ `status`='CONFIRMED' AND `receive_mails` > 0 ".PREPARE_SQL_HTML_HOLIDAY($mode),
__FUNCTION__, __LINE__);
// Get num rows
$CATS['name'][] = $content['cat'];
// Check which users are in this category
- $result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s",
- array(bigintval($content['id'])), __FUNCTION__, __LINE__);
+ $result_uids = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE `cat_id`=%s",
+ array(bigintval($content['id'])), __FUNCTION__, __LINE__);
// Start adding all
$uid_cnt = 0;
FROM
`{!_MYSQL_PREFIX!}_user_data`
WHERE
- `userid`=%s AND `status`='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML_HOLIDAY($mode)."
+ `userid`=%s AND `status`='CONFIRMED' AND `receive_mails` > 0".PREPARE_SQL_HTML_HOLIDAY($mode)."
LIMIT 1",
array(bigintval($ucat)), __FUNCTION__, __LINE__);
// Add HTML mail
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_bonus`
-(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, html_msg)
+(`subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `html_msg`)
VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s','%s')",
array(
- $subject,
- $text,
- $receiverList,
- $points,
- $seconds,
- $url,
- $cat,
- $target,
- bigintval($receiver),
- $HTML
+ $subject,
+ $text,
+ $receiverList,
+ $points,
+ $seconds,
+ $url,
+ $cat,
+ $target,
+ bigintval($receiver),
+ $HTML
), __FUNCTION__, __LINE__);
} else {
// Add regular mail
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_bonus`
-(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent)
+(`subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`)
VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(),'%s','%s','%s','%s')",
array(
- $subject,
- $text,
- $receiverList,
- $points,
- $seconds,
- $url,
- $cat,
- $target,
- bigintval($receiver),
+ $subject,
+ $text,
+ $receiverList,
+ $points,
+ $seconds,
+ $url,
+ $cat,
+ $target,
+ bigintval($receiver),
), __FUNCTION__, __LINE__);
}
}
} // END - if
// Try to find the entry
- $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`inserted`) AS `stamp`
-FROM `{!_MYSQL_PREFIX!}_user_stats_data`
-WHERE `userid`=%s AND `stats_type`='%s' AND `stats_data`='%s'
+ $result = SQL_QUERY_ESC("SELECT
+ UNIX_TIMESTAMP(`inserted`) AS stamp
+FROM
+ `{!_MYSQL_PREFIX!}_user_stats_data`
+WHERE
+ `userid`=%s AND `stats_type`='%s' AND `stats_data`='%s'
LIMIT 1",
array(
bigintval($uid),
if ((!getTimestampFromUserStats($type, $data, $uid)) && (!is_array($data))) {
// Then insert it!
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_stats_data` (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
- array(bigintval($uid), $type, $data), __FUNCTION__, __LINE__);
+ array(bigintval($uid), $type, $data), __FUNCTION__, __LINE__);
} elseif (is_array($data)) {
// Invalid data!
DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},type={$type},data={".gettype($data).": Invalid statistics data type!");
} // END - if
// Get refs from database
- $result = SQL_QUERY_ESC("SELECT ur.id, ur.refid, ud.status, ud.last_online, ud.mails_confirmed, ud.emails_received".$add."
-FROM `{!_MYSQL_PREFIX!}_user_refs` AS ur
-LEFT JOIN `{!_MYSQL_PREFIX!}_user_points` AS up
-ON ur.refid=up.userid AND ur.level=0
-LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS ud
-ON ur.refid=ud.userid
-WHERE ur.userid=%s AND ur.level=%s
+ $result = SQL_QUERY_ESC("SELECT
+ ur.id, ur.refid, ud.status, ud.last_online, ud.mails_confirmed, ud.emails_received".$add."
+FROM
+ `{!_MYSQL_PREFIX!}_user_refs` AS ur
+LEFT JOIN
+ `{!_MYSQL_PREFIX!}_user_points` AS up
+ON
+ ur.refid=up.userid AND ur.level=0
+LEFT JOIN
+ `{!_MYSQL_PREFIX!}_user_data` AS ud
+ON
+ ur.refid=ud.userid
+WHERE
+ ur.userid=%s AND ur.level=%s
ORDER BY ur.refid ASC",
- array(bigintval($uid), bigintval($level)), __FUNCTION__, __LINE__);
+ array(
+ bigintval($uid),
+ bigintval($level)
+ ), __FUNCTION__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) > 0) {
function reduceRecipientReceivedMails ($column, $id, $count) {
// Search for mail in database
$result = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
- array($column, bigintval($id), $count), __FUNCTION__, __LINE__);
+ array($column, bigintval($id), $count), __FUNCTION__, __LINE__);
// Are there entries?
if (SQL_NUMROWS($result) > 0) {