X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fpool-update.php;h=bc5ea6fd70f24a4611bac1df906d3e5e2b634650;hb=53b5edd1ee2b126087000ff842ac7bd0feea8814;hp=f5d6a9b36fcf1d288a83aa7ceaed3b7afd110d5f;hpb=51d65692668408a44920ce069a37c5fa4f5ba257;p=mailer.git diff --git a/inc/pool-update.php b/inc/pool-update.php index f5d6a9b36f..bc5ea6fd70 100644 --- a/inc/pool-update.php +++ b/inc/pool-update.php @@ -56,7 +56,7 @@ if ($HTML_EXT) { } // Reset variables -$cnt = 0; $cnt2 = 0; $LAST_SENT_ID = 0; $cnt_back = array("0"); $pointsBack = array("0"); +$cnt = 0; $cnt2 = 0; $LAST_SENT_ID = 0; $cnt_back = array("0"); $points_BACK = array("0"); if (SQL_NUMROWS($result_main) > 0) { while ($DATA = SQL_FETCHROW($result_main)) @@ -117,7 +117,7 @@ if (SQL_NUMROWS($result_main) > 0) if (SQL_NUMROWS($result_stats) == 0) { // No entry was found, so we add him! - $result_stats = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_stats (pool_id , userid, cat_id, payment_id, subject, url , max_rec , timestamp_ordered, timestamp_sstart) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' , UNIX_TIMESTAMP())", + $result_stats = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_stats (pool_id , userid, cat_id, payment_id, subject, url , max_rec , timestamp_ordered, timestamp_sstart) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())", array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[9]), bigintval($DATA[5]), $DATA[2], $DATA[7], $DATA[8], bigintval($DATA[6])), __FILE__, __LINE__); // Receive it's ID for the links table @@ -212,7 +212,9 @@ if (SQL_NUMROWS($result_main) > 0) // Get sender's data $result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array(bigintval($DATA[1])), __FILE__, __LINE__); + array(bigintval($DATA[1])), __FILE__, __LINE__); + + // Is the sender found? if (SQL_NUMROWS($result_sender) == 1) { // Load data and prepare mail list($sname, $fname, $email) = SQL_FETCHROW($result_sender); @@ -223,7 +225,7 @@ if (SQL_NUMROWS($result_main) > 0) // Send it also waway SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg); - } + } // END - if // Set status to SEND because we completely send it away $result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1", @@ -237,19 +239,17 @@ if (SQL_NUMROWS($result_main) > 0) $cnt2 += $cnt; // Update mediadata if version is 0.0.4 or higher - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { + if (GET_EXT_VERSION("mediadata") >= "0.0.4") { // Update entry (or add missing) //* DEBUG: */ echo "*MEDIA/L:".__LINE__."*
"; MEDIA_UPDATE_ENTRY(array("total_orders", "normal_orders"), "add", 1); - } + } // END - if //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$P."
"; break; } // Do we have send maximum mails? - elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send'])) - { + elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send'])) { // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered) $ADD = ""; if ($cnt <= $DATA[8]) $ADD = ", target_send=target_send-".$cnt; @@ -259,38 +259,27 @@ if (SQL_NUMROWS($result_main) > 0) //* DEBUG: */ echo"*EXIT/L:".__LINE__."*
"; break; } - } - else - { + } else { // User does not exists so we have add the sender's points back to sender's account - if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0]))) - { + if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0]))) { // List was empty $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND' WHERE id=%s LIMIT 1", array(bigintval($DATA[0])), __FILE__, __LINE__); - } - else - { - if ($uid > 0) - { - // User does exist so pay the points back + } else { + // Is the userid set? + if ($uid > 0) { + // User does not exists, pay points back $points = GET_PAY_POINTS($DATA[5]); - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s WHERE userid=%s AND ref_depth=0 LIMIT 1", - array($points, bigintval($DATA[1])), __FILE__, __LINE__); - - // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { - // Update database - //* DEBUG: */ echo "*MEDIA/L:".__LINE__."/".$points."*
"; - MEDIA_UPDATE_ENTRY(array("total_points"), "add", $points); - } + ADD_POINTS_REFSYSTEM("pool_payback", $DATA[1], $points, false, "0", false, "direct"); // Add points together and remove user - $pointsBack[$DATA[1]] += $points; - } + $points_BACK[$DATA[1]] += $points; + } // END - if + + // Count up $cnt_back[$DATA[1]]++; } + // Remove entry from list unset($dummy[$key]); @@ -301,8 +290,11 @@ if (SQL_NUMROWS($result_main) > 0) } } } - if ((sizeof($pointsBack) > 0) && (!empty($pointsBack[0]))) { - foreach ($pointsBack as $uid => $PB) { + + // Do we have points to "pay back"? + if ((sizeof($points_BACK) > 0) && (!empty($points_BACK[0]))) { + // Walk through all points + foreach ($points_BACK as $uid => $PB) { // Add points only when we have points left to add and a valid user ID if (($PB > 0) && ($uid > 0)) { // Prepare content @@ -314,6 +306,8 @@ if (SQL_NUMROWS($result_main) > 0) $result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); $DATA[10] = $PB; $DATA[11] = $cnt_back[$uid]; + + // User found? if (SQL_NUMROWS($result) == 1) { list($email) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -330,9 +324,9 @@ if (SQL_NUMROWS($result_main) > 0) // Send mail out to admin SEND_ADMIN_NOTIFICATION(ADMIN_BACK_JACKPOT." (".$uid.")", "back-admin", $content, "admin"); } - } - } - } + } // END - if + } // END - foreach + } // END - if } // Free memory