X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=254a29a17ef88d789297edfd803751925360f30c;hp=9e3240ea54feb9c9ae6009f5765e6b80727da1ef;hb=146d2e01f0ac11489e40a398dd79d5e3946f42ac;hpb=258298994a088aefae53df1d07f3ff586fcccc27 diff --git a/inc/functions.php b/inc/functions.php index 9e3240ea54..254a29a17e 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -18,6 +18,7 @@ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * + * Copyright (c) 2009, 2010 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -44,7 +45,9 @@ if (!defined('__SECURITY')) { // Output HTML code directly or 'render' it. You addionally switch the new-line character off function outputHtml ($htmlCode, $newLine = true) { // Init output - if (!isset($GLOBALS['output'])) $GLOBALS['output'] = ''; + if (!isset($GLOBALS['output'])) { + $GLOBALS['output'] = ''; + } // END - if // Transfer username $username = getMessage('USERNAME_UNKNOWN'); @@ -82,19 +85,10 @@ function outputHtml ($htmlCode, $newLine = true) { default: // Huh, something goes wrong or maybe you have edited config.php ??? - app_die(__FUNCTION__, __LINE__, '{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}'); + debug_report_bug(__FUNCTION__, __LINE__, '{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}'); break; } // END - switch - } elseif ((getPhpCaching() == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) { - // Headers already sent? - if (headers_sent()) { - // Log this error - logDebugMessage(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.'); - - // Trigger an user error - debug_report_bug('Headers are already sent!'); - } // END - if - + } elseif ((getPhpCaching() == 'on') && ((!isset($GLOBALS['header'])) || (count($GLOBALS['header']) == 0))) { // Output cached HTML code $GLOBALS['output'] = ob_get_contents(); @@ -103,33 +97,26 @@ function outputHtml ($htmlCode, $newLine = true) { clearOutputBuffer(); } // END - if - // Extension 'rewrite' installed? - if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) { - $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); - } // END - if + // Send all HTTP headers + sendHttpHeaders(); // Compile and run finished rendered HTML code compileFinalOutput(); - // Send all HTTP headers - sendHttpHeaders(); - // Output code here, DO NOT REMOVE! ;-) outputRawCode($GLOBALS['output']); } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) { - // Rewrite links when rewrite extension is active - if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) { - $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); - } // END - if + // Send all HTTP headers + sendHttpHeaders(); // Compile and run finished rendered HTML code compileFinalOutput(); - // Send all HTTP headers - sendHttpHeaders(); - // Output code here, DO NOT REMOVE! ;-) outputRawCode($GLOBALS['output']); + } else { + // And flush all headers + flushHeaders(); } } @@ -139,10 +126,10 @@ 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('Expired: ' . $now); // RFC2616 - Section 14.21 + sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21 sendHeader('Last-Modified: ' . $now); sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 sendHeader('Pragma: no-cache'); // HTTP/1.0 @@ -154,31 +141,62 @@ 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'], '{DQUOTE}') !== 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 = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($GLOBALS['output']))) . '";'; + //* DEBUG: */ die('
'.htmlentities($eval).'
'); eval($eval); + //* DEBUG: */ die('
'.htmlentities($newContent).'
'); // Was that eval okay? if (empty($newContent)) { // Something went wrong! - debug_report_bug('Evaluation error:
' . linenumberCode($eval) . '
', false); + debug_report_bug(__FUNCTION__, __LINE__, 'Evaluation error:
' . linenumberCode($eval) . '
', false); } // END - if + + // Use it again $GLOBALS['output'] = $newContent; // Count round $cnt++; } // END - while + // Extension 'rewrite' installed? + if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) { + $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); + } // END - if + + // Compress it? + if (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('gzip', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) { + // Compress it for HTTP gzip + $GLOBALS['output'] = gzencode($GLOBALS['output'], 9, true); + + // Add header + sendHeader('Content-Encoding: gzip'); + } elseif (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('deflate', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) { + // Compress it for HTTP deflate + $GLOBALS['output'] = gzcompress($GLOBALS['output'], 9); + + // Add header + sendHeader('Content-Encoding: deflate'); + } + // Add final length sendHeader('Content-Length: ' . strlen($GLOBALS['output'])); + + // Flush all headers + flushHeaders(); } // Output the raw HTML code @@ -217,7 +235,6 @@ function addFatalMessage ($F, $L, $message, $extra = '') { $GLOBALS['fatal_messages'][] = $message; // Log fatal messages away - debug_report_bug($message); logDebugMessage($F, $L, 'Fatal error message: ' . $message); } @@ -239,7 +256,7 @@ function getTotalFatalErrors () { // Load a template file and return it's content (only it's name; do not use ' or ") function loadTemplate ($template, $return = false, $content = array()) { // @TODO Remove this sanity-check if all is fine - if (!is_bool($return)) debug_report_bug('return is not bool (' . gettype($return) . ')'); + if (!is_bool($return)) debug_report_bug(__FUNCTION__, __LINE__, 'return is not bool (' . gettype($return) . ')'); // @TODO Try to rewrite all $DATA to $content global $DATA; @@ -284,7 +301,7 @@ function loadTemplate ($template, $return = false, $content = array()) { // Do we have to compile the code? $ret = ''; - if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false)) { + if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false) || (strpos($GLOBALS['tpl_content'], '{%') !== false)) { // Normal HTML output? if (getOutputMode() == '0') { // Add surrounding HTML comments to help finding bugs faster @@ -307,9 +324,6 @@ function loadTemplate ($template, $return = false, $content = array()) { // Cache the eval() command here $GLOBALS['template_eval'][$template] = $eval; - - // Eval the code - eval($GLOBALS['template_eval'][$template]); } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { // Only admins shall see this warning or when installation mode is active $ret = '
{--TEMPLATE_404--}
@@ -324,10 +338,13 @@ function loadTemplate ($template, $return = false, $content = array()) { // No file! $GLOBALS['template_eval'][$template] = '404'; } - } else { + } + + // Code set? + if ((isset($GLOBALS['template_eval'][$template])) && ($GLOBALS['template_eval'][$template] != '404')) { // Eval the code eval($GLOBALS['template_eval'][$template]); - } + } // END - if // Do we have some content to output or return? if (!empty($ret)) { @@ -400,7 +417,7 @@ function detectExtraTemplatePath ($template) { } // Loads an email template and compiles it -function loadEmailTemplate ($template, $content = array(), $UID = '0') { +function loadEmailTemplate ($template, $content = array(), $userid = '0') { global $DATA; // Make sure all template names are lowercase! @@ -409,61 +426,44 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { // Default 'nickname' if extension is not installed $nick = '---'; - // Prepare IP number and User Agent - $REMOTE_ADDR = detectRemoteAddr(); - $HTTP_USER_AGENT = detectUserAgent(); - - // Default admin - $ADMIN = getConfig('MAIN_TITLE'); - - // Is the admin logged in? - if (isAdmin()) { - // Get admin id - $adminId = getCurrentAdminId(); - - // Load Admin data - $ADMIN = getAdminEmail($adminId); - } // END - if - // Neutral email address is default $email = getConfig('WEBMASTER'); - // Expiration in a nice output format - // NOTE: Use $content[expiration] in your templates instead of $EXPIRATION - if (getConfig('auto_purge') == '0') { - // Will never expire! - $EXPIRATION = getMessage('MAIL_WILL_NEVER_EXPIRE'); - } else { - // Create nice date string - $EXPIRATION = createFancyTime(getConfig('auto_purge')); - } - // Is content an array? if (is_array($content)) { - // Add expiration to array, $EXPIRATION is now deprecated! - $content['expiration'] = $EXPIRATION; + // Add expiration to array + if ((isConfigEntrySet('auto_purge')) && (getConfig('auto_purge') == '0')) { + // Will never expire! + $content['expiration'] = getMessage('MAIL_WILL_NEVER_EXPIRE'); + } elseif (isConfigEntrySet('auto_purge')) { + // Create nice date string + $content['expiration'] = createFancyTime(getConfig('auto_purge')); + } else { + // Missing entry + $content['expiration'] = getMessage('MAIL_NO_CONFIG_AUTO_PURGE'); + } } // END - if // Load user's data - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content).'
'); - if (($UID > 0) && (is_array($content))) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UID={$userid},template={$template},content[]=".gettype($content).'
'); + if (($userid > 0) && (is_array($content))) { // If nickname extension is installed, fetch nickname as well - if ((isExtensionActive('nickname')) && (isNicknameUsed($UID))) { - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NICKNAME!
"); + if ((isExtensionActive('nickname')) && (isNicknameUsed($userid))) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NICKNAME!
"); // Load by nickname - fetchUserData($UID, 'nickname'); + fetchUserData($userid, 'nickname'); } else { - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NO-NICK!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NO-NICK!
"); /// Load by userid - fetchUserData($UID); + fetchUserData($userid); } // Merge data if valid - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - PRE
"); if (isUserDataValid()) { $content = merge_array($content, getUserDataArray()); } // END - if - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - AFTER
"); } // END - if // Translate M to male or F to female if present @@ -472,8 +472,8 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { // Overwrite email from data if present if (isset($content['email'])) $email = $content['email']; - // Store email for some functions in global data array - // @TODO Do only use $contentn, not $DATA or raw variables + // Store email for some functions in global $DATA array + // @TODO Do only use $content, not $DATA or raw variables $DATA['email'] = $email; // Base directory @@ -498,7 +498,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = '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! @@ -519,7 +519,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { // Is there some content? if (empty($newContent)) { // Compiling failed - $newContent = "Compiler error for template {$template}!\nUncompiled content:\n" . $GLOBALS['tpl_content']; + $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['tpl_content']; // Add last error if the required function exists if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx."; @@ -535,13 +535,13 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { // Send mail out to an email address function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '') { - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
"); + //* 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')) { @@ -561,7 +561,7 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' // Is the webmaster! $toEmail = getConfig('WEBMASTER'); } - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "TO={$toEmail}
"); // Check for PHPMailer or debug-mode if (!checkPhpMailerUsage()) { @@ -584,30 +584,30 @@ 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'; if (isDebugModeEnabled()) { // In debug mode we want to display the mail instead of sending it away so we can debug this part outputHtml('
-Headers : ' . str_replace('<', '<', str_replace('>', '>', secureString(trim($mailHeader)))) . '
-To      : ' . $toEmail . '
-Subject : ' . $subject . '
-Message : ' . $message . '
+Headers : ' . htmlentities(utf8_decode(trim($mailHeader))) . '
+To      : ' . htmlentities(utf8_decode($toEmail)) . '
+Subject : ' . htmlentities(utf8_decode($subject)) . '
+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); } } @@ -636,7 +636,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')); @@ -667,9 +667,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); } } @@ -758,7 +770,7 @@ function translateYesNo ($yn) { // Translates the "pool type" into human-readable function translatePoolType ($type) { // Default?type is unknown - $translated = sprintf(getMessage('POOL_TYPE_UNKNOWN'), $type); + $translated = getMaskedMessage('POOL_TYPE_UNKNOWN', $type); // Generate constant $constName = sprintf("POOL_TYPE_%s", $type); @@ -775,6 +787,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); @@ -823,10 +838,10 @@ function translateGender ($gender) { case 'F': $ret = getMessage('GENDER_F'); break; case 'C': $ret = getMessage('GENDER_C'); break; default: - // Log unknown gender - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown gender %s detected.", $gender)); + // Please report bugs on unknown genders + debug_report_bug(__FUNCTION__, __LINE__, sprintf("Unknown gender %s detected.", $gender)); break; - } + } // END - switch // Return translated gender return $ret; @@ -848,8 +863,8 @@ function translateUserStatus ($status) { break; default: - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); - $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status); + // Please report all unknown status + debug_report_bug(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); break; } // END - switch @@ -925,7 +940,7 @@ function makeTime ($hours, $minutes, $seconds, $stamp) { } // Redirects to an URL and if neccessarry extends it with own base URL -function redirectToUrl ($URL) { +function redirectToUrl ($URL, $allowSpider = true) { // Compile out codes eval('$URL = "' . compileRawCode(encodeUrl($URL)) . '";'); @@ -938,28 +953,22 @@ function redirectToUrl ($URL) { $rel = ''; } // END - if - // Get output buffer - $GLOBALS['output'] = ob_get_contents(); - - // Clear it only if there is content - if (!empty($GLOBALS['output'])) { - clearOutputBuffer(); - } // END - if - // Three different ways to debug... - //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); + //* DEBUG: */ debug_report_bug(__FUNCTION__, __LINE__, sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL); //* DEBUG: */ die($URL); // Simple probe for bots/spiders from search engines - if ((strpos(detectUserAgent(), 'spider') !== false) || (strpos(detectUserAgent(), 'bot') !== false)) { + if ((isSpider()) && ($allowSpider === true)) { // Secure the URL against bad things such als HTML insertions and so on... $URL = secureString($URL); + // Set content-type here to fix a missing array element + setContentType('text/html'); + // Output new location link as anchor outputHtml('' . $URL . ''); } elseif (!headers_sent()) { - //* DEBUG: */ debug_report_bug("URL={$URL}"); // Clear own output buffer $GLOBALS['output'] = ''; @@ -984,7 +993,7 @@ function redirectToConfiguredUrl ($configEntry) { // Is this URL set? if (is_null($URL)) { // Then abort here - debug_report_bug(sprintf("Configuration entry %s is not set!", $configEntry)); + debug_report_bug(__FUNCTION__, __LINE__, sprintf("Configuration entry %s is not set!", $configEntry)); } // END - if // Load the URL @@ -1068,10 +1077,10 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true $test = substr($found, 0, strlen($match)); // Does this entry exist? - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):found={$found},match={$match},set={$set}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "found={$found},match={$match},set={$set}
"); if ($test == $match) { // Match found! - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):fuzzyFound!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "fuzzyFound!
"); $fuzzyFound = true; break; } // END - if @@ -1083,14 +1092,14 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true // Take all string elements if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) { // Replace it in the code - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):key={$key},match={$match}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "key={$key},match={$match}
"); $newMatch = str_replace('[', "['", str_replace(']', "']", $match)); $code = str_replace($match, '".' . $newMatch . '."', $code); $matchesFound[$key . '_' . $matches[4][$key]] = 1; $matchesFound[$match] = 1; } elseif (!isset($matchesFound[$match])) { // Not yet replaced! - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):match={$match}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "match={$match}
"); $code = str_replace($match, '".' . $match . '."', $code); $matchesFound[$match] = 1; } @@ -1158,30 +1167,30 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're if ($type == 'yn') { // This is a yes/no selection only! - if ($id > 0) $prefix .= "[" . $id."]"; - $OUT .= " '; } else { // Begin with regular selection box here if (!empty($prefix)) $prefix .= "_"; $type2 = $type; - if ($id > 0) $type2 .= "[" . $id."]"; - $OUT .= " '; } switch ($type) { case 'day': // Day for ($idx = 1; $idx < 32; $idx++) { - $OUT .= "'; } // END - for break; case 'month': // Month - foreach ($GLOBALS['month_descr'] as $month => $descr) { - $OUT .= "'; } // END - for } elseif ($default == -1) { // Current year minus 1 - for ($idx = $startYear; $idx <= ($year + 1); $idx++) - { - $OUT .= "\n"; - } + for ($idx = $startYear; $idx <= ($year + 1); $idx++) { + $OUT .= ''; + } // END - for } else { // Get current year and subtract the configured minimum age - $OUT .= "\n"; + $OUT .= ''; // 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 { @@ -1228,41 +1236,41 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're // Construct year selection list for ($idx = $minYear; $idx <= $year; $idx++) { - $OUT .= "'; } // END - for } break; case 'sec': case 'min': - for ($idx = '0'; $idx < 60; $idx+=5) { + for ($idx = 0; $idx < 60; $idx+=5) { if (strlen($idx) == 1) $idx = '0' . $idx; - $OUT .= "'; } // END - for break; case 'hour': - for ($idx = '0'; $idx < 24; $idx++) { + for ($idx = 0; $idx < 24; $idx++) { if (strlen($idx) == 1) $idx = '0' . $idx; - $OUT .= "'; } // END - for break; case 'yn': - $OUT .= "