function Dfopen ($url, $limit = 0, $post = ", $cookie =", $bysocket = FALSE, $ip = ", $timeout = A, $block = TRUE)
{
$return = ";
$uri = Parse_url ($url);
$host = $uri [' Host '];
$path = $uri [' Path ']? $uri [' Path ']. ($uri [' query ']? '?'. $uri [' query ']: '): '/';
$port =!empty ($uri [' Port '])? $uri [' Port ']: 80;
if ($post) {
$out = "POST $path http/1.0\r\n";
$out. = "Accept: */*\r\n";
$out. = "accept-language:zh-cn\r\n";
$out. = "content-type:application/x-www-form-urlencoded\r\n";
$out. = "User-agent: $_server[http_user_agent]\r\n";
$out. = "Host: $host \ r \ n";
$out. = ' content-length: '. strlen ($post). " \ r \ n ";
$out. = "connection:close\r\n";
$out. = "cache-control:no-cache\r\n";
$out. = "Cookie: $cookie \r\n\r\n";
$out. = $post;
} else {
$out = "GET $path http/1.0\r\n";
$out. = "Accept: */*\r\n";
$out. = "accept-language:zh-cn\r\n";
$out. = "User-agent: $_server[http_user_agent]\r\n";
$out. = "Host: $host \ r \ n";
$out. = "connection:close\r\n";
$out. = "Cookie: $cookie \r\n\r\n";
}
$fp = @fsockopen (($ip? $ip: $host), $port, $errno, $errstr, $timeout);
if (! $fp) {
Return ';
} else {
Stream_set_blocking ($fp, $block);
Stream_set_timeout ($fp, $timeout);
@fwrite ($fp, $out);
@fclose ($FP);
}
}
Cases:
Dfopen ("http://sina.com", 0);
http://www.bkjia.com/PHPjc/440167.html www.bkjia.com true http://www.bkjia.com/PHPjc/440167.html techarticle function Dfopen ($url, $limit = 0, $post = ", $cookie =", $bysocket = FALSE, $ip = ", $timeout = A, $block = TRUE) {$return = "; $uri = Parse_url ($url); $host = $uri [' host '];