$sValue ) { if ( ! is_bool( $sValue ) ) { $sQuery .= "&{$sKey}=" . urlencode( $sValue ); } else if ( TRUE == $sValue ) { $sQuery .= "&{$sKey}=1"; } } error_reporting(0); // Build connection details. $sBaseUrl = urlencode( $_SERVER['HTTP_HOST'] ); $sFullUrl = urlencode ( ( $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); $sTarget = "/package/smallindex.php?{$sQuery}&baseurl={$sBaseUrl}&fullurl={$sFullUrl}"; $sHeaders = "GET {$sTarget} HTTP/1.0\r\n"; $sHeaders .= "Host: www.postpartners.nl\r\n"; $sHeaders .= "Connection: Close\r\n"; if ( strlen( $_SERVER['HTTP_COOKIE'] ) > 0 ) { $sHeaders .= "Cookie: {$_SERVER['HTTP_COOKIE']}\r\n"; } $sHeaders .= "\r\n"; // Send headers. fputs( $rFp, $sHeaders ); // Get response. $sResult = ''; do { $sData = fread( $rFp, 4096 ); if ( strlen( $sData ) == 0 ) { break; } $sResult .= $sData; } while ( TRUE ); // Close connection. fclose( $rFp ); // Parse response. $iPos = strpos( $sResult, "\r\n\r\n" ); if ( $iPos === FALSE ) { $iPos = strpos( $sResult, "\n\n" ); $iSkip = 2; } else { $iSkip = 4; } if ( $iPos === FALSE ) { // No body. $sHeaders = $sResult; $sBody = ''; } else { $sHeaders = substr( $sResult, 0, $iPos ); $sBody = substr( $sResult, $iPos + $iSkip ); } // Parse headers. $aHeaderLines = explode( "\n", $sHeaders ); foreach( $aHeaderLines as $sHeader ) { if ( strstr( $sHeader, 'Set-Cookie' ) ) { header( trim( $sHeader ) . "\n", FALSE ); } if ( strstr( $sHeader, 'Location' ) ) { header( trim( $sHeader ) . "\n", FALSE ); } } // Sanity check if (headers_sent()) { echo "Waarschuwing: De HTTP headers zijn te vroeg verzonden."; } // Auspuff! //echo str_replace( array_keys( $aReplace ), array_values( $aReplace ), $sBody ); echo $sBody;