//fsocket模拟post提交
$url = "http://localhost/test2.php?site=yuncode.net";
//echo $query;
sock_get($url,"user=gonn");
//sock_get($url, $query);
//fsocket模拟get提交
function sock_get($url, $query)
{
'foo'=>'bar',
'baz'=>'boom',
'site'=>'yuncode.net',
'name'=>'nowa magic');
$fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
//$head = "GET ".$info['path']."?".$info["query"]." HTTP/1.0\r\n";
$head = "GET ".$info['path']."?".$query_str." HTTP/1.0\r\n";
$head .= "Host: ".$info['host']."\r\n";
$head .= "\r\n";
$write = fputs($fp, $head);
{
echo $line;
}
}
sock_post($url,"user=gonn");
function sock_post($url, $query)
{
$fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
$head = "POST ".$info['path']."?".$info["query"]." HTTP/1.0\r\n";
$head .= "Host: ".$info['host']."\r\n";
$head .= "Referer: http://".$info['host'].$info['path']."\r\n";
$head .= "Content-type: application/x-www-form-urlencoded\r\n";
$head .= "Content-Length: ".strlen(trim($query))."\r\n";
$head .= "\r\n";
$write = fputs($fp, $head);
{
echo $line;
}
}