X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=f1a41e67ec3832f3ca075d7962fd13ffc361478a;hb=4b2090a4cedf39aafa708025c493685fab1036b5;hp=00cfe3b84c78f40ea3a1714f1f5209f68bbf7dae;hpb=95e7ebcc079858e287ea182a03cd372df0d0934f;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 00cfe3b84c..f1a41e67ec 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -131,13 +131,22 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' // Check for PHPMailer or debug-mode if ((!checkPhpMailerUsage()) || (isDebugModeEnabled())) { + // Prefix is '' for text mails + $prefix = ''; + + // Is HTML? + if ($isHtml == 'Y') { + // Set prefix + $prefix = 'html_'; + } // END - if + // Not in PHPMailer-Mode if (empty($mailHeader)) { // Load email header template - $mailHeader = loadEmailTemplate('header'); + $mailHeader = loadEmailTemplate($prefix . 'header'); } else { // Append header - $mailHeader .= loadEmailTemplate('header'); + $mailHeader .= loadEmailTemplate($prefix . 'header'); } } // END - if @@ -156,9 +165,6 @@ Message : ' . htmlentities(utf8_decode($message)) . ' // This is always fine return true; - } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) { - // Send mail as HTML away - return sendHtmlEmail($toEmail, $subject, $message, $mailHeader); } elseif (!empty($toEmail)) { // Send Mail away return sendRawEmail($toEmail, $subject, $message, $mailHeader); @@ -181,12 +187,12 @@ function checkPhpMailerUsage() { // Send out a raw email with PHPMailer class or legacy mail() command function sendRawEmail ($toEmail, $subject, $message, $headers) { // Just compile all to put out all configs, etc. - $eval = '$toEmail = decodeEntities("' . doFinalCompilation(compileRawCode(escapeQuotes($toEmail)), false) . '"); '; - $eval .= '$subject = decodeEntities("' . doFinalCompilation(compileRawCode(escapeQuotes($subject)), false) . '"); '; - $eval .= '$headers = decodeEntities("' . doFinalCompilation(compileRawCode(escapeQuotes($headers)), false) . '"); '; + $eval = '$toEmail = decodeEntities("' . escapeQuotes(doFinalCompilation(compileRawCode($toEmail), false)) . '"); '; + $eval .= '$subject = decodeEntities("' . escapeQuotes(doFinalCompilation(compileRawCode($subject), false)) . '"); '; + $eval .= '$headers = decodeEntities("' . escapeQuotes(doFinalCompilation(compileRawCode($headers), false)) . '"); '; // Do not decode entities in the message because we also send HTML mails through this function - $eval .= '$message = "' . doFinalCompilation(compileRawCode(escapeQuotes($message)), false) . '";'; + $eval .= '$message = "' . escapeQuotes(doFinalCompilation(compileRawCode($message), false)) . '";'; // Run the final eval() command eval($eval); @@ -579,9 +585,6 @@ function redirectToUrl ($URL, $allowSpider = true) { // Clear own output buffer $GLOBALS['output'] = ''; - // Set header - setHttpStatus('302 Found'); - // Load URL when headers are not sent sendRawRedirect(doFinalCompilation(str_replace('&', '&', $URL), false)); } else { @@ -828,20 +831,23 @@ function sendGetRequest ($script, $data = array()) { // Add data $body = http_build_query($data, '', '&'); - // Do we have a question-mark in the script? - if (strpos($script, '?') === false) { - // No, so first char must be question mark - $body = '?' . $body; - } else { - // Ok, add & - $body = '&' . $body; - } + // There should be data, else we don't need to extend $script with $body + if (empty($body)) { + // Do we have a question-mark in the script? + if (strpos($script, '?') === false) { + // No, so first char must be question mark + $body = '?' . $body; + } else { + // Ok, add & + $body = '&' . $body; + } - // Add script data - $script .= $body; + // Add script data + $script .= $body; - // Remove trailed & to make it more conform - if (substr($script, -1, 1) == '&') $script = substr($script, 0, -1); + // Remove trailed & to make it more conform + if (substr($script, -1, 1) == '&') $script = substr($script, 0, -1); + } // END - if // Generate GET request header $request = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL'); @@ -1469,12 +1475,13 @@ function getMessageFromErrorCode ($code) { case getCode('NO_MAIL_TYPE') : $message = '{--MEMBER_NO_MAIL_TYPE_SELECTED--}'; break; case getCode('UNKNOWN_ERROR') : $message = '{--LOGIN_UNKNOWN_ERROR--}'; break; case getCode('UNKNOWN_STATUS') : $message = '{--LOGIN_UNKNOWN_STATUS--}'; break; + case getCode('PROFILE_UPDATED') : $message = '{--MEMBER_PROFILE_UPDATED--}'; break; case getCode('ERROR_MAILID'): if (isExtensionActive('mailid', true)) { $message = '{--ERROR_CONFIRMING_MAIL--}'; } else { - $message = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', 'mailid'); + $message = generateExtensionInactiveNotInstalledMessage('mailid'); } break; @@ -1486,34 +1493,31 @@ function getMessageFromErrorCode ($code) { } break; - case getCode('URL_TLOCK'): + case getCode('URL_TIME_LOCK'): // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? $result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1", array(bigintval(getRequestParameter('id'))), __FUNCTION__, __LINE__); // Load timestamp from last order - list($timestamp) = SQL_FETCHROW($result); + $content = SQL_FETCHARRAY($result); // Free memory SQL_FREERESULT($result); // Translate it for templates - $timestamp = generateDateTime($timestamp, 1); + $content['timestamp'] = generateDateTime($content['timestamp'], 1); // Calculate hours... - $STD = round(getConfig('url_tlock') / 60 / 60); + $content['hours'] = round(getConfig('url_tlock') / 60 / 60); // Minutes... - $MIN = round((getConfig('url_tlock') - $STD * 60 * 60) / 60); + $content['minutes'] = round((getConfig('url_tlock') - $content['hours'] * 60 * 60) / 60); // And seconds - $SEC = getConfig('url_tlock') - $STD * 60 * 60 - $MIN * 60; + $content['seconds'] = round(getConfig('url_tlock') - $content['hours'] * 60 * 60 - $content['minutes'] * 60); // Finally contruct the message - // @TODO Rewrite this old lost code to a template - $message = '{--MEMBER_URL_TIME_LOCK--}
{--CONFIG_URL_TLOCK--} ' . $STD . ' - {--_HOURS--}, ' . $MIN . ' {--_MINUTES--} {--_AND--} ' . $SEC . ' {--_SECONDS--}
- {--MEMBER_LAST_TLOCK--}: ' . $timestamp; + $message = loadTemplate('tlock_message', true, $content); break; default: @@ -2007,7 +2011,9 @@ function initMemberId () { // Setter for member id function setMemberId ($memberid) { // We should not set member id to zero - if ($memberid == '0') debug_report_bug(__FUNCTION__, __LINE__, 'Userid should not be set zero.'); + if ($memberid == '0') { + debug_report_bug(__FUNCTION__, __LINE__, 'Userid should not be set zero.'); + } // END - if // Set it secured $GLOBALS['member_id'] = bigintval($memberid);