]> git.mxchange.org Git - mailer.git/commitdiff
Fixes for sending pool
authorRoland Häder <roland@mxchange.org>
Sun, 21 Sep 2008 15:40:18 +0000 (15:40 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 21 Sep 2008 15:40:18 +0000 (15:40 +0000)
inc/functions.php
inc/load_extensions.php
inc/modules/admin.php
inc/mysql-connect.php
inc/pool-update.php

index b888b2779f474ac59860e01cd8ba69ad48b8ee9d..892f983c6b68cf48f9f2efaf2f0ea13bd039c959 100644 (file)
@@ -2303,9 +2303,9 @@ function merge_array ($array1, $array2) {
        die("</pre>");
 }
 // Debug message logger
-function DEBUG_LOG ($message) {
+function DEBUG_LOG ($message, $force=false) {
        // Is debug mode enabled?
-       if (isBooleanConstantAndTrue('DEBUG_MODE')) {
+       if ((isBooleanConstantAndTrue('DEBUG_MODE')) || ($force)) {
                // Log this message away
                $fp = fopen(PATH."inc/cache/debug.log", 'a') or mxchange_die("Cannot write logfile debug.log!");
                fwrite($fp, date("d.m.Y|H:i:s", time())."|{$message}\n");
index 3fea0700f1513b4bd27cc4501934b4b0e4308f2a..bc9a4a5bb4c4cdfe24efc839c990a9a14c289d2c 100644 (file)
@@ -275,10 +275,10 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && (($cacheMode == "init") || ($cacheMode ==
                // Load more cache files (like admins)
                require_once(PATH."inc/load_cache.php");
        } // END - if
-}
 
-// Free memory
-SQL_FREERESULT($res_ext_crt);
+       // Free memory
+       SQL_FREERESULT($res_ext_crt);
+}
 
 // Load include files
 if (!empty($INC_POOL[0])) {
index 7578e6c7d582c34c36c21f59b84888d217df7b57..36a322a0c9e6a579d0797fb8b37197563f4ff308 100644 (file)
@@ -397,8 +397,8 @@ if (!defined('admin_registered')) {
 
 if (isBooleanConstantAndTrue('admin_registered')) {
        // Check config.php and inc directory for right access rights
-       if (is_INCWritable("config"))     ADD_FATAL(FATAL_CONFIG_WRITABLE);
-       if (is_INCWritable("dummy"))      ADD_FATAL(FATAL_INC_WRITABLE);
+       // DEPRECATED: if (is_INCWritable("config"))     ADD_FATAL(FATAL_CONFIG_WRITABLE);
+       // DEPRECATED: if (is_INCWritable("dummy"))      ADD_FATAL(FATAL_INC_WRITABLE);
 }
 //
 ?>
index 467f21827a2b8a918da9294fed70edaf8eb94ba9..fd24ac49037b6b064a069172a52d0f7a748cf886 100644 (file)
@@ -57,6 +57,23 @@ require_once(PATH."inc/mysql-manager.php"); // Functions which interact with the
 require_once(PATH."inc/extensions.php");
 require_once(PATH."inc/language.php");
 
+// Init error handler
+function __errorHandler ($errno, $errstr, $errfile, $errline) {
+       $msg = sprintf("errno=%s,errstr=%s,errfile=%s,errline=%s",
+               $errno,
+               $errstr,
+               basename($errfile),
+               $errline
+       );
+       DEBUG_LOG(__FUNCTION__.":".$msg, true);
+       print "Please report this error:<pre>";
+       debug_print_backtrace();
+       die("</pre>");
+}
+
+// Set error handler
+//set_error_handler('__errorHandler');
+
 // Check if the user setups his MySQL stuff...
 if ((empty($MySQL['login'])) && (!defined('mxchange_installing')) && (!isset($_GET['installing'])) && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // No login entered and outside installation mode
@@ -78,8 +95,8 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
        // Check for write-permission for config.php and inc directory
        if (empty($GLOBALS['module'])) $GLOBALS['module'] = "index";
        if (($GLOBALS['module'] != "admin") && (isBooleanConstantAndTrue('admin_registered')) && (!isset($_SERVER['WINDIR']))) {
-               if (is_INCWritable("config"))     ADD_FATAL(FATAL_CONFIG_WRITABLE);
-               if (is_INCWritable("dummy"))      ADD_FATAL(FATAL_INC_WRITABLE);
+               // DEPRECATED: if (is_INCWritable("config"))     ADD_FATAL(FATAL_CONFIG_WRITABLE);
+               // DEPRECATED: if (is_INCWritable("dummy"))      ADD_FATAL(FATAL_INC_WRITABLE);
        }
        $EXT_CSS_FILES = array();
 
index 20b406250295213b9e606b733a80e394f1e6508d..509e04b75461a3cbf8ac9de61426bbc8cf865d36 100644 (file)
@@ -62,14 +62,14 @@ if (SQL_NUMROWS($result_main) > 0)
        while ($DATA = SQL_FETCHROW($result_main))
        {
                // Check fetched data for HTML
-               $HTML = $DATA[10]; if ($HTML == $DATA['id']) $HTML = "N";
+               $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['id']), __FILE__, __LINE__);
+                array($DATA[0]), __FILE__, __LINE__);
                if (SQL_AFFECTEDROWS() == 1)
                {
                        // "Explode" all receivers into an array
@@ -110,7 +110,7 @@ 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['id'], $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 />";
@@ -118,11 +118,11 @@ if (SQL_NUMROWS($result_main) > 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['id']), 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['id']), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__);
+                                                array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__);
                                        }
 
                                        //* DEBUG: */ echo "!L:".__LINE__."/".SQL_NUMROWS($result_stats)."!<br />";
@@ -133,8 +133,8 @@ if (SQL_NUMROWS($result_main) > 0)
                                                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['id']."/".$stats_id."?<br />";
-                                               switch (REMOVE_RECEIVER($dummy, $key, bigintval($uid), bigintval($DATA['id']), bigintval($stats_id)))
+                                               //* DEBUG: */ echo "?L:".__LINE__."/".$dummy."/".$key."/".$uid."(".$DATA[1].")/".$DATA[0]."/".$stats_id."?<br />";
+                                               switch (REMOVE_RECEIVER($dummy, $key, bigintval($uid), bigintval($DATA[0]), bigintval($stats_id)))
                                                {
                                                case "done":
                                                        // Prepare the mail
@@ -151,7 +151,7 @@ if (SQL_NUMROWS($result_main) > 0)
                                                        // Prepare content
                                                        $content = array(
                                                                'id'         => $DATA[11],
-                                                               'url'        => $DATA[3],
+                                                               'url'        => $DATA[7],
                                                                'sender_uid' => $DATA[1],
                                                                'category'   => GET_CATEGORY($DATA[9]),
                                                                'time'       => CREATE_FANCY_TIME(GET_PAY_POINTS($DATA[5], "time")),
@@ -196,12 +196,15 @@ if (SQL_NUMROWS($result_main) > 0)
                                        }
 
                                        // Do we have reached the maximum to send mails? || ($_CONFIG['max_send'] >= $cnt)
-                                       //* DEBUG: */ echo "*L:".__LINE__."/".$cnt.">=".$DATA[8]."/".$_CONFIG['max_send'].">=".$cnt."/".$LAST_SENT_ID."!=".$DATA['id']."*<br />";
-                                       if ((($cnt >= $DATA[8])) && ($LAST_SENT_ID != $DATA['id'])) {
+                                       //* DEBUG: */ echo "*L:".__LINE__."/".$cnt.">=".$DATA[8]."/".$_CONFIG['max_send'].">=".$cnt."/".$LAST_SENT_ID."!=".$DATA[0]."*<br />";
+                                       if ((($cnt >= $DATA[8])) && ($LAST_SENT_ID != $DATA[0])) {
                                                // Prepare content
                                                $content = array(
                                                        'sender_uid' => $DATA[1],
-                                                       'category'   => GET_CATEGORY($DATA[9])
+                                                       'category'   => GET_CATEGORY($DATA[9]),
+                                                       'text'       => $DATA[3],
+                                                       'url'        => $DATA[7],
+                                                       'expiration' => CREATE_FANCY_TIME(GET_PAY_POINTS($DATA[5], "time"))
                                                );
 
                                                // Yes we do, so we notify admin and sender about fully sent mail!
@@ -224,13 +227,13 @@ if (SQL_NUMROWS($result_main) > 0)
 
                                                // 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['id'])), __FILE__, __LINE__);
+                                                array(bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                // Update send-completed-time
                                                $result_user = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_stats SET timestamp_send=UNIX_TIMESTAMP() WHERE pool_id=%s LIMIT 1",
-                                                array(bigintval($DATA['id'])), __FILE__, __LINE__);
+                                                array(bigintval($DATA[0])), __FILE__, __LINE__);
 
-                                               $LAST_SENT_ID = $DATA['id']; $cnt = 0;
+                                               $LAST_SENT_ID = $DATA[0]; $cnt = 0;
                                                $cnt2 += $cnt;
 
                                                // Update mediadata if version is 0.0.4 or higher
@@ -251,7 +254,7 @@ if (SQL_NUMROWS($result_main) > 0)
                                                $ADD = "";
                                                if ($cnt <= $DATA[8]) $ADD = ", target_send=target_send-".$cnt;
                                                $result_queue = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='NEW', receivers='%s'".$ADD." WHERE id=%s LIMIT 1",
-                                                array(implode(";", $dummy), bigintval($DATA['id'])), __FILE__, __LINE__);
+                                                array(implode(";", $dummy), bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
                                                break;
@@ -264,7 +267,7 @@ if (SQL_NUMROWS($result_main) > 0)
                                        {
                                                // List was empty
                                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND' WHERE id=%s LIMIT 1",
-                                                array(bigintval($DATA['id'])), __FILE__, __LINE__);
+                                                array(bigintval($DATA[0])), __FILE__, __LINE__);
                                        }
                                         else
                                        {
@@ -293,7 +296,7 @@ if (SQL_NUMROWS($result_main) > 0)
 
                                        // Update receivers
                                        $result_queue = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET receivers='%s' WHERE id=%s LIMIT 1",
-                                        array(implode(";", $dummy), bigintval($DATA['id'])), __FILE__, __LINE__);
+                                        array(implode(";", $dummy), bigintval($DATA[0])), __FILE__, __LINE__);
                                }
                        }
                }