Several minor rewrites, getter GET_JACKPOT_POINTS() added
[mailer.git] / inc / extensions / ext-sql_patches.php
index ecb7ec650d754ee35f7aa86b4dd7f9381ae0dbeb..8cfef71939303ba7310a07d1a40aac3696990c90 100644 (file)
@@ -48,8 +48,7 @@ EXT_SET_VERSION('0.6.3');
 // Version history array (add more with , '0.1.0' and so on)
 EXT_SET_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', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3'));
 
-switch ($EXT_LOAD_MODE)
-{
+switch ($EXT_LOAD_MODE) {
        case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
                // SQL commands to run
                ADD_EXT_SQL('');
@@ -131,10 +130,9 @@ switch ($EXT_LOAD_MODE)
                break;
 
        case 'update': // Update an extension
-               switch ($EXT_VER)
-               {
+               switch ($EXT_VER) {
                        case '0.0.1': // SQL queries for v0.0.1
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD ext_autopurge ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `ext_autopurge` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
                                ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('setup','config_extensions','Erweitungsmanagement','Alle Einstellungen am Erweiterungsmanagement.', 10)");
 
                                // Update notes (these will be set as task text!)
@@ -142,28 +140,28 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.0.2': // SQL queries for v0.0.2
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` CHANGE auto_purge auto_purge BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*14)."");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` CHANGE `auto_purge` `auto_purge` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*14)."");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("In der Tabelle <strong>{!_MYSQL_PREFIX!}_config</strong> musste die Spalte <strong>auto_purge</strong> (autom. L&ouml;schen von Best&auml;tigungsmails angepasst werden (war auf dem Testsystem auf TINYINT(4) gesetzt.)");
                                break;
 
                        case '0.0.3': // SQL queries for v0.0.3
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD points_word VARCHAR(255) NOT NULL DEFAULT 'Punkte'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `points_word` VARCHAR(255) NOT NULL DEFAULT 'Punkte'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_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.");
                                break;
 
                        case '0.0.4': // SQL queries for v0.0.4
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD mails_page BIGINT(20) UNSIGNED NOT NULL DEFAULT 10");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `mails_page` BIGINT(20) UNSIGNED NOT NULL DEFAULT 10");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Anzahl Mails pro Seite in <strong>EMail-Details ansehen</strong> und <strong>EMail-Archiv</strong> hinzugef&uuml;gt.");
                                break;
 
                        case '0.0.5': // SQL queries for v0.0.5
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD index_home VARCHAR(255) NOT NULL DEFAULT 'welcome'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `index_home` VARCHAR(255) NOT NULL DEFAULT 'welcome'");
                                ADD_EXT_SQL("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)");
 
                                // Update notes (these will be set as task text!)
@@ -171,21 +169,21 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.0.6': // SQL queries for v0.0.6
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_extensions` ADD ext_has_css ENUM('Y','N') NOT NULL DEFAULT 'N'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_extensions` ADD `ext_has_css` ENUM('Y','N') NOT NULL DEFAULT 'N'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_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.");
                                break;
 
                        case '0.0.7': // SQL queries for v0.0.7
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD verbose_sql ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `verbose_sql` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Die SQL-Anweisungen werden bei eingeschalteter Verbose-Funktion detailiert angezeigt.");
                                break;
 
                        case '0.0.8': // SQL queries for v0.0.8
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD menu_blur_spacer VARCHAR(255) NOT NULL DEFAULT '&nbsp;<strong><big>&middot;</big></strong>&nbsp;'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `menu_blur_spacer` VARCHAR(255) NOT NULL DEFAULT '&nbsp;<strong><big>&middot;</big></strong>&nbsp;'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Nette Mouse-Hover-Effekte eingebaut (Anleitung <strong>MENUE_HOVER.txt</strong> zum Patchen der general.css bitte lesen!)");
@@ -199,7 +197,7 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.1.0': // SQL queries for v0.2.1
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD reg_points_mode ENUM('ref','direct') NOT NULL DEFAULT 'ref'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `reg_points_mode` ENUM('ref','direct') NOT NULL DEFAULT 'ref'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Soll der einmalige Ref-Bonus &uuml;ber das Referal-System (also alle oberen Refs bekommen auch etwas davon ab) oder direkt dem Werber aufgebucht werden?");
@@ -207,8 +205,8 @@ switch ($EXT_LOAD_MODE)
 
                        case '0.1.1': // SQL queries for v0.1.1
                                ADD_EXT_SQL("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");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD index_delay TINYINT(3) UNSIGNED NOT NULL DEFAULT 0");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD index_cookie BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*365)."");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `index_delay` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `index_cookie` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*365)."");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_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.");
@@ -216,7 +214,7 @@ switch ($EXT_LOAD_MODE)
 
                        case '0.1.2': // SQL queries for v0.1.2
                                ADD_EXT_SQL("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 Referal-Link Ihren Mailtausch aufgerufen hat.', 7)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD def_refid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `def_refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Standart Referal-ID kann per Admin-Bereich eingestellt werden (war vorher nur in modules.php und index.php direkt eingebbar.)");
@@ -242,12 +240,12 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.1.6': // SQL queries for v0.1.6
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD enable_title_deco ENUM('Y','N') NOT NULL DEFAULT 'Y'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD title_left VARCHAR(10) NOT NULL DEFAULT '[--'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD title_middle VARCHAR(10) NOT NULL DEFAULT '-'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD title_right VARCHAR(10) NOT NULL DEFAULT '--]'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD enable_mod_title ENUM('Y','N') NOT NULL DEFAULT 'Y'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD enable_what_title ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `enable_title_deco` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `title_left` VARCHAR(10) NOT NULL DEFAULT '[--'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `title_middle` VARCHAR(10) NOT NULL DEFAULT '-'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `title_right` VARCHAR(10) NOT NULL DEFAULT '--]'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `enable_mod_title` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `enable_what_title` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
                                ADD_EXT_SQL("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)");
 
                                // Update notes (these will be set as task text!)
@@ -270,17 +268,17 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.2.0': // SQL queries for v0.2.0
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_jackpot` CHANGE points points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_jackpot` CHANGE `points` `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
 
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_payments` CHANGE payment payment FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_payments` CHANGE price price FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_payments` CHANGE `payment` `payment` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_payments` CHANGE `price` `price` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("5 Nachkommastellen implementiert");
                                break;
 
                        case '0.2.1': // SQL queries for v0.2.1
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD css_php ENUM('DIRECT','FILE') NOT NULL DEFAULT 'FILE'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `css_php` ENUM('DIRECT','FILE') NOT NULL DEFAULT 'FILE'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Ausgabe der CSS-Dateien entweder per css.php oder sie sind direkt eingebunden.");
@@ -292,9 +290,9 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.2.3': // SQL queries for v0.2.3
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD guest_menu ENUM('Y','N') NOT NULL DEFAULT 'Y'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD member_menu ENUM('Y','N') NOT NULL DEFAULT 'Y'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD youre_here ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `guest_menu` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `member_menu` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `youre_here` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Gast- und Mitgliedsmen&uuml;s lassen sich getrennt voneinander abschalten.");
@@ -306,7 +304,7 @@ switch ($EXT_LOAD_MODE)
                                        // Switch to JPEG format
                                        $auto_type = 'jpg';
                                }
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD img_type ENUM('jpg','png') NOT NULL DEFAULT '".$auto_type."'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `img_type` ENUM('jpg','png') NOT NULL DEFAULT '".$auto_type."'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_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.");
@@ -325,7 +323,7 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.2.7': // SQL queries for v0.2.7
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD stats_limit BIGINT(20) UNSIGNED NOT NULL DEFAULT 10");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `stats_limit` BIGINT(20) UNSIGNED NOT NULL DEFAULT 10");
                                ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_admin_menu` SET `what`='config_stats' WHERE `what`='stats' LIMIT 1");
 
                                // Update notes (these will be set as task text!)
@@ -341,9 +339,9 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.2.9': // SQL queries for v0.2.9
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD mt_word VARCHAR(255) NOT NULL DEFAULT 'Mailtausch'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD mt_word2 VARCHAR(255) NOT NULL DEFAULT 'Mailtausches'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD mt_word3 VARCHAR(255) NOT NULL DEFAULT 'Mailtauscher'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `mt_word` VARCHAR(255) NOT NULL DEFAULT 'Mailtausch'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `mt_word2` VARCHAR(255) NOT NULL DEFAULT 'Mailtausches'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `mt_word3` VARCHAR(255) NOT NULL DEFAULT 'Mailtauscher'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("W&ouml;rter <strong>Mailtausch</strong>, <strong>Mailtausches</strong> und <strong>Mailtauscher</strong> sind austauschbar.");
@@ -358,32 +356,32 @@ switch ($EXT_LOAD_MODE)
                                break;
 
                        case '0.3.1': // SQL queries for v0.3.1
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_extensions` ADD UNIQUE KEY (ext_name)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` ADD UNIQUE KEY (login)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_refbanner` ADD INDEX (visible)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_refdepths` ADD UNIQUE KEY (level)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_refsystem` ADD INDEX (level)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_pool` ADD INDEX (data_type)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_mod_reg` ADD UNIQUE KEY (module)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admin_menu` ADD INDEX (action)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admin_menu` ADD INDEX (what)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (task_type)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (status)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (task_created)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD FULLTEXT (subject)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (subject)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_extensions` ADD INDEX (ext_active)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (action)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (what)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (sort)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (visible)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (locked)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (what)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (sort)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (visible)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (locked)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_cats` ADD INDEX (visible)");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_cats` ADD INDEX (sort)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_extensions` ADD UNIQUE KEY (`ext_name`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` ADD UNIQUE KEY (`login`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_refbanner` ADD INDEX (`visible`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_refdepths` ADD UNIQUE KEY (`level`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_refsystem` ADD INDEX (`level`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_pool` ADD INDEX (`data_type`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_mod_reg` ADD UNIQUE KEY (`module`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admin_menu` ADD INDEX (`action`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admin_menu` ADD INDEX (`what`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (`task_type`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (`status`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (`task_created`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD FULLTEXT (`subject`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (`subject`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_extensions` ADD INDEX (`ext_active`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (`action`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (`what`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (`sort`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (`visible`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_guest_menu` ADD INDEX (`locked`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (`what`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (`sort`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (`visible`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_member_menu` ADD INDEX (`locked`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_cats` ADD INDEX (`visible`)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_cats` ADD INDEX (`sort`)");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Eindeutige Schl&uuml;ssel (UNIQUE KEY) und normale Schl&uuml;ssel (INDEX) gesetzt.");
@@ -393,30 +391,30 @@ switch ($EXT_LOAD_MODE)
                                // Connection table between the menu system and the "logical area" system
                                ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_admin_menu_las`");
                                ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_admin_menu_las` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-la_id VARCHAR(255) NOT NULL DEFAULT '',
-la_action VARCHAR(255) NOT NULL DEFAULT '',
-la_what VARCHAR(255) NOT NULL DEFAULT '',
-INDEX (la_id),
-INDEX (la_action),
-INDEX (la_what),
-PRIMARY KEY(id)
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`la_id` VARCHAR(255) NOT NULL DEFAULT '',
+`la_action` VARCHAR(255) NOT NULL DEFAULT '',
+`la_what` VARCHAR(255) NOT NULL DEFAULT '',
+INDEX (`la_id`),
+INDEX (`la_action`),
+INDEX (`la_what`),
+PRIMARY KEY(`id`)
 ) TYPE={!_TABLE_TYPE!}");
                                // All "logical areas" together
                                ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_admin_menu_las_data`");
                                ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_admin_menu_las_data` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-la_id VARCHAR(255) NOT NULL DEFAULT '',
-la_title VARCHAR(255) NOT NULL DEFAULT '',
-la_posx BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-la_posy BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-UNIQUE KEY (la_id),
-INDEX (la_posx),
-INDEX (la_posy),
-PRIMARY KEY(id)
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`la_id` VARCHAR(255) NOT NULL DEFAULT '',
+`la_title` VARCHAR(255) NOT NULL DEFAULT '',
+`la_posx` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`la_posy` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+UNIQUE KEY (`la_id`),
+INDEX (`la_posx`),
+INDEX (`la_posy`),
+PRIMARY KEY(`id`)
 ) TYPE={!_TABLE_TYPE!}");
                                // Which menu do you like?
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD admin_menu ENUM('NEW','OLD') NOT NULL DEFAULT 'OLD'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `admin_menu` ENUM('NEW','OLD') NOT NULL DEFAULT 'OLD'");
 
                                // Insert menus
                                ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('setup','config_admin','Adminmen&uuml;','Diverse Einstellungen am Adminmen&uuml; vornehmen.', 9)");
@@ -427,17 +425,17 @@ PRIMARY KEY(id)
 
                        case '0.3.3': // SQL queries for v0.3.3
                                // Switch of the "intelligent menu sorter" when you want to have a fixed menu structure...
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD admin_menu_sorter ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `admin_menu_sorter` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
 
                                // The statistics table
                                ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_admin_menu_stats`");
                                ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_admin_menu_stats` (
-id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-aid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-type ENUM('la','action','what') NOT NULL DEFAULT 'what',
-clicks BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-INDEX (aid),
-PRIMARY KEY (id)
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`aid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`type` ENUM('la','action','what') NOT NULL DEFAULT 'what',
+`clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+INDEX (`aid`),
+PRIMARY KEY (`id`)
 ) TYPE={!_TABLE_TYPE!}");
 
                                // Update notes (these will be set as task text!)
@@ -464,15 +462,15 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.3.6': // SQL queries for v0.3.6
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD salt_length TINYINT(3) UNSIGNED NOT NULL DEFAULT '9'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD pass_scramble VARCHAR(255) NOT NULL DEFAULT ''");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` MODIFY password VARCHAR(255) NOT NULL DEFAULT ''");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD rand_no BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD file_hash VARCHAR(255) NOT NULL DEFAULT ''");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD master_salt VARCHAR(255) NOT NULL DEFAULT ''");
-                               ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_config` SET rand_no=(ROUND(RAND() * 99999) + 100000) WHERE config=0 LIMIT 1");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_mod_reg` ADD has_menu ENUM('Y','N') NOT NULL DEFAULT 'N'");
-                               ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET has_menu='Y' WHERE `module`='admin' OR `module`='index' OR `module`='login' LIMIT 3");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `salt_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT '9'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `pass_scramble` VARCHAR(255) NOT NULL DEFAULT ''");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` MODIFY `password` VARCHAR(255) NOT NULL DEFAULT ''");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `rand_no` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `file_hash` VARCHAR(255) NOT NULL DEFAULT ''");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `master_salt` VARCHAR(255) NOT NULL DEFAULT ''");
+                               ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_config` SET `rand_no`=(ROUND(RAND() * 99999) + 100000) WHERE `config`=0 LIMIT 1");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_mod_reg` ADD `has_menu` ENUM('Y','N') NOT NULL DEFAULT 'N'");
+                               ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `has_menu`='Y' WHERE `module`='admin' OR `module`='index' OR `module`='login' LIMIT 3");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Passwort-System mit Zufallshash erweitert (Schutzt gegen Dictionary-Attacks!)");
@@ -483,7 +481,7 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.3.8': // SQL queries for v0.3.8
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admin_menu` CHANGE descr descr MEDIUMTEXT NULL");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admin_menu` CHANGE `descr` `descr` MEDIUMTEXT NULL");
                                ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_pool` CHANGE `text` `text` LONGTEXT NOT NULL");
 
                                // Update notes (these will be set as task text!)
@@ -491,17 +489,20 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.3.9': // SQL queries for v0.3.9
-                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_admin_menu` SET title = REPLACE(title, '--POINTS--','!POINTS!') WHERE title LIKE '%--POINTS--%'");
-                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_admin_menu` SET descr = REPLACE(descr, '--POINTS--','!POINTS!') WHERE descr LIKE '%--POINTS--%'");
-                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_guest_menu` SET title = REPLACE(title, '--POINTS--','!POINTS!') WHERE title LIKE '%--POINTS--%'");
-                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_member_menu` SET title = REPLACE(title, '--POINTS--','!POINTS!') WHERE title LIKE '%--POINTS--%'");
+                               /**
+                                * Obsolete update
+                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_admin_menu` SET `title` = REPLACE(`title`, '--POINTS--','!POINTS!') WHERE `title` LIKE '%--POINTS--%'");
+                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_admin_menu` SET `descr` = REPLACE(`descr`, '--POINTS--','!POINTS!') WHERE `descr` LIKE '%--POINTS--%'");
+                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_guest_menu` SET `title` = REPLACE(`title`, '--POINTS--','!POINTS!') WHERE `title` LIKE '%--POINTS--%'");
+                               ADD_EXT_SQL("UPDATE  `{!_MYSQL_PREFIX!}_member_menu` SET `title` = REPLACE(`title`, '--POINTS--','!POINTS!') WHERE `title` LIKE '%--POINTS--%'");
+                               */
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Beschreibungstexte f&uuml;r Admin-Men&uuml;s k&ouml;nnen l&auml;nger sein. Diverse Fixes.");
                                break;
 
                        case '0.4.0': // SQL queries for v0.4.0
-                               ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_admin_menu` SET title = 'Email-Management' WHERE action = 'email' AND (`what`='' OR `what` IS NULL) LIMIT 1");
+                               ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_admin_menu` SET `title` = 'Email-Management' WHERE `action` = 'email' AND (`what`='' OR `what` IS NULL) LIMIT 1");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Email-Verwaltung nach Email-Management umbenannt.");
@@ -550,8 +551,8 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.4.5': // SQL queries for v0.4.5
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD last_month CHAR(2) NOT NULL DEFAULT '00'");
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD last_week CHAR(2) NOT NULL DEFAULT '00'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `last_month` CHAR(2) NOT NULL DEFAULT '00'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `last_week` CHAR(2) NOT NULL DEFAULT '00'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("T&auml;glichen/w&ouml;chentlichen/monatlichen Reset verbessert.");
@@ -568,7 +569,7 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.4.8': // SQL queries for v0.4.8
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (subject)");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_task_system` ADD INDEX (`subject`)");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Index f&uuml;r Betreff eingef&uuml;gt.");
@@ -603,7 +604,7 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.5.3': // SQL queries for v0.5.3
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD session_save_path VARCHAR(255) NOT NULL DEFAULT ''");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `session_save_path` VARCHAR(255) NOT NULL DEFAULT ''");
                                ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('setup','config_session','Session-Einstellungen','&Auml;ndern Sie hier den Speicherpfad f&uuml;r Sessiondateien (Sitzungsdateien) ab, falls die Standart-Einstellung bei Ihrem Hoster zu Problem f&uuml;hren sollte.', 16)");
 
                                // Update notes (these will be set as task text!)
@@ -621,7 +622,7 @@ PRIMARY KEY (id)
                                break;
 
                        case '0.5.5': // SQL queries for v0.5.5
-                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD show_points_unconfirmed ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `show_points_unconfirmed` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
 
                                // Update notes (these will be set as task text!)
                                EXT_SET_UPDATE_NOTES("Anzeige der {!POINTS!} unter den unbest&auml;tigten Mails kann nun optional abgeschaltet werden.");
@@ -689,73 +690,73 @@ PRIMARY KEY (`filter_id`)
                                // Include special filte
                                loadIncludeOnce('inc/fix_filters.php');
                                break;
-               }
+               } // END - switch
+               break;
+
+       case 'modify': // When the extension got modified
+               break;
+
+       case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
                break;
 
-                       case 'modify': // When the extension got modified
-                               break;
-
-                       case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
-                               break;
-
-                       default: // Do stuff when extension is loaded
-                               // When the sql_patches is not installed we cannot load it's configuration... *sigh*
-                               if (GET_EXT_VERSION('sql_patches') != '') {
-                                       // Init key
-                                       setConfigEntry('secret_key', '');
-
-                                       // Read key from secret file
-                                       if ((getConfig('file_hash') == '') || (getConfig('master_salt') == '') || (getConfig('pass_scramble') == '')) {
-                                               // Cache instance
-                                               // Maybe need setup of secret key!
-                                               loadIncludeOnce('inc/gen_sql_patches.php');
-
-                                               // @TODO Rewrite this to a filter!
-                                               if ((GET_EXT_VERSION('cache') >= '0.1.2') && (isCacheInstanceValid())) {
-                                                       // Remove extensions and mod_reg cache file
-                                                       loadIncludeOnce('inc/libs/cache_functions.php');
-                                                       require(sprintf("%sinc/extensions/ext-cache.php", constant('PATH')));
-                                                       if ($GLOBALS['cache_instance']->loadCacheFile("extensions", true)) $GLOBALS['cache_instance']->destroyCacheFile();
-                                                       if ($GLOBALS['cache_instance']->loadCacheFile("modreg"))           $GLOBALS['cache_instance']->destroyCacheFile();
-                                               } // END - if
-                                       } // END - if
-
-                                       // Test again
-                                       if ((getConfig('file_hash') != '') && (getConfig('master_salt') != '') && (getConfig('pass_scramble') != '')) {
-                                               // File hash fas generated so we can also file the secret file... hopefully.
-                                               $hashFile = sprintf("%sinc/.secret/.%s", constant('PATH'), getConfig('file_hash'));
-                                               if (isFileReadable($hashFile)) {
-                                                       // Read file
-                                                       setConfigEntry('secret_key', readFromFile($hashFile));
-                                               } else {
-                                                       // Remove it from database
-                                                       updateConfiguration('file_hash', '');
-
-                                                       // Cannot read secret file!
-                                                       app_die(__FILE__, __LINE__, "Cannot read secret file! Please try to reload");
-                                               }
-                                       } // END - if
-
-                                       // Transfer words/numbers to constants
-                                       define('POINTS'  , getConfig('points_word'));
-                                       define('MT_WORD' , getConfig('mt_word'));
-                                       define('MT_WORD2', getConfig('mt_word2'));
-                                       define('MT_WORD3', getConfig('mt_word3'));
-                                       define('_MAX'    , getConfig('rand_no'));
+       default: // Do stuff when extension is loaded
+               // When the sql_patches is not installed we cannot load it's configuration... *sigh*
+               if (GET_EXT_VERSION('sql_patches') != '') {
+                       // Init key
+                       setConfigEntry('secret_key', '');
+
+                       // Read key from secret file
+                       if ((getConfig('file_hash') == '') || (getConfig('master_salt') == '') || (getConfig('pass_scramble') == '')) {
+                               // Cache instance
+                               // Maybe need setup of secret key!
+                               loadIncludeOnce('inc/gen_sql_patches.php');
+
+                               // @TODO Rewrite this to a filter!
+                               if ((GET_EXT_VERSION('cache') >= '0.1.2') && (isCacheInstanceValid())) {
+                                       // Remove extensions and mod_reg cache file
+                                       loadIncludeOnce('inc/libs/cache_functions.php');
+                                       require(sprintf("%sinc/extensions/ext-cache.php", constant('PATH')));
+                                       if ($GLOBALS['cache_instance']->loadCacheFile('extensions', true)) $GLOBALS['cache_instance']->destroyCacheFile();
+                                       if ($GLOBALS['cache_instance']->loadCacheFile('modreg'))           $GLOBALS['cache_instance']->destroyCacheFile();
+                               } // END - if
+                       } // END - if
+
+                       // Test again
+                       if ((getConfig('file_hash') != '') && (getConfig('master_salt') != '') && (getConfig('pass_scramble') != '')) {
+                               // File hash fas generated so we can also file the secret file... hopefully.
+                               $hashFile = sprintf("%sinc/.secret/.%s", constant('PATH'), getConfig('file_hash'));
+                               if (isFileReadable($hashFile)) {
+                                       // Read file
+                                       setConfigEntry('secret_key', readFromFile($hashFile));
                                } else {
-                                       // Set some lame ( ;-) ) default settings
-                                       setConfigEntry('def_refid'        , 0);
-                                       setConfigEntry('enable_title_deco', 'N');
-                                       setConfigEntry('title_mod_show'   , 'Y');
-                                       setConfigEntry('title_middle'     , '-');
-                                       // @TODO Can we remove this? setConfigEntry('verbose_sql'        , 'N');
-                                       define('MT_WORD' , getMessage('DEFAULT_MT_WORD'));
-                                       define('MT_WORD2', getMessage('DEFAULT_MT_WORD2'));
-                                       define('MT_WORD3', getMessage('DEFAULT_MT_WORD3'));
-                                       define('POINTS'  , getMessage('DEFAULT_POINTS'));
+                                       // Remove it from database
+                                       updateConfiguration('file_hash', '');
+
+                                       // Cannot read secret file!
+                                       app_die(__FILE__, __LINE__, "Cannot read secret file! Please try to reload");
                                }
-                               break;
-}
+                       } // END - if
+
+                       // Transfer words/numbers to constants
+                       define('POINTS'  , getConfig('points_word'));
+                       define('MT_WORD' , getConfig('mt_word'));
+                       define('MT_WORD2', getConfig('mt_word2'));
+                       define('MT_WORD3', getConfig('mt_word3'));
+                       define('_MAX'    , getConfig('rand_no'));
+               } else {
+                       // Set some lame ( ;-) ) default settings
+                       setConfigEntry('def_refid'        , 0);
+                       setConfigEntry('enable_title_deco', 'N');
+                       setConfigEntry('title_mod_show'   , 'Y');
+                       setConfigEntry('title_middle'     , '-');
+                       // @TODO Can we remove this? setConfigEntry('verbose_sql'        , 'N');
+                       define('MT_WORD' , getMessage('DEFAULT_MT_WORD'));
+                       define('MT_WORD2', getMessage('DEFAULT_MT_WORD2'));
+                       define('MT_WORD3', getMessage('DEFAULT_MT_WORD3'));
+                       define('POINTS'  , getMessage('DEFAULT_POINTS'));
+               }
+               break;
+} // END - switch
 
 // Keep this extension always active!
 EXT_SET_ALWAYS_ACTIVE('Y');