获取的话可以这样,是hdwiki里代码,当然,你用其它的类也是可以的.
function hfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$matches = parse_url($url);
$host = $matches['host'];
@$path = $matches['path'] ? $matches['path'].'?'.$matches['query'].'#'.$matches['fragment'] : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80; if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\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 .= "Referer: $boardurl\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);
$status = stream_get_meta_data($fp);
if(!$status['timed_out']) {
while (!feof($fp)) {
if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) {
break;
}
}
$stop = false;
while(!feof($fp) && !$stop) {
$data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
$return .= $data;
if($limit) {
$limit -= strlen($data);
$stop = $limit <= 0;
}
}
}
@fclose($fp);
return $return;
}
}
function hfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$matches = parse_url($url);
$host = $matches['host'];
@$path = $matches['path'] ? $matches['path'].'?'.$matches['query'].'#'.$matches['fragment'] : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80; if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\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 .= "Referer: $boardurl\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);
$status = stream_get_meta_data($fp);
if(!$status['timed_out']) {
while (!feof($fp)) {
if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) {
break;
}
}
$stop = false;
while(!feof($fp) && !$stop) {
$data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
$return .= $data;
if($limit) {
$limit -= strlen($data);
$stop = $limit <= 0;
}
}
}
@fclose($fp);
return $return;
}
}
<%
Function getHTTPPage(url)
On Error Resume Next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "POST",url,false
Http.send()
if Http.readystate <>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312")
set http=nothing
If Err.number <>0 then
Response.Write " <p align='center'> <font color='red'> <b>服务器获取文件内容出错 </b> </font> </p>"
Err.Clear
End If
End Function Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
已上是文件a.php以下是文件b.php
<!--#include file="a.php"-->
<%
dim code,key,requesturl
code=""
key=""
requesturl="" dim tel1,tel2,url,userip
tel1 = request.form("tel1")
tel2 = request.form("tel2")
url = "http://"&Request.ServerVariables("Local_Addr") '如果客户端通过代理服务器,则取HTTP_X_FORWARDED_FOR的值,如果没通过代理服务器,就取 REMOTE_ADDR的值'
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR") requesturl=requesturl&"?tel1="&tel1&"&tel2="&tel2&"&url="&url&"&code="&code&"&key="&key&"&userip="&userip dim result
result = getHTTPPage(requesturl) if result="1" then
response.write " <script languaga=""JavaScript"">alert(""已提交""); </script>"
elseif result= "2" then
response.write " <script languaga=""JavaScript"">alert(""用户信息非法!"");history.back() </script>"
elseif result= "3" then
response.write " <script languaga=""JavaScript"">alert(""已限制!"");history.back() </script>"
else
response.write " <script languaga=""JavaScript"">alert(""系统错误!"");history.back() </script>"
end if
%>
$key = '';
$requesturl = ''; $tel1 = $_GET['tel1'];
$tel2 = $_GET['tel2'];
$url = "http://" . $_SERVER['SERVER_ADDR'];$userip = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR'];
$requesturl .= "?tel1=" . $tel1 . "&tel2=" . $tel2 . "&url=" . $url . "&code=" . $code . "&key=" . $key . "&userip=" . $userip; $result = file_get_contents($requesturl); switch($result) {
case '1':
echo ' <script languaga="JavaScript">alert("已提交"); </script>';
break;
case '2':
echo ' <script languaga="JavaScript">alert("用户信息非法!");history.back() </script>';
break; case '3':
echo ' <script languaga="JavaScript">alert("已限制!");history.back() </script>';
break; default:
echo ' <script languaga="JavaScript">alert("系统错误!");history.back() </script>';
}
?>
Warning: file_get_contents(http://***.***.***?tel1=&tel2=&url=http://&code=********&key=********&userip=123.147.9.176) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 HTTP method GET is not supported by this URL in E:\a.php on line 14
我还以为就输出一个helloworld呢。。