Basic data of network GigaPromo added, keys rewritten
[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  * 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 - 2009 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         die();
42 }
43
44 // Version number
45 setThisExtensionVersion('0.0');
46
47 // Version history array (add more with , '0.1.0' and so on)
48 setExtensionVersionHistory(array('0.0'));
49
50 // Keep this extension always active!
51 setExtensionAlwaysActive('Y');
52
53 // This extension is in development (non-productive)
54 enableExtensionProductive(false);
55
56 switch (getExtensionMode()) {
57         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
58                 // Table for debug log entries
59                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_log`");
60                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_debug_log` (
61 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
62 `sender_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
63 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
64 `file` VARCHAR(255) NOT NULL DEFAULT '',
65 `line` MEDIUMINT NOT NOT NULL DEFAULT 0,
66 `message` LONGTEXT,
67 `comment` TINYTEXT,
68 `status` ENUM('NEW','PENDING','ACCEPTED','FIXED','INVALID','DUBLICATE','SPAM') NOT NULL DEFAULT 'NEW',
69 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
70 INDEX (`sender_id`),
71 PRIMARY KEY (`id`)
72 ) TYPE={?_TABLE_TYPE?} COMMENT='Debug log data'");
73
74                 // Table against debug log abuse
75                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_log_abuse`");
76                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_debug_log_abuse` (
77 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
78 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
79 `timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
80 `raw_data` LONGTEXT,
81 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
82 INDEX (`client_id`),
83 PRIMARY KEY (`id`)
84 ) TYPE={?_TABLE_TYPE?} COMMENT='Debug log abuse'");
85
86                 // Table on relay/server for client exchanges
87                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_client`");
88                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_debug_client` (
89 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
90 `key` VARCHAR(255) NOT NULL DEFAULT 'SELF',
91 `url` VARCHAR(255) NOT NULL DEFAULT '',
92 `webmaster` VARCHAR(255) NOT NULL DEFAULT '',
93 `title` VARCHAR(255) NOT NULL DEFAULT '',
94 `status` ENUM('ACTIVE','NEW','PENDING','LOCKED','DELETED','SPAM') NOT NULL DEFAULT 'PENDING',
95 `type` ENUM ('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT',
96 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
97 `lock_spam_reason` TINYTEXT,
98 UNIQUE (`key`),
99 UNIQUE (`url`),
100 PRIMARY KEY (`id`)
101 ) TYPE={?_TABLE_TYPE?} COMMENT='Debug clients'");
102
103                 // Add this exchange as first client
104                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_debug_client` (`url`,`title`,`webmaster`,`status`) VALUES ('{?URL?}','{?MAIN_TITLE?}','{?WEBMASTER?}','ACTIVE')");
105
106                 // Table for debug log <-> client connection
107                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_client_log`");
108                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_debug_client_log` (
109 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
110 `client_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 1,
111 `log_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
112 INDEX `client_log` (`client_id`,`log_id`),
113 UNIQUE (`log_id`),
114 PRIMARY KEY (`id`)
115 ) TYPE={?_TABLE_TYPE?} COMMENT='Debug client <-> log connection'");
116
117                 // Guest menus
118                 addGuestMenuSql('debug',NULL,'Debug-System','Y','Y',2);
119                 addGuestMenuSql('debug','debug_info','Informationen','Y','Y',1);
120                 addGuestMenuSql('debug','debug_reg','Anmeldung','Y','Y',2);
121                 addGuestMenuSql('debug','debug_unreg','Abmeldung','Y','Y',3);
122                 addGuestMenuSql('debug','debug_pilory','Spam-Pranger','Y','Y',4);
123
124                 // Admin menu
125                 addAdminMenuSql('debug',NULL,'Debug-System','Verwalten Sie hier komfortabel das debug.log, welches sich im Verzeichnis <strong>{?CACHE_PATH?}/</strong> befindet.',10);
126                 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 <em>debug.log</em> wird nach dem Import automatisch vom Server entfernt. Dieser Vorgang wird f&uuml;r Sie nachts automatisch erledigt!',1);
127                 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 Entwicklerteam gepr&uuml;ft werden k&ouml;nnen.',2);
128                 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);
129                 addAdminMenuSql('debug','unreg_debug','Vom Server abmelden','Melden Sie bitte Ihren {?mt_word?} wieder vom Projekt-Server ab, damit mein Entwicklerteam weiss, welche Keys nicht mehr genutzt werden.',4);
130                 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);
131
132                 // Config entries
133                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
134                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_key` VARCHAR(255) NOT NULL DEFAULT ''");
135                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_mode` ENUM('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT'");
136                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_new_log` ENUM('ACCEPT','FIRST','REG') NOT NULL DEFAULT 'FIRST'");
137                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_new_client` ENUM('ACTIVE','NEW','REG') NOT NULL DEFAULT 'NEW'");
138                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_reject_log` BIGINT(20) UNSIGNED NOT NULL DEFAULT " . (getConfig('ONE_DAY') * 30));
139                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `debug_master_url` VARCHAR(255) NOT NULL DEFAULT '{?SERVER_URL?}'");
140                 break;
141
142         case 'remove': // Do stuff when removing extension
143                 // SQL commands to run
144                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_client_log`");
145                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_client`");
146                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_log`");
147                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_debug_log_abuse`");
148                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `action`='debug'");
149                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='debug'");
150                 break;
151
152         case 'activate': // Do stuff when admin activates this extension
153                 // SQL commands to run
154                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `action`='debug' LIMIT 5");
155                 break;
156
157         case 'deactivate': // Do stuff when admin deactivates this extension
158                 // SQL commands to run
159                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='Y' WHERE `action`='debug' LIMIT 5");
160                 break;
161
162         case 'update': // Update an extension
163                 switch (getCurrentExtensionVersion())
164                 {
165                         case '0.0.1': // SQL queries for v0.0.1
166                                 addExtensionSql('');
167
168                                 // Update notes (these will be set as task text!)
169                                 setExtensionUpdateNotes('');
170                                 break;
171                 }
172                 break;
173
174         case 'modify': // When the extension got modified
175                 break;
176
177         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
178                 break;
179
180         case 'init': // Do stuff when extension is initialized
181                 break;
182
183         default: // Unknown extension mode
184                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
185                 break;
186 }
187
188 // [EOF]
189 ?>