A lot bugfixes for ext-cache and deprecated files removed:
authorRoland Häder <roland@mxchange.org>
Tue, 28 Jul 2009 21:19:54 +0000 (21:19 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 28 Jul 2009 21:19:54 +0000 (21:19 +0000)
- Fixed a problem that no cache file was removed and later used after another registration
- Fixed a problem with CSS mode: cache files got created and removed, now only allowed in 'mode 0'
- Fixed a problem with CSS mode again: When ext-cache is registered css.php raises a missing array element 'revision'
- Some double quotes to single quotes converted
- Deprecated (ext-repair vs. ext-menu) includes removed
- Other minor improvements like more debug messages in debug-mode

16 files changed:
.gitattributes
inc/extensions.php
inc/filters.php
inc/functions.php
inc/libs/cache_functions.php
inc/libs/sponsor_functions.php
inc/load_extensions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-extensions.php
inc/modules/admin/what-list_doubler.php
inc/modules/admin/what-repair_amenu.php [deleted file]
inc/modules/admin/what-repair_gmenu.php [deleted file]
inc/modules/admin/what-repair_mmenu.php [deleted file]
inc/mysql-manager.php
inc/pool/pool-user.php
modules.php

index 2f89381e9c56ff7f5c588c92223b548e55d9bbba..278d7ab8fc61a4ff020e4276283418cfa9f3da14 100644 (file)
@@ -421,12 +421,9 @@ inc/modules/admin/what-optimize.php -text
 inc/modules/admin/what-overview.php -text
 inc/modules/admin/what-payments.php -text
 inc/modules/admin/what-refbanner.php -text
 inc/modules/admin/what-overview.php -text
 inc/modules/admin/what-payments.php -text
 inc/modules/admin/what-refbanner.php -text
-inc/modules/admin/what-repair_amenu.php -text
 inc/modules/admin/what-repair_amnu.php -text
 inc/modules/admin/what-repair_cats.php -text
 inc/modules/admin/what-repair_amnu.php -text
 inc/modules/admin/what-repair_cats.php -text
-inc/modules/admin/what-repair_gmenu.php -text
 inc/modules/admin/what-repair_gmnu.php -text
 inc/modules/admin/what-repair_gmnu.php -text
-inc/modules/admin/what-repair_mmenu.php -text
 inc/modules/admin/what-repair_mmnu.php -text
 inc/modules/admin/what-send_bonus.php -text
 inc/modules/admin/what-send_newsletter.php -text
 inc/modules/admin/what-repair_mmnu.php -text
 inc/modules/admin/what-send_bonus.php -text
 inc/modules/admin/what-send_newsletter.php -text
index 62ab4f43018852eede4458dad60983498b366e17..5eb14f67ad7f43e8aaa1163807ee7a20897780ce 100644 (file)
@@ -88,7 +88,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
                $GLOBALS['ext_loaded']['lang'][$ext_name] = true;
                loadIncludeOnce($langInclude);
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
                $GLOBALS['ext_loaded']['lang'][$ext_name] = true;
                loadIncludeOnce($langInclude);
-       } elseif (($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
+       } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
                // No language file is not so good...
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s",
                        $ext_name, getLanguage()
                // No language file is not so good...
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s",
                        $ext_name, getLanguage()
@@ -104,7 +104,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
                $GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
                loadIncludeOnce($funcsInclude);
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
                $GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
                loadIncludeOnce($funcsInclude);
-       } elseif (($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
+       } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
                // No functions file is not so good...
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no own functions file or we cannot read from it.",
                        $ext_name
                // No functions file is not so good...
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no own functions file or we cannot read from it.",
                        $ext_name
@@ -328,7 +328,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
                //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />\n";
                // Remove task from system when id and extension's name is valid
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
                //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />\n";
                // Remove task from system when id and extension's name is valid
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
-               array(bigintval($task_id)), __FUNCTION__, __LINE__);
+                       array(bigintval($task_id)), __FUNCTION__, __LINE__);
        }
 
        // Is this the sql_patches?
        }
 
        // Is this the sql_patches?
@@ -361,7 +361,10 @@ function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
        $ext_name = GET_EXT_NAME($ext_id);
 
        // If it is not set then maybe there is no extension for that ID number
        $ext_name = GET_EXT_NAME($ext_id);
 
        // If it is not set then maybe there is no extension for that ID number
-       if ($ext_name == '') return false;
+       if (empty($ext_name)) {
+               // We should fix these all!
+               debug_report_bug(__FUNCTION__ . ': ext_name is empty. ext_id=' . $ext_id);
+       } // END - if
 
        // Set current SQL name
        EXT_SET_CURR_NAME($ext_name);
 
        // Set current SQL name
        EXT_SET_CURR_NAME($ext_name);
@@ -385,6 +388,9 @@ function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
 
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQLs::count=".COUNT_SQLS()."");
        if ((IS_SQLS_VALID() && (COUNT_SQLS() > 0))) {
 
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQLs::count=".COUNT_SQLS()."");
        if ((IS_SQLS_VALID() && (COUNT_SQLS() > 0))) {
+               // Run any filters depending on the action here
+               runFilterChain('extension_' . $load_mode, $ext_name);
+
                // Run SQL commands...
                runFilterChain('run_sqls');
 
                // Run SQL commands...
                runFilterChain('run_sqls');
 
@@ -468,7 +474,7 @@ function GET_EXT_VERSION ($ext_name) {
        // Empty extension name should be fixed!
        if (empty($ext_name)) {
                // Please report this bug!
        // Empty extension name should be fixed!
        if (empty($ext_name)) {
                // Please report this bug!
-               debug_report_bug(__FUNCTION__.": ext_name is empty which is not allowed here.");
+               debug_report_bug(__FUNCTION__ . ': ext_name is empty which is not allowed here.');
        } // END - if
 
        // Extensions are all inactive during installation
        } // END - if
 
        // Extensions are all inactive during installation
@@ -669,10 +675,12 @@ function GET_EXT_NAME ($ext_id) {
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_name FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1",
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_name FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `id`=%s LIMIT 1",
-               array(bigintval($ext_id)), __FUNCTION__, __LINE__);
+                       array(bigintval($ext_id)), __FUNCTION__, __LINE__);
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
+
+       // Return the extension name
        return $ret;
 }
 
        return $ret;
 }
 
@@ -689,7 +697,7 @@ function GET_EXT_ID ($ext_name) {
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
-               array($ext_name), __FUNCTION__, __LINE__);
+                       array($ext_name), __FUNCTION__, __LINE__);
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
index 6d02e30e8409261650cab20ce3669268ccf6b6a2..e8f598c857c1f18dc1c89c20055ef1f343e61b3b 100644 (file)
@@ -180,10 +180,9 @@ function unregisterFilter ($filterName, $filterFunction, $force = false, $dry_ru
        } // END - if
 
        // Shall we remove? (default, not while just showing an extension removal)
        } // END - if
 
        // Shall we remove? (default, not while just showing an extension removal)
-       if (!$dry_run) {
+       if ($dry_run === false) {
                // Mark for filter removal
                // Mark for filter removal
-               $GLOBALS['filters']['chains'][$filterName][$filterFunction] = "R";
-               unset($GLOBALS['filters']['counter'][$filterName][$filterFunction]);
+               $GLOBALS['filters']['chains'][$filterName][$filterFunction] = 'R';
        } // END  - if
 }
 
        } // END  - if
 }
 
@@ -192,7 +191,7 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) {
        // Is that filter chain there?
        if (!isset($GLOBALS['filters']['chains'][$filterName])) {
                // Then abort here (quick'N'dirty hack)
        // Is that filter chain there?
        if (!isset($GLOBALS['filters']['chains'][$filterName])) {
                // Then abort here (quick'N'dirty hack)
-               if ((!$silentAbort) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
+               if (($silentAbort === false) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
                        // Add fatal message
                        addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_NO_FILTER_FOUND'), $filterName);
                } // END - if
                        // Add fatal message
                        addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_NO_FILTER_FOUND'), $filterName);
                } // END - if
@@ -207,10 +206,10 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) {
        // Then run all filters
        foreach ($GLOBALS['filters']['chains'][$filterName] as $filterFunction=>$active) {
                // Debug message
        // Then run all filters
        foreach ($GLOBALS['filters']['chains'][$filterName] as $filterFunction=>$active) {
                // Debug message
-               //* DEBUG: */ echo __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): name={$filterName},func={$filterFunction},active={$active}<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running: name={$filterName},func={$filterFunction},active={$active}");
 
                // Is the filter active?
 
                // Is the filter active?
-               if ($active == 'Y') {
+               if (($active == 'Y') || ((in_array($filterName, array('extension_remove', 'post_extension_run_sql'))) && ($active == 'R'))) {
                        // Is this filter there?
                        if (!function_exists($filterFunction)) {
                                // Unregister it
                        // Is this filter there?
                        if (!function_exists($filterFunction)) {
                                // Unregister it
@@ -224,14 +223,29 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) {
                        $returnValue = call_user_func_array($filterFunction, array($returnValue));
 
                        // Update usage counter
                        $returnValue = call_user_func_array($filterFunction, array($returnValue));
 
                        // Update usage counter
-                       $GLOBALS['filters']['counter'][$filterName][$filterFunction]++;
-               } // END - if
+                       countFilterUsage($filterName, $filterFunction);
+               } elseif (isDebugModeEnabled()) {
+                       // Debug message
+                       DEBUG_LOG(__FUNCTION__, __LINE__, "Skipped: name={$filterName},func={$filterFunction},active={$active}");
+               }
        } // END - foreach
 
        // Return the filtered content
        return $returnValue;
 }
 
        } // END - foreach
 
        // Return the filtered content
        return $returnValue;
 }
 
+// Count the filter usage
+function countFilterUsage ($filterName, $filterFunction) {
+       // Is it there?
+       if (isset($GLOBALS['filters']['counter'][$filterName][$filterFunction])) {
+               // Yes, then increase
+               $GLOBALS['filters']['counter'][$filterName][$filterFunction]++;
+       } else {
+               // No, then create
+               $GLOBALS['filters']['counter'][$filterName][$filterFunction] = 1;
+       }
+}
+
 // -----------------------------------------------------------------------------
 // Generic filter functions we always need
 // -----------------------------------------------------------------------------
 // -----------------------------------------------------------------------------
 // Generic filter functions we always need
 // -----------------------------------------------------------------------------
index 78bd0a85409b62f7ff3237993f4a7eeebe421db2..545a2f2eb41823b76000be5e197cb823262656a8 100644 (file)
@@ -2221,9 +2221,12 @@ function app_die ($F, $L, $message) {
                // Load header
                loadIncludeOnce('inc/header.php');
 
                // Load header
                loadIncludeOnce('inc/header.php');
 
-               // Prepare message for output
+               // Rewrite message for output
                $message = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $message);
 
                $message = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $message);
 
+               // Better log this message away
+               DEBUG_LOG($F, $L, $message);
+
                // Load the message template
                LOAD_TEMPLATE('admin_settings_saved', false, $message);
 
                // Load the message template
                LOAD_TEMPLATE('admin_settings_saved', false, $message);
 
@@ -2458,25 +2461,37 @@ function getActualVersion ($type = 'Revision') {
 
        if (EXT_IS_ACTIVE('cache')) {
                // Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
 
        if (EXT_IS_ACTIVE('cache')) {
                // Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
-               if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') $new = true;
-               if (!isset($GLOBALS['cache_array']['revision'][$type])
-               || count($GLOBALS['cache_array']['revision']) < 3
-               || !$GLOBALS['cache_instance']->loadCacheFile('revision')) $new = true;
+               if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') {
+                       // Force rebuild by URL parameter
+                       $new = true;
+               } elseif ((
+                       !isset($GLOBALS['cache_array']['revision'][$type])
+               ) || (
+                       count($GLOBALS['cache_array']['revision']) < 3
+               ) || (
+                       !$GLOBALS['cache_instance']->loadCacheFile('revision')
+               )) {
+                       // Out-dated cache
+                       $new = true;
+               } // END - if
 
                // Is the cache file outdated/invalid?
                if ($new === true){
 
                // Is the cache file outdated/invalid?
                if ($new === true){
-                       $GLOBALS['cache_instance']->destroyCacheFile(); // @TODO isn't it better to do $GLOBALS['cache_instance']->destroyCacheFile('revision')?
+                       // Destroy cache file
+                       $GLOBALS['cache_instance']->destroyCacheFile();
 
                        // @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
                        unset($GLOBALS['cache_array']['revision']);
 
                        // Reload load_cach-revison.php
                        loadInclude('inc/loader/load_cache-revision.php');
 
                        // @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
                        unset($GLOBALS['cache_array']['revision']);
 
                        // Reload load_cach-revison.php
                        loadInclude('inc/loader/load_cache-revision.php');
+
+                       // Abort here
+                       return;
                } // END - if
 
                // Return found value
                return $GLOBALS['cache_array']['revision'][$type][0];
                } // END - if
 
                // Return found value
                return $GLOBALS['cache_array']['revision'][$type][0];
-
        } else {
                // Old Version without ext-cache active (deprecated ?)
 
        } else {
                // Old Version without ext-cache active (deprecated ?)
 
@@ -2485,7 +2500,7 @@ function getActualVersion ($type = 'Revision') {
 
                // Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
                if ((REQUEST_ISSET_GET('check_revision_data')) && (REQUEST_GET('check_revision_data') == 'yes')) {
 
                // Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
                if ((REQUEST_ISSET_GET('check_revision_data')) && (REQUEST_GET('check_revision_data') == 'yes')) {
-                       // Has changed!
+                       // Forced rebuild of .revision file
                        $new = true;
                } else {
                        // Check for revision file
                        $new = true;
                } else {
                        // Check for revision file
@@ -2628,7 +2643,7 @@ function debug_report_bug ($message = '') {
        } // END - if
 
        // Add output
        } // END - if
 
        // Add output
-       $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you cannot attach files!):<pre>";
+       $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you can now attach files):<pre>";
        $debug .= debug_get_printable_backtrace();
        $debug .= "</pre>\nRequest-URI: " . $_SERVER['REQUEST_URI']."<br />\n";
        $debug .= "Thank you for finding bugs.";
        $debug .= debug_get_printable_backtrace();
        $debug .= "</pre>\nRequest-URI: " . $_SERVER['REQUEST_URI']."<br />\n";
        $debug .= "Thank you for finding bugs.";
@@ -3269,7 +3284,7 @@ function isUserIdSet () {
 // Handle message codes from URL
 function handleCodeMessage () {
        if (REQUEST_ISSET_GET('msg')) {
 // Handle message codes from URL
 function handleCodeMessage () {
        if (REQUEST_ISSET_GET('msg')) {
-               // Default extension is "unknown"
+               // Default extension is 'unknown'
                $ext = 'unknown';
 
                // Is extension given?
                $ext = 'unknown';
 
                // Is extension given?
index 4dfed15897d770f3a997001f0523f7fdba06c8de..ca0aee8331aebeb06611e7661d97b930e790755e 100644 (file)
@@ -66,7 +66,7 @@ class CacheSystem {
                $this->path = $path;
 
                // Check if path exists
                $this->path = $path;
 
                // Check if path exists
-               if ((isDirectory($path)) && (!$tested)) {
+               if ((isDirectory($path)) && ($tested === false)) {
                        // Make FQFN for dummy file
                        $fqfn = $path . 'dummy.tmp';
 
                        // Make FQFN for dummy file
                        $fqfn = $path . 'dummy.tmp';
 
@@ -226,16 +226,44 @@ class CacheSystem {
        }
 
        // Destroy an existing cache file
        }
 
        // Destroy an existing cache file
-       function destroyCacheFile () {
+       function destroyCacheFile ($removeArray = false) {
+               // Only run in regular output mode
+               if (getOutputMode() != 0) {
+                       // Debug message if allowed
+                       if (isDebugModeEnabled()) {
+                               // Debug message
+                               DEBUG_LOG(__METHOD__, __LINE__, 'Not removing cache ' . $this->name . ' in output_mode=' . getOutputMode());
+                       } // END - if
+
+                       // Abort here
+                       return;
+               } // END - if
+
                // Is the cache file there?
                if ((!isset($this->rebuilt[$this->name])) && ($this->isCacheReadable())) {
                        // Close cache
                        $this->finalize();
 
                // Is the cache file there?
                if ((!isset($this->rebuilt[$this->name])) && ($this->isCacheReadable())) {
                        // Close cache
                        $this->finalize();
 
+                       // Debug-mode enabled?
+                       if (isDebugModeEnabled()) {
+                               // Log removal of cache
+                               DEBUG_LOG(__METHOD__, __LINE__, 'removing cache: ' . $this->name);
+                       } // END - if
+
                        // Remove cache file from system
                        // Remove cache file from system
-                       //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - DESTROYED!<br />\n";
                        removeFile($this->fqfn);
                        removeFile($this->fqfn);
-                       // @TODO remove from $GLOBALS['cache_array']!!!
+
+                       // Shall we remove the array from memory?
+                       if ($removeArray === true) {
+                               // Debug message if allowed
+                               if (isDebugModeEnabled()) {
+                                       // Debug message
+                                       DEBUG_LOG(__METHOD__, __LINE__, 'removing array!');
+                               } // END - if
+
+                               // Remove it from memory
+                               unset($GLOBALS['cache_array'][$this->name]);
+                       } // END - if
 
                        // Is the file there?
                        if (!$this->isCacheReadable()) {
 
                        // Is the file there?
                        if (!$this->isCacheReadable()) {
@@ -429,9 +457,9 @@ function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) {
        if (!isCacheInstanceValid()) return $data;
 
        // Remove cache
        if (!isCacheInstanceValid()) return $data;
 
        // Remove cache
-       if ($GLOBALS['cache_instance']->loadCacheFile('config'))     $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('extensions')) $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('modreg'))     $GLOBALS['cache_instance']->destroyCacheFile();
+       if ($GLOBALS['cache_instance']->loadCacheFile('config'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('extensions'))  $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('modreg'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
 
        // Return it
        return $data;
 
        // Return it
        return $data;
@@ -443,24 +471,26 @@ function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE () {
        if (!isCacheInstanceValid()) return false;
 
        // Remove cache
        if (!isCacheInstanceValid()) return false;
 
        // Remove cache
-       if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->destroyCacheFile();
+       if ($GLOBALS['cache_instance']->loadCacheFile('admins'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
 }
 
 // Destroy all cache files
 function FILTER_CACHE_DESTROY_ALL () {
        // Skip this step if the cache instance is not there
 }
 
 // Destroy all cache files
 function FILTER_CACHE_DESTROY_ALL () {
        // Skip this step if the cache instance is not there
+       DEBUG_LOG(__FUNCTION__, __LINE__, 'Called!');
        if (!isCacheInstanceValid()) return false;
 
        // Remove cache files
        if (!isCacheInstanceValid()) return false;
 
        // Remove cache files
-       if ($GLOBALS['cache_instance']->loadCacheFile('admins'))      $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('config'))      $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('extensions'))  $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('modreg'))      $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('refdepths'))   $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('refsystem'))   $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('themes'))      $GLOBALS['cache_instance']->destroyCacheFile();
-       if ($GLOBALS['cache_instance']->loadCacheFile('revision'))    $GLOBALS['cache_instance']->destroyCacheFile();
+       if ($GLOBALS['cache_instance']->loadCacheFile('admins'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('config'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('extensions'))  $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('modreg'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('refdepths'))   $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('refsystem'))   $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('themes'))      $GLOBALS['cache_instance']->destroyCacheFile(false);
+       if ($GLOBALS['cache_instance']->loadCacheFile('revision'))    $GLOBALS['cache_instance']->destroyCacheFile(false);
+       DEBUG_LOG(__FUNCTION__, __LINE__, 'Done!');
 }
 
 // Filter for purging entire admin menu cache
 }
 
 // Filter for purging entire admin menu cache
index 3c8a36d81185485082b6ba7ee0e07817189d7b59..21bd10f847f14aca86ef8a808dbb0174bf7f7df9 100644 (file)
@@ -188,7 +188,7 @@ function SPONSOR_HANDLE_SPONSOR (&$POST, $NO_UPDATE=false, $messageArray=array()
                        } else {
                                // Already added!
                                $message = sprintf(getMessage('SPONSOR_ALREADY_FOUND', $POST['email']));
                        } else {
                                // Already added!
                                $message = sprintf(getMessage('SPONSOR_ALREADY_FOUND', $POST['email']));
-                               $ret = "already";
+                               $ret = 'already';
                        }
 
                        if (!empty($sql)) {
                        }
 
                        if (!empty($sql)) {
index 207b3fe022d8ac2f1020f83dfec88aa4194a9fc0..f8589b66d2f7f4a51a932a74ed05747f4512d366 100644 (file)
@@ -90,10 +90,10 @@ if (EXT_IS_ACTIVE('cache')) {
        switch (($GLOBALS['cache_instance']->loadCacheFile('extensions', true)) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
                case true : $GLOBALS['cache_mode'] = 'load'; break;
                case false: $GLOBALS['cache_mode'] = 'init'; break;
        switch (($GLOBALS['cache_instance']->loadCacheFile('extensions', true)) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) {
                case true : $GLOBALS['cache_mode'] = 'load'; break;
                case false: $GLOBALS['cache_mode'] = 'init'; break;
-       }
+       } // END - switch
 
 
-       // Do we need to init the cache?
-       if (($GLOBALS['cache_mode'] == 'init') && (getConfig('cache_exts') == 'Y')) {
+       // Do we need to init the cache? But not in "CSS mode".
+       if (($GLOBALS['cache_mode'] == 'init') && (getConfig('cache_exts') == 'Y') && (getOutputMode() == '0')) {
                // Init cache file
                $GLOBALS['cache_instance']->init('EXTENSIONS');
                $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
                // Init cache file
                $GLOBALS['cache_instance']->init('EXTENSIONS');
                $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches');
index bdb9dedaf6c4ed86e8a64b269737850f92662f81..0903d1311ab4b072d8bf6c045a39252cecc757e3 100644 (file)
@@ -45,11 +45,11 @@ if (!defined('__SECURITY')) {
 // Register an administrator account
 function REGISTER_ADMIN ($user, $md5, $email) {
        // Login does already exist
 // Register an administrator account
 function REGISTER_ADMIN ($user, $md5, $email) {
        // Login does already exist
-       $ret = "already";
+       $ret = 'already';
 
        // Lookup the admin
        $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1",
 
        // Lookup the admin
        $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1",
-       array($user), __FUNCTION__, __LINE__);
+               array($user), __FUNCTION__, __LINE__);
 
        // Is the entry there?
        if (SQL_NUMROWS($result) == 0) {
 
        // Is the entry there?
        if (SQL_NUMROWS($result) == 0) {
@@ -95,8 +95,8 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password) {
                $add = runFilterChain('sql_admin_extra_data');
 
                // Get password from DB
                $add = runFilterChain('sql_admin_extra_data');
 
                // Get password from DB
-               $result = SQL_QUERY_ESC("SELECT password".$add." FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1",
-               array($aid), __FUNCTION__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT password" . $add . " FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1",
+                       array($aid), __FUNCTION__, __LINE__);
 
                // Entry found?
                if (SQL_NUMROWS($result) == 1) {
 
                // Entry found?
                if (SQL_NUMROWS($result) == 1) {
@@ -195,30 +195,29 @@ function LOGIN_ADMIN ($adminLogin, $passHash) {
        if ((GET_EXT_VERSION('admins') >= '0.7.0') && ((EXT_VERSION_IS_OLDER('sql_patches', '0.3.6')) || (GET_EXT_VERSION('sql_patches') == ''))) {
                // Reset counter on out-dated sql_patches version
                SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_admins` SET login_failures=0,last_failure='0000-00-00 00:00:00' WHERE login='%s' LIMIT 1",
        if ((GET_EXT_VERSION('admins') >= '0.7.0') && ((EXT_VERSION_IS_OLDER('sql_patches', '0.3.6')) || (GET_EXT_VERSION('sql_patches') == ''))) {
                // Reset counter on out-dated sql_patches version
                SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_admins` SET login_failures=0,last_failure='0000-00-00 00:00:00' WHERE login='%s' LIMIT 1",
-               array($adminLogin), __FUNCTION__, __LINE__);
+                       array($adminLogin), __FUNCTION__, __LINE__);
 
                // Rebuild cache
                rebuildCacheFiles('admins', 'admin');
        } // END - if
 
        // Now set all session variables and return the result
 
                // Rebuild cache
                rebuildCacheFiles('admins', 'admin');
        } // END - if
 
        // Now set all session variables and return the result
-       return (
-       (
-       setSession('admin_md5', generatePassString($passHash))
+       return ((
+               setSession('admin_md5', generatePassString($passHash))
        ) && (
        ) && (
-       setSession('admin_login', $adminLogin)
+               setSession('admin_login', $adminLogin)
        ) && (
        ) && (
-       setSession('admin_last', time())
+               setSession('admin_last', time())
        ) && (
        ) && (
-       setSession('admin_to', bigintval(REQUEST_POST('timeout')))
-       )
-       );
+               setSession('admin_to', bigintval(REQUEST_POST('timeout')))
+       ));
 }
 
 // Only be executed on cookie checking
 function CHECK_ADMIN_COOKIES ($admin_login, $password) {
        // By default no admin cookies are found
 }
 
 // Only be executed on cookie checking
 function CHECK_ADMIN_COOKIES ($admin_login, $password) {
        // By default no admin cookies are found
-       $ret = '404'; $pass = '';
+       $ret  = '404';
+       $pass = '';
 
        // Get hash
        $pass = GET_ADMIN_HASH(GET_ADMIN_ID($admin_login));
 
        // Get hash
        $pass = GET_ADMIN_HASH(GET_ADMIN_ID($admin_login));
@@ -230,7 +229,7 @@ function CHECK_ADMIN_COOKIES ($admin_login, $password) {
        if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
                // Passwords matches!
                $ret = 'done';
        if (($ret == 'pass') && ((generatePassString($pass) == $password) || ($pass == $password) || ((strlen($pass) == 32) && (md5($password) == $pass)))) {
                // Passwords matches!
                $ret = 'done';
-       }
+       } // END - if
 
        // Return result
        return $ret;
 
        // Return result
        return $ret;
@@ -356,7 +355,7 @@ function ADD_ADMIN_MENU ($act, $wht, $return=false) {
                                        $GLOBALS['menu']['description'][$menu] = $descr;
                                }
                                $OUT .= "<li class=\"admin_menu\">
                                        $GLOBALS['menu']['description'][$menu] = $descr;
                                }
                                $OUT .= "<li class=\"admin_menu\">
-               <div class=\"nobr\"><strong>&middot;</strong>&nbsp;";
+<div class=\"nobr\"><strong>&middot;</strong>&nbsp;";
 
                                if (($menu == $act) && (empty($wht))) {
                                        $OUT .= "<strong>";
 
                                if (($menu == $act) && (empty($wht))) {
                                        $OUT .= "<strong>";
@@ -886,13 +885,11 @@ function ADMIN_BUILD_STATUS_HANDLER ($mode, $IDs, $table, $columns, $filterFunct
                // "Walk" through all entries
                foreach ($IDs as $id => $sel) {
                        // Construct SQL query
                // "Walk" through all entries
                foreach ($IDs as $id => $sel) {
                        // Construct SQL query
-                       $sql = sprintf("UPDATE `{!_MYSQL_PREFIX!}_%s` SET",
-                       SQL_ESCAPE($table)
-                       );
+                       $sql = sprintf("UPDATE `{!_MYSQL_PREFIX!}_%s` SET", SQL_ESCAPE($table));
 
                        // Load data of entry
                        $result = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_%s` WHERE %s=%s LIMIT 1",
 
                        // Load data of entry
                        $result = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_%s` WHERE %s=%s LIMIT 1",
-                       array($table, $idColumn, $id), __FUNCTION__, __LINE__);
+                               array($table, $idColumn, $id), __FUNCTION__, __LINE__);
 
                        // Fetch the data
                        $content = SQL_FETCHARRAY($result);
 
                        // Fetch the data
                        $content = SQL_FETCHARRAY($result);
@@ -901,9 +898,9 @@ function ADMIN_BUILD_STATUS_HANDLER ($mode, $IDs, $table, $columns, $filterFunct
                        SQL_FREERESULT($result);
 
                        // Add all status entries (e.g. status column last_updated or so)
                        SQL_FREERESULT($result);
 
                        // Add all status entries (e.g. status column last_updated or so)
-                       $newStatus = "UNKNOWN";
-                       $oldStatus = "UNKNOWN";
-                       $statusColumn = "unknown";
+                       $newStatus = 'UNKNOWN';
+                       $oldStatus = 'UNKNOWN';
+                       $statusColumn = 'unknown';
                        foreach ($statusArray as $column => $statusInfo) {
                                // Does the entry exist?
                                if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
                        foreach ($statusArray as $column => $statusInfo) {
                                // Does the entry exist?
                                if ((isset($content[$column])) && (isset($statusInfo[$content[$column]]))) {
@@ -911,7 +908,7 @@ function ADMIN_BUILD_STATUS_HANDLER ($mode, $IDs, $table, $columns, $filterFunct
                                        $sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
 
                                        // Remember status
                                        $sql .= sprintf(" %s='%s',", SQL_ESCAPE($column), SQL_ESCAPE($statusInfo[$content[$column]]));
 
                                        // Remember status
-                                       if ($statusColumn == "unknown") {
+                                       if ($statusColumn == 'unknown') {
                                                // Always (!!!) change status column first!
                                                $oldStatus = $content[$column];
                                                $newStatus = $statusInfo[$oldStatus];
                                                // Always (!!!) change status column first!
                                                $oldStatus = $content[$column];
                                                $newStatus = $statusInfo[$oldStatus];
index 68849e0a63ff6c303459159a5eacaefa1ccdc130..b159ab3d45f43775a758dbb2e9a5253accba9776 100644 (file)
@@ -134,12 +134,12 @@ if (REQUEST_ISSET_GET('reg_ext')) {
                                        array(bigintval($ext_id)), __FILE__, __LINE__);
                                        list($name, $active) = SQL_FETCHROW($result);
                                        SQL_FREERESULT($result);
                                        array(bigintval($ext_id)), __FILE__, __LINE__);
                                        list($name, $active) = SQL_FETCHROW($result);
                                        SQL_FREERESULT($result);
-                                       $css = "X";
+                                       $css = 'X';
                                }
 
                                // Output row
                                $cssSelection = '---';
                                }
 
                                // Output row
                                $cssSelection = '---';
-                               if (GET_EXT_VERSION('sql_patches') >= '0.0.6') $cssSelection = ADD_SELECTION('yn', $css, "css", $ext_id);
+                               if (GET_EXT_VERSION('sql_patches') >= '0.0.6') $cssSelection = ADD_SELECTION('yn', $css, 'css', $ext_id);
 
                                // Prepare data for the row template
                                $content = array(
 
                                // Prepare data for the row template
                                $content = array(
@@ -151,7 +151,7 @@ if (REQUEST_ISSET_GET('reg_ext')) {
                                );
 
                                // Load row template and switch color
                                );
 
                                // Load row template and switch color
-                               $OUT .= LOAD_TEMPLATE("admin_extensions_edit_row", true, $content);
+                               $OUT .= LOAD_TEMPLATE('admin_extensions_edit_row', true, $content);
                                $SW = 3 - $SW;
                        }
                } // END - foreach
                                $SW = 3 - $SW;
                        }
                } // END - foreach
@@ -160,7 +160,7 @@ if (REQUEST_ISSET_GET('reg_ext')) {
                define('__EXTENSIONS_ROWS', $OUT);
 
                // Load template
                define('__EXTENSIONS_ROWS', $OUT);
 
                // Load template
-               LOAD_TEMPLATE("admin_extensions_edit");
+               LOAD_TEMPLATE('admin_extensions_edit');
                $do = 'edit';
        }
 } elseif ((REQUEST_ISSET_POST('delete')) && ($SEL > 0) && (!IS_DEMO())) {
                $do = 'edit';
        }
 } elseif ((REQUEST_ISSET_POST('delete')) && ($SEL > 0) && (!IS_DEMO())) {
@@ -195,14 +195,14 @@ if (REQUEST_ISSET_GET('reg_ext')) {
                );
 
                // Load row template and switch color
                );
 
                // Load row template and switch color
-               $OUT .= LOAD_TEMPLATE("admin_extensions_delete_row", true, $content);
+               $OUT .= LOAD_TEMPLATE('admin_extensions_delete_row', true, $content);
                $SW = 3 - $SW;
        } // END - foreach
        define('__EXTENSIONS_ROWS', $OUT);
 
        // Load template
                $SW = 3 - $SW;
        } // END - foreach
        define('__EXTENSIONS_ROWS', $OUT);
 
        // Load template
-       LOAD_TEMPLATE("admin_extensions_delete");
-       $do = "delete";
+       LOAD_TEMPLATE('admin_extensions_delete');
+       $do = 'delete';
 } elseif ((REQUEST_ISSET_POST('remove')) && ($SEL > 0) && (!IS_DEMO())) {
        // Remove extensions from DB (you have to delete all files manually!)
        $cache_update = 0;
 } elseif ((REQUEST_ISSET_POST('remove')) && ($SEL > 0) && (!IS_DEMO())) {
        // Remove extensions from DB (you have to delete all files manually!)
        $cache_update = 0;
@@ -212,9 +212,6 @@ if (REQUEST_ISSET_GET('reg_ext')) {
 
                // Is this extension selected?
                if ($active == 1) {
 
                // Is this extension selected?
                if ($active == 1) {
-                       // Run any assigned removal filters
-                       runFilterChain('extension_remove', GET_EXT_NAME($ext_id));
-
                        // Run embeded SQL commands
                        EXTENSION_RUN_SQLS($ext_id, 'remove');
                } // END - if
                        // Run embeded SQL commands
                        EXTENSION_RUN_SQLS($ext_id, 'remove');
                } // END - if
index c6ffdd6749b61e2cf099874c7de78f408ba59402..70eaefa18be90e7b4f8e4c70f55897c544d83588 100644 (file)
@@ -56,9 +56,9 @@ if (!REQUEST_ISSET_GET('mode')) {
 }
 
 // Load data for the template
 }
 
 // Load data for the template
-switch (REQUEST_GET('mode'))
-{
-       case "already":  // Already payed out points
+// @TODO Try to rewrite this into include files
+switch (REQUEST_GET('mode')) {
+       case 'already':  // Already payed out points
                break;
 
        case 'overview': // General overview page
                break;
 
        case 'overview': // General overview page
@@ -68,73 +68,64 @@ switch (REQUEST_GET('mode'))
                list($cnt) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
 
                list($cnt) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
 
-               if ((empty($cnt)) || ($cnt == '0'))
-               {
+               if ((empty($cnt)) || ($cnt == '0')) {
                        // Nothing payed out so far
                        // Nothing payed out so far
+                       // @TODO Rewrite all these constants
                        define('__DOUBLER_ALREADY_DIRECT_LINK', '0');
                        define('__DOUBLER_ALREADY_DIRECT_LINK', '0');
+               } else {
+                       // Something was payed out
+                       $SUM_ALREADY += $cnt;
+                       define('__DOUBLER_ALREADY_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=already&amp;select=direct\">".$cnt."</a>");
                }
                }
-        else
-        {
-               // Something was payed out
-               $SUM_ALREADY += $cnt;
-               define('__DOUBLER_ALREADY_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=already&amp;select=direct\">".$cnt."</a>");
-        }
-        $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='Y' AND is_ref='Y'", __FILE__, __LINE__);
-        list($cnt) = SQL_FETCHROW($result);
-        SQL_FREERESULT($result);
 
 
-        if ((empty($cnt)) || ($cnt == '0'))
-        {
-               // Nothing payed out so far
-               define('__DOUBLER_ALREADY_REF_LINK', '0');
-        }
-        else
-        {
-               // Something was payed out
-               $SUM_ALREADY += $cnt;
-               define('__DOUBLER_ALREADY_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=already&amp;select=ref\">".$cnt."</a>");
-        }
-        define('__DOUBLER_ALREADY_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=already&amp;select=all\">".$SUM_ALREADY."</a>");
+               $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='Y' AND is_ref='Y'", __FILE__, __LINE__);
+               list($cnt) = SQL_FETCHROW($result);
+               SQL_FREERESULT($result);
+
+       if ((empty($cnt)) || ($cnt == '0')) {
+               // Nothing payed out so far
+               define('__DOUBLER_ALREADY_REF_LINK', '0');
+       } else {
+               // Something was payed out
+               $SUM_ALREADY += $cnt;
+               define('__DOUBLER_ALREADY_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=already&amp;select=ref\">".$cnt."</a>");
+       }
+       define('__DOUBLER_ALREADY_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=already&amp;select=all\">".$SUM_ALREADY."</a>");
+
+       // And the same for waiting pouts (direct and referal)
+       $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='N'", __FILE__, __LINE__);
+       list($cnt) = SQL_FETCHROW($result);
+       SQL_FREERESULT($result);
 
 
-        // And the same for waiting pouts (direct and referal)
-        $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='N'", __FILE__, __LINE__);
-        list($cnt) = SQL_FETCHROW($result);
-        SQL_FREERESULT($result);
+       if ((empty($cnt)) || ($cnt == '0')) {
+               // Nothing payed out so far
+               define('__DOUBLER_WAITING_DIRECT_LINK', '0');
+       } else {
+               // Something was payed out
+               $SUM_WAITING += $cnt;
+               define('__DOUBLER_WAITING_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=waiting&amp;select=direct\">".$cnt."</a>");
+       }
 
 
-        if ((empty($cnt)) || ($cnt == '0'))
-        {
-               // Nothing payed out so far
-               define('__DOUBLER_WAITING_DIRECT_LINK', '0');
-        }
-        else
-        {
-               // Something was payed out
-               $SUM_WAITING += $cnt;
-               define('__DOUBLER_WAITING_DIRECT_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=waiting&amp;select=direct\">".$cnt."</a>");
-        }
-        $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='Y'", __FILE__, __LINE__);
-        list($cnt) = SQL_FETCHROW($result);
-        SQL_FREERESULT($result);
+       $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND is_ref='Y'", __FILE__, __LINE__);
+       list($cnt) = SQL_FETCHROW($result);
+       SQL_FREERESULT($result);
 
 
-        if ((empty($cnt)) || ($cnt == '0'))
-        {
-               // Nothing payed out so far
-               define('__DOUBLER_WAITING_REF_LINK', '0');
-        }
-        else
-        {
-               // Something was payed out
-               $SUM_WAITING += $cnt;
-               define('__DOUBLER_WAITING_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=waiting&amp;select=ref\">".$cnt."</a>");
-        }
-        define('__DOUBLER_WAITING_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=waiting&amp;select=all\">".$SUM_WAITING."</a>");
+       if ((empty($cnt)) || ($cnt == '0')) {
+               // Nothing payed out so far
+               define('__DOUBLER_WAITING_REF_LINK', '0');
+       } else {
+               // Something was payed out
+               $SUM_WAITING += $cnt;
+               define('__DOUBLER_WAITING_REF_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=waiting&amp;select=ref\">".$cnt."</a>");
+       }
+       define('__DOUBLER_WAITING_ALL_LINK', "<a href=\"{!URL!}/modules.php?module=admin&amp;what=list_doubler&amp;mode=waiting&amp;select=all\">".$SUM_WAITING."</a>");
 
 
-        // All data is loaded here...
-        break;
+       // All data is loaded here...
+       break;
 }
 
 // Load mode template
 }
 
 // Load mode template
-LOAD_TEMPLATE("admin_list_doubler_".REQUEST_GET('mode'));
+LOAD_TEMPLATE('admin_list_doubler_' . REQUEST_GET('mode'));
 
 //
 ?>
 
 //
 ?>
diff --git a/inc/modules/admin/what-repair_amenu.php b/inc/modules/admin/what-repair_amenu.php
deleted file mode 100644 (file)
index 96710ab..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-// @DERECATED
-?>
diff --git a/inc/modules/admin/what-repair_gmenu.php b/inc/modules/admin/what-repair_gmenu.php
deleted file mode 100644 (file)
index 96710ab..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-// @DERECATED
-?>
diff --git a/inc/modules/admin/what-repair_mmenu.php b/inc/modules/admin/what-repair_mmenu.php
deleted file mode 100644 (file)
index 96710ab..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-// @DERECATED
-?>
index 4fda5f3680729d6841a1bc0afc900f38a79c3951..8acc8e75a3b5df62059451fbdefca11601be2b9a 100644 (file)
@@ -146,6 +146,7 @@ function checkModulePermissions ($mod) {
        // Check if cache is latest version
        if (GET_EXT_VERSION('cache') >= '0.1.2') {
                // Is the cache there?
        // Check if cache is latest version
        if (GET_EXT_VERSION('cache') >= '0.1.2') {
                // Is the cache there?
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Using cache.');
                if (!isset($GLOBALS['cache_array']['modules'])) {
                        // This happens when a new extension is registered while ext-cache is installed
                        $ret = 'cache_miss';
                if (!isset($GLOBALS['cache_array']['modules'])) {
                        // This happens when a new extension is registered while ext-cache is installed
                        $ret = 'cache_miss';
@@ -154,6 +155,7 @@ function checkModulePermissions ($mod) {
                // Is the module cached?
                if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) {
                        // Check cache
                // Is the module cached?
                if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) {
                        // Check cache
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Cache found.');
                        $locked = $GLOBALS['cache_array']['modules']['locked'][$mod_chk];
                        $hidden = $GLOBALS['cache_array']['modules']['hidden'][$mod_chk];
                        $admin  = $GLOBALS['cache_array']['modules']['admin_only'][$mod_chk];
                        $locked = $GLOBALS['cache_array']['modules']['locked'][$mod_chk];
                        $hidden = $GLOBALS['cache_array']['modules']['hidden'][$mod_chk];
                        $admin  = $GLOBALS['cache_array']['modules']['admin_only'][$mod_chk];
@@ -168,15 +170,23 @@ function checkModulePermissions ($mod) {
                }
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Check for module in database
                }
        } elseif (!EXT_IS_ACTIVE('cache')) {
                // Check for module in database
-               $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1",
-               array($mod_chk), __FUNCTION__, __LINE__);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Using database.');
+               $result = SQL_QUERY_ESC("SELECT `locked`, `hidden`, `admin_only`, `mem_only` FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1",
+                       array($mod_chk), __FUNCTION__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
                        // Read data
                if (SQL_NUMROWS($result) == 1) {
                        // Read data
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Entry found.');
                        list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
                        list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
-                       SQL_FREERESULT($result);
                        $found = true;
                        $found = true;
+               } elseif (isDebugModeEnabled()) {
+                       // Debug message only in debug-mode...
+                       DEBUG_LOG(__FUNCTION__, __LINE__, 'Module ' . $mod_chk . ' not found!');
                }
                }
+
+               // Free result
+               SQL_FREERESULT($result);
        }
        }
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'ret=' . $ret);
 
        // Is the module found?
        if ($found === true) {
 
        // Is the module found?
        if ($found === true) {
@@ -207,7 +217,7 @@ function checkModulePermissions ($mod) {
        } // END - if
 
        // Still no luck or not found?
        } // END - if
 
        // Still no luck or not found?
-       if (($ret == 'cache_miss') || (!$found)) {
+       if ((($ret == 'cache_miss') || ($found === false)) && (getOutputMode() == '0')) {
                //              ----- Legacy module -----                                               ---- Module in base folder  ----                       --- Module with extension's name ---
                if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) {
                        // Data is missing so we add it
                //              ----- Legacy module -----                                               ---- Module in base folder  ----                       --- Module with extension's name ---
                if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) {
                        // Data is missing so we add it
@@ -215,12 +225,12 @@ function checkModulePermissions ($mod) {
                                // Since 0.3.6 we have a has_menu column, this took me a half hour
                                // to find a loop here... *sigh*
                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg`
                                // Since 0.3.6 we have a has_menu column, this took me a half hour
                                // to find a loop here... *sigh*
                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg`
-(module, locked, hidden, mem_only, admin_only, has_menu) VALUES
+(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`) VALUES
 ('%s','Y','N','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__);
                        } else {
                                // Wrong/missing sql_patches!
                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg`
 ('%s','Y','N','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__);
                        } else {
                                // Wrong/missing sql_patches!
                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg`
-(module, locked, hidden, mem_only, admin_only) VALUES
+(`module`, `locked`, `hidden`, `mem_only`, `admin_only`) VALUES
 ('%s','Y','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__);
                        }
 
 ('%s','Y','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__);
                        }
 
@@ -231,6 +241,7 @@ function checkModulePermissions ($mod) {
                        } // END - if
 
                        // Destroy cache here
                        } // END - if
 
                        // Destroy cache here
+                       // @TODO Rewrite this to a filter
                        rebuildCacheFiles('modreg', 'modreg');
 
                        // And reload data
                        rebuildCacheFiles('modreg', 'modreg');
 
                        // And reload data
@@ -242,21 +253,22 @@ function checkModulePermissions ($mod) {
        } elseif (!$found) {
                // Problem with module detected
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s",
        } elseif (!$found) {
                // Problem with module detected
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s",
-               $mod,
-               $ret,
-               $locked,
-               $hidden,
-               $mem,
-               $admin
+                       $mod,
+                       $ret,
+                       $locked,
+                       $hidden,
+                       $mem,
+                       $admin
                ));
        }
 
        // Return the value
                ));
        }
 
        // Return the value
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'ret=' . $ret);
        return $ret;
 }
 
 // Add menu description pending on given file name (without path!)
        return $ret;
 }
 
 // Add menu description pending on given file name (without path!)
-function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
+function ADD_DESCR ($accessLevel, $FQFN, $return = false, $output = true) {
        // Use only filename of the FQFN...
        $file = basename($FQFN);
 
        // Use only filename of the FQFN...
        $file = basename($FQFN);
 
@@ -270,7 +282,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                // This is an action file!
                $type = 'action';
                $search = substr($file, 7);
                // This is an action file!
                $type = 'action';
                $search = substr($file, 7);
-               switch ($ACC_LVL) {
+               switch ($accessLevel) {
                        case 'admin':
                                $modCheck = 'admin';
                                break;
                        case 'admin':
                                $modCheck = 'admin';
                                break;
@@ -287,7 +299,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                $type = 'what';
                $search = substr($file, 5);
                $AND = '';
                $type = 'what';
                $search = substr($file, 5);
                $AND = '';
-               switch ($ACC_LVL) {
+               switch ($accessLevel) {
                        case 'admin':
                                $modCheck = 'admin';
                                break;
                        case 'admin':
                                $modCheck = 'admin';
                                break;
@@ -300,9 +312,10 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                                }
                                break;
                }
                                }
                                break;
                }
+
                $dummy = substr($search, 0, -4);
                $dummy = substr($search, 0, -4);
-               $AND .= " AND `action`='".getModeAction($ACC_LVL, $dummy)."'";
-       } elseif (($ACC_LVL == 'sponsor') || ($ACC_LVL == "engine")) {
+               $AND .= " AND `action`='".getModeAction($accessLevel, $dummy)."'";
+       } elseif (($accessLevel == 'sponsor') || ($accessLevel == "engine")) {
                // Sponsor / engine menu
                $type     = 'what';
                $search   = $file;
                // Sponsor / engine menu
                $type     = 'what';
                $search   = $file;
@@ -310,7 +323,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                $AND      = '';
        } else {
                // Other
                $AND      = '';
        } else {
                // Other
-               $type     = "menu";
+               $type     = 'menu';
                $search   = $file;
                $modCheck = getModule();
                $AND      = '';
                $search   = $file;
                $modCheck = getModule();
                $AND      = '';
@@ -325,7 +338,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                $prefix = '';
        }
 
                $prefix = '';
        }
 
-       $prefix .= "&nbsp;-&gt;&nbsp;";
+       $prefix .= '&nbsp;-&gt;&nbsp;';
 
        // We need to remove .php and the end
        if (substr($search, -4, 4) == '.php') {
 
        // We need to remove .php and the end
        if (substr($search, -4, 4) == '.php') {
@@ -335,7 +348,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
 
        // Get the title from menu
        $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE %s='%s' ".$AND." LIMIT 1",
 
        // Get the title from menu
        $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE %s='%s' ".$AND." LIMIT 1",
-       array($ACC_LVL, $type, $search), __FUNCTION__, __LINE__);
+       array($accessLevel, $type, $search), __FUNCTION__, __LINE__);
 
        // Menu found?
        if (SQL_NUMROWS($result) == 1) {
 
        // Menu found?
        if (SQL_NUMROWS($result) == 1) {
@@ -348,7 +361,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                        return $ret;
                } elseif (((GET_EXT_VERSION('sql_patches') >= '0.2.3') && (getConfig('youre_here') == 'Y')) || ((IS_ADMIN()) && ($modCheck == 'admin'))) {
                        // Output HTML code
                        return $ret;
                } elseif (((GET_EXT_VERSION('sql_patches') >= '0.2.3') && (getConfig('youre_here') == 'Y')) || ((IS_ADMIN()) && ($modCheck == 'admin'))) {
                        // Output HTML code
-                       $OUT = $prefix."<strong><a class=\"you_are_here\" href=\"{!URL!}/modules.php?module=".$modCheck.'&amp;'.$type.'='.$search.$LINK_ADD."\">".$ret."</a></strong>\n";
+                       $OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{!URL!}/modules.php?module=" . $modCheck . '&amp;' . $type . '=' . $search.$LINK_ADD . "\">" . $ret . "</a></strong>\n";
 
                        // Can we close the you-are-here navigation?
                        //* DEBUG: */ echo __LINE__."*".$type.'/'.getWhat()."*<br />\n";
 
                        // Can we close the you-are-here navigation?
                        //* DEBUG: */ echo __LINE__."*".$type.'/'.getWhat()."*<br />\n";
@@ -359,7 +372,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                                $GLOBALS['nav_depth'] = '0';
 
                                // Run the filter chain
                                $GLOBALS['nav_depth'] = '0';
 
                                // Run the filter chain
-                               $ret = runFilterChain('post_youhere_line', array('access_level' => $ACC_LVL, 'type' => $type, 'content' => ""));
+                               $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
                                $OUT .= $ret['content'];
                        } // END - if
                }
                                $OUT .= $ret['content'];
                        } // END - if
                }
index fa5a74fc3012e5e2e160627afbe2778b4858563b..a0b400076eaf25df527ae808ccf639ea824df2b0 100644 (file)
@@ -183,7 +183,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."*<br />";
                                                                break;
 
                                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."*<br />";
                                                                break;
 
-                                                       case "already":
+                                                       case 'already':
                                                                // Entry already found, but we still count one up!
                                                                $GLOBALS['pool_cnt']++;
                                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."<br />";
                                                                // Entry already found, but we still count one up!
                                                                $GLOBALS['pool_cnt']++;
                                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."<br />";
index d77af8437d879930b40659aec4d142a805309426..68bcc4d2e95ee2282276a9e875b6df5ef0f61cfb 100644 (file)
@@ -107,9 +107,10 @@ if ((getConfig('maintenance') == 'Y') && (!IS_ADMIN()) && ($GLOBALS['module'] !=
        $check = checkModulePermissions($GLOBALS['module']);
        switch ($check)
        {
        $check = checkModulePermissions($GLOBALS['module']);
        switch ($check)
        {
-               case 'admin_only':
-               case 'mem_only':
-               case 'done':
+               case 'cache_miss': // The cache is gone
+               case 'admin_only': // Admin-only access
+               case 'mem_only': // Member-only access
+               case 'done': // All fine!
                        // Does the module exists on local file system?
                        if ((isFileReadable(constant('__MODULE'))) && (getTotalFatalErrors() == 0)) {
                                // Module is valid, active and located on the local disc...
                        // Does the module exists on local file system?
                        if ((isFileReadable(constant('__MODULE'))) && (getTotalFatalErrors() == 0)) {
                                // Module is valid, active and located on the local disc...