471300b250885254195ac2c197658f05a7dd9125
[mailer.git] / inc / extensions / ext-sql_patches.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/21/2004 *
4  * ================                             Last change: 12/04/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-sql_patches.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : SQL fixes for pro versions                       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ausgelagertes "Profildaten aendern"              *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF']))) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Version number
41 $EXT_VERSION = "0.4.3";
42
43 // Auto-set extension version
44 if (!isset($EXT_VER)) $EXT_VER = $EXT_VERSION;
45
46 // Version history array (add more with , "0.1" and so on)
47 $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", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1", "0.4.2", "0.4.3");
48
49 switch ($EXT_LOAD_MODE)
50 {
51 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
52         // SQL commands to run
53         $SQLs[] = "";
54         break;
55
56 case "remove": // Do stuff when removing extension
57         // SQL commands to run
58         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE
59 (action='theme' AND (what='theme_import' OR what='theme_edit')) OR
60 what='config_extensions' OR
61 what='config_home' OR
62 what='list_unconfirmed' OR
63 what='config_refid' OR
64 what='config_title' OR
65 what='sub_points' OR
66 what='config_admin' OR
67 what='config_proxy' OR
68 what='list_norefs'
69 LIMIT 13";
70         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_themes";
71         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_guest_menu WHERE action='themes' LIMIT 1";
72         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE
73 action='themes' OR
74 what='themes' OR
75 (action='stats' AND what='') OR
76 (action='extras' AND what='') OR
77 (action='rals' AND what='') OR
78 (action='account' AND what='') LIMIT 7";
79         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='main' WHERE
80 action='stats' OR
81 action='extras' OR
82 action='rals' OR
83 action='account'";
84         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_admin_menu_las";
85         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_admin_menu_las_data";
86         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_admin_menu_stats";
87         break;
88
89 case "activate": // Do stuff when admin activates this extension
90         // SQL commands to run
91         $SQLs[] = "";
92         break;
93
94 case "deactivate": // Do stuff when admin deactivates this extension
95         // SQL commands to run
96         $SQLs[] = "";
97         break;
98
99 case "update": // Update an extension
100         switch ($EXT_VER)
101         {
102         case "0.0.1": // SQL queries for v0.0.1
103                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD ext_autopurge enum('Y', 'N') not null default 'Y'";
104                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_extensions', 'Erweitungsmanagement', 'Alle Einstellungen am Erweiterungsmanagement.', 10)";
105
106                 // Update notes (these will be set as task text!)
107                 $UPDATE_NOTES = "Es kann nun bestimmt werden, ob vom Server gel&ouml;schte ext-xxx.php erkannt werden sollen und die verkn&uuml;pften Daten auch aus der Datenbank entfernt werden sollen.";
108                 break;
109
110         case "0.0.2": // SQL queries for v0.0.2
111                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config CHANGE auto_purge auto_purge bigint(20) not null default '1209600'";
112
113                 // Update notes (these will be set as task text!)
114                 $UPDATE_NOTES = "In der Tabelle <STRONG>mxchange_config</STRONG> musste die Spalte <STRONG>auto_purge</STRONG> (autom. L&ouml;schen von Best&auml;tigungsmails angepasst werden (war auf dem Testsystem auf tiny(4) gesetzt.)";
115                 break;
116
117         case "0.0.3": // SQL queries for v0.0.3
118                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD points_word varchar(255) not null default 'Punkte'";
119
120                 // Update notes (these will be set as task text!)
121                 $UPDATE_NOTES = "Das Wort &quot;Punkte&quot; kann nun per Datenbank ge&auml;ndert werden. Damit k&ouml;nnen Sie anstelle des Wortes Punkte auch Klammlose oder &euro; schreiben.";
122                 break;
123
124         case "0.0.4": // SQL queries for v0.0.4
125                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD mails_page bigint(20) not null default '10'";
126
127                 // Update notes (these will be set as task text!)
128                 $UPDATE_NOTES = "Anzahl Mails pro Seite in <STRONG>EMail-Details ansehen</STRONG> und <STRONG>EMail-Archiv</STRONG> hinzugef&uuml;gt.";
129                 break;
130
131         case "0.0.5": // SQL queries for v0.0.5
132                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD index_home varchar(255) not null default 'welcome'";
133                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_home', 'Home-Seite festlegen', 'Stellen Sie hier ein, welcher Men&uuml;punkt (what-welcome ist Standart) als Einstiegspunkt in das Men&uuml;system genutzt werden soll.', 5)";
134
135                 // Update notes (these will be set as task text!)
136                 $UPDATE_NOTES = "Die what-welcome.php ist derzeit die &quot;Home&quot;-Seite (Eingangsseite). Dies kann nun per Datenbank ge&auml;ndert werden.";
137                 break;
138
139         case "0.0.6": // SQL queries for v0.0.6
140                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_extensions ADD ext_has_css enum('Y', 'N') not null default 'N'";
141
142                 // Update notes (these will be set as task text!)
143                 $UPDATE_NOTES = "Es k&ouml;nnen nun SQL-Updates von einander abh&auml;ngig gemacht werden und die CSS-Datei kann per Admin-Bereich (wegen Debuggings) ein- bzw. ausgeschaltet werden.";
144                 break;
145
146         case "0.0.7": // SQL queries for v0.0.7
147                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD verbose_sql enum('Y', 'N') not null default 'Y'";
148
149                 // Update notes (these will be set as task text!)
150                 $UPDATE_NOTES = "Die SQL-Anweisungen werden bei eingeschalteter Verbose-Funktion detailiert angezeigt.";
151                 break;
152
153         case "0.0.8": // SQL queries for v0.0.8
154                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD menu_blur_spacer varchar(255) not null default '&nbsp;<STRONG><BIG>&middot;</BIG></STRONG>&nbsp;'";
155
156                 // Update notes (these will be set as task text!)
157                 $UPDATE_NOTES = "Nette Mouse-Hover-Effekte eingebaut (Anleitung <STRONG>MENUE_HOVER.txt</STRONG> zum Patchen der general.css bitte lesen!)";
158                 break;
159
160         case "0.0.9": // SQL queries for v0.0.9
161                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('email', 'list_unconfirmed', 'Unbest. Mails auflisten', 'Schauen Sie sich hier unbest&auml;tigte Maillinks an. Bitte diesen Link nur &uuml;ber dem EMail-Archiv oder EMail-Details aufrufen, direkt aufgerufen bekommen Sie eine Fehlermeldung.', 8)";
162
163                 // Update notes (these will be set as task text!)
164                 $UPDATE_NOTES = "Unbest&auml;tigte Maillinks k&ouml;nnen unter Email-Management -&gt; Unbest. Mails auflisten aufgelistet werden.";
165                 break;
166
167         case "0.1.0": // SQL queries for v0.2.1
168                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD reg_points_mode enum('ref', 'direct') not null default 'ref'";
169
170                 // Update notes (these will be set as task text!)
171                 $UPDATE_NOTES = "Soll der einmalige Ref-Bonus &uuml;ber das Referral-System (also alle oberen Refs bekommen auch etwas davon ab) oder direkt dem Werber aufgebucht werden?";
172                 break;
173
174         case "0.1.1": // SQL queries for v0.1.1
175                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET title='Home-/Eingangsseite', descr='Stellen Sie hier ein, welcher Men&uuml;punkt (what-welcome ist Standart) als Einstiegspunkt in das Men&uuml;system genutzt werden soll und wie die automatische Weiterleitung in der Eingangsseite funktionieren soll.' WHERE what='config_home' LIMIT 1";
176                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD index_delay tinyint(4) not null default '-1'";
177                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD index_cookie bigint(20) not null default '31536000'";
178
179                 // Update notes (these will be set as task text!)
180                 $UPDATE_NOTES = "Sie k&ouml;nnen nun <A href=\"".URL."/modules.php?module=admin&amp;what=config_home\">hier</A> die Verz&ouml;gerungszeit in der <A href=\"".URL."/index.php\">Eingangsseite</A> einstellen.";
181                 break;
182
183         case "0.1.2": // SQL queries for v0.1.2
184                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_refid', 'Standart-Ref-ID', 'Stellen Sie hier die User-ID ein, die genommen werden soll, wenn der Gast n icht per Referral-Link Ihren Mailtausch aufgerufen hat.', 7)";
185                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD def_refid bigint(20) not null default '0'";
186
187                 // Update notes (these will be set as task text!)
188                 $UPDATE_NOTES = "Standart Referral-ID kann per Admin-Bereich eingestellt werden (war vorher nur in modules.php und index.php direkt eingebbar.)";
189                 break;
190
191         case "0.1.3": // SQL queries for v0.1.3
192                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD refid_target enum('register', 'index') not null default 'register'";
193
194                 // Update notes (these will be set as task text!)
195                 $UPDATE_NOTES = "Auf welche Seite soll der Ref-Link zeigen? Eingangsseite oder Anmeldeformular?";
196                 break;
197
198         case "0.1.4": // SQL queries for v0.1.4
199                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD default_theme varchar(255) not null default '".GET_CURR_THEME()."'";
200                 $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='theme' LIMIT 3";
201                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('theme', '', 'Themes', 'Verwalten Sie hier alle Designs (Themes) Ihres Mailtausch-Scriptes.', 8)";
202                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('theme', 'theme_import', 'Importieren', 'Es wird das Verzeichnis &quot;theme&quot; nach neuen Ordnern durchsucht und anschliessend in die Datenbank gesperrt aufgenommen.', 1)";
203                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('theme', 'theme_edit', 'Modifizieren', '&Auml;ndern Sie Titel, Freigaben usw. an den Themes. Sie k&ouml;nnen bis auf das Standart-Theme &quot;default&quot; auch Themes aus der Datenbank entfernen. Vorher sollten Sie es jedoch vom Server l&ouml;schen, damit es niht erneut importiert werden kann.', 2)";
204                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_guest_menu (action, what, title, sort, visible, locked) VALUES ('themes', '', 'Design-Auswahl', 4, 'Y', 'N')";
205                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('themes', '', 'Design-Auswahl', 3, 'Y', 'N')";
206                 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_themes";
207                 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_themes (
208 id bigint(20) not null auto_increment,
209 theme_path varchar(255) not null default '',
210 theme_active enum('Y', 'N') not null default 'N',
211 theme_ver varchar(255) not null default '0.0',
212 PRIMARY KEY(id)
213 ) TYPE=MyISAM";
214
215                 // Update notes (these will be set as task text!)
216                 $UPDATE_NOTES = "Theme-Support integriert. Bitte laden Sie sich zu dieser Version das <A href=\"http://www.mxchange.org\">281-Patch</A> (wenn Ihr Script v0.2.0-pre7 ist) herunter, da ansonsten die Themes nicht klappen werden!";
217                 break;
218
219         case "0.1.5": // SQL queries for v0.1.5
220                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_extensions DROP ext_has_admin";
221
222                 // Update notes (these will be set as task text!)
223                 $UPDATE_NOTES = "Spalte <U>ext_has_admin</U> aus der Tabelle <U>"._MYSQL_PREFIX."_extensions</U> entfernt, da sie keinen Sinn mehr macht.";
224                 break;
225
226         case "0.1.6": // SQL queries for v0.1.6
227                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD enable_title_deco enum('Y', 'N') not null default 'Y'";
228                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD title_left varchar(10) not null default '[--'";
229                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD title_middle varchar(10) not null default '-'";
230                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD title_right varchar(10) not null default '--]'";
231                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD enable_mod_title enum('Y', 'N') not null default 'Y'";
232                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD enable_what_title enum('Y', 'N') not null default 'Y'";
233                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_title', 'Seitentitel &auml;ndern', 'De-/aktivieren Sie hier die Dekorationen, sowie Modul-Titel und what-Titel im Seitentitel.', 8)";
234
235                 // Update notes (these will be set as task text!)
236                 $UPDATE_NOTES = "Dekorationen des Seitentiteles lassen sich ein- und ausschalten und selber definieren; Modul-Titel und Titel der <STRONG>what</STRONG>-Dateien kann hinzugef&uuml;gt werden.";
237                 break;
238
239         case "0.1.7": // SQL queries for v0.1.7
240                 // Update notes (these will be set as task text!)
241                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
242                 break;
243
244         case "0.1.8": // SQL queries for v0.1.8
245                 // Update notes (these will be set as task text!)
246                 $UPDATE_NOTES = "mad_counter und last_mad werden nun aus der Datenbank geladen";
247                 break;
248
249         case "0.1.9": // SQL queries for v0.1.9
250                 // Update notes (these will be set as task text!)
251                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
252                 break;
253
254         case "0.2.0": // SQL queries for v0.2.0
255                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_jackpot CHANGE points points double(22,5) not null default '0.00000'";
256
257                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_payments CHANGE payment payment double(22,5) not null default '0.00000'";
258                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_payments CHANGE price price double(22,5) not null default '0.00000'";
259
260                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data CHANGE used_points used_points double(22,5) not null default '0.00000'";
261                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_points CHANGE points points double(22,5) not null default '0.00000'";
262                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_points CHANGE locked_points locked_points double(22,5) not null default '0.00000'";
263
264                 // Update notes (these will be set as task text!)
265                 $UPDATE_NOTES = "5 Nachkommastellen implementiert";
266                 break;
267
268         case "0.2.1": // SQL queries for v0.2.1
269                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD css_php enum('DIRECT', 'FILE') not null default 'FILE'";
270
271                 // Update notes (these will be set as task text!)
272                 $UPDATE_NOTES = "Ausgabe der CSS-Dateien entweder per css.php oder sie sind direkt eingebunden.";
273                 break;
274
275         case "0.2.2": // SQL queries for v0.2.2
276                 // Update notes (these will be set as task text!)
277                 $UPDATE_NOTES = "Erweiterung bleibt wegen integrierten Schalters immer aktiv.";
278                 break;
279
280         case "0.2.3": // SQL queries for v0.2.3
281                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD guest_menu enum('Y', 'N') not null default 'Y'";
282                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD member_menu enum('Y', 'N') not null default 'Y'";
283                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD youre_here enum('Y', 'N') not null default 'Y'";
284
285                 // Update notes (these will be set as task text!)
286                 $UPDATE_NOTES = "Gast- und Mitgliedsmen&uuml;s lassen sich getrennt voneinander abschalten.";
287                 break;
288
289         case "0.2.4": // SQL queries for v0.2.4
290                 $auto_type = "png"; // PNG image is the default
291                 if ((file_exists(PATH."theme/".GET_CURR_THEME()."/images/code_bg.jpg")) && function_exists('imagecreatefromjpeg'))
292                 {
293                         // Switch to JPEG format
294                         $auto_type = "jpg";
295                 }
296                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD img_type enum('jpg', 'png') not null default '".$auto_type."'";
297
298                 // Update notes (these will be set as task text!)
299                 $UPDATE_NOTES = "Generierung des Mailbest&auml;tigungscodes h&auml;ngt davon ab, ob die PHP-Funktion <U>imagecreatefromjpeg()</U> und das JPEG-Bild vorhanden sind oder nicht.";
300                 break;
301
302         case "0.2.5": // SQL queries for v0.2.5
303                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data CHANGE receive_mails receive_mails bigint(20) not null default '0'";
304                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data CHANGE max_mails max_mails bigint(20) not null default '0'";
305
306                 // Update notes (these will be set as task text!)
307                 $UPDATE_NOTES = "Spalten <U>max_mails</U> und <U>receive_mails</U> auf bigint(20) gesetzt.";
308                 break;
309
310         case "0.2.6": // SQL queries for v0.2.6
311                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('user', 'sub_points', '{!POINTS!} abziehen', 'Allen oder einem Mitglied {!POINTS!} abziehen.', 8)";
312
313                 // Update notes (these will be set as task text!)
314                 $UPDATE_NOTES = "Abzug von {!POINTS!} nun m&ouml;glich.";
315                 break;
316
317         case "0.2.7": // SQL queries for v0.2.7
318                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort) VALUES ('main', 'themes', 'Designs', 6)";
319                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD curr_theme varchar(255) not null default 'default'";
320                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD stats_limit bigint(20) not null default '10'";
321                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET what='config_stats' WHERE what='stats' LIMIT 1";
322
323                 // Update notes (these will be set as task text!)
324                 $UPDATE_NOTES = "<OL>
325 <LI>Das Mitglied kann das derzeitige Design in sein Profil abspeichern.</LI>
326 <LI>Mitgliederstatistik mit Seitennavigation.</LI>
327 </OL>";
328                 break;
329
330         case "0.2.8": // SQL queries for v0.2.8
331                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD last_login varchar(10) not null default '0'";
332
333                 // Update notes (these will be set as task text!)
334                 $UPDATE_NOTES = "Letzter Login wird gespeichert, Cache wird bei installierter Cache-Erweiterung bei Sprachen&auml;nderung aufgefrischt.";
335                 break;
336
337         case "0.2.9": // SQL queries for v0.2.9
338                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD mt_word varchar(255) not null default 'Mailtausch'";
339                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD mt_word2 varchar(255) not null default 'Mailtausches'";
340                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD mt_word3 varchar(255) not null default 'Mailtauscher'";
341
342                 // Update notes (these will be set as task text!)
343                 $UPDATE_NOTES = "W&ouml;rter <STRONG>Mailtausch</STRONG>, <STRONG>Mailtausches</STRONG> und <STRONG>Mailtauscher</STRONG> sind austauschbar.";
344                 break;
345
346         case "0.3.0": // SQL queries for v0.3.0
347                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET title='{!POINTS!}/Referral-Ebenen' WHERE what='config_points' LIMIT 1";
348                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET title='Mailverg&uuml;tungen...' WHERE what='payments' LIMIT 1";
349
350                 // Update notes (these will be set as task text!)
351                 $UPDATE_NOTES = "Zwei Men&uuml;punkte umbenannt.";
352                 break;
353
354         case "0.3.1": // SQL queries for v0.3.1
355                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_extensions ADD UNIQUE KEY (ext_name)";
356                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_themes ADD UNIQUE KEY (theme_path)";
357                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_themes ADD INDEX (theme_active)";
358                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_admins ADD UNIQUE KEY (login)";
359                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD INDEX (status)";
360                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_refbanner ADD INDEX (visible)";
361                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_refdepths ADD UNIQUE KEY (level)";
362                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_refsystem ADD INDEX (level)";
363                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_pool ADD INDEX (data_type)";
364                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_mod_reg ADD UNIQUE KEY (module)";
365                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_admin_menu ADD INDEX (action)";
366                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_admin_menu ADD INDEX (what)";
367                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_task_system ADD INDEX (task_type)";
368                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_task_system ADD INDEX (status)";
369                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_task_system ADD INDEX (task_created)";
370                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_task_system ADD FULLTEXT (subject)";
371                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_task_system ADD INDEX (subject)";
372                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_extensions ADD INDEX (ext_active)";
373                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD INDEX (status)";
374                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD FULLTEXT (family)";
375                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD INDEX (max_mails)";
376                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD INDEX (password)";
377                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_guest_menu ADD INDEX (action)";
378                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_guest_menu ADD INDEX (what)";
379                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_guest_menu ADD INDEX (sort)";
380                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_guest_menu ADD INDEX (visible)";
381                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_guest_menu ADD INDEX (locked)";
382                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_member_menu ADD INDEX (what)";
383                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_member_menu ADD INDEX (sort)";
384                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_member_menu ADD INDEX (visible)";
385                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_member_menu ADD INDEX (locked)";
386                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_cats ADD INDEX (visible)";
387                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_cats ADD INDEX (sort)";
388
389                 // Update notes (these will be set as task text!)
390                 $UPDATE_NOTES = "Eindeutige Schl&uuml;ssel (UNIQUE KEY) und normale Schl&uuml;ssel (INDEX) gesetzt.";
391                 break;
392
393         case "0.3.2": // SQL queries for v0.3.2
394                 // Connection table between the menu system and the "logical area" system
395                 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_admin_menu_las";
396                 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_admin_menu_las (
397 id bigint(20) not null auto_increment,
398 la_id varchar(255) not null default '',
399 la_action varchar(255) not null default '',
400 la_what varchar(255) not null default '',
401 INDEX (la_id),
402 INDEX (la_action),
403 INDEX (la_what),
404 PRIMARY KEY(id)
405 ) TYPE=MyISAM";
406                 // All "logical areas" together
407                 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_admin_menu_las_data";
408                 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_admin_menu_las_data (
409 id bigint(20) not null auto_increment,
410 la_id varchar(255) not null default '',
411 la_title varchar(255) not null default '',
412 la_posx bigint(20) not null default '0',
413 la_posy bigint(20) not null default '0',
414 UNIQUE KEY (la_id),
415 INDEX (la_posx),
416 INDEX (la_posy),
417 PRIMARY KEY(id)
418 ) TYPE=MyISAM";
419                 // Which menu do you like?
420                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD admin_menu enum('NEW', 'OLD') not null default 'OLD'";
421
422                 // Insert menus
423                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_admin', 'Adminmen&uuml;', 'Diverse Einstellungen am Adminmen&uuml; vornehmen.', 9)";
424
425                 // Update notes (these will be set as task text!)
426                 $UPDATE_NOTES = "Logische Bereiche (Logical Areas = LAs) eingef&uuml;hrt. Dadurch wird das immer st&auml;rker anwachsende Admin-Men&uuml; in grosse Hauptgruppen unterteilt, wodurch ein Auffinden von Men&uuml;punkten verbessert wird.";
427                 break;
428
429         case "0.3.3": // SQL queries for v0.3.3
430                 // Switch of the "intelligent menu sorter" when you want to have a fixed menu structure...
431                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD admin_menu_sorter enum('Y', 'N') not null default 'Y'";
432
433                 // The statistics table
434                 $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_admin_menu_stats";
435                 $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_admin_menu_stats (
436 id bigint(20) not null auto_increment,
437 aid bigint(20) not null default '0',
438 type enum('la', 'action', 'what') not null default 'what',
439 clicks bigint(20) not null default '0',
440 INDEX (aid),
441 PRIMARY KEY (id)
442 ) TYPE=MyISAM";
443
444                 // Update notes (these will be set as task text!)
445                 $UPDATE_NOTES = "Admin-abh&auml;ngig werden nun Klicks im Admin-Men&uuml; gez&auml;hlt, die zur automatischen Anpassung des Men&uuml;s in den logischen Bereichen diennen. Dieses &quot;intelligente Unbauen&quot; k&ouml;nnen Sie auch ganz abschalten.";
446                 break;
447
448         case "0.3.4": // SQL queries for v0.3.4
449                 // List accounts with no referral
450                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('user', 'list_norefs', 'Mitglieder ohne Werber', 'Finden Sie hier alle Mitglieder-Accounts, die von niemandem ({--MAIN_TITLE--} wird in der Mail als Werber angegebenen) geworben wurden.', 7)";
451
452                 // Update notes (these will be set as task text!)
453                 $UPDATE_NOTES = "F&uuml;gt den Men&uuml;punkt &quot;Mitglieder ohne Werber&quot; in die Mitglieder-Management hinzu. Mit dieser neuen Funktion k&ouml;nnen Sie nach Mitglieder-Accounts ohne Werber suchen. TODO-ID #2 CLOSED";
454                 break;
455
456         case "0.3.5": // SQL queries for v0.3.5
457                 // List accounts with no referral
458                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('stats', '', 'Statistiken', 4, 'Y', 'N')";
459                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('stats', 'stats2', 'Framekiller-Mails', 2, 'Y', 'N')";
460                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('extras', '', 'Extras', 5, 'Y', 'N')";
461                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('rals', '', 'Rallyes', 6, 'Y', 'N')";
462                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, sort, visible, locked) VALUES ('account', '', 'Ihr Account', 7, 'Y', 'N')";
463                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET sort='8' WHERE action='themes' LIMIT 1";
464                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='stats', sort='1', title='Klick-Mails' WHERE what='stats' LIMIT 1";
465                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='account', sort='1', title='Designs' WHERE what='themes' LIMIT 1";
466                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='extras', sort='3' WHERE what='reflinks' LIMIT 1";
467
468                 // Update notes (these will be set as task text!)
469                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett umgebaut.";
470                 break;
471
472         case "0.3.6": // SQL queries for v0.3.6
473                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD salt_length tinyint(4) not null default '9'";
474                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD pass_scramble varchar(255) not null default ''";
475                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data MODIFY password varchar(255) not null default ''";
476                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data MODIFY user_hash varchar(255) not null default ''";
477                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_admins MODIFY password varchar(255) not null default ''";
478                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD rand_no bigint(20) not null default '0'";
479                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD file_hash varchar(255) not null default ''";
480                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD master_salt varchar(255) not null default ''";
481                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_config SET rand_no=(ROUND(RAND() * 99999) + 100000) WHERE config=0 LIMIT 1";
482                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_mod_reg ADD has_menu enum('Y', 'N') NOT NULL default 'N'";
483                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_mod_reg SET has_menu='Y' WHERE module='admin' OR module='index' OR module='login' LIMIT 3";
484
485                 // Update notes (these will be set as task text!)
486                 $UPDATE_NOTES = "Passwort-System mit Zufallshash erweitert (Schutzt gegen Dictionary-Attacks!)";
487                 break;
488
489         case "0.3.7": // SQL queries for v0.3.7
490                 $UPDATE_NOTES = "Problem w&auml;hrend des Installationsvorganges behoben.";
491                 break;
492
493         case "0.3.8": // SQL queries for v0.3.8
494                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_admin_menu CHANGE descr descr MEDIUMTEXT NULL";
495                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_pool CHANGE `text` `text` LONGTEXT NOT NULL";
496
497                 // Update notes (these will be set as task text!)
498                 $UPDATE_NOTES = "Beschreibungstexte f&uuml;r Admin-Men&uuml;s k&ouml;nnen l&auml;nger sein. Diverse Fixes.";
499                 break;
500
501         case "0.3.9": // SQL queries for v0.3.9
502                 $SQLs[] = "UPDATE  "._MYSQL_PREFIX."_admin_menu SET title = REPLACE(title, '--POINTS--', '!POINTS!') WHERE title LIKE '%--POINTS--%'";
503                 $SQLs[] = "UPDATE  "._MYSQL_PREFIX."_admin_menu SET descr = REPLACE(descr, '--POINTS--', '!POINTS!') WHERE descr LIKE '%--POINTS--%'";
504                 $SQLs[] = "UPDATE  "._MYSQL_PREFIX."_guest_menu SET title = REPLACE(title, '--POINTS--', '!POINTS!') WHERE title LIKE '%--POINTS--%'";
505                 $SQLs[] = "UPDATE  "._MYSQL_PREFIX."_member_menu SET title = REPLACE(title, '--POINTS--', '!POINTS!') WHERE title LIKE '%--POINTS--%'";
506
507                 // Update notes (these will be set as task text!)
508                 $UPDATE_NOTES = "Beschreibungstexte f&uuml;r Admin-Men&uuml;s k&ouml;nnen l&auml;nger sein. Diverse Fixes.";
509                 break;
510
511         case "0.4.0": // SQL queries for v0.4.0
512                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_admin_menu SET title = 'Email-Management' WHERE action = 'email' AND what='' LIMIT 1";
513
514                 // Update notes (these will be set as task text!)
515                 $UPDATE_NOTES = "Email-Verwaltung nach Email-Management umbenannt.";
516                 break;
517
518         case "0.4.1": // SQL queries for v0.4.1
519                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_user_data` DROP INDEX `status` , ADD INDEX `status` ( `status` , `max_mails` )";
520                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `show_timings` ENUM ('Y','N') NOT NULL DEFAULT 'Y'";
521
522                 // Update notes (these will be set as task text!)
523                 $UPDATE_NOTES = "Tabellen-Schl&uuml;ssel neu gesetzt und Parsing-Zeit im Footer eingeblendet.";
524                 break;
525
526         case "0.4.2": // SQL queries for v0.4.2
527                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_online` ADD INDEX `admin_member` (`is_admin`, `is_member`)";
528                 break;
529
530         case "0.4.3": // SQL queries for v0.4.3
531                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `proxy_host` VARCHAR(255) NOT NULL DEFAULT ''";
532                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `proxy_port` INT(5) NOT NULL DEFAULT '0'";
533                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `proxy_username` VARCHAR(255) NOT NULL DEFAULT ''";
534                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `proxy_password` VARCHAR(255) NOT NULL DEFAULT ''";
535                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('setup', 'config_proxy', 'Proxy-Einstellungen', 'Sollte Ihr Webserver sich hinter einem Proxy befinden, so k&ouml;nnen Sie hier MXChange so konfigurieren, dass es Updates durch diesen hindurch sucht!', 15)";
536                 break;
537         }
538         break;
539
540 default: // Do stuff when extension is loaded
541         $dummy = LOAD_CONFIG();
542
543         // When the sql_patches is not installed we cannot load it's configuration... *sigh*
544         if (GET_EXT_VERSION("sql_patches") != '') {
545                 $_CONFIG['secret_key']        = "";
546                 //die("<pre>".print_r($dummy, true)."</pre>");
547                 $_CONFIG = array_merge($_CONFIG, $dummy);
548
549                 // Read key from secret file
550                 if ((empty($_CONFIG['file_hash'])) || (empty($_CONFIG['master_salt'])) || (empty($_CONFIG['pass_scramble']))) {
551                         // Maybe need setup of secret key!
552                         require_once(PATH."inc/gen_sql_patches.php");
553
554                         if (GET_EXT_VERSION("cache") >= "0.1.2") {
555                                 // Remove extensions and mod_reg cache file
556                                 require_once(PATH."inc/libs/cache_functions.php");
557                                 require_once(PATH."inc/extensions/ext-cache.php");
558                                 if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
559                                 if ($cacheInstance->cache_file("mod_reg", true)) $cacheInstance->cache_destroy();
560                         }
561                 }
562
563                 // Test again
564                 if ((!empty($_CONFIG['file_hash'])) && (!empty($_CONFIG['master_salt'])) && (!empty($_CONFIG['pass_scramble']))) {
565                         // File hash fas generated so we can also file the secret file... hopefully.
566                         if ((file_exists(PATH."inc/.secret/.".$_CONFIG['file_hash'])) && (is_readable(PATH."inc/.secret/.".$_CONFIG['file_hash']))) {
567                                 $_CONFIG['secret_key'] = implode("", file(PATH."inc/.secret/.".$_CONFIG['file_hash']));
568                         } else {
569                                 // Cannot read secret file!
570                                 mxchange_die("Cannot read secret file!");
571                         }
572                 }
573
574                 // Transfer words/numbers to constants
575                 define('POINTS'  , $dummy['points_word']);
576                 define('MT_WORD' , $dummy['mt_word']);
577                 define('MT_WORD2', $dummy['mt_word2']);
578                 define('MT_WORD3', $dummy['mt_word3']);
579                 define('_MAX'    , $dummy['rand_no']);
580         } else {
581                 // Set some lame ;-) default settings
582                 $_CONFIG['def_refid'] = 0;
583                 $_CONFIG['enable_title_deco'] = 'N';
584                 $_CONFIG['title_mod_show']    = 'Y';
585                 $_CONFIG['title_middle']      = "-";
586                 //$_CONFIG['verbose_sql']       = 'N';
587                 define('MT_WORD' , DEFAULT_MT_WORD );
588                 define('MT_WORD2', DEFAULT_MT_WORD2);
589                 define('POINTS'  , DEFAULT_POINTS);
590         }
591
592         // Remove dummy config array
593         unset($dummy);
594         break;
595 }
596
597 // Language file prefix (hmmm, what shall I write with SQL fixes? ;-) )
598 $EXT_LANG_PREFIX = "sql_patches";
599
600 // Extension is always active?
601 $EXT_ALWAYS_ACTIVE = 'Y';
602
603 //
604 ?>