From c08df20b10d0771e7f749d7afbe1f76be9f1b028 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 12 Dec 2008 20:05:05 +0000 Subject: [PATCH] Minor rewrites to sending pools --- img.php | 6 ++++++ inc/databases.php | 2 +- inc/pool/pool-bonus.php | 41 ++++++++++++++++------------------------- inc/pool/pool-user.php | 40 +++++++++++++++++++++------------------- 4 files changed, 44 insertions(+), 45 deletions(-) diff --git a/img.php b/img.php index 2e7d46fb9d..09cafe5146 100644 --- a/img.php +++ b/img.php @@ -46,6 +46,9 @@ require("inc/config.php"); // Script installed? if (isBooleanConstantAndTrue('mxchange_installed')) { + // Load header + require_once(PATH."inc/header.php"); + // Code set? if (!empty($_GET['code'])) { // Generate image @@ -63,6 +66,9 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { require($fqfn); } // END - if } + + // Finish generation here + require_once(PATH."inc/footer.php"); } else { // You have to configure first! LOAD_URL("install.php"); diff --git a/inc/databases.php b/inc/databases.php index dfd79546c6..3a51cc507e 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "621"); +define('CURR_SVN_REVISION', "622"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/pool/pool-bonus.php b/inc/pool/pool-bonus.php index e44b30ef71..c525382125 100644 --- a/inc/pool/pool-bonus.php +++ b/inc/pool/pool-bonus.php @@ -87,18 +87,16 @@ if ($cnt < $_CONFIG['max_send']) { // Load personal data //* DEBUG: */ echo "*L:".__LINE__."/".$uid."*
"; $result_user = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); + array(bigintval($uid)), __FILE__, __LINE__); // Is his data available? - if (SQL_NUMROWS($result_user) == 1) - { + if (SQL_NUMROWS($result_user) == 1) { // The final receiver does exists so we can continue... list($sname, $fname, $email) = SQL_FETCHROW($result_user); //* DEBUG: */ echo "OK!/L:".__LINE__."
"; // Mark this user as "spammed" ;-) And place a line for him... - if (REMOVE_RECEIVER($dummy, $key, $uid, $DATA['id'], $DATA['id'], true) == "done") - { + if (REMOVE_RECEIVER($dummy, $key, $uid, $DATA['id'], $DATA['id'], true) == "done") { // Replace text variables foreach ($REPLACER as $key => $value) { if (isset($DATA[$key])) $DATA['text'] = str_replace($value, $DATA[$key], $DATA['text']); @@ -129,56 +127,49 @@ if ($cnt < $_CONFIG['max_send']) { // Count one up and remove entry from dummy array $cnt++; unset($dummy[$key]); - if (GET_EXT_VERSION("user") >= "0.1.4") - { + if (GET_EXT_VERSION("user") >= "0.1.4") { // Update mails received for receiver $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET emails_received=emails_received+1 WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); - } + array(bigintval($uid)), __FILE__, __LINE__); + } // END - if // Do we have send maximum mails? - if (($cnt >= $_CONFIG['max_send']) || (SELECTION_COUNT($dummy) == 0)) - { + if (($cnt >= $_CONFIG['max_send']) || (SELECTION_COUNT($dummy) == 0)) { // Yes, we have //* DEBUG: */ echo "*EXIT/L:".__LINE__."
"; break; - } - } - } + } // END - if + } // END - if + } // END - if // Free some memory SQL_FREERESULT($result_user); } // 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 $P = $cnt; if (!empty($cnt2) && empty($cnt)) $P = $cnt2; //* DEBUG: */ echo "+MEDIA/L:".__LINE__."/".$P."+
"; MEDIA_UPDATE_ENTRY(array("total_send", "bonus_send"), "add", $P); - } + } // END - if // Close sending system //* DEBUG: */ echo "-L:".__LINE__."/".SELECTION_COUNT($dummy)."-
"; - if (SELECTION_COUNT($dummy) == 0) - { + if (SELECTION_COUNT($dummy) == 0) { // Queue reached! $result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1", array(bigintval($DATA['id'])), __FILE__, __LINE__); //* DEBUG: */ echo "*L:".__LINE__."*
"; // 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", "bonus_orders"), "add", 1); - } - } - elseif ($cnt >= $_CONFIG['max_send']) - { + } // END - if + } elseif ($cnt >= $_CONFIG['max_send']) { // Update bonus pool $result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='NEW', target_send=%s, receivers='%s' WHERE id=%s LIMIT 1", array(SELECTION_COUNT($dummy), implode(";", $dummy), bigintval($DATA['id'])), __FILE__, __LINE__); diff --git a/inc/pool/pool-user.php b/inc/pool/pool-user.php index beb483ca08..dab61b1c46 100644 --- a/inc/pool/pool-user.php +++ b/inc/pool/pool-user.php @@ -58,17 +58,18 @@ if (EXT_IS_ACTIVE("html_mail")) { // Reset variables $cnt2 = 0; $LAST_SENT_ID = 0; $cnt_back = array("0"); $pointsBack = array("0"); if (SQL_NUMROWS($result_main) > 0) { + // Parse all mails while ($DATA = SQL_FETCHROW($result_main)) { + // Set mail order as "active". That means it will be sent out + $result_active = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='ACTIVE' WHERE id=%s AND data_type='NEW' LIMIT 1", + array($DATA[0]), __FILE__, __LINE__); + // Check fetched data for HTML $HTML = $DATA[10]; if ($HTML == $DATA[0]) $HTML = "N"; // Compile URL and subject line $DATA[7] = COMPILE_CODE($DATA[7]); - // Set mail order as "active". That means it will be sent out - $result_active = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='ACTIVE' WHERE id=%s AND data_type='NEW' LIMIT 1", - array($DATA[0]), __FILE__, __LINE__); - // Entry updated? if (SQL_AFFECTEDROWS() == 1) { // "Explode" all receivers into an array @@ -89,12 +90,11 @@ if (SQL_NUMROWS($result_main) > 0) { foreach ($RECEIVERS as $key => $uid) { // Lookup user ID $result_user = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); + array(bigintval($uid)), __FILE__, __LINE__); // Is his data available? //* DEBUG: */ echo "*L:".__LINE__."/".SQL_NUMROWS($result_user)."*
"; - if (SQL_NUMROWS($result_user) == 1) - { + if (SQL_NUMROWS($result_user) == 1) { // The final receiver does exists so we can continue... list($gender, $sname, $fname, $email) = SQL_FETCHROW($result_user); @@ -103,27 +103,24 @@ if (SQL_NUMROWS($result_main) > 0) { // Do we have a stats entry? $result_stats = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%s AND userid=%s AND timestamp_ordered='%s' LIMIT 1", - array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__); + array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__); // If there's no stats entry add it! //* DEBUG: */ echo "!L:".__LINE__."/".SQL_NUMROWS($result_stats)."!
"; - if (SQL_NUMROWS($result_stats) == 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())", - array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[9]), bigintval($DATA[5]), $DATA[2], $DATA[7], $DATA[8], bigintval($DATA[6])), __FILE__, __LINE__); + 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 $result_stats = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%s AND userid=%s AND timestamp_ordered='%s' LIMIT 1", - array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__); - } + array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__); + } // END - if //* DEBUG: */ echo "!L:".__LINE__."/".SQL_NUMROWS($result_stats)."!
"; - if (SQL_NUMROWS($result_stats) == 1) - { + if (SQL_NUMROWS($result_stats) == 1) { // We got one! list($stats_id) = SQL_FETCHROW($result_stats); - SQL_FREERESULT($result_stats); // Mark this user as "spammed" ;-) And place a line for him... //* DEBUG: */ echo "?L:".__LINE__."/".$dummy."/".$key."/".$uid."(".$DATA[1].")/".$DATA[0]."/".$stats_id."?
"; @@ -160,12 +157,12 @@ if (SQL_NUMROWS($result_main) > 0) { // Count sent mails... $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET emails_sent=emails_sent+1 WHERE userid=%s LIMIT 1", - array(bigintval($DATA[1])), __FILE__, __LINE__); + array(bigintval($DATA[1])), __FILE__, __LINE__); if (GET_EXT_VERSION("user") >= "0.1.4") { // Update mails received for receiver $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET emails_received=emails_received+1 WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); + array(bigintval($uid)), __FILE__, __LINE__); } // END - if // Update mediadata if version is 0.0.4 or higher @@ -211,7 +208,6 @@ if (SQL_NUMROWS($result_main) > 0) { if (SQL_NUMROWS($result_sender) == 1) { // Load data and prepare mail list($sname, $fname, $email) = SQL_FETCHROW($result_sender); - SQL_FREERESULT($result_sender); // Load email template $msg = LOAD_EMAIL_TEMPLATE("done-member", $content, $DATA[1]); @@ -220,6 +216,9 @@ if (SQL_NUMROWS($result_main) > 0) { SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg); } // END - if + // Free result + SQL_FREERESULT($result_sender); + // 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", array(bigintval($DATA[0])), __FILE__, __LINE__); @@ -252,6 +251,9 @@ if (SQL_NUMROWS($result_main) > 0) { //* DEBUG: */ echo"*EXIT/L:".__LINE__."*
"; break; } + + // Free result + SQL_FREERESULT($result_stats); } 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]))) { -- 2.39.5