ae191d87aabffa72a12f98cdb22040b07d02ff14
[mailer.git] / inc / extensions / ext-debug.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/12/2008 *
4  * ================                             Last change: 10/12/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-debug.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Extension for sending/receiving debug requests   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Erweiterung zum Versenden/Empfangen von Debug-Q. *
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 (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Version number
41 EXT_SET_VERSION("0.0");
42
43 // Version history array (add more with , "0.1" and so on)
44 EXT_SET_VER_HISTORY(array("0.0"));
45
46 switch ($EXT_LOAD_MODE)
47 {
48 case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
49         // Table for debug log entries
50         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log`");
51         ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_log` (
52 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
53 `sender_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
54 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
55 `file` VARCHAR(255) NOT NULL DEFAULT '',
56 `line` MEDIUMINT NOT NOT NULL DEFAULT 0,
57 `message` LONGTEXT,
58 `comment` TINYTEXT,
59 `status` ENUM('NEW','PENDING','ACCEPTED','FIXED','INVALID','DUBLICATE','SPAM') NOT NULL DEFAULT 'NEW',
60 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
61 INDEX (`sender_id`),
62 PRIMARY KEY (`id`)
63 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug log data'");
64
65         // Table against debug log abuse
66         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log_abuse`");
67         ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_log_abuse` (
68 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
69 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
70 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
71 `raw_data` LONGTEXT,
72 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
73 INDEX (`client_id`),
74 PRIMARY KEY (`id`)
75 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug log abuse'");
76
77         // Table on relay/server for client exchanges
78         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client`");
79         ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_client` (
80 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
81 `key` VARCHAR(255) NOT NULL DEFAULT 'SELF',
82 `url` VARCHAR(255) NOT NULL DEFAULT '',
83 `webmaster` VARCHAR(255) NOT NULL DEFAULT '',
84 `title` VARCHAR(255) NOT NULL DEFAULT '',
85 `status` ENUM('ACTIVE','NEW','PENDING','LOCKED','DELETED','SPAM') NOT NULL DEFAULT 'PENDING',
86 `type` ENUM ('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT',
87 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
88 `lock_spam_reason` TINYTEXT,
89 UNIQUE (`key`),
90 UNIQUE (`url`),
91 PRIMARY KEY (`id`)
92 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug clients'");
93
94         // Add this exchange as first client
95         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_debug_client` (`url`,`title`,`webmaster`,`status`) VALUES ('{!URL!}','{!MAIN_TITLE!}','{!WEBMASTER!}','ACTIVE')");
96
97         // Table for debug log <-> client connection
98         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client_log`");
99         ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_client_log` (
100 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
101 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
102 `log_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
103 INDEX `client_log` (`client_id`,`log_id`),
104 UNIQUE (`log_id`),
105 PRIMARY KEY (`id`)
106 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug client <-> log connection'");
107
108         // Guest menus
109         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug',NULL,'Debug-System','Y','Y',2)");
110         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_info','Informationen','Y','Y',1)");
111         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_reg','Anmeldung','Y','Y',2)");
112         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_unreg','Abmeldung','Y','Y',3)");
113         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_pilory','Spam-Pranger','Y','Y',4)");
114
115         // Admin menu
116         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug',NULL,'Debug-System','Verwalten Sie hier komfortabel das debug.log, welches sich im Verzeichnis <strong>inc/cache/</strong> befindet.',10)");
117         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','import_debug','debug.log importieren','Importieren Sie hier manuell die debug.log, damit neue Eintr&auml;ge mit bestehenden abgeglichen werden k&ouml;nnen und dann evtl. hinzugef&uuml;gt werden. Die <em>debug.log</em> wird nach dem Import automatisch vom Server entfernt. Dieser Vorgang wird f&uuml;r Sie nachts automatisch erledigt!',1)");
118         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','list_debug','Eintr&auml;ge anzeigen','Listet alle bereits importierten Eintr&auml;ge auf. Von hier aus versenden Sie noch nicht gemeldete Fehler an das Relay-Netzwerk, damt diese vom MXChange-Team gepr&uuml;ft werden k&ouml;nnen.',2)");
119         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','reg_debug','Am Server anmelden','Sie m&uuml;ssen zuerst Ihren Debug-Client (Ihr {!MT_WORD!} ist dies) oder Relay am Server von MXChange.org anmelden. Dies geschieht f&uuml;r Sie nicht automatisch, da Sie Ihre Daten zuvor &uuml;berpr&uuml;fen m&uuml;ssen, wie z.B. URL, eMail-Adresse und {!MT_WORD!}-Titel.',3)");
120         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','unreg_debug','Vom Server abmelden','Melden Sie bitte Ihren {!MT_WORD!} wieder vom MXChange-Server ab, damit das Team von MXChange.org weiss, welche Keys nicht mehr genutzt werden.',4)");
121         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','config_debug','Einstellungen','&Auml;ndern Sie hier alle Einstellungen, wie auch den Debug-Modus - ob Client, Hub oder selber Server sein. Lesen Sie dazu die Anleitung unter DOCs/de/debug/README.txt durch! Oder kommen Sie in&#39;s Forum. Das Team von MXChange.org hilft Ihnen gerne weiter.',5)");
122
123         // Config entries
124         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
125         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_key` VARCHAR(255) NOT NULL DEFAULT ''");
126         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_mode` ENUM('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT'");
127         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_new_log` ENUM('ACCEPT','FIRST','REG') NOT NULL DEFAULT 'FIRST'");
128         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_new_client` ENUM('ACTIVE','NEW','REG') NOT NULL DEFAULT 'NEW'");
129         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_reject_log` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day') * 30)."");
130         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_master_url` VARCHAR(255) NOT NULL DEFAULT '{!SERVER_URL!}'");
131         break;
132
133 case "remove": // Do stuff when removing extension
134         // SQL commands to run
135         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client_log`");
136         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client`");
137         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log`");
138         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log_abuse`");
139         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE `action`='debug' LIMIT 5");
140         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='debug' LIMIT 6");
141         break;
142
143 case "activate": // Do stuff when admin activates this extension
144         // SQL commands to run
145         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `action`='debug' LIMIT 5");
146         break;
147
148 case "deactivate": // Do stuff when admin deactivates this extension
149         // SQL commands to run
150         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `locked`='Y' WHERE `action`='debug' LIMIT 5");
151         break;
152
153 case "update": // Update an extension
154         switch ($EXT_VER)
155         {
156         case "0.0.1": // SQL queries for v0.0.1
157                 ADD_SQL("");
158
159                 // Update notes (these will be set as task text!)
160                 EXT_SET_UPDATE_NOTES("");
161                 break;
162         }
163         break;
164
165 case "modify": // When the extension got modified
166         break;
167
168 case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
169         break;
170
171 default: // Do stuff when extension is loaded
172         break;
173 }
174
175 // Keep this extension always active!
176 EXT_SET_ALWAYS_ACTIVE("Y");
177
178 //
179 ?>