0fa72bdff88adcd6f00abdecc4f89b2e7ec66a2a
[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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44
45 // Version number
46 EXT_SET_VERSION('0.0');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 EXT_SET_VER_HISTORY(array('0.0'));
50
51 switch ($EXT_LOAD_MODE)
52 {
53 case 'register': // Do stuff when installation is running (modules.php?module=admin&action=login is called)
54         // Table for debug log entries
55         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log`");
56         ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_log` (
57 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
58 `sender_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
59 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
60 `file` VARCHAR(255) NOT NULL DEFAULT '',
61 `line` MEDIUMINT NOT NOT NULL DEFAULT 0,
62 `message` LONGTEXT,
63 `comment` TINYTEXT,
64 `status` ENUM('NEW','PENDING','ACCEPTED','FIXED','INVALID','DUBLICATE','SPAM') NOT NULL DEFAULT 'NEW',
65 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
66 INDEX (`sender_id`),
67 PRIMARY KEY (`id`)
68 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug log data'");
69
70         // Table against debug log abuse
71         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log_abuse`");
72         ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_log_abuse` (
73 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
74 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
75 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
76 `raw_data` LONGTEXT,
77 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
78 INDEX (`client_id`),
79 PRIMARY KEY (`id`)
80 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug log abuse'");
81
82         // Table on relay/server for client exchanges
83         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client`");
84         ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_client` (
85 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
86 `key` VARCHAR(255) NOT NULL DEFAULT 'SELF',
87 `url` VARCHAR(255) NOT NULL DEFAULT '',
88 `webmaster` VARCHAR(255) NOT NULL DEFAULT '',
89 `title` VARCHAR(255) NOT NULL DEFAULT '',
90 `status` ENUM('ACTIVE','NEW','PENDING','LOCKED','DELETED','SPAM') NOT NULL DEFAULT 'PENDING',
91 `type` ENUM ('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT',
92 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
93 `lock_spam_reason` TINYTEXT,
94 UNIQUE (`key`),
95 UNIQUE (`url`),
96 PRIMARY KEY (`id`)
97 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug clients'");
98
99         // Add this exchange as first client
100         ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_debug_client` (`url`,`title`,`webmaster`,`status`) VALUES ('{!URL!}','{!MAIN_TITLE!}','{!WEBMASTER!}','ACTIVE')");
101
102         // Table for debug log <-> client connection
103         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client_log`");
104         ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_debug_client_log` (
105 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
106 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
107 `log_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
108 INDEX `client_log` (`client_id`,`log_id`),
109 UNIQUE (`log_id`),
110 PRIMARY KEY (`id`)
111 ) TYPE={!_TABLE_TYPE!} COMMENT='Debug client <-> log connection'");
112
113         // Guest menus
114         ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug',NULL,'Debug-System','Y','Y',2)");
115         ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_info','Informationen','Y','Y',1)");
116         ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_reg','Anmeldung','Y','Y',2)");
117         ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_unreg','Abmeldung','Y','Y',3)");
118         ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_pilory','Spam-Pranger','Y','Y',4)");
119
120         // Admin menu
121         ADD_EXT_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)");
122         ADD_EXT_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)");
123         ADD_EXT_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)");
124         ADD_EXT_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)");
125         ADD_EXT_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)");
126         ADD_EXT_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)");
127
128         // Config entries
129         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
130         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_key` VARCHAR(255) NOT NULL DEFAULT ''");
131         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_mode` ENUM('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT'");
132         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_new_log` ENUM('ACCEPT','FIRST','REG') NOT NULL DEFAULT 'FIRST'");
133         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_new_client` ENUM('ACTIVE','NEW','REG') NOT NULL DEFAULT 'NEW'");
134         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_reject_log` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day') * 30)."");
135         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `debug_master_url` VARCHAR(255) NOT NULL DEFAULT '{!SERVER_URL!}'");
136         break;
137
138 case 'remove': // Do stuff when removing extension
139         // SQL commands to run
140         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client_log`");
141         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_client`");
142         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log`");
143         ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_debug_log_abuse`");
144         ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE `action`='debug'");
145         ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='debug'");
146         break;
147
148 case 'activate': // Do stuff when admin activates this extension
149         // SQL commands to run
150         ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `action`='debug' LIMIT 5");
151         break;
152
153 case 'deactivate': // Do stuff when admin deactivates this extension
154         // SQL commands to run
155         ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `locked`='Y' WHERE `action`='debug' LIMIT 5");
156         break;
157
158 case 'update': // Update an extension
159         switch ($EXT_VER)
160         {
161         case '0.0.1': // SQL queries for v0.0.1
162                 ADD_EXT_SQL("");
163
164                 // Update notes (these will be set as task text!)
165                 EXT_SET_UPDATE_NOTES("");
166                 break;
167         }
168         break;
169
170 case 'modify': // When the extension got modified
171         break;
172
173 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
174         break;
175
176 default: // Do stuff when extension is loaded
177         break;
178 }
179
180 // Keep this extension always active!
181 EXT_SET_ALWAYS_ACTIVE("Y");
182
183 //
184 ?>