$now = gmdate('D, d M Y H:i:s') . ' GMT';
// Send HTTP header
- sendHeader('HTTP/1.1 ' . getHttpStatus());
+ addHttpHeader('HTTP/1.1 ' . getHttpStatus());
// General headers for no caching
- sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21
- sendHeader('Last-Modified: ' . $now);
- sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
- sendHeader('Pragma: no-cache'); // HTTP/1.0
- sendHeader('Connection: Close');
- sendHeader('Content-Type: ' . getContentType() . '; charset=UTF-8');
- sendHeader('Content-Language: ' . getLanguage());
+ addHttpHeader('Expires: ' . $now); // RFC2616 - Section 14.21
+ addHttpHeader('Last-Modified: ' . $now);
+ addHttpHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+ addHttpHeader('Pragma: no-cache'); // HTTP/1.0
+ addHttpHeader('Connection: Close');
+ addHttpHeader('Content-Type: ' . getContentType() . '; charset=UTF-8');
+ addHttpHeader('Content-Language: ' . getLanguage());
}
// Checks wether the URL is full-qualified (http[s]:// + hostname [+ request data])
return $host;
}
+// Adds a HTTP header to array
+function addHttpHeader ($header) {
+ // Send the header
+ //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
+ $GLOBALS['http_header'][] = trim($header);
+}
+
+// Flushes all HTTP headers
+function flushHttpHeaders () {
+ // Is the header already sent?
+ if (headers_sent()) {
+ // Then abort here
+ debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
+ } // END - if
+
+ // Flush all headers if found
+ if ((isset($GLOBALS['http_header'])) && (is_array($GLOBALS['http_header']))) {
+ foreach ($GLOBALS['http_header'] as $header) {
+ header($header);
+ } // END - foreach
+ } // END - if
+
+ // Mark them as flushed
+ $GLOBALS['http_header'] = array();
+}
+
// [EOF]
?>
// Set header
if (substr($access, -3, 3) == 'log') {
// Output header
- sendHeader('Content-Type: text/plain');
+ addHttpHeader('Content-Type: text/plain');
// Clean content
clearOutputBuffer();
} elseif (substr($access, -3, 3) == '.gz') {
// @TODO Fix content-type here
- sendHeader('Content-Type: text/plain');
+ addHttpHeader('Content-Type: text/plain');
// Clean content
clearOutputBuffer();
} elseif (substr($access, -3, 3) == '.bz2') {
// @TODO Fix content-type here
- sendHeader('Content-Type: text/plain');
+ addHttpHeader('Content-Type: text/plain');
// Clean content
clearOutputBuffer();
outputRawCode($GLOBALS['output']);
} else {
// And flush all headers
- flushHeaders();
+ flushHttpHeaders();
}
}
$GLOBALS['output'] = gzencode($GLOBALS['output'], 9);
// Add header
- sendHeader('Content-Encoding: gzip');
+ addHttpHeader('Content-Encoding: gzip');
} elseif (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (isInStringIgnoreCase('deflate', $_SERVER['HTTP_ACCEPT_ENCODING']))) {
// Compress it for HTTP deflate
$GLOBALS['output'] = gzcompress($GLOBALS['output'], 9);
// Add header
- sendHeader('Content-Encoding: deflate');
+ addHttpHeader('Content-Encoding: deflate');
}
*/
// Add final length
- sendHeader('Content-Length: ' . strlen($GLOBALS['output']));
+ addHttpHeader('Content-Length: ' . strlen($GLOBALS['output']));
// Flush all headers
- flushHeaders();
+ flushHttpHeaders();
}
// Main compilation loop
return $status;
}
-// Wrapper function for header()
-// Send a header but checks before if we can do so
-function sendHeader ($header) {
- // Send the header
- //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
- $GLOBALS['header'][] = trim($header);
-}
-
-// Flushes all headers
-function flushHeaders () {
- // Is the header already sent?
- if (headers_sent()) {
- // Then abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
- } // END - if
-
- // Flush all headers if found
- if ((isset($GLOBALS['header'])) && (is_array($GLOBALS['header']))) {
- foreach ($GLOBALS['header'] as $header) {
- header($header);
- } // END - foreach
- } // END - if
-
- // Mark them as flushed
- $GLOBALS['header'] = array();
-}
-
// Wrapper function for chmod()
// @TODO Do some more sanity check here
function changeMode ($FQFN, $mode) {
(preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
($matches[1] < 6)) {
// Send the IIS header
- sendHeader('Refresh: 0;url=' . $url);
+ addHttpHeader('Refresh: 0;url=' . $url);
} else {
// Send generic header
- sendHeader('Location: ' . $url);
+ addHttpHeader('Location: ' . $url);
}
// Shutdown here