X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=76b94ebf864263378e32bb36d72456e5e77d369d;hp=1c3e2b60d1f61690bbc7f7a8ab7dda538c804c8a;hb=8fa01ac88b1208b28b47f57d997db6223f60cb9c;hpb=f8cc979307416fbd9b27908ec461004a3feb9387 diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 1c3e2b60d1..76b94ebf86 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -481,33 +481,6 @@ function copyFileVerified ($source, $dest, $chmod = '') { return $status; } -// Wrapper function for header() -// Send a header but checks before if we can do so -function sendHeader ($header) { - // Send the header - //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header); - $GLOBALS['header'][] = trim($header); -} - -// Flushes all headers -function flushHeaders () { - // Is the header already sent? - if (headers_sent()) { - // Then abort here - debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!'); - } // END - if - - // Flush all headers if found - if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) { - foreach ($GLOBALS['header'] as $header) { - header($header); - } // END - foreach - } // END - if - - // Mark them as flushed - $GLOBALS['header'] = array(); -} - // Wrapper function for chmod() // @TODO Do some more sanity check here function changeMode ($FQFN, $mode) { @@ -567,14 +540,14 @@ function isNicknameUsed ($userid) { } // Getter for 'what' value -function getWhat () { +function getWhat ($strict = true) { // Default is null $what = NULL; // Is the value set? - if (isWhatSet(true)) { + if (isWhatSet($strict)) { // Then use it - $what = $GLOBALS['what']; + $what = $GLOBALS['__what']; } // END - if // Return it @@ -583,7 +556,7 @@ function getWhat () { // Setter for 'what' value function setWhat ($newWhat) { - $GLOBALS['what'] = SQL_ESCAPE($newWhat); + $GLOBALS['__what'] = $newWhat; } // Setter for 'what' from configuration @@ -598,11 +571,12 @@ function setWhatFromConfig ($configEntry) { // Checks wether what is set and optionally aborts on miss function isWhatSet ($strict = false) { // Check for it - $isset = isset($GLOBALS['what']); + $isset = ((isset($GLOBALS['__what']) && (!empty($GLOBALS['__what']))) || (is_null($GLOBALS['__what']))); // Should we abort here? if (($strict === true) && ($isset === false)) { // Output backtrace + die(debug_get_printable_backtrace()); debug_report_bug(__FUNCTION__, __LINE__, 'what is empty.'); } // END - if @@ -618,7 +592,7 @@ function getAction ($strict = true) { // Is the value set? if (isActionSet(($strict) && (isHtmlOutputMode()))) { // Then use it - $action = $GLOBALS['action']; + $action = $GLOBALS['__action']; } // END - if // Return it @@ -627,13 +601,13 @@ function getAction ($strict = true) { // Setter for 'action' value function setAction ($newAction) { - $GLOBALS['action'] = SQL_ESCAPE($newAction); + $GLOBALS['__action'] = $newAction; } // Checks wether action is set and optionally aborts on miss function isActionSet ($strict = false) { // Check for it - $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action']))); + $isset = (((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action']))) || (is_null($GLOBALS['__action']))); // Should we abort here? if (($strict === true) && ($isset === false)) { @@ -653,7 +627,7 @@ function getModule ($strict = true) { // Is the value set? if (isModuleSet($strict)) { // Then use it - $module = $GLOBALS['module']; + $module = $GLOBALS['__module']; } // END - if // Return it @@ -663,13 +637,13 @@ function getModule ($strict = true) { // Setter for 'module' value function setModule ($newModule) { // Secure it and make all modules lower-case - $GLOBALS['module'] = SQL_ESCAPE(strtolower($newModule)); + $GLOBALS['__module'] = strtolower($newModule); } // Checks wether module is set and optionally aborts on miss function isModuleSet ($strict = false) { // Check for it - $isset = (!empty($GLOBALS['module'])); + $isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module']))); // Should we abort here? if (($strict === true) && ($isset === false)) { @@ -678,7 +652,7 @@ function isModuleSet ($strict = false) { } // END - if // Return it - return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ; + return (($isset === true) && ($GLOBALS['__module'] != 'unknown')) ; } // Getter for 'output_mode' value @@ -704,7 +678,9 @@ function getScriptOutputMode () { // Setter for 'output_mode' value function setOutputMode ($newOutputMode) { - $GLOBALS['output_mode'] = (int) $newOutputMode; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode); + $GLOBALS['output_mode'] = (int) $newOutputMode; + $GLOBALS['getScriptOutputMode'] = (int) $newOutputMode; } // Checks wether output_mode is set and optionally aborts on miss @@ -1133,6 +1109,15 @@ function getHttpStatus () { * @access private */ function sendRawRedirect ($url) { + // Clear output buffer + clearOutputBuffer(); + + // Clear own output buffer + $GLOBALS['output'] = ''; + + // To make redirects working (no content type), output mode must be raw + setOutputMode(-1); + // Send helping header setHttpStatus('302 Found'); @@ -1148,10 +1133,10 @@ function sendRawRedirect ($url) { (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) && ($matches[1] < 6)) { // Send the IIS header - sendHeader('Refresh: 0;url=' . $url); + addHttpHeader('Refresh: 0;url=' . $url); } else { // Send generic header - sendHeader('Location: ' . $url); + addHttpHeader('Location: ' . $url); } // Shutdown here @@ -2458,6 +2443,18 @@ function isDisplayHomeInIndexEnabled () { return $GLOBALS[__FUNCTION__]; } +// Getter for 'admin_menu_javascript' +function getAdminMenuJavascript () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + // Checks wether proxy configuration is used function isProxyUsed () { // Do we have cache? @@ -2581,6 +2578,18 @@ function isRawOutputMode () { return (getScriptOutputMode() == -1); } +// Wrapper to check if output mode is AJAX +function isAjaxOutputMode () { + // Determine it + return (getScriptOutputMode() == -2); +} + +// Wrapper to check if output mode is image +function isImageOutputMode () { + // Determine it + return (getScriptOutputMode() == -3); +} + // Wrapper to generate a user email link function generateWrappedUserEmailLink ($email) { // Just call the inner function @@ -2669,16 +2678,23 @@ function convertCommaToDotInPostDataArray ($postEntries) { * @link http://de.php.net/manual/en/function.floatval.php#92563 */ function parseFloat ($floatString){ - $LocaleInfo = localeconv(); - $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '', $floatString); - $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString); - return floatval($floatString); + // Load locale info + $LocaleInfo = localeconv(); + + // Remove thousand separators + $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString); + + // Convert decimal point + $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString); + + // Return float value of converted string + return floatval($floatString); } // Generates a YES/NO option list from given default -function generateYesNoOptionList ($configValue = '') { +function generateYesNoOptionList ($defaultValue = '') { // Generate it - return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $configValue); + return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue); } // "Getter" for total available receivers @@ -2702,5 +2718,35 @@ function getTotalUnconfirmedMails ($userid) { return $GLOBALS[__FUNCTION__][$userid]; } +// Checks wether 'mailer_theme' was found in session +function isMailerThemeSet () { + // Check session + return isSessionVariableSet('mailer_theme'); +} + +/** + * Setter for theme in session (This setter does return the success of + * setSession() which is required e.g. for destroySponsorSession(). + */ +function setMailerTheme ($newTheme) { + // Set it in session + return setSession('mailer_theme', $newTheme); +} + +/** + * Getter for theme from session (This getter does return 'mailer_theme' from + * session data or throws an error if not possible + */ +function getMailerTheme () { + // Is 'mailer_theme' set? + if (!isMailerThemeSet()) { + // No, then abort here + debug_report_bug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.'); + } // END - if + + // Return the theme from session + return getSession('mailer_theme'); +} + // [EOF] ?>