]> git.mxchange.org Git - mailer.git/blobdiff - inc/monthly/monthly_beg.php
Some cleanups/improvements
[mailer.git] / inc / monthly / monthly_beg.php
index 75e58be8d8c1f9fbf1cbddf00493bae217c654a6..16cb2762d7d4e43c30d3d42af793ba3febd6349c 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
 // Some security stuff...
 if (!defined('__SECURITY')) {
        die();
-} elseif ((isCssOutputMode()) || (!isResetModeEnabled())) {
-       // Do not execute when script is in CSS mode or no hourly reset
+} elseif ((!isHtmlOutputMode()) || (!isMonthlyResetEnabled())) {
+       // Do not execute when script is in non-HTML mode or no hourly reset
        return;
-} elseif (((!isExtensionActive('beg')) || (!isBegRallyeEnabled())) && (isDebugModeEnabled())) {
-       logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension ext-beg disabled.');
+} elseif ((!isExtensionActive('beg')) || (!isBegRallyeEnabled())) {
+       if (isDebugModeEnabled()) logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension ext-beg disabled.');
        return;
 }
 
@@ -55,36 +55,36 @@ if ((getBegRanks() > 0) && (!isCssOutputMode())) {
        $whereStatement = '';
 
        // Shall we exclude webmaster's own userid?
+       // @TODO Rewrite these if() blocks to a filter
        if ((!isBegIncludeOwnEnabled()) && (isValidId(getBegUserid()))) {
                // Exclude it
-               $whereStatement .= ' AND `userid` != {?beg_userid?}';
+               $whereStatement .= ' AND `d`.`userid` != {?beg_userid?}';
        } // END - if
 
        // Let's check if there are some points left we can pay...
        if ((isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) {
                // Okay, include last online timestamp
-               $whereStatement .= ' AND (UNIX_TIMESTAMP() - `last_online`) < {?ap_inactive_since?}';
+               $whereStatement .= ' AND (UNIX_TIMESTAMP() - `d`.`last_online`) < {?ap_inactive_since?}';
        } // END - if
 
        // SQL string to check for accounts
-       $result_main = SQL_QUERY("SELECT
-       `userid`,
-       `beg_points`
+       $result_main = sqlQuery("SELECT
+       `d`.`userid`,
+       `d`.`beg_points`
 FROM
-       `{?_MYSQL_PREFIX?}_user_data`
+       `{?_MYSQL_PREFIX?}_user_data` AS `d`
 WHERE
-       `status`='CONFIRMED'
-       " . $whereStatement . "
-       " . runFilterChain('user_exclusion_sql', ' ') . " AND
-       `beg_points` > 0
+       `d`.`status`='CONFIRMED'
+       " . runFilterChain('user_exclusion_sql', $whereStatement) . " AND
+       `d`.`beg_points` > 0
 ORDER BY
-       `beg_points` DESC,
-       `userid` ASC
+       `d`.`beg_points` DESC,
+       `d`.`userid` ASC
 LIMIT {?beg_ranks?}", __FILE__, __LINE__);
 
-       if (!SQL_HASZERONUMS($result_main)) {
+       if (!ifSqlHasZeroNums($result_main)) {
                // Load our winners...
-               while ($content = SQL_FETCHARRAY($result_main)) {
+               while ($content = sqlFetchArray($result_main)) {
                        // Add points to user's account directly
                        initReferralSystem();
                        addPointsThroughReferralSystem('monthly_beg', $content['userid'], $content['beg_points']);
@@ -95,11 +95,11 @@ LIMIT {?beg_ranks?}", __FILE__, __LINE__);
                } // END - while
 
                // Reset accounts
-               $result = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=0.00000 WHERE `beg_points` > 0', __FILE__, __LINE__);
+               $result = sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_points`=0.00000 WHERE `beg_points` > 0', __FILE__, __LINE__);
        } // END - if
 
        // Free memory
-       SQL_FREERESULT($result_main);
+       sqlFreeResult($result_main);
 } // END - if
 
 // Debug line