+<?php
+/************************************************************************
+ * MXChange v0.2.1 Start: 10/12/2008 *
+ * ================ Last change: 10/12/2008 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : ext-debug.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Extension for sending/receiving debug requests *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Erweiterung zum Versenden/Empfangen von Debug-Q. *
+ * -------------------------------------------------------------------- *
+ * *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * For more information visit: http://www.mxchange.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ require($INC);
+}
+
+// Version number
+$EXT_VERSION = "0.0";
+
+// Auto-set extension version
+if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
+
+// Version history array (add more with , "0.1" and so on)
+$EXT_VER_HISTORY = array("0.0");
+
+switch ($EXT_LOAD_MODE)
+{
+case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
+ // Table for debug log entries
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_log`";
+ $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_debug_log` (
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`sender_id` BIGINT(20) NOT NULL DEFAULT 0,
+`timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
+`message` LONGTEXT,
+`comment` TINYTEXT,
+`status` ENUM('NEW','PENDING','ACCEPTED','FIXED','INVALID','DUBLICATE','SPAM') NOT NULL DEFAULT 'NEW',
+`inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+INDEX (`sender_id`),
+PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Debug log data'";
+
+ // Table against debug log abuse
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_log_abuse`";
+ $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_debug_log_abuse` (
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`client_id` BIGINT(20) NOT NULL DEFAULT 0,
+`timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00',
+`raw_data` LONGTEXT,
+`inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+INDEX (`client_id`),
+PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Debug log abuse'";
+
+ // Table on relay/server for client exchanges
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_client`";
+ $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_debug_client` (
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`key` VARCHAR(255) NOT NULL DEFAULT 'SELF',
+`url` VARCHAR(255) NOT NULL DEFAULT '',
+`webmaster` VARCHAR(255) NOT NULL DEFAULT '',
+`title` VARCHAR(255) NOT NULL DEFAULT '',
+`status` ENUM('ACTIVE','NEW','PENDING','LOCKED','DELETED','SPAM') NOT NULL DEFAULT 'PENDING',
+`type` ENUM ('CLIENT','RELAY') NOT NULL DEFAULT 'CLIENT',
+`inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+`lock_spam_reason` TINYTEXT,
+UNIQUE (`key`),
+UNIQUE (`url`),
+PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Debug clients'";
+
+ // Add this exchange as first client
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_debug_client` (`url`,`title`,`webmaster`,`status`) VALUES ('".URL."','".MAIN_TITLE."','".WEBMASTER."','ACTIVE')";
+
+ // Table for debug log <-> client connection
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_client_log`";
+ $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_debug_client_log` (
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`client_id` BIGINT(20) NOT NULL DEFAULT 1,
+`log_id` BIGINT(20) NOT NULL DEFAULT 0,
+INDEX `client_log` (`client_id`,`log_id`),
+UNIQUE (`log_id`),
+PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Debug client <-> log connection'";
+
+ // Guest menus
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug',NULL,'Debug-System','Y','Y',2)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_info','Informationen','Y','Y',1)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_reg','Anmeldung','Y','Y',2)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_unreg','Abmeldung','Y','Y',3)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_guest_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('debug','debug_pilory','Pranger','Y','Y',4)";
+
+ // Admin menu
+ $SQLs[] = "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)";
+ $SQLs[] = "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äge mit bestehenden abgeglichen werden können und dann evtl. hinzugefügt werden. Die <em>debug.log</em> wird nach dem Import automatisch vom Server entfernt. Dieser Vorgang wird für Sie nachts automatisch erledigt!',1)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','list_debug','Einträge anzeigen','Listet alle bereits importierten Einträge auf. Von hier aus versenden Sie noch nicht gemeldete Fehler an das Relay-Netzwerk, damt diese vom MXChange-Team geprüft werden können.',2)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','reg_debug','Am Server anmelden','Sie müssen zuerst Ihren Debug-Client (Ihr {!MT_WORD!} ist dies) oder Relay am Server von MXChange.org anmelden. Dies geschieht für Sie nicht automatisch, da Sie Ihre Daten zuvor überprüfen müssen, wie z.B. URL, eMail-Adresse und {!MT_WORD!}-Titel.',3)";
+ $SQLs[] = "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)";
+ $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('debug','config_debug','Einstellungen','Ä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's Forum. Das Team von MXChange.org hilft Ihnen gerne weiter.',5)";
+
+ // Config entries
+ $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `debug_id` BIGINT(20) NOT NULL DEFAULT 0";
+ $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `debug_key` VARCHAR(255) NOT NULL DEFAULT ''";
+ $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `debug_mode` ENUM('CLIENT','RELAY','SERVER') NOT NULL DEFAULT 'CLIENT'";
+ $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `debug_new_log` ENUM('ACCEPT','FIRST','REG') NOT NULL DEFAULT 'FIRST'";
+ $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `debug_new_client` ENUM('ACTIVE','NEW','REG') NOT NULL DEFAULT 'NEW'";
+ $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `debug_reject_log` BIGINT(20) NOT NULL DEFAULT ".($_CONFIG['one_day'] * 30)."";
+ break;
+
+case "remove": // Do stuff when removing extension
+ // SQL commands to run
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_client_log`";
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_client`";
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_log`";
+ $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_debug_log_abuse`";
+ $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_guest_menu` WHERE `action`='debug' LIMIT 5";
+ $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE `action`='debug' LIMIT 6";
+ break;
+
+case "activate": // Do stuff when admin activates this extension
+ // SQL commands to run
+ $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_guest_menu` SET `visible`='Y',`locked`='N' WHERE `action`='debug' LIMIT 5";
+ break;
+
+case "deactivate": // Do stuff when admin deactivates this extension
+ // SQL commands to run
+ $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_guest_menu` SET `locked`='Y' WHERE `action`='debug' LIMIT 5";
+ break;
+
+case "update": // Update an extension
+ switch ($EXT_VER)
+ {
+ case "0.0.1": // SQL queries for v0.0.1
+ $SQLs[] = "";
+
+ // Update notes (these will be set as task text!)
+ $UPDATE_NOTES = "";
+ break;
+ }
+ break;
+
+default: // Do stuff when extension is loaded
+ break;
+}
+
+// Language file prefix
+$EXT_LANG_PREFIX = "debug";
+
+// Keep this extension always active!
+$EXT_ALWAYS_ACTIVE = "Y";
+
+//
+?>