- $UIDs = "";
- while(list($uid, $email, $points) = SQL_FETCHROW($result_main))
- {
- // Add userids in a row
- $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);
- }
-
- // 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);
-
- // Get current month
- $curr = date("m", time());
- if (strlen($curr) == 1) $curr = "0".$curr;
- if ($curr == "00") $curr = "12";
+ while ($content = SQL_FETCHARRAY($result_main)) {
+ // Make sure zero points are not mailed
+ if ($content['points'] > 0) {
+ // Add points to user's account directly
+ ADD_POINTS_REFSYSTEM_DIRECT('monthly_bonus', $content['uid'], $content['points']);
+
+ // Translate gender/points
+ $content['gender'] = translateGender($content['gender']);
+ $content['points'] = translateComma($content['points']);
+
+ // Load email template and email it away
+ $msg = LOAD_EMAIL_TEMPLATE("member_bonus", $content['points'], bigintval($content['uid']));
+ sendEmail($content['email'], getMessage('BONUS_MONTHLY_ONLINE_BONUS'), $msg);
+ } // END - if
+ } // END - while