public static function ReadRemoteDocument($handle)
	{
		// THIS FUNCTION IS A CRAP!!!!
		// I NEED REFACTORY THIS!
		$retdocument = "";
		$xml = true;
		$canread = true;

		// READ HEADER
		while (!feof($handle))
		{
			$buffer = fgets($handle, 4096);
			if (strpos(strtolower($buffer), "content-type:")!==false)
			{
				$xml = (strpos(strtolower($buffer), "xml")!==false);
				$canread = !$xml;
			}
			if (trim($buffer) == "")
			{
				break;
			}
		}

		// READ CONTENT
		while (!feof($handle))
		{
			$buffer = fgets($handle, 4096);
			if (!$canread && ($buffer[0] != "<"))
			{
				$buffer = "";
			}
			else
			{
				$canread = true;
			}
			$retdocument = $retdocument . $buffer;
		}
		fclose($handle);

		if ($xml)
		{
			$lastvalid = strrpos($retdocument, ">");
			$retdocument = substr($retdocument, 0, $lastvalid+1);
		}

		return $retdocument;
	}