Security line in all includes changed
[mailer.git] / inc / extensions / ext-cache.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/11/2004 *
4  * ================                             Last change: 10/11/2004 *
5  *                                                                      *
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  * -------------------------------------------------------------------- *
14  *                                                                      *
15  * -------------------------------------------------------------------- *
16  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
17  * For more information visit: http://www.mxchange.org                  *
18  *                                                                      *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or    *
22  * (at your option) any later version.                                  *
23  *                                                                      *
24  * This program is distributed in the hope that it will be useful,      *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
27  * GNU General Public License for more details.                         *
28  *                                                                      *
29  * You should have received a copy of the GNU General Public License    *
30  * along with this program; if not, write to the Free Software          *
31  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
32  * MA  02110-1301  USA                                                  *
33  ************************************************************************/
34
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Version number
42 $EXT_VERSION = "0.1.8";
43
44 // Auto-set extension version
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
46
47 // Version history array (add more with , "0.1" and so on)
48 $EXT_VER_HISTORY = 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");
49
50 switch ($EXT_LOAD_MODE)
51 {
52 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
53         // SQL commands to run
54         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_update BIGINT(20) UNSIGNED NOT NULL DEFAULT '3600'";
55         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_path VARCHAR(255) NOT NULL DEFAULT 'cache/'";
56         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_tested tinyint(1) NOT NULL DEFAULT '0'";
57         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_cache', 'Cache-Einstellungen', 'Update-Interval des Caches usw. k&ouml;nnen Sie hier &auml;ndern.', 9)";
58         break;
59
60 case "remove": // Do stuff when removing extension
61         // SQL commands to run
62         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what='config_cache' OR what='cache_stats' LIMIT 2";
63         break;
64
65 case "activate": // Do stuff when admin activates this extension
66         // SQL commands to run
67         $SQLs[] = "";
68         break;
69
70 case "deactivate": // Do stuff when admin deactivates this extension
71         // SQL commands to run
72         $SQLs[] = "";
73         break;
74
75 case "update": // Update an extension
76         switch ($EXT_VER)
77         {
78         case "0.0.1": // SQL queries for v0.0.1
79                 // Update notes (these will be set as task text!)
80                 $UPDATE_NOTES = "Es wurde die Zeitmarke der Cache-Datei extensions.cache mit ber&uuml;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.";
81                 break;
82
83         case "0.0.2": // SQL queries for v0.0.2
84                 // Update notes (these will be set as task text!)
85                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
86                 break;
87
88         case "0.0.3": // SQL queries for v0.0.3
89                 // Update notes (these will be set as task text!)
90                 $UPDATE_NOTES = "Cache-Update repariert.";
91                 break;
92
93         case "0.0.4": // SQL queries for v0.0.4
94                 // Update notes (these will be set as task text!)
95                 if (EXT_IS_ACTIVE("cache"))
96                 {
97                         // Check for cache when extension is already installed
98                         if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
99                 }
100                 $UPDATE_NOTES = "Spalte &quot;keep_active&quot; ist hinzugef&uuml;gt. Cache wurde reinitialisiert.";
101                 break;
102
103         case "0.0.5": // SQL queries for v0.0.5
104                 // Update notes (these will be set as task text!)
105                 $UPDATE_NOTES = "Registrierung der Cache-Erweiterung repariert";
106                 break;
107
108         case "0.0.6": // SQL queries for v0.0.6
109                 // Update notes (these will be set as task text!)
110                 $UPDATE_NOTES = "Validierung der Cache-Datei admins.cache integriert.";
111                 break;
112
113         case "0.0.7": // SQL queries for v0.0.7
114                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD db_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
115                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_hits BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'";
116                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('stats', 'cache_stats', 'DB-Cache', 'Auf Cache und gesamte Datenbank registrierte Anfragen anzeigen.', 4)";
117
118                 // Update notes (these will be set as task text!)
119                 $UPDATE_NOTES = "Hits auf den Cache werden gez&auml;hlt.";
120                 break;
121
122         case "0.0.8": // SQL queries for v0.0.8
123                 // Update notes (these will be set as task text!)
124                 $UPDATE_NOTES = "Das Umschreiben der Cache-Daten hat eine Fehlermeldung <STRONG>Falsches Passwort!</STRONG> im Admin-Bereich verursacht.";
125                 break;
126
127         case "0.0.9": // SQL queries for v0.0.9
128                 // Update notes (these will be set as task text!)
129                 $UPDATE_NOTES = "Interne Datenfeld-Management korregiert und Cache-Statistiken korregiert.";
130                 break;
131
132         case "0.1.0": // SQL queries for v0.2.1
133                 // Update notes (these will be set as task text!)
134                 $UPDATE_NOTES = "Problem mit fehlender admins-Erweiterung beseitigt.";
135                 break;
136
137         case "0.1.1": // SQL queries for v0.1.1
138                 // Update notes (these will be set as task text!)
139                 $UPDATE_NOTES = "Fehler <STRONG>Division durch 0</STRONG> repariert in den DB-Cache Statistiken.";
140                 break;
141
142         case "0.1.2": // SQL queries for v0.1.2
143                 // Update notes (these will be set as task text!)
144                 $UPDATE_NOTES = "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.";
145                 break;
146
147         case "0.1.3": // SQL queries for v0.1.3
148                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_admins ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
149                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_acls ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
150                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_exts ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
151                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_config ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
152                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_modreg ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
153                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_refdepth ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
154                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_refsys ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
155
156                 // Update notes (these will be set as task text!)
157                 $UPDATE_NOTES = "Alle cache-baren Tabellen sind nun einzelnt ein- bzw. ausschaltbar. Falls die eine oder andere ausgelagerte Tabelle also Fehler verursachen sollte, so k&ouml;nnen Sie diese hier abschalten. Beachten Sie aber bitte, dass dann mehr Abfragen an die Datenbank gestellt wird und dies bedeutend mehr Zeit braucht, als nur die Daten aus einem Datenfeld zu laden, das sich im Speicher aufh&auml;lt.";
158                 break;
159
160         case "0.1.4": // SQL queries for v0.1.4
161                 // Update notes (these will be set as task text!)
162                 $UPDATE_NOTES = "Fehler <STRONG>Division durch 0</STRONG> repariert in <STRONG>inc/load_cache.php</STRONG>.";
163                 break;
164
165         case "0.1.5": // SQL queries for v0.1.5
166                 // Update notes (these will be set as task text!)
167                 $UPDATE_NOTES = "Weitere Fehler im System beseitigt.";
168                 break;
169
170         case "0.1.6": // SQL queries for v0.1.6
171                 // Update notes (these will be set as task text!)
172                 $UPDATE_NOTES = "Probleme w&auuml;hrend des Installationsvorganges beseitigt.";
173                 break;
174
175         case "0.1.7": // SQL queries for v0.1.7
176                 // Update notes (these will be set as task text!)
177                 $UPDATE_NOTES = "CSS-Klassenname gefixt in Templates.";
178                 break;
179
180         case "0.1.8": // SQL queries for v0.1.8
181                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD cache_theme ENUM('Y', 'N') NOT NULL DEFAULT 'Y'";
182
183                 // Update notes (these will be set as task text!)
184                 $UPDATE_NOTES = "Daten von installierten Themes werden nun gecacht.";
185                 break;
186         }
187         break;
188
189 default: // Do stuff when extension is loaded
190         // Create instance on class
191         if ($cacheMode != "init") {
192                 // Initialize cache system only when it's needed
193                 $cacheInstance = new mxchange_cache($_CONFIG['cache_update'], PATH."inc/".$_CONFIG['cache_path'], $_CONFIG['cache_tested']);
194                 if ($cacheInstance->ret != "done") {
195                         // Failed to initialize cache sustem
196                         ADD_FATAL(__FILE__."(".__LINE__."): ".CACHE_CANNOT_INITIALIZE);
197                 }
198         }
199         break;
200 }
201
202 // Language file prefix
203 $EXT_LANG_PREFIX = "cache";
204
205 // Extension is always active?
206 $EXT_ALWAYS_ACTIVE = "Y";
207
208 //
209 ?>