Baidu Tieba AutoSign PHP

From NAT, 7 Years ago, written in PHP, viewed 1'355 times.
URL https://code.nat.moe/view/492532a5 Embed
Download Paste or View Raw
  1. <?php
  2. /* Baidu Tieba Auto Sign Script
  3.    This Script is designed to run under CLI, however, you can also run it under httpd.
  4.    In order to use this auto sign script, you will need PHP MySQL Extension, you should be able to use it if you have MySQL Server, if not, try php5-mysql package .
  5.    You need to initialize your MySQL database first. We have dump the sql script for you : http://c.magicnat.com/view/42fdb1b9
  6. */
  7. // Basic Settings
  8. $cookie = 'BDUSS=';//Your BUDSS Cookie, we need this in order to access your account.
  9. $dbname = ''; //The name of database which yor initialized.
  10. $host = '127.0.0.1'; //Addess of MySQL Server
  11. $port = '3306';//Port of MySQL Server
  12. $user = '';//Username of MySQL Server
  13. $pwd = '';//Password of MySQL Server account
  14. //All right. You shuold be able to use this script now.
  15.  
  16. $link = @mysql_connect("{$host}:{$port}",$user,$pwd,true);
  17. if(!$link) {
  18.     die("Connect Server Failed: " . mysql_error($link));
  19. }
  20. if(!mysql_select_db($dbname,$link)) {
  21.     die("Select Database Failed: " . mysql_error($link));
  22. }
  23. function curl_get($url,$ua=false,$post_data=''){
  24.     global $cookie;
  25.     $ch=curl_init($url);
  26.     if ($ua){
  27.         curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0 (Linux; U; Android 2.3.4; zh-cn; W806 Build/GRJ22) AppleWebKit/530.17 (KHTML, like Gecko) FlyFlow/2.4 Version/4.0 Mobile Safari/530.17 baidubrowser/042_1.8.4.2_diordna_008_084/AIDIVN_01_4.3.2_608W/1000591a/9B673AC85965A58761CF435A48076629%7C880249110567268/1'));
  28.     }
  29.     else{
  30.         curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0','Connection:keep-alive','Referer:http://wapp.baidu.com/'));
  31.     }
  32.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  33.     if (is_array($post_data)) {
  34.         curl_setopt($ch, CURLOPT_POST, 1);
  35.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  36.     }
  37.     curl_setopt($ch,CURLOPT_COOKIE,$cookie);
  38.     $content = curl_exec($ch);
  39.     curl_close($ch);
  40.     return $content;
  41. }
  42. function sign(){
  43.     global $cookie;
  44.     $result = mysql_query('SELECT * FROM tieba_list');
  45.     while($row = mysql_fetch_array($result))
  46.     {
  47.         $value = $row['kw_name'];
  48.         $url = "http://tieba.baidu.com/mo/m?kw={$value}";
  49.         $get_url = curl_get($url);
  50.         preg_match_all('/<td style="text-align:right;"><a href="(.*?)">签到<\/a>/', $get_url, $matches);
  51.         if (isset($matches[1][0]))
  52.         {
  53.             preg_match('/BDUSS=(.*?);/', $cookie,$cookie_match);
  54.             preg_match('/name="tbs" value="(.*?)"/', $get_url,$tbs_match);
  55.             preg_match('/name="fid" value="(.*?)"/', $get_url,$fid_match);
  56.  
  57.             $postarr = array(
  58.                 'BDUSS' =>$cookie_match[1],
  59.                 '_client_id' => '04-00-DA-69-15-00-73-97-08-00-02-00-06-00-3C-43-01-00-34-F4-22-00-BC-35-19-01-5E-46',
  60.                 '_client_type' => '4',
  61.                 '_client_version' => '1.2.1.17',
  62.                 '_phone_imei' => '641b43b58d21b7a5814e1fd41b08e2a5',
  63.                 'fid' => $fid_match[1],
  64.                 'kw' => iconv('GBK', 'UTF-8', urldecode($value)),
  65.                 'net_type' => '3',
  66.                 'tbs' => $tbs_match[1]
  67.             );
  68.  
  69.             $sign = '';
  70.             foreach ($postarr as $key => $val){
  71.                 $sign .= $key . '=' . $val;
  72.             }
  73.  
  74.             $postarr['sign'] = md5($sign.'tiebaclient!!!');
  75.  
  76.             $sign_url='http://c.tieba.baidu.com/c/c/forum/sign';
  77.  
  78.             $get_sign = curl_get($sign_url,true,$postarr);
  79.             $json_data=json_decode($get_sign);
  80.  
  81.             switch ($json_data -> {'error_code'})
  82.             {
  83.             case '0':
  84.                 echo iconv('GBK', 'UTF-8', urldecode($value))."-OK\n";
  85.                 mysql_query("DELETE FROM tieba_list WHERE kw_name = '$value'");
  86.                 break;
  87.             case '160002':
  88.                 echo iconv('GBK', 'UTF-8', urldecode($value))."-Already Done\n";
  89.                 mysql_query("DELETE FROM tieba_list WHERE kw_name = '$value'");
  90.                 break;
  91.             case '160008':
  92.                 echo iconv('GBK', 'UTF-8', urldecode($value))."-Frequency TOO FAST, Retried\n";;
  93.                 sleep(1);
  94.                 curl_get($sign_url,true,$postarr);
  95.                 break;
  96.             default:
  97.                 echo 'Unknow Error, Code:'.$json_data -> {'error_code'}.$json_data -> {'error_msg'}.'\n';
  98.             }
  99.         }
  100.         elseif (strpos($get_url, 'OK\n')){
  101.             mysql_query("DELETE FROM tieba_list WHERE kw_name = '$value'");
  102.             echo iconv('GBK', 'UTF-8', urldecode($value))."-Already Done\n";
  103.         }
  104.         else{
  105.             echo iconv('GBK', 'UTF-8', urldecode($value))."-Unknow Error, Maybe already signed.\n";
  106.         }
  107.     }
  108. }
  109. function getmylike(){
  110.     global $cookie;
  111.     $day = date('Y-m-d',time());
  112.     mysql_query("UPDATE sign_notes SET last_sign = '$day'");
  113.     mysql_query('TRUNCATE tieba_list');
  114.     $islogin = "http://tieba.baidu.com/dc/common/tbs?t=".time();
  115.     $check = json_decode(curl_get($islogin));
  116.     if (!$check->is_login){
  117.         echo "Maybe Wrong Cookies?";
  118.         exit();
  119.     }
  120.     $mylikeurl = 'http://tieba.baidu.com/f/like/mylike?';
  121.     $result = curl_get($mylikeurl);
  122.     $page = 2;
  123.     $result2 = curl_get($mylikeurl.'&pn=2');
  124.     $result .= $result2;
  125.     while (strpos($result2, '/f?kw')) {
  126.         $page ++;
  127.         $result2 = curl_get($mylikeurl.'&pn='.$page);
  128.         $result .=$result2;
  129.     }
  130.     $pre_reg = '/f\?kw=(.*?)"/';
  131.     preg_match_all($pre_reg, $result, $matches);
  132.     $i = 0;
  133.     foreach ($matches[1] as $key => $value) {
  134.         $sql = "INSERT INTO tieba_list (kw_name) VALUES ('$value')";
  135.         $re = mysql_query($sql);
  136.         if(!$re)
  137.             {
  138.                 die('Error: ' . mysql_error());
  139.             }
  140.         $i++;
  141.     }
  142.     echo "Get liked successful, total $i.\n";
  143.     return true;
  144. }
  145. getmylike();
  146. sign();
  147. ?>

Replies to Baidu Tieba AutoSign PHP rss

Title Name Language When
Baidu Tieba AutoSign PHP NAT php 7 Years ago.

Reply to "Baidu Tieba AutoSign PHP"

Here you can reply to the paste above

captcha