<?
function SendPostBody($URL, $PostBody){
	$UrlPath = parse_url($URL);
	if(empty($UrlPath['port'])){
		$UrlPath['port'] = '80';
	}
	$Address = $UrlPath['path'];
	if(!empty($UrlPath['query'])){
		$Address .= '?'.$UrlPath['query'];
	}
	$Request  = "POST http://".$UrlPath['host']."/".$Address." HTTP/1.0\r\n";
	$Request .= "Host: ".$UrlPath['host']."\r\n";
	$Request .= "Accept: text/html, */*\r\n";
	$Request .= "Content-Type: application/x-www-form-urlencoded\r\n";
	$Request .= "Content-Length: ".strlen($PostBody)."\r\n";
	$Request .= "\r\n";
	$Request .= $PostBody;
	$service_port = getservbyname('www', 'tcp');
	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	if ($socket < 0)
		return "socket_create() failed: reason: "
			.socket_strerror($socket)."\n";
	$result = socket_connect ($socket, $UrlPath['host'], $service_port);
	if ($result < 0)
		return "socket_connect() failed.\nReason: ($result) "
			.socket_strerror($result)."\n";
	socket_write($socket, $Request, strlen($Request));
	$res = "";
	while ($out = socket_read($socket, 2048))
		$res .= $out;
	socket_close($socket);
	return $res;
}
?>