]> git.mxchange.org Git - mailer.git/blobdiff - inc/monthly/monthly_bonus.php
Notification mails rewritten
[mailer.git] / inc / monthly / monthly_bonus.php
index f6c8f30c39eae2e06c7f6766d04ce44e40433e6a..2b18fb308db7ce2fff6269027a4b52dd15becf39 100644 (file)
 if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
-} elseif ((!EXT_IS_ACTIVE("bonus")) && (!IS_ADMIN())) {
-       ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "bonus");
+} elseif (!EXT_IS_ACTIVE("bonus")) {
        return;
 }
 
 // Do not execute when script is in CSS mode or no daily reset
 if (($CSS == 1) || (!defined('__DAILY_RESET'))) return;
+//* DEBUG: */ echo basename(__FILE__)."<br />\n";
 
 // Get current month (2 digits)
 $curr = date("m", time());
@@ -73,7 +73,7 @@ if (($curr != $_CONFIG['last_month']) && ($_CONFIG['bonus_ranks'] > 0) && ($CSS
        if ($_CONFIG['bonus_ref_yn']   == "Y") $ADD .= " + bonus_ref";
 
        if (!empty($ADD)) {
-               $ADD .= "AND (0".$ADD.") > 0";
+               $ADD .= " AND (0".$ADD.") > 0";
        } // END - if
 
        // SQL string to check for accounts
@@ -93,21 +93,13 @@ ORDER BY active_bonus DESC, userid LIMIT %s",
                        $UIDs .= ",'".$uid."'";
 
                        // Add points to user's account directly
-                       $result_data = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points
-SET points=points+%s WHERE ref_depth=0 AND userid=%s LIMIT 1",
- array($points, bigintval($uid)), __FILE__, __LINE__);
-
-                       // Update mediadata as well
-                       if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                       {
-                               // Update database
-                               MEDIA_UPDATE_ENTRY(array("total_points"), "add", $points);
-                       }
+                       ADD_POINTS_REFSYSTEM($uid, $points, false, "0", false, "direct");
 
                        // Load email template and email it away
                        $msg = LOAD_EMAIL_TEMPLATE("member_bonus", $points, bigintval($uid));
                        SEND_EMAIL($email, BONUS_MONTHLY_ONLINE_BONUS, $msg);
                }
+
                // Remove first commata
                $UIDs = substr($UIDs, 1);
 
@@ -119,7 +111,6 @@ SET points=points+%s WHERE ref_depth=0 AND userid=%s LIMIT 1",
                // Reset accounts
                $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_user_data
 SET turbo_bonus=0, login_bonus=0, bonus_order=0, bonus_stats=0, bonus_ref=0", __FILE__, __LINE__);
-
        }
 
        // Free memory