]> git.mxchange.org Git - mailer.git/commitdiff
Minor rewrites to sending pools
authorRoland Häder <roland@mxchange.org>
Fri, 12 Dec 2008 20:05:05 +0000 (20:05 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 12 Dec 2008 20:05:05 +0000 (20:05 +0000)
img.php
inc/databases.php
inc/pool/pool-bonus.php
inc/pool/pool-user.php

diff --git a/img.php b/img.php
index 2e7d46fb9d1f1ca0e75859e5f315b5659db0c14e..09cafe5146de8bc60609fdd19009d34073a20158 100644 (file)
--- 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");
index dfd79546c6c6dadeaf79a037ba316ad9de73934a..3a51cc507ebeaecc52df0b6ea50a7cf565e9a970 100644 (file)
@@ -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);
index e44b30ef7132fca156191c3fd771535e12124610..c525382125dfd9d03d3badbc1faf7d81b3b5f340 100644 (file)
@@ -87,18 +87,16 @@ if ($cnt < $_CONFIG['max_send']) {
                                // Load personal data
                                //* DEBUG: */ echo "*L:".__LINE__."/".$uid."*<br />";
                                $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__."<br />";
 
                                        // 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__."<br />";
                                                        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."+<br />";
                                MEDIA_UPDATE_ENTRY(array("total_send", "bonus_send"), "add", $P);
-                       }
+                       } // END - if
 
                        // Close sending system
                        //* DEBUG: */ echo "-L:".__LINE__."/".SELECTION_COUNT($dummy)."-<br />";
-                       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__."*<br />";
 
                                // 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__."*<br />";
                                        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__);
index beb483ca083f0e6d7e792e903ae3b405ae88aef3..dab61b1c4665b93eda7ab7331d56bcdd6fc4763d 100644 (file)
@@ -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)."*<br />";
-                               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)."!<br />";
-                                       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)."!<br />";
-                                       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."?<br />";
@@ -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__."*<br />";
                                                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]))) {