Phpfsockopen imitates user post data. A simple php-related function is used to implement data submission. For more information, see. The code is as follows: Copy the code? Phpfunctionwfopen ($ url, $ post, $ cookie, $ timeo is a simple function that uses php to submit data. For more information, see.
The code is as follows: |
|
Function wfopen ($ url, $ post = '', $ cookie ='', $ timeout = 15 ){ $ Matches = parse_url ($ url ); $ Out = "POST {$ matches ['path']} HTTP/1.0rn "; $ Out. = "Accept: */* rn "; $ Out. = "Accept-Language: zh-cnrn "; $ Out. = "Content-Type: application/x-www-form-urlencodedrn "; $ Out. = "User-Agent: $ _ SERVER [HTTP_USER_AGENT] rn "; $ Out. = "Host: {$ matches ['host']} rn "; $ Out. = 'content-Length: '. strlen ($ post). "rn "; $ Out. = "Connection: Closern "; $ Out. = "Cache-Control: no-cachern "; $ Out. = "Cookie: $ cookiernrn "; $ Out. = $ post; $ Socket = @ fsockopen ($ matches ['host'], 80, $ errno, $ errstr, $ timeout) or die ("$ errstr ($ errno )"); Fwrite ($ socket, $ out ); $ Header = $ data = ""; While ($ infos = trim (fgets ($ socket, 4096 ))){ $ Header. = $ infos; } While (! Feof ($ socket )){ $ Data. = fgets ($ socket, 4096 ); } Return $ data; } Echo wfopen ('http: // localhost/te. php', 'id = 5 '); ?> Te. php If (! Empty ($ _ POST ['id']) { Echo setcookie ('auth', 'haowei', time () + 3600 ,'/')? 1: 0; } |
Bytes. The code is as follows? Php function wfopen ($ url, $ post = '', $ cookie ='', $ timeo...