From: Roland Häder Date: Sat, 20 Sep 2008 17:09:33 +0000 (+0000) Subject: Fix for non-compiled to-address X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=9958d6a82e0f13377b855f386bd2b1f13c75f22b Fix for non-compiled to-address --- diff --git a/inc/databases.php b/inc/databases.php index 25ab14a7a6..cd89754c17 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -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); diff --git a/inc/functions.php b/inc/functions.php index be503dcc6c..0e6812343d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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") {