HTTP status codes added for missing/locked modules, fixed double-logging of debug...
authorRoland Häder <roland@mxchange.org>
Mon, 7 Jun 2010 22:17:16 +0000 (22:17 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 7 Jun 2010 22:17:16 +0000 (22:17 +0000)
inc/functions.php
inc/header.php
inc/wrapper-functions.php
modules.php

index 254a29a..864e26f 100644 (file)
@@ -126,7 +126,7 @@ function sendHttpHeaders () {
        $now = gmdate('D, d M Y H:i:s') . ' GMT';
 
        // Send HTTP header
-       sendHeader('HTTP/1.1 200 OK');
+       sendHeader('HTTP/1.1 ' . getHttpStatus());
 
        // General headers for no caching
        sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21
@@ -2364,12 +2364,6 @@ function app_die ($F, $L, $message) {
                // Rewrite message for output
                $message = sprintf(getMessage('MAILER_HAS_DIED'), basename($F), $L, $message);
 
-               // We don't want to log messages from debug_report_bug() itself...
-               if ($F != 'debug_report_bug') {
-                       // Better log this message away
-                       logDebugMessage($F, $L, $message);
-               } // END - if
-
                // Load the message template
                loadTemplate('app_die_message', false, $message);
 
index 06f8f74..0313f88 100644 (file)
@@ -49,6 +49,9 @@ $GLOBALS['page_header'] = '';
 
 // Is the header already sent?
 if (($GLOBALS['header_sent'] != 1) && ($GLOBALS['header_sent'] != 2)) {
+       // Set default HTTP status to "200 OK"
+       setHttpStatus('200 OK');
+
        // If not in CSS mode generate the header
        if (getOutputMode() != 1) {
                // Prepare the header for HTML output
index dbd6e71..8877bcc 100644 (file)
@@ -946,5 +946,15 @@ function preCompileCode ($code, $template = '', $compiled = false, $full = true,
        return compileCode($code, false, true, $full);
 }
 
+// Setter for HTTP status
+function setHttpStatus ($status) {
+       $GLOBALS['http_status'] = (string) $status;
+}
+
+// Getter for HTTP status
+function getHttpStatus () {
+       return $GLOBALS['http_status'];
+}
+
 // [EOF]
 ?>
index 9bddeb8..796b1e8 100644 (file)
@@ -93,17 +93,30 @@ if ((isExtensionActive('maintenance')) && (getConfig('maintenance') == 'Y') && (
                                // Module is valid, active and located on the local disc...
                                $isModuleValid = true;
                        } elseif (!ifFatalErrorsDetected()) {
+                               // Set HTTP status
+                               setHttpStatus('404');
+
                                // Module not found!
                                addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_REGISTRY_404', getModule()));
                        }
                        break;
 
                case '404':
+                       // Set HTTP status
+                       setHttpStatus('404');
+
+                       // Add fatal message
                        addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_REGISTRY_404', getModule()));
                        break;
 
                case 'locked':
+                       // Set HTTP status
+                       setHttpStatus('403');
+
                        if (!isIncludeReadable($GLOBALS['module_inc'])) {
+                               // Set HTTP status
+                               setHttpStatus('404');
+
                                // Module does addionally not exists
                                addFatalMessage(__FILE__, __LINE__, getMaskedMessage('MODULE_REGISTRY_404', getModule()));
                        } // END - if
@@ -113,6 +126,7 @@ if ((isExtensionActive('maintenance')) && (getConfig('maintenance') == 'Y') && (
                        break;
 
                default:
+                       // Unknown module status
                        logDebugMessage(__FILE__, __LINE__, sprintf("Unknown status %s return from module check. Module=%s", $check, getModule()));
                        addFatalMessage(__FILE__, __LINE__, getMaskedMessage('UNKNOWN_MODULE_STATUS', $check));
                        break;