]> git.mxchange.org Git - mailer.git/commitdiff
Some functions renamed:
authorRoland Häder <roland@mxchange.org>
Tue, 13 Sep 2011 16:06:27 +0000 (16:06 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 13 Sep 2011 16:06:27 +0000 (16:06 +0000)
- sendHeader() and flushHeaders() renamed to addHttpHeader() and
  flushHttpHeaders(), these are only HTTP-related functions
- Therefore they have been moved to proper library script

inc/http-functions.php
inc/modules/admin/what-logs.php
inc/template-functions.php
inc/wrapper-functions.php

index 85ae678a45f4badc55c9e6d443a7e7e626c7796b..6877963cc377011b98077db157be3956b1f5cd6c 100644 (file)
@@ -46,16 +46,16 @@ function sendHttpHeaders () {
        $now = gmdate('D, d M Y H:i:s') . ' GMT';
 
        // Send HTTP header
        $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
 
        // 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])
 }
 
 // Checks wether the URL is full-qualified (http[s]:// + hostname [+ request data])
@@ -773,5 +773,31 @@ function extractHostnameFromUrl (&$script) {
        return $host;
 }
 
        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]
 ?>
 // [EOF]
 ?>
index 896073d96093a0f20187d99266e00ef53a717899..e3ba9580c3a431f2a2396fd9389bb2ea5dad5115 100644 (file)
@@ -56,19 +56,19 @@ if (isGetRequestElementSet('access')) {
                // Set header
                if (substr($access, -3, 3) == 'log') {
                        // Output header
                // 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
 
                        // 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
 
                        // 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();
 
                        // Clean content
                        clearOutputBuffer();
index 2259ffc2e5dd94c3878eb8ab88d0943c47b3ae2d..25f31b3e88255cc478c2d979efb0ede3371ee4fd 100644 (file)
@@ -171,7 +171,7 @@ function outputHtml ($htmlCode, $newLine = true) {
                outputRawCode($GLOBALS['output']);
        } else {
                // And flush all headers
                outputRawCode($GLOBALS['output']);
        } else {
                // And flush all headers
-               flushHeaders();
+               flushHttpHeaders();
        }
 }
 
        }
 }
 
@@ -196,21 +196,21 @@ function compileFinalOutput () {
                $GLOBALS['output'] = gzencode($GLOBALS['output'], 9);
 
                // Add header
                $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
        } 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
        }
        */
 
        // Add final length
-       sendHeader('Content-Length: ' . strlen($GLOBALS['output']));
+       addHttpHeader('Content-Length: ' . strlen($GLOBALS['output']));
 
        // Flush all headers
 
        // Flush all headers
-       flushHeaders();
+       flushHttpHeaders();
 }
 
 // Main compilation loop
 }
 
 // Main compilation loop
index 5dde76d70ff69b904af45f5c951adead74aa4139..ce74b918bd4c1a10208dee248b5106f238204ede 100644 (file)
@@ -481,33 +481,6 @@ function copyFileVerified ($source, $dest, $chmod = '') {
        return $status;
 }
 
        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) {
 // Wrapper function for chmod()
 // @TODO Do some more sanity check here
 function changeMode ($FQFN, $mode) {
@@ -1148,10 +1121,10 @@ function sendRawRedirect ($url) {
                (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
                ($matches[1] < 6)) {
                // Send the IIS header
                (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
        } else {
                // Send generic header
-               sendHeader('Location: ' . $url);
+               addHttpHeader('Location: ' . $url);
        }
 
        // Shutdown here
        }
 
        // Shutdown here