2e080a7c99b60f70e1a869ba8c2c92d58f781eb1
[mailer.git] / inc / extensions / ext-debug.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Version number
44 setThisExtensionVersion('0.0.0');
45
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.0.0'));
48
49 // Keep this extension always active!
50 setExtensionAlwaysActive('Y');
51
52 // This extension is in development (non-productive)
53 enableExtensionProductive(false);
54
55 switch (getExtensionMode()) {
56         case 'register': // Do stuff when installation is running
57                 // Table for debug log entries
58                 addDropTableSql('debug_log');
59                 addCreateTableSql('debug_log', "
60 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
61 `sender_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
62 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
63 `file` VARCHAR(255) NOT NULL DEFAULT '',
64 `line` MEDIUMINT NOT NOT NULL DEFAULT 0,
65 `message` LONGTEXT NOT NULL,
66 `comment` TINYTEXT NOT NULL,
67 `status` ENUM('NEW','PENDING','ACCEPTED','FIXED','INVALID','DUBLICATE','SPAM') NOT NULL DEFAULT 'NEW',
68 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
69 PRIMARY KEY (`id`),
70 INDEX (`sender_id`)",
71                         'Debug log data');
72
73                 // Table against debug log abuse
74                 addDropTableSql('debug_log_abuse');
75                 addCreateTableSql('debug_log_abuse', "
76 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
77 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
78 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
79 `raw_data` LONGTEXT NOT NULL,
80 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
81 PRIMARY KEY (`id`),
82 INDEX (`client_id`)",
83                         'Debug log abuse');
84
85                 // Table on relay/server for client exchanges
86                 addDropTableSql('debug_client');
87                 addCreateTableSql('debug_client', "
88 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
89 `key` VARCHAR(255) NOT NULL DEFAULT 'SELF',
90 `url` VARCHAR(255) NOT NULL DEFAULT '',
91 `webmaster` VARCHAR(255) NOT NULL DEFAULT '',
92 `title` VARCHAR(255) NOT NULL DEFAULT '',
93 `status` ENUM('ACTIVE','NEW','PENDING','LOCKED','DELETED','SPAM') NOT NULL DEFAULT 'PENDING',
94 `type` ENUM ('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT',
95 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
96 `lock_spam_reason` TINYTEXT NOT NULL,
97 PRIMARY KEY (`id`),
98 UNIQUE INDEX (`key`),
99 UNIQUE INDEX (`url`)",
100                         'Debug clients');
101
102                 // Add this exchange as first client
103                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_debug_client` (`url`, `title`, `webmaster`, `status`) VALUES ('{?URL?}','{?MAIN_TITLE?}','{?WEBMASTER?}','ACTIVE')");
104
105                 // Table for debug log <-> client connection
106                 addDropTableSql('debug_client_log');
107                 addCreateTableSql('debug_client_log', "
108 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
109 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
110 `log_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
111 PRIMARY KEY (`id`),
112 UNIQUE INDEX (`log_id`),
113 INDEX `client_log` (`client_id`, `log_id`)",
114                         'Debug client <-> log connection');
115
116                 // Guest menus
117                 addGuestMenuSql('debug', NULL, 'Debug-System', 2);
118                 addGuestMenuSql('debug', 'debug_info', 'Informationen', 1);
119                 addGuestMenuSql('debug', 'debug_reg', 'Anmeldung', 2);
120                 addGuestMenuSql('debug', 'debug_unreg', 'Abmeldung', 3);
121                 addGuestMenuSql('debug', 'debug_pilory', 'Spam-Pranger', 4);
122
123                 // Admin menu
124                 addAdminMenuSql('debug', NULL, 'Debug-System', 'Verwalten Sie hier komfortabel das debug.log, welches sich im Verzeichnis <strong>{?CACHE_PATH?}</strong> befindet.', 10);
125                 addAdminMenuSql('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 <span class="notice">debug.log</span> wird nach dem Import automatisch vom Server entfernt. Dieser Vorgang wird f&uuml;r Sie nachts automatisch erledigt!', 1);
126                 addAdminMenuSql('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 {?TITLE?}-Entwicklerteam gepr&uuml;ft werden k&ouml;nnen.', 2);
127                 addAdminMenuSql('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);
128                 addAdminMenuSql('debug', 'unreg_debug', 'Vom Server abmelden', 'Melden Sie bitte Ihren {?mt_word?} wieder vom Projekt-Server ab, damit mein {?TITLE?}-Entwicklerteam weiss, welche Keys nicht mehr genutzt werden.', 4);
129                 addAdminMenuSql('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);
130
131                 // Config entries
132                 addConfigAddSql('debug_id', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
133                 addConfigAddSql('debug_key', "VARCHAR(255) NOT NULL DEFAULT ''");
134                 addConfigAddSql('debug_mode', "ENUM('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT'");
135                 addConfigAddSql('debug_new_log', "ENUM('ACCEPT','FIRST','REG') NOT NULL DEFAULT 'FIRST'");
136                 addConfigAddSql('debug_new_client', "ENUM('ACTIVE','NEW','REG') NOT NULL DEFAULT 'NEW'");
137                 addConfigAddSql('debug_reject_log', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 30));
138                 addConfigAddSql('debug_master_url', "VARCHAR(255) NOT NULL DEFAULT '{?SERVER_URL?}'");
139                 break;
140
141         case 'remove': // Do stuff when removing extension
142                 // SQL commands to run
143                 addDropTableSql('debug_client_log');
144                 addDropTableSql('debug_client');
145                 addDropTableSql('debug_log');
146                 addDropTableSql('debug_log_abuse');
147                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='debug'");
148                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='debug'");
149                 break;
150
151         case 'activate': // Do stuff when admin activates this extension
152                 // SQL commands to run
153                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `action`='debug' LIMIT 5");
154                 break;
155
156         case 'deactivate': // Do stuff when admin deactivates this extension
157                 // SQL commands to run
158                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='Y' WHERE `action`='debug' LIMIT 5");
159                 break;
160
161         case 'update': // Update an extension
162                 switch (getCurrentExtensionVersion()) {
163                         case '0.0.1': // SQL queries for v0.0.1
164                                 addExtensionSql('');
165
166                                 // Update notes (these will be set as task text!)
167                                 setExtensionUpdateNotes('');
168                                 break;
169                 } // END - switch
170                 break;
171
172         case 'modify': // When the extension got modified
173                 break;
174
175         case 'test': // For testing purposes
176                 break;
177
178         case 'init': // Do stuff when extension is initialized
179                 break;
180
181         default: // Unknown extension mode
182                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
183                 break;
184 } // END - switch
185
186 // [EOF]
187 ?>