Home >Backend Development >PHP Tutorial >php fsockopen fake post and get methods_PHP tutorial

php fsockopen fake post and get methods_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:07:121173browse

This article provides you with a PHP tutorial for fsockopen to fake post and get methods. If you are looking for PHP processing code for fake post and get methods, this one is good.

//fsocket simulates post submission
$purl = "http://localhost/netphp/test2.php?uu=rrrrrrrrrr";
print_r(parse_url( $url));
sock_post($purl,"uu=55555555555555555");

//fsocket simulates get submission
function sock_get($url, $query)
{
$info = parse_url($url);
$fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
$head = "GET ".$info[ 'path']."?".$info["query"]." HTTP/1.0rn";
$head .= "Host: ".$info['host']."rn";
$head .= "rn";
$write = fputs($fp, $head);
while (!feof($fp))
{
$line = fread($fp ,4096);
echo $line;
}
}
sock_post($purl,"uu=rrrrrrrrrrrrrr");

function sock_post($url, $query)
{
$info = parse_url($url);
$fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
$head = "POST ".$info['path']."?".$info["query"]." HTTP/1.0rn";
$head .= "Host: ".$info['host']." rn";
$head .= "Referer: http://".$info['host'].$info['path']."rn";
$head .= "Content-type : application/x-www-form-urlencodedrn";
$head .= "Content-Length: ".strlen(trim($query))."rn";
$head .= "rn";
$head .= trim($query);
$write = fputs($fp, $head);
while (!feof($fp))
{
$line = fread($fp,4096);
echo $line;
}
}

?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444965.htmlTechArticleThis article provides you with a php tutorial fsockopen fake post and get methods, if you are looking for fake post and The PHP processing code for the get method is pretty good. ?php //fsocket simulation post...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn