X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=f85b4df13e107b501931b6c35c2555f4ac387ff1;hb=adec9e8fa79778d9bc050f092e494272e3f19925;hp=03376db72e20103835833c2b16695e5e1b336895;hpb=18e32f1a8971b18bace4f051094acf27800bd7d9;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 03376db72e..f85b4df13e 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -85,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))) { @@ -97,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(); @@ -111,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(); @@ -136,7 +126,7 @@ function sendHttpHeaders () { $now = gmdate('D, d M Y H:i:s') . ' GMT'; // Send HTTP header - sendHeader('HTTP/1.1 200 OK'); + sendHeader('HTTP/1.1 ' . getHttpStatus()); // General headers for no caching sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21 @@ -157,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 @@ -181,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 @@ -260,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; @@ -328,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--}
@@ -345,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)) { @@ -843,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 @@ -868,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 @@ -876,6 +872,34 @@ function translateUserStatus ($status) { return $ret; } +// "Translates" 'visible' and 'locked' to a CSS class +function translateMenuVisibleLocked ($content, $prefix = '') { + // Translate 'visible' and keep an eye on the prefix + switch ($content[$prefix . 'visible']) { + // Should be visible + case 'Y': $content[$prefix . 'visible_css'] = $prefix . 'menu_visible' ; break; + case 'N': $content[$prefix . 'visible_css'] = $prefix . 'menu_invisible'; break; + default: + // Please report this + debug_report_bug('Unsupported visible value detected. content=
'.print_r($content, true).'
'); + break; + } // END - switch + + // Translate 'locked' and keep an eye on the prefix + switch ($content[$prefix . 'locked']) { + // Should be locked + case 'Y': $content[$prefix . 'locked_css'] = $prefix . 'menu_locked' ; break; + case 'N': $content[$prefix . 'locked_css'] = $prefix . 'menu_unlocked'; break; + default: + // Please report this + debug_report_bug('Unsupported locked value detected. content=
'.print_r($content, true).'
'); + break; + } // END - switch + + // Return the resulting array + return $content; +} + // Generates an URL for the dereferer function generateDerefererUrl ($URL) { // Don't de-refer our own links! @@ -958,7 +982,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); @@ -997,7 +1021,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 @@ -1345,7 +1369,7 @@ function bigintval ($num, $castValue = true, $abortOnMismatch = true) { // Has the whole value changed? if (('' . $ret . '' != '' . $num . '') && ($abortOnMismatch === true)) { // Log the values - debug_report_bug('Problem with number found. ret=' . $ret . ', num='. $num); + debug_report_bug(__FUNCTION__, __LINE__, 'Problem with number found. ret=' . $ret . ', num='. $num); } // END - if // Return result @@ -1357,7 +1381,7 @@ function generateImageOrCode ($img_code, $headerSent = true) { // Is the code size oversized or shouldn't we display it? if ((strlen($img_code) > 6) || (empty($img_code)) || (getConfig('code_length') == '0')) { // Stop execution of function here because of over-sized code length - debug_report_bug('img_code ' . $img_code .' has invalid length. img_code()=' . strlen($img_code) . ' code_length=' . getConfig('code_length')); + debug_report_bug(__FUNCTION__, __LINE__, 'img_code ' . $img_code .' has invalid length. img_code()=' . strlen($img_code) . ' code_length=' . getConfig('code_length')); } elseif ($headerSent === false) { // Return an HTML code here return 'Image'; @@ -1708,7 +1732,10 @@ function addEmailNavigation ($PAGES, $offset, $show_form, $colspan, $return=fals } // Add seperator if we have not yet reached total pages - if ($page < $PAGES) $NAV .= ' | '; + if ($page < $PAGES) { + // Add it + $NAV .= '|'; + } // END - if } // END - for // Define constants only once @@ -2075,13 +2102,13 @@ function isUrlValid ($URL, $compile=true) { // Generate a list of administrative links to a given userid function generateMemberAdminActionLinks ($userid, $status = '') { // Make sure userid is a number - if ($userid != bigintval($userid)) debug_report_bug('userid is not a number!'); + if ($userid != bigintval($userid)) debug_report_bug(__FUNCTION__, __LINE__, 'userid is not a number!'); // Define all main targets $targetArray = array('del_user', 'edit_user', 'lock_user', 'add_points', 'sub_points'); // Begin of navigation links - $OUT = '[ '; + $OUT = '['; foreach ($targetArray as $tar) { $OUT .= 'getStatus() != 'done') { // Failed to initialize cache sustem - addFatalMessage(__FILE__, __LINE__, '(' . __LINE__ . '): ' . getMessage('CACHE_CANNOT_INITIALIZE')); + addFatalMessage(__FUNCTION__, __LINE__, '(' . __LINE__ . '): ' . getMessage('CACHE_CANNOT_INITIALIZE')); } // END - if } @@ -3552,16 +3577,16 @@ function determinePageTitle () { $pageTitle = '[-- ' . getConfig('MAIN_TITLE') . ' - ' . getModuleTitle(getModule()) . ' --]'; } elseif ((isInstalled()) && (!isAdminRegistered())) { // Installed but no admin registered - $pageTitle = getMessage('SETUP_OF_MXCHANGE'); + $pageTitle = getMessage('SETUP_OF_MAILER'); } elseif ((!isInstalled()) || (!isAdminRegistered())) { // Installation mode - $pageTitle = getMessage('INSTALLATION_OF_MXCHANGE'); + $pageTitle = getMessage('INSTALLATION_OF_MAILER'); } else { // Configuration not found! $pageTitle = getMessage('NO_CONFIG_FOUND_TITLE'); // Do not add the fatal message in installation mode - if ((!isInstalling()) && (!isConfigurationLoaded())) addFatalMessage(__FILE__, __LINE__, getMessage('NO_CONFIG_FOUND')); + if ((!isInstalling()) && (!isConfigurationLoaded())) addFatalMessage(__FUNCTION__, __LINE__, getMessage('NO_CONFIG_FOUND')); } // Return title @@ -3748,7 +3773,7 @@ function sendModeMails ($mod, $modes) { } // Generates a 'selection box' from given array -function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent='') { +function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent = '', $extraName = '') { // Start the output $OUT = '