]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/bonus_functions.php
More queries now depends on UNIX_TIMESTAMP() SQL function, wrong index in autopurge...
[mailer.git] / inc / libs / bonus_functions.php
index 266866130f5455344450cb2e255e51e7858960dd..14041197537088410364f5bdf19f86569af48595 100644 (file)
  ************************************************************************/
 
 // 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)
 {
@@ -52,13 +52,13 @@ function BONUS_ADD_TURBO_POINTS($mid, $uid, $type)
        case "bonusid":
                $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=%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['bonus_ranks']);
                if (!empty($test[$rank - 2]))
                {
                        // Level found
@@ -104,7 +104,7 @@ 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['bonus_ranks'])) + 1;
 
        // Load current user's data
        $result = SQL_QUERY_ESC("SELECT level, points, timemark FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s AND userid=%s LIMIT 1",
@@ -239,10 +239,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, "");
        }