X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=66b0c63e190892a6e095c919f5eabb0edf6bed47;hp=da1d2508a2afe7707f4165b829c49018f4159201;hb=8d70fd41c880ca61bafb47a69a6411c741c71dff;hpb=9d7b66c75a69d7e56944708940580a8b14ef401d diff --git a/inc/functions.php b/inc/functions.php index da1d2508a2..66b0c63e19 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -134,7 +134,7 @@ function sendHttpHeaders () { $now = gmdate('D, d M Y H:i:s') . ' GMT'; // Send HTTP header - sendHeader('HTTP/1.1 200'); + sendHeader('HTTP/1.1 200 OK'); // General headers for no caching sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21 @@ -149,19 +149,21 @@ function sendHttpHeaders () { // Compiles the final output function compileFinalOutput () { // Init counter - $cnt = '0'; + $cnt = 0; // Add page header and footer addPageHeaderFooter(); // Compile all out - while (((strpos($GLOBALS['output'], '{--') > 0) || (strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) && ($cnt < 3)) { + while (((strpos($GLOBALS['output'], '{--') !== false) || (strpos($GLOBALS['output'], '{!') !== false) || (strpos($GLOBALS['output'], '{?') !== false) || (strpos($GLOBALS['output'], '{%') !== false)) && ($cnt < 3)) { // Init common variables $content = array(); $newContent = ''; // Compile it - $eval = "\$newContent = \"".compileCode(escapeQuotes($GLOBALS['output']))."\";"; + //* DEBUG: */ print '
'.htmlentities($GLOBALS['output']).'
'; + $eval = '$newContent = "' . compileCode(escapeQuotes($GLOBALS['output'])) . '";'; + //* DEBUG: */ die('
'.htmlentities($eval).'
'); eval($eval); // Was that eval okay? @@ -169,6 +171,8 @@ function compileFinalOutput () { // Something went wrong! debug_report_bug('Evaluation error:
' . linenumberCode($eval) . '
', false); } // END - if + + // Use it again $GLOBALS['output'] = $newContent; // Count round @@ -496,7 +500,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') { $GLOBALS['tpl_content'] = readFromFile($FQFN); // Run code - $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileRawCode(escapeQuotes($GLOBALS['tpl_content']))."\");"; + $GLOBALS['tpl_content'] = '$newContent = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['tpl_content'])) . '");'; eval($GLOBALS['tpl_content']); } elseif (!empty($template)) { // Template file not found! @@ -536,10 +540,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "TO={$toEmail},SUBJECT={$subject}
"); // Compile subject line (for POINTS constant etc.) - eval("\$subject = decodeEntities(\"".compileRawCode(escapeQuotes($subject))."\");"); + eval('$subject = decodeEntities("' . compileRawCode(escapeQuotes($subject)) . '");'); // Set from header - if ((!eregi('@', $toEmail)) && ($toEmail > 0)) { + if ((!isInStringIgnoreCase('@', $toEmail)) && ($toEmail > 0)) { // Value detected, is the message extension installed? // @TODO Extension 'msg' does not exist if (isExtensionActive('msg')) { @@ -582,10 +586,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' } // Compile "TO" - eval("\$toEmail = \"".compileRawCode(escapeQuotes($toEmail))."\";"); + eval('$toEmail = "' . compileRawCode(escapeQuotes($toEmail)) . '";'); // Compile "MSG" - eval("\$message = \"".str_replace('$', '$', compileRawCode(escapeQuotes($message)))."\";"); + eval('$message = "' . str_replace('$', '$', compileRawCode(escapeQuotes($message))) . '";'); // Fix HTML parameter (default is no!) if (empty($isHtml)) $isHtml = 'N'; @@ -599,13 +603,13 @@ Message : ' . htmlentities(utf8_decode($message)) . ' '); } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) { // Send mail as HTML away - sendHtmlEmail($toEmail, $subject, $message, $mailHeader); + return sendHtmlEmail($toEmail, $subject, $message, $mailHeader); } elseif (!empty($toEmail)) { // Send Mail away - sendRawEmail($toEmail, $subject, $message, $mailHeader); + return sendRawEmail($toEmail, $subject, $message, $mailHeader); } elseif ($isHtml != 'Y') { // Problem found! - sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader); + return sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader); } } @@ -634,7 +638,7 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { $mail = new PHPMailer(); // Set charset to UTF-8 - $mail->CharSet('UTF-8'); + $mail->CharSet = 'UTF-8'; // Path for PHPMailer $mail->PluginDir = sprintf("%sinc/phpmailer/", getConfig('PATH')); @@ -665,9 +669,21 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { $mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER')); $mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER')); $mail->Send(); + + // Has an error occured? + if (!empty($mail->ErrorInfo)) { + // Log message + logDebugMessage(__FUNCTION__, __LINE__, 'Error while sending mail: ' . $mail->ErrorInfo); + + // Raise an error + return false; + } else { + // All fine! + return true; + } } else { // Use legacy mail() command - mail($toEmail, $subject, decodeEntities($message), $from); + return mail($toEmail, $subject, decodeEntities($message), $from); } } @@ -773,6 +789,9 @@ function translatePoolType ($type) { // Translates the american decimal dot into a german comma function translateComma ($dotted, $cut = true, $max = '0') { + // First, cast all to double, due to PHP changes + $dotted = (double) $dotted; + // Default is 3 you can change this in admin area "Misc -> Misc Options" if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', 3); @@ -1182,7 +1201,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're $year = date('Y', time()); // Use configured min age or fixed? - if ((isExtensionActive('other')) && (getExtensionVersion('other') >= '0.2.1')) { + if (isExtensionInstalledAndNewer('order', '0.2.1')) { // Configured $startYear = $year - getConfig('min_age'); } else { @@ -1210,7 +1229,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're // Get current year and subtract the configured minimum age $OUT .= "\n"; // Calculate earliest year depending on extension version - if ((isExtensionActive('other')) && (getExtensionVersion('other') >= '0.2.1')) { + if (isExtensionInstalledAndNewer('order', '0.2.1')) { // Use configured minimum age $year = date('Y', time()) - getConfig('min_age'); } else { @@ -1462,38 +1481,38 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = $OUT .= "\n"; $OUT .= "\n"; - if (ereg('Y', $display) || (empty($display))) { + if (isInString('Y', $display) || (empty($display))) { $OUT .= " \n"; } - if (ereg('M', $display) || (empty($display))) { + if (isInString('M', $display) || (empty($display))) { $OUT .= " \n"; } - if (ereg('W', $display) || (empty($display))) { + if (isInString('W', $display) || (empty($display))) { $OUT .= " \n"; } - if (ereg('D', $display) || (empty($display))) { + if (isInString('D', $display) || (empty($display))) { $OUT .= " \n"; } - if (ereg('h', $display) || (empty($display))) { + if (isInString('h', $display) || (empty($display))) { $OUT .= " \n"; } - if (ereg('m', $display) || (empty($display))) { + if (isInString('m', $display) || (empty($display))) { $OUT .= " \n"; } - if (ereg('s', $display) || (empty($display))) { + if (isInString('s', $display) || (empty($display))) { $OUT .= " \n"; } $OUT .= "\n"; $OUT .= "\n"; - if (ereg('Y', $display) || (empty($display))) { + if (isInString('Y', $display) || (empty($display))) { // Generate year selection $OUT .= "
{--_YEARS--}
{--_MONTHS--}
{--_WEEKS--}
{--_DAYS--}
{--_HOURS--}
{--_MINUTES--}
{--_SECONDS--}
'; } - if (ereg('M', $display) || (empty($display))) { + if (isInString('M', $display) || (empty($display))) { // Generate month selection $OUT .= " '; } - if (ereg('W', $display) || (empty($display))) { + if (isInString('W', $display) || (empty($display))) { // Generate week selection $OUT .= " '; } - if (ereg('D', $display) || (empty($display))) { + if (isInString('D', $display) || (empty($display))) { // Generate day selection $OUT .= " '; } - if (ereg('h', $display) || (empty($display))) { + if (isInString('h', $display) || (empty($display))) { // Generate hour selection $OUT .= " '; } - if (ereg('m', $display) || (empty($display))) { + if (isInString('m', $display) || (empty($display))) { // Generate minute selection $OUT .= " '; } - if (ereg('s', $display) || (empty($display))) { + if (isInString('s', $display) || (empty($display))) { // Generate second selection $OUT .= "