From: Roland Häder Date: Mon, 7 Jun 2010 22:17:16 +0000 (+0000) Subject: HTTP status codes added for missing/locked modules, fixed double-logging of debug... X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=7a2bf6b757eb25795956d48453f1afa940156bc5 HTTP status codes added for missing/locked modules, fixed double-logging of debug messages by removing obsolete code --- diff --git a/inc/functions.php b/inc/functions.php index 254a29a17e..864e26f967 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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); diff --git a/inc/header.php b/inc/header.php index 06f8f74daa..0313f88583 100644 --- a/inc/header.php +++ b/inc/header.php @@ -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 diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index dbd6e713f4..8877bcc150 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -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] ?> diff --git a/modules.php b/modules.php index 9bddeb8a60..796b1e8128 100644 --- a/modules.php +++ b/modules.php @@ -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;