2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/11/2004 *
4 * ================ Last change: 10/11/2004 *
6 * -------------------------------------------------------------------- *
7 * File : ext-cache.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Caching system for SQL tables on hard disc *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Caching-System zum Auslagern von SQL-Tabellen *
12 * auf der Festplatte des Servers *
13 * -------------------------------------------------------------------- *
16 * $Tag:: 0.2.1-FINAL $ *
18 * Needs to be in all Files and every File needs "svn propset *
19 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
20 * -------------------------------------------------------------------- *
21 * Copyright (c) 2003 - 2009 by Roland Haeder *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 setThisExtensionVersion('0.2.5');
48 // Version history array (add more with , '0.1.0' and so on)
49 setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5'));
51 // Keep this extension always active!
52 setExtensionAlwaysActive('Y');
55 switch (getExtensionMode()) {
56 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
59 case 'remove': // Do stuff when removing extension
60 // SQL commands to run
61 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('cache_stats','config_config')");
63 // Unregister all filters
64 unregisterFilter('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true, getExtensionDryRun());
65 unregisterFilter('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true, getExtensionDryRun());
66 unregisterFilter('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true, getExtensionDryRun());
67 unregisterFilter('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
68 unregisterFilter('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
69 unregisterFilter('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
70 unregisterFilter('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, getExtensionDryRun());
71 unregisterFilter('extension_remove', 'CACHE_DESTROY_ALL', true, getExtensionDryRun());
72 unregisterFilter('shutdown', 'CACHE_DESTROY_FILTER', true, getExtensionDryRun());
75 case 'activate': // Do stuff when admin activates this extension
76 // SQL commands to run
80 case 'deactivate': // Do stuff when admin deactivates this extension
81 // SQL commands to run
85 case 'update': // Update an extension
87 switch (getCurrentExtensionVersion()) {
88 case '0.0.1': // SQL queries for v0.0.1
89 // Update notes (these will be set as task text!)
90 setExtensionUpdateNotes("Es wurde die Zeitmarke der Cache-Datei extensions.cache mit berücksichtigt. Dies hatte die Folge, dass wenn bei einem Gast die Datei aktualisiert wurde, nur aktivierte und nicht die deaktivierten mit geladen wurden. Folglich fiehlen einfach ein paar Erweiterungen aus.");
93 case '0.0.2': // SQL queries for v0.0.2
94 // Update notes (these will be set as task text!)
95 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
98 case '0.0.3': // SQL queries for v0.0.3
99 // Update notes (these will be set as task text!)
100 setExtensionUpdateNotes("Cache-Update repariert.");
103 case '0.0.4': // SQL queries for v0.0.4
104 // Is the cache extension itself there?
105 if (isExtensionActive('cache')) {
106 // Check for cache when extension is already installed
107 if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile();
110 // Update notes (these will be set as task text!)
111 setExtensionUpdateNotes("Spalte "keep_active" ist hinzugefügt. Cache wurde reinitialisiert.");
114 case '0.0.5': // SQL queries for v0.0.5
115 // Update notes (these will be set as task text!)
116 setExtensionUpdateNotes("Registrierung der Cache-Erweiterung repariert");
119 case '0.0.6': // SQL queries for v0.0.6
120 // Update notes (these will be set as task text!)
121 setExtensionUpdateNotes("Validierung der Cache-Datei admins.cache integriert.");
124 case '0.0.7': // SQL queries for v0.0.7
125 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD db_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
126 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD cache_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
127 addAdminMenuSql('stats','cache_stats','DB-Cache','Auf Cache und gesamte Datenbank registrierte Anfragen anzeigen.', 4);
129 // Update notes (these will be set as task text!)
130 setExtensionUpdateNotes("Hits auf den Cache werden gezählt.");
133 case '0.0.8': // SQL queries for v0.0.8
134 // Update notes (these will be set as task text!)
135 setExtensionUpdateNotes("Das Umschreiben der Cache-Daten hat eine Fehlermeldung <strong>Falsches Passwort!</strong> im Admin-Bereich verursacht.");
138 case '0.0.9': // SQL queries for v0.0.9
139 // Update notes (these will be set as task text!)
140 setExtensionUpdateNotes("Interne Datenfeld-Management korregiert und Cache-Statistiken korregiert.");
143 case '0.1.0': // SQL queries for v0.2.1
144 // Update notes (these will be set as task text!)
145 setExtensionUpdateNotes("Problem mit fehlender admins-Erweiterung beseitigt.");
148 case '0.1.1': // SQL queries for v0.1.1
149 // Update notes (these will be set as task text!)
150 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in den DB-Cache Statistiken.");
153 case '0.1.2': // SQL queries for v0.1.2
154 // Update notes (these will be set as task text!)
155 setExtensionUpdateNotes("Die Tabelen <strong>{?_MYSQL_PREFIX?}_config</strong>, <strong>{?_MYSQL_PREFIX?}_refsystem</strong>, <strong>{?_MYSQL_PREFIX?}_refdepths</strong> und <strong>{?_MYSQL_PREFIX?}_mod_reg</strong> werden nun auch ausgelagert.");
158 case '0.1.3': // SQL queries for v0.1.3
159 // Update notes (these will be set as task text!)
160 setExtensionUpdateNotes("Ungültiges Update.");
163 case '0.1.4': // SQL queries for v0.1.4
164 // Update notes (these will be set as task text!)
165 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in <strong>inc/load_cache.php</strong>.");
168 case '0.1.5': // SQL queries for v0.1.5
169 // Update notes (these will be set as task text!)
170 setExtensionUpdateNotes("Weitere Fehler im System beseitigt.");
173 case '0.1.6': // SQL queries for v0.1.6
174 // Update notes (these will be set as task text!)
175 setExtensionUpdateNotes("Probleme während des Installationsvorganges beseitigt.");
178 case '0.1.7': // SQL queries for v0.1.7
179 // Update notes (these will be set as task text!)
180 setExtensionUpdateNotes("CSS-Klassenname gefixt in Templates.");
183 case '0.1.8': // SQL queries for v0.1.8
184 // Update notes (these will be set as task text!)
185 setExtensionUpdateNotes("Daten von installierten Themes werden nun gecacht.");
188 case '0.1.9': // SQL queries for v0.1.9
189 // Update notes (these will be set as task text!)
190 setExtensionUpdateNotes("Update nicht mehr gültig.");
193 case '0.2.0': // SQL queries for v0.2.0
194 // This update depends on sql_patches
195 addExtensionUpdateDependency('sql_patches');
197 // Update notes (these will be set as task text!)
198 setExtensionUpdateNotes("Die Erweiterung hängt nun von der <strong>sql_patches</strong> ab.");
201 case '0.2.1': // SQL queries for v0.2.1
202 // Register the new filter
203 registerFilter('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, getExtensionDryRun());
204 registerFilter('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, getExtensionDryRun());
205 registerFilter('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, getExtensionDryRun());
206 registerFilter('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
207 registerFilter('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
208 registerFilter('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
209 registerFilter('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, getExtensionDryRun());
210 registerFilter('extension_remove', 'CACHE_DESTROY_ALL', false, true, getExtensionDryRun());
212 // Update notes (these will be set as task text!)
213 setExtensionUpdateNotes("Filter für Erweiterungsmanagement hinzugefügt.");
216 case '0.2.2': // SQL queries for v0.2.2
217 // Update notes (these will be set as task text!)
218 setExtensionUpdateNotes("Update nicht mehr gültig.");
221 case '0.2.3': // SQL queries for v0.2.3
222 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD cache_filter ENUM('Y','N') NOT NULL DEFAULT 'Y'");
224 // Update notes (these will be set as task text!)
225 setExtensionUpdateNotes("Cachen von Filtern hinzugefügt.");
227 // Register a new filter
228 registerFilter('shutdown', 'CACHE_DESTROY_FILTER', false, true, getExtensionDryRun());
231 case '0.2.4': // SQL queries for v0.2.4
232 // SQL commands to run
233 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_cache')");
235 // Remove config entries
236 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_themes`");
237 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_admins`");
238 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_acls`");
239 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_exts`");
240 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_config`");
241 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_modreg`");
242 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refdepth`");
243 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refsys`");
245 // Update notes (these will be set as task text!)
246 setExtensionUpdateNotes("Der Cache hat keine Konfiguration mehr.");
249 case '0.2.5': // SQL queries for v0.2.5
250 // Update notes (these will be set as task text!)
251 setExtensionUpdateNotes("Daten von gefundenen Sprachdateien werden zu den Erweiterungen gecacht.");
256 case 'modify': // When the extension got modified
259 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
262 case 'init': // Do stuff when extension is initialized
265 default: // Unknown extension mode
266 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));