php中fsockopen模仿post与get详解

在php中fsockopen函数可以模仿用户去访问一些网站并且还可以带一些常用的信息,如果浏览器,IP,post,get 等等数据,下面我分别一来给大家介绍介绍。

如果你要使用fsockopen函数我们必须在php.ini中把allow_url_fopen = On 设置为开启状态。

 fsockopen() Example

 代码如下 复制代码

<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />n";
} else {
    $out = "GET / HTTP/1.1rn";
    $out .= "Host: www.example.comrn";
    $out .= "Connection: Closernrn";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
?>


伪造post

POST HTTP请求(URL)并获取返回值

 

全文:http://www.php100.com/html/php/lei/2013/0905/5382.html //更详细

posted @ 2014-05-11 10:29  stma  阅读(168)  评论(0)    收藏  举报