2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * -------------------------------------------------------------------- *
19 * Copyright (c) 2003 - 2009 by Roland Haeder *
20 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
45 setThisExtensionVersion('0.2.5');
47 // Version history array (add more with , '0.1.0' and so on)
48 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'));
50 // Keep this extension always active!
51 setExtensionAlwaysActive('Y');
54 switch (getExtensionMode()) {
55 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
58 case 'remove': // Do stuff when removing extension
59 // SQL commands to run
60 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('cache_stats','config_config')");
62 // Unregister all filters
63 unregisterFilter(__FUNCTION__, __LINE__, 'extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true, isExtensionDryRun());
64 unregisterFilter(__FUNCTION__, __LINE__, 'post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true, isExtensionDryRun());
65 unregisterFilter(__FUNCTION__, __LINE__, 'post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true, isExtensionDryRun());
66 unregisterFilter(__FUNCTION__, __LINE__, 'post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
67 unregisterFilter(__FUNCTION__, __LINE__, 'post_form_submited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
68 unregisterFilter(__FUNCTION__, __LINE__, 'post_form_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
69 unregisterFilter(__FUNCTION__, __LINE__, 'post_form_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, isExtensionDryRun());
70 unregisterFilter(__FUNCTION__, __LINE__, 'extension_remove', 'CACHE_DESTROY_ALL', true, isExtensionDryRun());
71 unregisterFilter(__FUNCTION__, __LINE__, 'shutdown', 'CACHE_DESTROY_FILTER', true, isExtensionDryRun());
74 case 'activate': // Do stuff when admin activates this extension
75 // SQL commands to run
79 case 'deactivate': // Do stuff when admin deactivates this extension
80 // SQL commands to run
84 case 'update': // Update an extension
86 switch (getCurrentExtensionVersion()) {
87 case '0.0.1': // SQL queries for v0.0.1
88 // Update notes (these will be set as task text!)
89 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.");
92 case '0.0.2': // SQL queries for v0.0.2
93 // Update notes (these will be set as task text!)
94 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
97 case '0.0.3': // SQL queries for v0.0.3
98 // Update notes (these will be set as task text!)
99 setExtensionUpdateNotes("Cache-Update repariert.");
102 case '0.0.4': // SQL queries for v0.0.4
103 // Is the cache extension itself there?
104 if (isExtensionActive('cache')) {
105 // Check for cache when extension is already installed
106 if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile();
109 // Update notes (these will be set as task text!)
110 setExtensionUpdateNotes("Spalte "keep_active" ist hinzugefügt. Cache wurde reinitialisiert.");
113 case '0.0.5': // SQL queries for v0.0.5
114 // Update notes (these will be set as task text!)
115 setExtensionUpdateNotes("Registrierung der Cache-Erweiterung repariert");
118 case '0.0.6': // SQL queries for v0.0.6
119 // Update notes (these will be set as task text!)
120 setExtensionUpdateNotes("Validierung der Cache-Datei admins.cache integriert.");
123 case '0.0.7': // SQL queries for v0.0.7
124 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD db_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
125 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD cache_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
126 addAdminMenuSql('stats','cache_stats','DB-Cache','Auf Cache und gesamte Datenbank registrierte Anfragen anzeigen.', 4);
128 // Update notes (these will be set as task text!)
129 setExtensionUpdateNotes("Hits auf den Cache werden gezählt.");
132 case '0.0.8': // SQL queries for v0.0.8
133 // Update notes (these will be set as task text!)
134 setExtensionUpdateNotes("Das Umschreiben der Cache-Daten hat eine Fehlermeldung <strong>Falsches Passwort!</strong> im Admin-Bereich verursacht.");
137 case '0.0.9': // SQL queries for v0.0.9
138 // Update notes (these will be set as task text!)
139 setExtensionUpdateNotes("Interne Datenfeld-Management korregiert und Cache-Statistiken korregiert.");
142 case '0.1.0': // SQL queries for v0.2.1
143 // Update notes (these will be set as task text!)
144 setExtensionUpdateNotes("Problem mit fehlender admins-Erweiterung beseitigt.");
147 case '0.1.1': // SQL queries for v0.1.1
148 // Update notes (these will be set as task text!)
149 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in den DB-Cache Statistiken.");
152 case '0.1.2': // SQL queries for v0.1.2
153 // Update notes (these will be set as task text!)
154 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.");
157 case '0.1.3': // SQL queries for v0.1.3
158 // Update notes (these will be set as task text!)
159 setExtensionUpdateNotes("Ungültiges Update.");
162 case '0.1.4': // SQL queries for v0.1.4
163 // Update notes (these will be set as task text!)
164 setExtensionUpdateNotes("Fehler <strong>Division durch 0</strong> repariert in <strong>inc/load_cache.php</strong>.");
167 case '0.1.5': // SQL queries for v0.1.5
168 // Update notes (these will be set as task text!)
169 setExtensionUpdateNotes("Weitere Fehler im System beseitigt.");
172 case '0.1.6': // SQL queries for v0.1.6
173 // Update notes (these will be set as task text!)
174 setExtensionUpdateNotes("Probleme während des Installationsvorganges beseitigt.");
177 case '0.1.7': // SQL queries for v0.1.7
178 // Update notes (these will be set as task text!)
179 setExtensionUpdateNotes("CSS-Klassenname gefixt in Templates.");
182 case '0.1.8': // SQL queries for v0.1.8
183 // Update notes (these will be set as task text!)
184 setExtensionUpdateNotes("Daten von installierten Themes werden nun gecacht.");
187 case '0.1.9': // SQL queries for v0.1.9
188 // Update notes (these will be set as task text!)
189 setExtensionUpdateNotes("Update nicht mehr gültig.");
192 case '0.2.0': // SQL queries for v0.2.0
193 // This update depends on sql_patches
194 addExtensionDependency('sql_patches');
196 // Update notes (these will be set as task text!)
197 setExtensionUpdateNotes("Die Erweiterung hängt nun von der <strong>sql_patches</strong> ab.");
200 case '0.2.1': // SQL queries for v0.2.1
201 // Register the new filter
202 registerFilter('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, isExtensionDryRun());
203 registerFilter('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, isExtensionDryRun());
204 registerFilter('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true, isExtensionDryRun());
205 registerFilter('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
206 registerFilter('post_form_submited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
207 registerFilter('post_form_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
208 registerFilter('post_form_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true, isExtensionDryRun());
209 registerFilter('extension_remove', 'CACHE_DESTROY_ALL', false, true, isExtensionDryRun());
211 // Update notes (these will be set as task text!)
212 setExtensionUpdateNotes("Filter für Erweiterungsmanagement hinzugefügt.");
215 case '0.2.2': // SQL queries for v0.2.2
216 // Update notes (these will be set as task text!)
217 setExtensionUpdateNotes("Update nicht mehr gültig.");
220 case '0.2.3': // SQL queries for v0.2.3
221 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD cache_filter ENUM('Y','N') NOT NULL DEFAULT 'Y'");
223 // Update notes (these will be set as task text!)
224 setExtensionUpdateNotes("Cachen von Filtern hinzugefügt.");
226 // Register a new filter
227 registerFilter('shutdown', 'CACHE_DESTROY_FILTER', false, true, isExtensionDryRun());
230 case '0.2.4': // SQL queries for v0.2.4
231 // SQL commands to run
232 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_cache' LIMIT 1");
234 // Remove config entries
235 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_themes`");
236 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_admins`");
237 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_acls`");
238 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_exts`");
239 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_config`");
240 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_modreg`");
241 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refdepth`");
242 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `cache_refsys`");
244 // Update notes (these will be set as task text!)
245 setExtensionUpdateNotes("Der Cache hat keine Konfiguration mehr.");
248 case '0.2.5': // SQL queries for v0.2.5
249 // Update notes (these will be set as task text!)
250 setExtensionUpdateNotes("Daten von gefundenen Sprachdateien werden zu den Erweiterungen gecacht.");
255 case 'modify': // When the extension got modified
258 case 'test': // For testing purposes
261 case 'init': // Do stuff when extension is initialized
264 default: // Unknown extension mode
265 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));