]> git.mxchange.org Git - mailer.git/blobdiff - inc/http-functions.php
Extension ext-cprping introduced (dummy), 'install' directory excluded from GNU GPL:
[mailer.git] / inc / http-functions.php
index 6877963cc377011b98077db157be3956b1f5cd6c..9398678b10d3ec170bf7e798b1508ddf25a3e39e 100644 (file)
@@ -584,6 +584,71 @@ function isBrokenHttpServerImplentation () {
        return $isBroken;
 }
 
+// Extract host from script name
+function extractHostnameFromUrl (&$script) {
+       // Use default SERVER_URL by default... ;) So?
+       $url = getServerUrl();
+
+       // Is this URL valid?
+       if (substr($script, 0, 7) == 'http://') {
+               // Use the hostname from script URL as new hostname
+               $url = substr($script, 7);
+               $extract = explode('/', $url);
+               $url = $extract[0];
+               // Done extracting the URL :)
+       } // END - if
+
+       // Extract host name
+       $host = str_replace('http://', '', $url);
+       if (isInString('/', $host)) {
+               $host = substr($host, 0, strpos($host, '/'));
+       } // END - if
+
+       // Generate relative URL
+       //* DEBUG: */ debugOutput('SCRIPT=' . $script);
+       if (substr(strtolower($script), 0, 7) == 'http://') {
+               // But only if http:// is in front!
+               $script = substr($script, (strlen($url) + 7));
+       } elseif (substr(strtolower($script), 0, 8) == 'https://') {
+               // Does this work?!
+               $script = substr($script, (strlen($url) + 8));
+       }
+
+       //* DEBUG: */ debugOutput('SCRIPT=' . $script);
+       if (substr($script, 0, 1) == '/') {
+               $script = substr($script, 1);
+       } // END - if
+
+       // Return host name
+       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();
+}
+
 //-----------------------------------------------------------------------------
 // Automatically re-created functions, all taken from user comments on www.php.net
 //-----------------------------------------------------------------------------
@@ -734,70 +799,5 @@ next[100]=<pre>'.replaceReturnNewLine(htmlentities(call_user_func_array($mbPrefi
        }
 } // END - if
 
-// Extract host from script name
-function extractHostnameFromUrl (&$script) {
-       // Use default SERVER_URL by default... ;) So?
-       $url = getServerUrl();
-
-       // Is this URL valid?
-       if (substr($script, 0, 7) == 'http://') {
-               // Use the hostname from script URL as new hostname
-               $url = substr($script, 7);
-               $extract = explode('/', $url);
-               $url = $extract[0];
-               // Done extracting the URL :)
-       } // END - if
-
-       // Extract host name
-       $host = str_replace('http://', '', $url);
-       if (isInString('/', $host)) {
-               $host = substr($host, 0, strpos($host, '/'));
-       } // END - if
-
-       // Generate relative URL
-       //* DEBUG: */ debugOutput('SCRIPT=' . $script);
-       if (substr(strtolower($script), 0, 7) == 'http://') {
-               // But only if http:// is in front!
-               $script = substr($script, (strlen($url) + 7));
-       } elseif (substr(strtolower($script), 0, 8) == 'https://') {
-               // Does this work?!
-               $script = substr($script, (strlen($url) + 8));
-       }
-
-       //* DEBUG: */ debugOutput('SCRIPT=' . $script);
-       if (substr($script, 0, 1) == '/') {
-               $script = substr($script, 1);
-       } // END - if
-
-       // Return host name
-       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]
 ?>