[PHP] 用php的fsocket模拟get提交 模拟post提交表单 →→→→→进入此内容的聊天室

来自 , 2020-02-11, 写在 PHP, 查看 125 次.
URL http://www.code666.cn/view/92bf5e62
  1. <?php
  2. //fsocket模拟post提交
  3. $purl = "http://www.baidu.com";
  4. sock_post($purl, "parm=ping");
  5.  
  6. //fsocket模拟get提交
  7. function sock_get($url, $query)
  8. {
  9.     $info = parse_url($url);
  10.     $fp   = fsockopen($info["host"], 80, $errno, $errstr, 3);
  11.     $head = "GET " . $info['path'] . "?" . $info["query"] . " HTTP/1.0rn";
  12.     $head .= "Host: " . $info['host'] . "rn";
  13.     $head .= "rn";
  14.     $write = fputs($fp, $head);
  15.     while (!feof($fp)) {
  16.         $line = fread($fp, 4096);
  17.         echo $line;
  18.     }
  19. }
  20. sock_post($purl, "parm=ping");
  21.  
  22. function sock_post($url, $query)
  23. {
  24.     $info = parse_url($url);
  25.     $fp   = fsockopen($info["host"], 80, $errno, $errstr, 3);
  26.     $head = "POST " . $info['path'] . "?" . $info["query"] . " HTTP/1.0rn";
  27.     $head .= "Host: " . $info['host'] . "rn";
  28.     $head .= "Referer: http://" . $info['host'] . $info['path'] . "rn";
  29.     $head .= "Content-type: application/x-www-form-urlencodedrn";
  30.     $head .= "Content-Length: " . strlen(trim($query)) . "rn";
  31.     $head .= "rn";
  32.     $head .= trim($query);
  33.     $write = fputs($fp, $head);
  34.     while (!feof($fp)) {
  35.         $line = fread($fp, 4096);
  36.         echo $line;
  37.     }
  38. }
  39.  
  40. ?>

回复 "用php的fsocket模拟get提交 模拟post提交表单"

这儿你可以回复上面这条便签

captcha