Discuz发帖机PHP版

字体大小: 中小 标准 ->行高大小: 标准
写这个的目的不是为了漫天去发广告,所以没考虑验证码和验证问答。

<?
error_reporting("7");
$url = "http://www.*********.com/logging.php";
$headers = get_headers($url);
preg_match("/Set-Cookie: (.+?);/", $headers[6], $harr);
$cookie = $harr[1];
$data = array(
                'action'=>'login',
                'loginsubmit'=>'yes',
                'username'=>'*********',
                'password'=>'*********',
                'cookietime'=>'2592000'
                );
$data = http_build_query($data);
$opts = array(
                'http'=>array(
                        'method'=>'POST',
                        'header'=>"Content-type: application/x-www-form-urlencoded\r\n".
                        "$cookie\r\n"."Content-Length:".strlen($data)."\r\n",
                        'content'=>$data
                        )
                );
$context = stream_context_create($opts);

$fp = fopen($url, 'r', false, $context);
while(!feof($fp)){
        $html .= fgets($fp);
}
preg_match("/formhash=(.{8})\"\>/", $html, $array);
$formhash = $array['1'];
echo "cookie:$cookie\nformhash:$formhash\n";
?>
 


上面是登录部分,取得cookie和formhash。

需要注意的是formhash,这个东西是会变的,唯一一个肯定会受到影响的因素就是时间,如果其他因素(用户名,UID,密码,AUTHKEY,等等)都不变的话, formhash会每隔100000000秒改变一次(1157天)。

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/67197.html