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

Detailed explanation of php fsockopen fake post and get methods_PHP tutorial

WBOY
Release: 2016-07-21 15:06:37
Original
781 people have browsed it

fsockopen fakes the post and get methods. If you are looking for the PHP processing code that fakes the post and get methods, this one is good.

Copy code The code is as follows:

//fsocket simulated post submission
$purl = "http://localhost/netphp/test2.php?uu=rrrrrrrrrrr";
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/327613.htmlTechArticlefsockopen fake post and get methods, if you are looking for php processing code for fake post and get methods, this is a good one oh. Copy the code. The code is as follows: ?php //fsocket simulates post submission $purl...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template