General directory structure added for debug extension
[mailer.git] / debug.php
index dd213e44f9a2ea27a767913ade8eb233b2b36d88..0d6150cadb20880a8c97ca87bfefe41dd1ea3e57 100644 (file)
--- a/debug.php
+++ b/debug.php
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
  * MXChange v0.2.1                                    Start: 10/12/2008 *
- * ===============                              Last change: 10/12/2008 *
+ * ===============                              Last change: 23/12/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : debug.php                                        *
 require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
-global $what, $action;
-$GLOBALS['what'] = ""; $GLOBALS['action'] = "";
+global $what, $action, $FATAL;
+$GLOBALS['what'] = "";
+$GLOBALS['action'] = "";
+$FATAL = array();
 
-// Set module
+// Set module and fake "CSS mode"
 $GLOBALS['module'] = "debug"; $CSS = -1;
 
 // Load the required file(s)
 require("inc/config.php");
 
 // Redirect only to registration page when this script is installed
-if (isBooleanConstantAndTrue('mxchange_installed')) {
-       // TODO Do something useful here...
+if ((isBooleanConstantAndTrue('mxchange_installed')) && (count($FATAL) == 0)) {
+       // Is the request parameter set?
+       if (isset($_POST['request'])) {
+               // Handle the request
+               if (DEBUG_HANDLE_REQUEST($_POST['request'])) {
+                       // Construct FQFN for the module
+                       $fqfn = sprintf("%sinc/debug/%s/request_%s",
+                               PATH,
+                               getConfig('debug_mode'),
+                               SQL_ESCAPE($_POST['request'])
+                       );
+
+                       // Is the module there? Else we log it!
+                       if (FILE_READABLE($fqfn)) {
+                               // Load the request module
+                               require($fqfn);
+                       } else {
+                               // Missing request file, may happen while development
+                               DEBUG_ABUSE_LOG(__FILE__, __LINE__, "request_404", $_POST['request']);
+                       }
+               } else {
+                       // Unhandled request detected
+                       DEBUG_ABUSE_LOG(__FILE__, __LINE__, "request_unhandled", $_POST['request']);
+               }
+       } else {
+               // Empty request
+               DEBUG_ABUSE_LOG(__FILE__, __LINE__, "request_empty", "");
+       }
+} else {
+       // Not installed or fatal errors
+       DEBUG_ABUSE_LOG(__FILE__, __LINE__, "request_fatal", count($FATAL));
 } // END - if
 
 // Really all done here... ;-)