Fsockopen spoofs the post and get methods. If you are looking for php processing code that spoofs the post and get methods, this is good.
Copy codeThe Code is as follows:
<? Php
// Fsocket simulate post submission
$ Purl = "http: // localhost/netphp/test2.php? Uu = rrrrrrrrrrrr ";
Print_r (parse_url ($ url ));
Sock_post ($ purl, "uu = 55555555555555555 ");
// Fsocket simulate 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;
}
}
?>