]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Global variables rewritten
[mailer.git] / inc / functions.php
index a5113472977aa303ea17762ca25da7a4a384b4d9..a292a5b1bce53c775c69869d2d4f78c3b9dea785 100644 (file)
@@ -62,7 +62,7 @@ function IS_INC_WRITEABLE($inc) {
 // Output HTML code directly or "render" it. You addionally switch the new-line character off
 function OUTPUT_HTML ($HTML, $newLine = true) {
        // Some global variables
-       global $OUTPUT, $footer, $CSS;
+       global $OUTPUT;
 
        // Do we have HTML-Code here?
        if (!empty($HTML)) {
@@ -101,7 +101,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
                        mxchange_die("<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}");
                        break;
                }
-       } elseif ((constant('_OB_CACHING') == "on") && ($footer == 1)) {
+       } elseif ((constant('_OB_CACHING') == "on") && ($GLOBALS['footer_sent'] == 1)) {
                // Headers already sent?
                if (headers_sent()) {
                        // Log this error
@@ -131,7 +131,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
                header("Connection: Close");
 
                // Extension "rewrite" installed?
-               if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) {
+               if ((EXT_IS_ACTIVE("rewrite")) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                } // END - if
 
@@ -154,7 +154,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
                OUTPUT_RAW($OUTPUT);
        } elseif ((constant('OUTPUT_MODE') == "render") && (!empty($OUTPUT))) {
                // Rewrite links when rewrite extension is active
-               if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) {
+               if ((EXT_IS_ACTIVE("rewrite")) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                } // END - if
 
@@ -703,8 +703,6 @@ function TRANSLATE_STATUS ($status) {
 }
 //
 function GET_LANGUAGE() {
-       global $cacheArray;
-
        // Set default return value to default language from config
        $ret = constant('DEFAULT_LANG');
 
@@ -715,9 +713,9 @@ function GET_LANGUAGE() {
        if (!empty($_GET['mx_lang'])) {
                // Accept only first 2 chars
                $lang = substr($_GET['mx_lang'], 0, 2);
-       } elseif (isset($cacheArray['language'])) {
+       } elseif (isset($GLOBALS['cache_array']['language'])) {
                // Use cached
-               $ret = $cacheArray['language'];
+               $ret = $GLOBALS['cache_array']['language'];
        } elseif (!empty($lang)) {
                // Check if main language file does exist
                if (FILE_READABLE(constant('PATH')."inc/language/".$lang.".php")) {
@@ -733,7 +731,7 @@ function GET_LANGUAGE() {
        }
 
        // Cache entry
-       $cacheArray['language'] = $ret;
+       $GLOBALS['cache_array']['language'] = $ret;
 
        // Return value
        return $ret;
@@ -908,8 +906,6 @@ function MAKE_TIME($H, $M, $S, $stamp) {
 }
 //
 function LOAD_URL($URL, $addUrlData=true) {
-       global $CSS, $footer;
-
        // Compile out URI codes
        $URL = compileUriCode($URL);
 
@@ -1309,11 +1305,11 @@ function bigintval($num, $castValue = true) {
 }
 
 // Insert the code in $img_code into jpeg or PNG image
-function GENERATE_IMAGE ($img_code, $header=true) {
+function GENERATE_IMAGE ($img_code, $headerSent=true) {
        if ((strlen($img_code) > 6) || (empty($img_code)) || (getConfig('code_length') == 0)) {
                // Stop execution of function here because of over-sized code length
                return;
-       } elseif (!$header) {
+       } elseif (!$headerSent) {
                // Return in an HTML code code
                return "<img src=\"{!URL!}/img.php?code=".$img_code."\" alt=\"Image\" />\n";
        }
@@ -2288,10 +2284,8 @@ function DISPLAY_PARSING_TIME_FOOTER() {
 
 // Unset/set session variables
 function set_session ($var, $value) {
-       global $CSS;
-
        // Abort in CSS mode here
-       if ($CSS == 1) return true;
+       if ($GLOBALS['output_mode'] == 1) return true;
 
        // Trim value and session variable
        $var = trim(SQL_ESCAPE($var)); $value = trim($value);
@@ -2322,23 +2316,21 @@ function set_session ($var, $value) {
 // Check wether a boolean constant is set
 // Taken from user comments in PHP documentation for function constant()
 function isBooleanConstantAndTrue($constName) { // : Boolean
-       global $cacheArray;
-
        // Failed by default
        $res = false;
 
        // In cache?
-       if (isset($cacheArray['const'][$constName])) {
+       if (isset($GLOBALS['cache_array']['const'][$constName])) {
                // Use cache
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$constName."-CACHE!<br />\n";
-               $res = $cacheArray['const'][$constName];
+               $res = $GLOBALS['cache_array']['const'][$constName];
        } else {
                // Check constant
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$constName."-RESOLVE!<br />\n";
                if (defined($constName)) $res = (constant($constName) === true);
 
                // Set cache
-               $cacheArray['const'][$constName] = $res;
+               $GLOBALS['cache_array']['const'][$constName] = $res;
        }
        //* DEBUG: */ var_dump($res);
 
@@ -2353,23 +2345,21 @@ function isSessionVariableSet ($var) {
 }
 // Returns wether the value of the session variable or NULL if not set
 function get_session ($var) {
-       global $cacheArray;
-
        // Default is not found! ;-)
        $value = null;
 
        // Is the variable there or cached values?
-       if (isset($cacheArray['session'][$var])) {
+       if (isset($GLOBALS['cache_array']['session'][$var])) {
                // Get cached value (skips a lot SQL_ESCAPE() calles!
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$var."-CACHE!<br />\n";
-               $value = $cacheArray['session'][$var];
+               $value = $GLOBALS['cache_array']['session'][$var];
        } elseif (isSessionVariableSet($var)) {
                // Then  get it secured!
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$var."-RESOLVE!<br />\n";
                $value = SQL_ESCAPE($_SESSION[$var]);
 
                // Cache the value
-               $cacheArray['session'][$var] = $value;
+               $GLOBALS['cache_array']['session'][$var] = $value;
        } // END - if
 
        // Return the value
@@ -2634,14 +2624,12 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) {
 
 // Rebuild cache
 function REBUILD_CACHE ($cache, $inc="") {
-       global $cacheInstance, $CSS;
-
        // Shall I remove the cache file?
-       if ((EXT_IS_ACTIVE("cache")) && (is_object($cacheInstance))) {
+       if ((EXT_IS_ACTIVE("cache")) && (is_object($GLOBALS['cache_instance']))) {
                // Rebuild cache
-               if ($cacheInstance->loadCacheFile($cache)) {
+               if ($GLOBALS['cache_instance']->loadCacheFile($cache)) {
                        // Destroy it
-                       $cacheInstance->destroyCacheFile();
+                       $GLOBALS['cache_instance']->destroyCacheFile();
                } // END - if
 
                // Include file given?
@@ -2664,13 +2652,11 @@ function REBUILD_CACHE ($cache, $inc="") {
 
 // Purge admin menu cache
 function CACHE_PURGE_ADMIN_MENU ($id=0, $action="", $what="", $str="") {
-       global $cacheInstance;
-
        // Is the cache extension enabled or no cache instance or admin menu cache disabled?
        if (!EXT_IS_ACTIVE("cache")) {
                // Cache extension not active
                return false;
-       } elseif (!is_object($cacheInstance)) {
+       } elseif (!is_object($GLOBALS['cache_instance'])) {
                // No cache instance!
                DEBUG_LOG(__FUNCTION__, __LINE__, " No cache instance found.");
                return false;
@@ -2936,7 +2922,7 @@ function getMessage ($messageId) {
 
 // Get current theme name
 function GET_CURR_THEME() {
-       global $INC_POOL, $CSS, $cacheArray;
+       global $INC_POOL;
 
        // The default theme is 'default'... ;-)
        $ret = "default";
@@ -2948,7 +2934,7 @@ function GET_CURR_THEME() {
                // Set default theme
                set_session('mxchange_theme', $ret);
        } elseif ((isSessionVariableSet('mxchange_theme')) && (GET_EXT_VERSION("sql_patches") >= "0.1.4")) {
-               //die("<pre>".print_r($cacheArray['themes'], true)."</pre>");
+               //die("<pre>".print_r($GLOBALS['cache_array']['themes'], true)."</pre>");
                // Get theme from cookie
                $ret = get_session('mxchange_theme');
 
@@ -2957,7 +2943,7 @@ function GET_CURR_THEME() {
                        // Fix it to default
                        $ret = "default";
                } // END - if
-       } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) {
+       } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isBooleanConstantAndTrue('mxchange_installing')) || ($GLOBALS['output_mode'] == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme'])))) {
                // Prepare FQFN for checking
                $theme = sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE($_GET['theme']));
 
@@ -2989,8 +2975,6 @@ function GET_CURR_THEME() {
 
 // Get id from theme
 function THEME_GET_ID ($name) {
-       global $cacheArray;
-
        // Is the extension "theme" installed?
        if (!EXT_IS_ACTIVE("theme")) {
                // Then abort here
@@ -3001,9 +2985,9 @@ function THEME_GET_ID ($name) {
        $id = 0;
 
        // Is the cache entry there?
-       if (isset($cacheArray['themes']['id'][$name])) {
+       if (isset($GLOBALS['cache_array']['themes']['id'][$name])) {
                // Get the version from cache
-               $id = $cacheArray['themes']['id'][$name];
+               $id = $GLOBALS['cache_array']['themes']['id'][$name];
 
                // Count up
                incrementConfigEntry('cache_hits');
@@ -3183,15 +3167,13 @@ function LOAD_INC ($INC) {
 
 // Loads an include file once
 function LOAD_INC_ONCE ($INC) {
-       global $cacheArray;
-
        // Is it not loaded?
-       if (!isset($cacheArray['load_once'][$INC])) {
+       if (!isset($GLOBALS['cache_array']['load_once'][$INC])) {
                // Then try to load it
                LOAD_INC($INC);
 
                // And mark it as loaded
-               $cacheArray['load_once'][$INC] = true;
+               $GLOBALS['cache_array']['load_once'][$INC] = true;
        } // END - if
 }