X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fhttp-functions.php;h=9398678b10d3ec170bf7e798b1508ddf25a3e39e;hp=6877963cc377011b98077db157be3956b1f5cd6c;hb=3971209b0996a1b0506d6ddaf7326432933eae1b;hpb=21b7860d55b9125cb4adb9b48511d6b1cf0cae20 diff --git a/inc/http-functions.php b/inc/http-functions.php index 6877963cc3..9398678b10 100644 --- a/inc/http-functions.php +++ b/inc/http-functions.php @@ -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]=
'.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]
 ?>