function HttpGet ($url, $followredirects =true) {global $final _url; $url _parsed = Parse_url ($url); if (Emptyempty ($url _parsed[' scheme ')) {$url _parsed = Parse_url (' http://' $url); } $final _url = $url _parsed; $port = $url _parsed["Port"]; if (! $port) {$port =//www.php.cn} $rtn [' url '] [' port '] = $port; $path = $url _parsed["path"]; if (Emptyempty ($path)) {$path = "/"; } if (!emptyempty ($url _parsed["Query"]) {$path. = "?". $url _parsed["Query"]; } $rtn [' url '] [' path '] = $path; $host = $url _parsed["host"]; $foundbody = false; $out = "Get $path http/1.0"; $out. = "Host: $host"; $out. = "user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; En-us; rv:1.8.1) gecko/20061010 firefox/2.0 "; $out. = "Connection:close"; if (! $fp = @fsockopen ($host, $port, $errno, $errstr,)) {$rtn [' errornumber '] = $errno; $rtn [' errorstring '] = $errstr; } fwrite ($fp, $out); while (! @feof ($fp)) {$s = @fgets ($fp, 128); if ($s = = "") {$foundbody = true; Continue } if ($foundbody) {$body. = $s; } else {if ($followredirects) && (Stristr ($s, "location:") = = False)) {$redirect = Preg _replace ("/location:/i", "", $s); Return HttpGet (Trim ($redirect)); } $header. = $s; }} fclose ($FP); Return (Trim ($body));