From: Roland Häder Date: Tue, 16 Dec 2008 21:14:54 +0000 (+0000) Subject: Several fixes for extension handling X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=ad851a23313d8ac6489a759a0f3d62e3bc6f4682 Several fixes for extension handling --- diff --git a/inc/databases.php b/inc/databases.php index ba9e76ec5b..39abdceaec 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "636"); +define('CURR_SVN_REVISION', "637"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/db/lib.php b/inc/db/lib.php index 7578d60770..4384bfea81 100644 --- a/inc/db/lib.php +++ b/inc/db/lib.php @@ -51,5 +51,8 @@ if ((file_exists($INC)) && (is_readable($INC))) { die("Cannot load database abstraction layer! R.I.P."); } +// Remove this globally used variable +unset($INC); + // ?> diff --git a/inc/extensions/ext-cache.php b/inc/extensions/ext-cache.php index 867bf66a1b..d55b2afb55 100644 --- a/inc/extensions/ext-cache.php +++ b/inc/extensions/ext-cache.php @@ -62,13 +62,13 @@ case "remove": // Do stuff when removing extension $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE what='config_cache' OR what='cache_stats' LIMIT 2"; // Unregister all filters - UNREGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE'); - UNREGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE'); - UNREGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE'); - UNREGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); + UNREGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true); + UNREGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true); + UNREGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true); + UNREGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true); UNREGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); - UNREGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); - UNREGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); + UNREGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true); + UNREGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true); break; case "activate": // Do stuff when admin activates this extension @@ -211,13 +211,13 @@ case "update": // Update an extension case "0.2.1": // SQL queries for v0.2.1 // Register the new filter - REGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE'); - REGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE'); - REGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE'); - REGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); - REGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); - REGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); - REGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE'); + REGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true); + REGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true); + REGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true); + REGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true); + REGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true); + REGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true); + REGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true); // Update notes (these will be set as task text!) $UPDATE_NOTES = "Filter hinzugefügt für Erweiterungsmanagement."; diff --git a/inc/extensions/ext-theme.php b/inc/extensions/ext-theme.php index 39d74b135d..1a95e558ef 100644 --- a/inc/extensions/ext-theme.php +++ b/inc/extensions/ext-theme.php @@ -54,7 +54,7 @@ case "register": // Do stuff when installation is running (modules.php?module=ad case "remove": // Do stuff when removing extension // Drop theme table - $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_themes"; + $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_themes`"; // Delete admin menu $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE `action`='theme' LIMIT 4"; @@ -62,7 +62,7 @@ case "remove": // Do stuff when removing extension // Delete guest menu entries $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_guest_menu` WHERE action='themes' LIMIT 1"; - // Delete/update member menu entries + // Delete member menu entries $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_member_menu` WHERE action='themes' OR `what`='themes' LIMIT 2"; break; @@ -110,24 +110,23 @@ case "update": // Update an extension break; case "0.0.7": // SQL queries for v0.0.7 - $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_themes ADD theme_name VARCHAR(255) NOT NULL DEFAULT ''"; - // Update notes (these will be set as task text!) - $UPDATE_NOTES = "Designname (von Menschen lesbar) hinzugefügt."; + $UPDATE_NOTES = "Ungültiges Update."; break; case "0.0.8": // SQL queries for v0.0.8 // Theme table - $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_themes"; - $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_themes ( + $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_themes`"; + $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_themes` ( id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, theme_path VARCHAR(255) NOT NULL DEFAULT '', +theme_name VARCHAR(255) NOT NULL DEFAULT '', theme_active ENUM('Y','N') NOT NULL DEFAULT 'N', theme_ver VARCHAR(255) NOT NULL DEFAULT '0.0', -PRIMARY KEY(`id`), -UNIQUE KEY(`theme_path`), -INDEX(`theme_active`), -) TYPE=MyISAM"; +PRIMARY KEY (`id`), +UNIQUE KEY (`theme_path`), +INDEX (`theme_active`) +) TYPE=MyISAM COMMENT='Themes'"; // Admin menu $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('theme', NULL, 'Themes','Verwalten Sie hier alle Designs (Themes) Ihres Mailtausch-Scriptes.', 8)"; diff --git a/inc/filters.php b/inc/filters.php index 33c59228a0..b750c4a772 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -92,14 +92,14 @@ ORDER BY `filter_id` ASC", __FILE__, __LINE__); } // "Registers" a new filter function -function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true) { +function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true, $force = false) { global $filters; // Extend the filter function name $filterFunction = sprintf("FILTER_%s", strtoupper($filterFunction)); // Is that filter already there? - if (isset($filters[$filterName][$filterFunction])) { + if ((isset($filters[$filterName][$filterFunction])) && (!$force)) { // Then abort here if (!$silentAbort) { ADD_FATAL(sprintf(FILTER_FAILED_ALREADY_ADDED, $filterFunction, $filterName)); @@ -121,11 +121,14 @@ function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true) { } // "Unregisters" a filter from the given chain -function UNREGISTER_FILTER ($filterName, $filterFunction) { +function UNREGISTER_FILTER ($filterName, $filterFunction, $force = false) { global $filters; + // Extend the filter function name + $filterFunction = sprintf("FILTER_%s", strtoupper($filterFunction)); + // Is that filter there? - if (!isset($filters[$filterName][$filterFunction])) { + if ((!isset($filters[$filterName][$filterFunction])) && (!$force)) { // Not found, so abort here ADD_FATAL(sprintf(FILTER_FAILED_NOT_REMOVED, $filterFunction, $filterName)); return false; diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 978b87ba5a..76d794d9cc 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -485,13 +485,13 @@ ORDER BY beg_points DESC, userid"; if (EXT_IS_ACTIVE("theme")) { // List all themes - $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_themes ORDER BY id"; + $SQLs[] = "SELECT id FROM `"._MYSQL_PREFIX."_themes` ORDER BY id"; $WHATs[] = "theme_edit"; $DESCRs[] = TASK_ADMIN_LIST_THEME_ALL; $TITLEs[] = TASK_ADMIN_LIST_THEME_ALL_TITLE; // List active themes - $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_active='Y' ORDER BY id"; + $SQLs[] = "SELECT id FROM `"._MYSQL_PREFIX."_themes` WHERE theme_active='Y' ORDER BY id"; $WHATs[] = "theme_edit"; $DESCRs[] = TASK_ADMIN_LIST_THEME_ACTIVE; $TITLEs[] = TASK_ADMIN_LIST_THEME_ACTIVE_TITLE; diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 5adb09e7df..6fbcd98904 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -157,7 +157,7 @@ function THEME_GET_VERSION ($name) { if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } } elseif (GET_EXT_VERSION("cache") != "0.1.8") { // Load version from database - $result = SQL_QUERY_ESC("SELECT theme_ver FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT theme_ver FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' LIMIT 1", array($name), __FILE__, __LINE__); // Entry found? @@ -196,7 +196,7 @@ function THEME_GET_ID ($name) { if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } } elseif (GET_EXT_VERSION("cache") != "0.1.8") { // Check if current theme is already imported or not - $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT id FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' LIMIT 1", array($name), __FILE__, __LINE__); // Entry found? @@ -241,7 +241,7 @@ function THEME_IS_ACTIVE ($name) { if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } } elseif (GET_EXT_VERSION("cache") != "0.1.8") { // Check if current theme is already imported or not - $result = SQL_QUERY_ESC("SELECT theme_active FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' AND theme_active='Y' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT theme_active FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' AND theme_active='Y' LIMIT 1", array($name), __FILE__, __LINE__); // Is the theme active and installed? @@ -277,7 +277,7 @@ function GET_CURR_THEME_NAME () { if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } } elseif (GET_EXT_VERSION("cache") != "0.1.8") { // Check if current theme is already imported or not - $result = SQL_QUERY_ESC("SELECT theme_name FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' AND theme_active='Y' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT theme_name FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' AND theme_active='Y' LIMIT 1", array($name), __FILE__, __LINE__); // Load theme name diff --git a/inc/loader/load_cache-them.php b/inc/loader/load_cache-them.php index a92039fe18..9f09a159f4 100644 --- a/inc/loader/load_cache-them.php +++ b/inc/loader/load_cache-them.php @@ -69,9 +69,9 @@ if (($cacheInstance->loadCacheFile("themes")) && ($cacheInstance->extensionVersi // Load all themes and their data if (GET_EXT_VERSION("theme") >= "0.0.7") { - $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM "._MYSQL_PREFIX."_themes ORDER BY id", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM `"._MYSQL_PREFIX."_themes` ORDER BY id", __FILE__, __LINE__); } else { - $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver FROM "._MYSQL_PREFIX."_themes ORDER BY id", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver FROM `"._MYSQL_PREFIX."_themes` ORDER BY id", __FILE__, __LINE__); } while ($data = SQL_FETCHARRAY($result)) { // Add row to cache file diff --git a/inc/modules/admin/what-theme_edit.php b/inc/modules/admin/what-theme_edit.php index 7a9024674e..f5de9a864a 100644 --- a/inc/modules/admin/what-theme_edit.php +++ b/inc/modules/admin/what-theme_edit.php @@ -54,14 +54,14 @@ if ($SEL > 0) { if (isset($_POST['status'])) { // Change status if ($_POST['active'][$id] == "Y") { - $SQL = "UPDATE "._MYSQL_PREFIX."_themes SET theme_active='N' WHERE id='".$id."' LIMIT 1"; + $SQL = "UPDATE `"._MYSQL_PREFIX."_themes` SET theme_active='N' WHERE id='".$id."' LIMIT 1"; } else { - $SQL = "UPDATE "._MYSQL_PREFIX."_themes SET theme_active='Y' WHERE id='".$id."' LIMIT 1"; + $SQL = "UPDATE `"._MYSQL_PREFIX."_themes` SET theme_active='Y' WHERE id='".$id."' LIMIT 1"; } $OUT = ADMIN_THEMES_UPDATED; } elseif (isset($_POST['del'])) { // Delete themes - $SQL = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_themes WHERE id='".$id."' LIMIT 1"; + $SQL = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_themes` WHERE id='".$id."' LIMIT 1"; $OUT = ADMIN_THEMES_DELETED; } @@ -98,7 +98,7 @@ $THEME_MODE = "test"; // Generate output lines for the template $OUT = ""; $SW = 2; -$result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM "._MYSQL_PREFIX."_themes ORDER BY theme_path", __FILE__, __LINE__); +$result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM `"._MYSQL_PREFIX."_themes` ORDER BY theme_path", __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { while(list($id, $unix, $active, $ver, $name) = SQL_FETCHROW($result)) diff --git a/inc/modules/guest/action-themes.php b/inc/modules/guest/action-themes.php index e0b248c952..8bbac22d46 100644 --- a/inc/modules/guest/action-themes.php +++ b/inc/modules/guest/action-themes.php @@ -46,7 +46,7 @@ if (defined('__THEME_SELECTION_CONTENT')) return false; // Load all active designs (or all if admin) $whereStatement = ""; $OUT = ""; if (!IS_ADMIN()) $whereStatement = " WHERE theme_active='Y'"; -$result_themes = SQL_QUERY("SELECT theme_path FROM "._MYSQL_PREFIX."_themes".$whereStatement, __FILE__, __LINE__); +$result_themes = SQL_QUERY("SELECT theme_path FROM `"._MYSQL_PREFIX."_themes`".$whereStatement, __FILE__, __LINE__); $num_themes = SQL_NUMROWS($result_themes); if ($num_themes > 1) { diff --git a/inc/modules/member/action-themes.php b/inc/modules/member/action-themes.php index 3b395570bb..c06b4d9b21 100644 --- a/inc/modules/member/action-themes.php +++ b/inc/modules/member/action-themes.php @@ -48,7 +48,7 @@ if (defined('__THEME_SELECTION_CONTENT')) return false; // Load all active designs (or all if admin) $whereStatement = ""; $OUT = ""; if (!IS_ADMIN()) $whereStatement = " WHERE theme_active='Y'"; -$result_themes = SQL_QUERY("SELECT theme_path FROM "._MYSQL_PREFIX."_themes".$whereStatement, __FILE__, __LINE__); +$result_themes = SQL_QUERY("SELECT theme_path FROM `"._MYSQL_PREFIX."_themes`".$whereStatement, __FILE__, __LINE__); $num_themes = SQL_NUMROWS($result_themes); if ($num_themes > 1) { diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index f52848abc0..b81ae597f6 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -151,6 +151,12 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT // Run daily reset require_once(PATH."inc/check-reset.php"); + // Create missing configuration file + if (!function_exists('GET_CURR_THEME')) { + // Load dummy theme functions + require_once(PATH."inc/theme-dummy.php"); + } // END - if + // Load admin include file if he is admin if (IS_ADMIN()) { // Administrative functions @@ -255,6 +261,12 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT require_once(PATH."inc/databases.php"); require_once(PATH."inc/session.php"); + // Create missing configuration file + if (!function_exists('GET_CURR_THEME')) { + // Load dummy theme functions + require_once(PATH."inc/theme-dummy.php"); + } // END - if + // Check if we are in installation routine $installPhp = basename($_SERVER['PHP_SELF']); if (($installPhp != "install.php") && ($CSS != "1") && ($CSS != -1)) { diff --git a/inc/stylesheet.php b/inc/stylesheet.php index 4d7c214aaf..a8e5748a83 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -56,12 +56,6 @@ if (($CSS == "1") || ($_CONFIG['css_php'] == "DIRECT")) { foreach ($EXT_CSS_FILES as $value) $STYLES[] = $value; } // END - if - // Create missing configuration file - if (!function_exists('GET_CURR_THEME')) { - // Load dummy theme functions - require_once(PATH."inc/theme-dummy.php"); - } // END - if - // Output inclusion lines foreach ($STYLES as $value) { // Only include found CSS files (to reduce 404 requests)