X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=254a29a17ef88d789297edfd803751925360f30c;hp=e0bee7f20cc894cd130df6c8081deb157cd1a9a1;hb=146d2e01f0ac11489e40a398dd79d5e3946f42ac;hpb=8cd3d68a23aa285f2fe149698a46cf8b4e3ac0ca diff --git a/inc/functions.php b/inc/functions.php index e0bee7f20c..254a29a17e 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -45,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'); @@ -83,7 +85,7 @@ 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['header'])) || (count($GLOBALS['header']) == 0))) { @@ -95,11 +97,6 @@ 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(); @@ -109,11 +106,6 @@ function outputHtml ($htmlCode, $newLine = true) { // 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(); @@ -155,21 +147,22 @@ function compileFinalOutput () { addPageHeaderFooter(); // Compile all out - while (((strpos($GLOBALS['output'], '{--') !== false) || (strpos($GLOBALS['output'], '{!') !== false) || (strpos($GLOBALS['output'], '{?') !== false) || (strpos($GLOBALS['output'], '{%') !== false)) && ($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 //* DEBUG: */ print '
'.htmlentities($GLOBALS['output']).'
'; - $eval = '$newContent = "' . compileCode(escapeQuotes($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 @@ -179,6 +172,11 @@ function compileFinalOutput () { $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 @@ -258,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; @@ -326,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--}
@@ -343,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)) { @@ -841,7 +839,7 @@ function translateGender ($gender) { case 'C': $ret = getMessage('GENDER_C'); break; default: // Please report bugs on unknown genders - debug_report_bug(sprintf("Unknown gender %s detected.", $gender)); + debug_report_bug(__FUNCTION__, __LINE__, sprintf("Unknown gender %s detected.", $gender)); break; } // END - switch @@ -866,7 +864,7 @@ function translateUserStatus ($status) { default: // Please report all unknown status - debug_report_bug(sprintf("Unknown status %s detected.", $status)); + debug_report_bug(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); break; } // END - switch @@ -956,7 +954,7 @@ function redirectToUrl ($URL, $allowSpider = true) { } // 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); @@ -995,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 @@ -1169,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 (isExtensionInstalledAndNewer('order', '0.2.1')) { // Use configured minimum age @@ -1239,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 .= "