X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Fbonus_functions.php;h=3d3a648ebc49bc03874a3bf6242aded6e87fdbd3;hb=3df5cfd765d32de200a4db2a21a04cb2fde40b23;hp=ebd186a483860ca374665957387d0849c10c6330;hpb=19cd0d37b2bcbf9dd4f3c38a9cecd7f5011d6b66;p=mailer.git diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index ebd186a483..3d3a648ebc 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -32,11 +32,11 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) -{ +if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); } + // This function must be run *BEFORE* a link is removed from table 'mxchange_user_links' ! function BONUS_ADD_TURBO_POINTS($mid, $uid, $type) { @@ -50,15 +50,15 @@ function BONUS_ADD_TURBO_POINTS($mid, $uid, $type) switch ($type) { case "bonusid": - $result = SQL_QUERY_ESC("SELECT clicks FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1", + $result = SQL_QUERY_ESC("SELECT clicks FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1", array($mid), __FILE__, __LINE__); - $bonus = $mid; $mail = "0"; + $bonus = $mid; $mail = 0; break; case "mailid" : - $result = SQL_QUERY_ESC("SELECT clicks FROM "._MYSQL_PREFIX."_user_stats WHERE id=%d LIMIT 1", + $result = SQL_QUERY_ESC("SELECT clicks FROM "._MYSQL_PREFIX."_user_stats WHERE id=%s LIMIT 1", array($mid), __FILE__, __LINE__); - $bonus = "0"; $mail = $mid; + $bonus = 0; $mail = $mid; break; } @@ -74,7 +74,7 @@ function BONUS_ADD_TURBO_POINTS($mid, $uid, $type) else { // Anything else so let's explode all entered rank points - $test = explode(";", $_CONFIG['bonus_rates']); + $test = explode(";", $_CONFIG['turbo_rates']); if (!empty($test[$rank - 2])) { // Level found @@ -88,7 +88,7 @@ function BONUS_ADD_TURBO_POINTS($mid, $uid, $type) } // Add points to his account directly - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET turbo_bonus=turbo_bonus+".$points." WHERE userid=%d LIMIT 1", + $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET turbo_bonus=turbo_bonus+".$points." WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); // Rember this whole data for displaying ranking list @@ -104,10 +104,10 @@ function BONUS_MAKE_RANK_ROWS($data, $type, $uid) $self = false; $OUT = ""; // How many ranks do we have? - $ranks = sizeof(explode(";", $_CONFIG['bonus_rates'])) + 1; + $ranks = sizeof(explode(";", $_CONFIG['turbo_rates'])) + 1; // Load current user's data - $result = SQL_QUERY_ESC("SELECT level, points, timemark FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s AND userid=%d LIMIT 1", + $result = SQL_QUERY_ESC("SELECT level, points, timemark FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s AND userid=%s LIMIT 1", array($type, $data, $uid), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { @@ -206,44 +206,23 @@ function BONUS_POINTS_HANDLER($MODE) switch ($_CONFIG['bonus_mode']) { case "JACKPOT": // ... jackpot - if ((SUB_JACKPOT($points) == -1) && ($_CONFIG['bonus_uid'] > 0)) - { + if ((SUB_JACKPOT($points) == -1) && ($_CONFIG['bonus_uid'] > 0)) { // Check points amount first... $TOTAL = GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_data", "used_points"); - if ($TOTAL >= $points) - { + if ($TOTAL >= $points) { // Subtract points from userid's account - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1", - array(bigintval($points), bigintval($_CONFIG['bonus_uid'])), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { - // Update database - MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points); - } - } - } + SUB_POINTS("bonus_payout_jackpot", $_CONFIG['bonus_uid'], $points); + } // END - if + } // END - if break; case "UID": // ... userid's account // Check his amount first $TOTAL = GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_data", "used_points"); - if ($TOTAL >= $points) - { + if ($TOTAL >= $points) { // Subtract points from userid's account - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1", - array(bigintval($points), bigintval($_CONFIG['bonus_uid'])), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { - // Update database - MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points); - } - } - else - { + SUB_POINTS("bonus_payout_uid", $_CONFIG['bonus_uid'], $points); + } else { // Try to subtract from jackpot $dummy = SUB_JACKPOT($points); } @@ -255,10 +234,8 @@ function BONUS_PURGE_EXPIRED_TURBO_BONUS() { global $_CONFIG; // Remove entries - $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < ".(time() - $_CONFIG['bonus_timeout']), __FILE__, __LINE__); - $DELETED = SQL_AFFECTEDROWS($result); - if ($DELETED > 0) - { + $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < (UNIX_TIMESTAMP() - ".$_CONFIG['bonus_timeout'].")", __FILE__, __LINE__); + if (SQL_AFFECTEDROWS() > 0) { // Send out email to admin SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_TURBO_SUBJECT, "admin_autopurge_turbo", $DELETED, ""); }