Fix for non-compiled to-address
authorRoland Häder <roland@mxchange.org>
Sat, 20 Sep 2008 17:09:33 +0000 (17:09 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 20 Sep 2008 17:09:33 +0000 (17:09 +0000)
inc/databases.php
inc/functions.php

index 25ab14a7a6b9f1d7252c94ce334abfd193951068..cd89754c17cedae259aeefbb2ee7e3681e5f8678 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "368");
+define('CURR_SVN_REVISION', "369");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index be503dcc6c07c68da41bb4350e490d889ec366d5..0e6812343dd13ad168e9a40de97110632a002f35 100644 (file)
@@ -348,11 +348,10 @@ function LOAD_TEMPLATE($template, $return=false, $content="") {
 }
 
 // Send mail out to an email address
-function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") {
+function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = 'N', $FROM = "") {
        // Compile subject line (for POINTS constant etc.)
-       $eval = "\$SUBJECT = \"".COMPILE_CODE(addslashes($SUBJECT))."\";";
+       $eval = "\$SUBJECT = html_entity_decode(\"".COMPILE_CODE(addslashes($SUBJECT))."\");";
        eval($eval);
-       $SUBJECT = html_entity_decode($SUBJECT);
 
        // Set from header
        if ((!eregi("@", $TO)) && ($TO > 0)) {
@@ -361,17 +360,29 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") {
                        ADD_MESSAGE_TO_BOX($TO, $SUBJECT, $MSG, $HTML);
                        return;
                } else {
+                       // Load email address
                        $result_email = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($TO)), __FILE__, __LINE__);
-                       list($TO) = SQL_FETCHROW($result_email);
+
+                       // Does the user exist?
+                       if (SQL_NUMROWS($result_email)) {
+                               // Load email address
+                               list($TO) = SQL_FETCHROW($result_email);
+                       } else {
+                               // Set webmaster
+                               $TO = WEBMASTER;
+                       }
+
+                       // Free result
                        SQL_FREERESULT($result_email);
                }
-       } elseif ($TO == 0) {
+       } elseif ("$TO" == "0") {
                // Is the webmaster!
                $TO = WEBMASTER;
        }
 
-       // Not in PHPMailer-Mode
+       // Check for PHPMailer or debug-mode
        if (!CHECK_PHPMAILER_USAGE()) {
+               // Not in PHPMailer-Mode
                if (empty($FROM)) {
                        // Load email header template
                        $FROM = LOAD_EMAIL_TEMPLATE("header");
@@ -389,6 +400,10 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") {
                }
        }
 
+       // Compile "TO"
+       $eval = "\$TO = \"".COMPILE_CODE(addslashes($TO))."\";";
+       eval($eval);
+
        // Fix HTML parameter (default is no!)
        if (empty($HTML)) $HTML = "N";
        if (isBooleanConstantAndTrue('DEBUG_MODE')) {
@@ -403,9 +418,6 @@ Message : ".$MSG."
                // Send mail as HTML away
                SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM);
        } elseif (!empty($TO)) {
-               // Compile email
-               $TO = COMPILE_CODE($TO);
-
                // Send Mail away
                SEND_RAW_EMAIL($TO, COMPILE_CODE($SUBJECT), COMPILE_CODE($MSG), $FROM);
        } elseif ($HTML == "N") {