From: Roland Häder Date: Tue, 28 Jul 2009 21:19:54 +0000 (+0000) Subject: A lot bugfixes for ext-cache and deprecated files removed: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=06a24901c58897845bafc1e5b428fee99024bc64;p=mailer.git A lot bugfixes for ext-cache and deprecated files removed: - 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 --- diff --git a/.gitattributes b/.gitattributes index 2f89381e9c..278d7ab8fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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-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_gmenu.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 diff --git a/inc/extensions.php b/inc/extensions.php index 62ab4f4301..5eb14f67ad 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -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); - } 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() @@ -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); - } 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 @@ -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()."
\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? @@ -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 - 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); @@ -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))) { + // Run any filters depending on the action here + runFilterChain('extension_' . $load_mode, $ext_name); + // 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! - 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 @@ -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", - array(bigintval($ext_id)), __FUNCTION__, __LINE__); + array(bigintval($ext_id)), __FUNCTION__, __LINE__); list($ret) = SQL_FETCHROW($result); SQL_FREERESULT($result); } + + // Return the extension name 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", - array($ext_name), __FUNCTION__, __LINE__); + array($ext_name), __FUNCTION__, __LINE__); list($ret) = SQL_FETCHROW($result); SQL_FREERESULT($result); } diff --git a/inc/filters.php b/inc/filters.php index 6d02e30e84..e8f598c857 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -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) - if (!$dry_run) { + if ($dry_run === false) { // Mark for filter removal - $GLOBALS['filters']['chains'][$filterName][$filterFunction] = "R"; - unset($GLOBALS['filters']['counter'][$filterName][$filterFunction]); + $GLOBALS['filters']['chains'][$filterName][$filterFunction] = 'R'; } // 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) - 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 @@ -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 - //* DEBUG: */ echo __FUNCTION__."(".__LINE__."): name={$filterName},func={$filterFunction},active={$active}
\n"; + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running: name={$filterName},func={$filterFunction},active={$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 @@ -224,14 +223,29 @@ function runFilterChain ($filterName, $data = null, $silentAbort = true) { $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; } +// 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 // ----------------------------------------------------------------------------- diff --git a/inc/functions.php b/inc/functions.php index 78bd0a8540..545a2f2eb4 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2221,9 +2221,12 @@ function app_die ($F, $L, $message) { // Load header loadIncludeOnce('inc/header.php'); - // Prepare message for output + // Rewrite message for output $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); @@ -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 (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){ - $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'); + + // Abort here + return; } // END - if // Return found value return $GLOBALS['cache_array']['revision'][$type][0]; - } 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')) { - // Has changed! + // Forced rebuild of .revision file $new = true; } else { // Check for revision file @@ -2628,7 +2643,7 @@ function debug_report_bug ($message = '') { } // END - if // Add output - $debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you cannot attach files!):
";
+	$debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you can now attach files):
";
 	$debug .= debug_get_printable_backtrace();
 	$debug .= "
\nRequest-URI: " . $_SERVER['REQUEST_URI']."
\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')) { - // Default extension is "unknown" + // Default extension is 'unknown' $ext = 'unknown'; // Is extension given? diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php index 4dfed15897..ca0aee8331 100644 --- a/inc/libs/cache_functions.php +++ b/inc/libs/cache_functions.php @@ -66,7 +66,7 @@ class CacheSystem { $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'; @@ -226,16 +226,44 @@ class CacheSystem { } // 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(); + // Debug-mode enabled? + if (isDebugModeEnabled()) { + // Log removal of cache + DEBUG_LOG(__METHOD__, __LINE__, 'removing cache: ' . $this->name); + } // END - if + // Remove cache file from system - //* DEBUG: */ print __METHOD__."(".__LINE__."): {$this->name} - DESTROYED!
\n"; 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()) { @@ -429,9 +457,9 @@ function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) { 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; @@ -443,24 +471,26 @@ function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE () { 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 + DEBUG_LOG(__FUNCTION__, __LINE__, 'Called!'); 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 diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index 3c8a36d811..21bd10f847 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -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'])); - $ret = "already"; + $ret = 'already'; } if (!empty($sql)) { diff --git a/inc/load_extensions.php b/inc/load_extensions.php index 207b3fe022..f8589b66d2 100644 --- a/inc/load_extensions.php +++ b/inc/load_extensions.php @@ -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; - } + } // 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'); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index bdb9dedaf6..0903d1311a 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -45,11 +45,11 @@ if (!defined('__SECURITY')) { // 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", - array($user), __FUNCTION__, __LINE__); + array($user), __FUNCTION__, __LINE__); // 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 - $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) { @@ -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", - array($adminLogin), __FUNCTION__, __LINE__); + array($adminLogin), __FUNCTION__, __LINE__); // 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 - $ret = '404'; $pass = ''; + $ret = '404'; + $pass = ''; // 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'; - } + } // END - if // Return result return $ret; @@ -356,7 +355,7 @@ function ADD_ADMIN_MENU ($act, $wht, $return=false) { $GLOBALS['menu']['description'][$menu] = $descr; } $OUT .= "
  • -
    · "; +
    · "; if (($menu == $act) && (empty($wht))) { $OUT .= ""; @@ -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 - $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", - array($table, $idColumn, $id), __FUNCTION__, __LINE__); + array($table, $idColumn, $id), __FUNCTION__, __LINE__); // 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) - $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]]))) { @@ -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 - if ($statusColumn == "unknown") { + if ($statusColumn == 'unknown') { // Always (!!!) change status column first! $oldStatus = $content[$column]; $newStatus = $statusInfo[$oldStatus]; diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index 68849e0a63..b159ab3d45 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -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); - $css = "X"; + $css = 'X'; } // 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( @@ -151,7 +151,7 @@ if (REQUEST_ISSET_GET('reg_ext')) { ); // 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 @@ -160,7 +160,7 @@ if (REQUEST_ISSET_GET('reg_ext')) { 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())) { @@ -195,14 +195,14 @@ if (REQUEST_ISSET_GET('reg_ext')) { ); // 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 - 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; @@ -212,9 +212,6 @@ if (REQUEST_ISSET_GET('reg_ext')) { // 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 diff --git a/inc/modules/admin/what-list_doubler.php b/inc/modules/admin/what-list_doubler.php index c6ffdd6749..70eaefa18b 100644 --- a/inc/modules/admin/what-list_doubler.php +++ b/inc/modules/admin/what-list_doubler.php @@ -56,9 +56,9 @@ if (!REQUEST_ISSET_GET('mode')) { } // 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 @@ -68,73 +68,64 @@ switch (REQUEST_GET('mode')) list($cnt) = SQL_FETCHROW($result); SQL_FREERESULT($result); - if ((empty($cnt)) || ($cnt == '0')) - { + if ((empty($cnt)) || ($cnt == '0')) { // Nothing payed out so far + // @TODO Rewrite all these constants define('__DOUBLER_ALREADY_DIRECT_LINK', '0'); + } else { + // Something was payed out + $SUM_ALREADY += $cnt; + define('__DOUBLER_ALREADY_DIRECT_LINK', "".$cnt.""); } - else - { - // Something was payed out - $SUM_ALREADY += $cnt; - define('__DOUBLER_ALREADY_DIRECT_LINK', "".$cnt.""); - } - $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', "".$cnt.""); - } - define('__DOUBLER_ALREADY_ALL_LINK', "".$SUM_ALREADY.""); + $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', "".$cnt.""); + } + define('__DOUBLER_ALREADY_ALL_LINK', "".$SUM_ALREADY.""); + + // 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', "".$cnt.""); + } - 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', "".$cnt.""); - } - $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', "".$cnt.""); - } - define('__DOUBLER_WAITING_ALL_LINK', "".$SUM_WAITING.""); + 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', "".$cnt.""); + } + define('__DOUBLER_WAITING_ALL_LINK', "".$SUM_WAITING.""); - // All data is loaded here... - break; + // All data is loaded here... + break; } // 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 index 96710ab452..0000000000 --- a/inc/modules/admin/what-repair_amenu.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/inc/modules/admin/what-repair_gmenu.php b/inc/modules/admin/what-repair_gmenu.php deleted file mode 100644 index 96710ab452..0000000000 --- a/inc/modules/admin/what-repair_gmenu.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/inc/modules/admin/what-repair_mmenu.php b/inc/modules/admin/what-repair_mmenu.php deleted file mode 100644 index 96710ab452..0000000000 --- a/inc/modules/admin/what-repair_mmenu.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 4fda5f3680..8acc8e75a3 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -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? + //* 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'; @@ -154,6 +155,7 @@ function checkModulePermissions ($mod) { // 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]; @@ -168,15 +170,23 @@ function checkModulePermissions ($mod) { } } 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 + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Entry found.'); list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result); - SQL_FREERESULT($result); $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) { @@ -207,7 +217,7 @@ function checkModulePermissions ($mod) { } // 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 @@ -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` -(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` -(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__); } @@ -231,6 +241,7 @@ function checkModulePermissions ($mod) { } // END - if // Destroy cache here + // @TODO Rewrite this to a filter 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", - $mod, - $ret, - $locked, - $hidden, - $mem, - $admin + $mod, + $ret, + $locked, + $hidden, + $mem, + $admin )); } // Return the value + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'ret=' . $ret); 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); @@ -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); - switch ($ACC_LVL) { + switch ($accessLevel) { 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 = ''; - switch ($ACC_LVL) { + switch ($accessLevel) { case 'admin': $modCheck = 'admin'; break; @@ -300,9 +312,10 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { } break; } + $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; @@ -310,7 +323,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { $AND = ''; } else { // Other - $type = "menu"; + $type = 'menu'; $search = $file; $modCheck = getModule(); $AND = ''; @@ -325,7 +338,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { $prefix = ''; } - $prefix .= " -> "; + $prefix .= ' -> '; // 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", - array($ACC_LVL, $type, $search), __FUNCTION__, __LINE__); + array($accessLevel, $type, $search), __FUNCTION__, __LINE__); // 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 - $OUT = $prefix."".$ret."\n"; + $OUT = $prefix . "\n"; @@ -359,7 +372,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { $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 } diff --git a/inc/pool/pool-user.php b/inc/pool/pool-user.php index fa5a74fc30..a0b400076e 100644 --- a/inc/pool/pool-user.php +++ b/inc/pool/pool-user.php @@ -183,7 +183,7 @@ if (SQL_NUMROWS($result_main) > 0) { //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."*
    "; 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']."
    "; diff --git a/modules.php b/modules.php index d77af8437d..68bcc4d2e9 100644 --- a/modules.php +++ b/modules.php @@ -107,9 +107,10 @@ if ((getConfig('maintenance') == 'Y') && (!IS_ADMIN()) && ($GLOBALS['module'] != $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...