夏广沫吧 关注:41贴子:266
  • 3回复贴,共1

【唯独`广沫No.①】你是尸体。

只看楼主收藏回复



IP属地:湖北1楼2010-06-17 22:55回复
    <?php
    /**
     * baidu 贴吧自动回帖机
     * author: hetal
     * email : [email]huoqi29@163.com[/email]
     * qq  : 231073376
     * msn  : [email]hetao29@hotmail.com[/email]
     * web  : [url]http://www.haqoo.com[/url]
     *
     */
    class Baidu_Post{
      var $proxyPort;
      var $proxyHost;
      var $cookie;
      //设置代理 ,ok
      function setProxy($proxyHost,$proxyPort){
        $this->proxyPort=$proxyPort;
        $this->proxyHost=$proxyHost;
      }
      //初始化baiduID ,ok
      function init(){
        $data = $this->_getUrl("/u/info_img/2008-08/18/logo.gif");
          preg_match_all ("/Set-Cookie: (.+?)=(.+?);/", $data, $_matches,PREG_SET_ORDER);
          $tmp=array();
          for($i=0;$i<count($_matches);$i++){
              $tmp[]=$_matches[$i][1]."=".$_matches[$i][2];
          }
          $this->cookie=implode(';',$tmp);
      }
      //登录
      function login($user,$pass){
        $cookie=$this->cookie;
        $post_data ="tpl=&tpl_ok=&skip_ok=&aid=0&need_pay=&need_coin=0&pay_method=0&u=&next_target=&return_method=&more_param=&return_type=&username=$user&password=$pass&Submit=+%B5%C7%C2%BC+";
        $post_data_le = strlen($post_data);
        if(!empty($this->proxyPort) and !empty($this->proxyHost)){
          $post_url="http://passport.baidu.com/?login";
          $post_port=$this->proxyPort;
          $post_host=$this->proxyHost;
          $connect="Proxy-Connection";
        }else{
          $post_url="/?login";
          $post_port=80;
          $connect="Connection";
          $post_host="passport.baidu.com";
        }
        $data="POST $post_url HTTP/1.1nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*nReferer: [url]http://passport.baidu.com/?login[/url]nAccept-Language: zh-cnnContent-Type: application/x-www-form-urlencodednAccept-Encoding: gzip, deflatenUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)nHost: passport.baidu.comnContent-Length: $post_data_len$connect: Keep-AlivenCache-Control: no-cachenCookie: $cookienn$post_datan";
        $sock = fsockopen($post_host,$post_port,$errno,$error,3);
        fputs($sock,$data);
        while($rt[]=fgets($sock)){}
        fclose($sock);
        $rt=implode("",$rt);
        $rt=str_replace("n","",$rt);
        $rt=str_replace("t","",$rt);
        preg_match_all ("/Set-Cookie: (.+?)=(.+?);/", $rt, $_matches,PREG_SET_ORDER);
        $tmp=array();
        for($i=0;$i<count($_matches);$i++){
            $tmp[]=$_matches[$i][1]."=".$_matches[$i][2];
        }
        $this->cookie=$cookie.";".implode(';',$tmp);
        if(isset($tmp['BDUSS']) and !empty($tmp['BDUSS'])){
          return 0;
        }else{
          return 1;
        }
      }
      //得到最热的500个贴吧
      function getTop500($url="http://post.baidu.com/tb/firstindex/1.html"){
    


    2楼2010-06-21 11:16
    回复
          $content=$this->_getUrl($url);
          $title=array();
          //preg_match_all ("/<a href="http://post.baidu.com/f(.+?)"(.+?)>(.+?)</a>/", $content, $_matches,PREG_SET_ORDER);
          preg_match_all ("/<a href="/f(.+?)"(.+?)>(.+?)</a>/", $content, $_matches,PREG_SET_ORDER);
          foreach($_matches as $value){
            $tmp=array();
            $tmp['url']="http://post.baidu.com/f".$value[1];
            $tmp['title']=$value[3];
            $title[]=$tmp;
          }
          return $title;
      }
        //得到每个贴吧对应的第1页的贴子
        function getTitle($tieba_url){
          $content=$this->_getUrl($tieba_url);
          //echo $content;
          $title=array();
          preg_match_all ("/<a(.+?)href="/f?kz=(.+?)"(.+?)>(.+?)</a>/", $content, $_matches,PREG_SET_ORDER);
          //print_r($_matches);
          foreach($_matches as $value){
            $tmp=array();
            $tmp['url']="http://post.baidu.com/f?kz=".$value[2];
            $tmp['title']=$value[4];
            $title[]=$tmp;
          }
          return $title;
        }
        //回贴
        function huitie($url,$title1,$title="",$content="",$logo="http://"){
          $fileds=$this->_getTie($url);
          if(empty($fileds)){return -1;}
          $tmp[]="ct=".$fileds['ct'];
          $tmp[]="tn=".$fileds['tn'];
          $tmp[]="word=".urlencode($fileds['word']);
          $tmp[]="lm=".$fileds['lm'];
          $tmp[]="z=".$fileds['z'];
          $tmp[]="sc=".$fileds['sc'];//贴子总数
          $tmp[]="cm=".$fileds['cm'];
          $tmp[]="rn=".$fileds['rn'];
          $tmp[]="bs=".$fileds['bs'];
          $tmp[]="str2=".$fileds['str2'];
          $tmp[]="rs3=".$fileds['rs3'];
          $tmp[]="bu=".urlencode($url);//这是回跳地址 //window.location
          $tmp[]="ti=".rawurlencode($title);//标题
          $tmp[]="ti1=".rawurlencode($title1);
          $tmp[]="co=".rawurlencode($content);
          $tmp[]="str1=".rawurlencode($logo);
          $tmp[]="ch1=on";
          $tmp[]="Submit3=%B7%A2%B1%ED%CC%F9%D7%D3";
          $cookie=$this->cookie;
          $post_data =implode("&",$tmp);
          $post_data_le = strlen($post_data);
          if(!empty($this->proxyPort) and !empty($this->proxyHost)){
            $post_url="http://tiebacommit.baidu.com/f";
            $post_port=$this->proxyPort;
            $connect="Proxy-Connection";
            $post_host=$this->proxyHost;
          }else{
            $post_url="/f";
            $post_port=80;
            $connect="Connection";
            $post_host="tiebacommit.baidu.com";
          }
          $data="POST $post_url HTTP/1.1nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, 


      3楼2010-06-21 11:16
      回复
        application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*nAccept-Language: zh-cnnContent-Type: application/x-www-form-urlencodednUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar)nHost: tiebacommit.baidu.comnContent-Length: $post_data_lenConnection: Keep-AlivenCache-Control: no-cachenCookie: $cookienn$post_datan";
            $sock = fsockopen($post_host,$post_port,$errno,$error,3);
            fputs($sock,$data);
            while (!feof($sock)) {
              $rt[]=fgets($sock,1024);
            }
            fclose($sock);
            $rt=implode("",$rt);
            $rt=str_replace("n","",$rt);
            $rt=str_replace("t","",$rt);
            preg_match_all ("/var rsn=(.+?);/", $rt, $_matches,PREG_SET_ORDER);
            return isset($_matches[0][1])?$_matches[0][1]:-99;
          }
          function _getTie($url="http://post.baidu.com/f?kz=190275966"){
            $content=$this->_getUrl($url);
            $title=array();
            preg_match_all ("/<input type=hidden name=(.+?) value=(.+?)>/", $content, $_matches,PREG_SET_ORDER);
            foreach($_matches as $value){
              $key =trim($value[1]);
              $v  =str_replace(""","",trim($value[2]));
              $title[$key]=($v);
            }
            preg_match_all ("/fr_as_js_tr(){(.+)}/", $content, $_matches,PREG_SET_ORDER);
            $title['str2']=$this->_getStr2($_matches[0][1]);
            unset($title['pn']);
            unset($title['kw']);
            unset($title['rs2']);
            preg_match_all ("/var need_verify=(.+?);/", $content, $_matches,PREG_SET_ORDER);
            if($_matches[0][1]==10){
              return null;
            }
            return $title;
          }
          function _getStr2($cmd){
            $cmd = str_replace("var ","",$cmd);
            $cmd = str_replace("Math.","",$cmd);
            $cmd = str_replace("v",'$v',$cmd);
            $cmd = str_replace("i",'$i',$cmd);
            return eval($cmd);
          }
          function _getUrl($url,$referer="")
          {
            $purl= parse_url($url);
            $host=$purl['host'];
            if(!empty($this->proxyHost) and !empty($this->proxyPort)){
              $port=$this->proxyPort;
              $post_host=$this->proxyHost;
            }else{
              $post_host=$purl['host'];
              if(empty($purl['port'])){
                $port=80;
              }else{
                $port=$purl['port'];
              }
            }
            $cookie = $this->cookie;
            $path=$purl['path'];
            $query=empty($purl['query'])?"":$purl['query'];
            if(!empty($proxyhost) and !empty($proxyport)){
              $content="";
              $content.="GET $url HTTP/1.0rn";
              $content.="Accept: */*rn";
              if(!empty($referer))
              $content.="Referer: $refererrn";
              $content.="Accept-Language: zh-cnrn";
              $content.="Proxy-Connection: Keep-Alivern";
              $content.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn";
              $content.="Host: $hostrn";
              $content.="Pragma: no-cachern";
              $content.="Cookie: $cookiern";
              $content.="rnrn";
            }else{
              $content="";
              if(!empty($query))
              $content.="GET $path?$query HTTP/1.0rn";
              else
              $content.="GET $path HTTP/1.0rn";
              $content.="Accept: */*rn";
              if(!empty($referer))
              $content.="Referer: $refererrn";
              $content.="Accept-Language: zh-cnrn";
              $content.="Connection: Keep-Alivern";
              $content.="User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)rn";
              $content.="Host: $hostrn";
              $content.="Pragma: no-cachern";
              $content.="Cookie: $cookiern";
              $content.="rnrn";
            }
            $sock=fsockopen ($post_host,$port,$errno, $errstr, 3);
            if($sock){
              fwrite($sock,$content);
            }else{
              return null;
            }
            while($r[]=fgets($sock)){};
            fclose($sock);
            return implode("n",$r);
          }
        }
        $baidu = new Baidu_Post;
        $baidu->init();
        $baidu->login("user","pass");
        $baidu->huitie($url,$title,$my_title,$my_content,$my_logo);
        $baidu->huitie("http://post.baidu.com/f?kz=199435887","【懂我】为什么排名上不去了 ","我的标题","我的内容","");
        ?>


        4楼2010-06-21 11:16
        回复