2021-10-07

此处仅作记录。

 

<?php
error_reporting(0);
if(version_compare(PHP_VERSION,'5.6.0','<')){exit('请升级当前PHP环境,本版本解析需PHP5.6以上版本支持!');}

  $uin='';//QQ号码(要求全新账号)
  $qqpw='';//QQ密码(要求全新账号)
  $cookie_file1 = './cookie/qqcookie_f.php';
  $cookie_fles = 'cookie/';
  $cookie_def = 8*3600; 




if(is_file($cookie_file1)){
  if((time() - filemtime($cookie_file1) > $cookie_def ) || (filesize($cookie_file1) < 39)){
    $h2_qqcookie_data = login($uin, $qqpw);
        print_r($h2_qqcookie_data);
        $h2_qqcookie_cehtml = '<?php'.PHP_EOL;
        $h2_qqcookie_cehtml .= '$h2_qqcookie_data_arr = [];'.PHP_EOL;
        foreach( $h2_qqcookie_data as $k=>$v) {
        $h2_qqcookie_cehtml .= '$h2_qqcookie_data_arr["'.$k.'"] = "'.$v.'";'.PHP_EOL;
        }
        $h2_qqcookie_cehtml .= PHP_EOL .'?>';
      
    xmlsc1_qqc('qqc',$h2_qqcookie_cehtml,$cookie_file1);
  }
}else{
  if(!is_readable($cookie_fles)){is_dir($cookie_fles) or mkdir($cookie_fles,0777,true);}
    $h2_qqcookie_data = login($uin, $qqpw);
  
      $h2_qqcookie_cehtml = '<?php'.PHP_EOL;
        $h2_qqcookie_cehtml .= '$h2_qqcookie_data_arr = [];'.PHP_EOL;
        foreach( $h2_qqcookie_data as $k=>$v) {
        $h2_qqcookie_cehtml .= '$h2_qqcookie_data_arr["'.$k.'"] = "'.$v.'";'.PHP_EOL;
        }
        $h2_qqcookie_cehtml .= PHP_EOL .'?>';
      
    xmlsc1_qqc('qqc',$h2_qqcookie_cehtml,$cookie_file1);

}
include($cookie_file1);



/****************************************************************************
解析QQ密码的类,开始
*****************************************************************************/

  class RSA
  {
    public static $pt = 28;
    public static $rt = 0xdeadbeefcafe;
    public static $st;
    public static $lt = 52;

    public static $at;
    public static $ct;
    public static $ut = "0123456789abcdefghijklmnopqrstuvwxyz";
        public static $gt = array();

    public static $dt;
    public static $ht;
    public static $ft;

    public static $_bt;
    
    public static $NavigatorAppName = "Netscape";

    /**
     * [一些对象值]
     */
    public static $r_DB;
    public static $r_DM;
    public static $r_DV;
    public static $r_FV;
    public static $r_F1;
    public static $r_F2;
    public static $r_ZERO;
    public static $r_ONE;

    public static $f_Arr = array();
    public static $ot_Arr = array();
    public static $o_Arr = array();
    public static $n_Arr = array();
    public static $Y_Arr = array();
    public static $Y_e = array();
    public static $PP_Arr = array();
    public static $Wj_Arr = array();
    public static $UU_Arr = array();
    public static $EE_n = array();
    public static $EE_o = array();
    public static $EE_p = array();
    public static $EE_vv = array();

    /**
     * 公共函数
     */
    private function random($min = 0, $max = 1)
    {
      return $min + mt_rand()/mt_getrandmax()*($max-$min);
    }
    private function charCodeAt($s,$n){
      $str = substr($s, $n, 1);
      if (strlen($str) == 1)
        return ord($str);
      $str = mb_convert_encoding($str, 'UCS-4BE', 'utf-8');
      $tmp = unpack('N', $str);
      return $tmp[1];
    }
    private function shr32($x, $bits){
      if($bits <= 0){
        return $x;
      }
      if($bits >= 32){
        return 0;
      }
      $bin = decbin($x);
      $l = strlen($bin);
      if($l > 32){
        $bin = substr($bin, $l - 32, 32);
      }elseif($l < 32){
        $bin = str_pad($bin, 32, '0', STR_PAD_LEFT);
      }
      return bindec(str_pad(substr($bin, 0, 32 - $bits), 32, '0', STR_PAD_LEFT));
    }
    private function DateGetTime() {
      list($msec, $sec) = explode(' ', microtime());
      $msectime =  (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
      return $msectime;
    }

    /**
     * [初始化]
     */
    function __construct()
    {
      /**
       *  初始化对象值
       */
      self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />r_DB = self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />pt;
      self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />r_DM = (1 << self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />pt) - 1;
      self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />r_DV = 1 << self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />pt;
      self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />r_FV = pow(2, self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />lt);
      self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />r_F1 = self:<img src=\"static/image/smiley/default/shy.gif\" smilieid=\"8\" border=\"0\" alt=\"\" />lt - self::$pt;
      self::$r_F2 = 2 * self::$pt - self::$lt;

      //self::$rt = number_format(self::$rt,0,'','');
      (15715070 == (16777215 & self::$rt)) ? self::$st = True : self::$st = False;
      
      if(self::$st && "Microsoft Internet Explorer" == self::$NavigatorAppName)
      {
        //r.prototype.am = a;
        self::$pt = 30;
      }else if(self::$st && "Netscape" != self::$NavigatorAppName)
      {
        //r.prototype.am = l;
        self::$pt = 26;
      }else
      {
        //r.prototype.am = c;
        self::$pt = 28;
      }
      for (self::$at = $this -> charCodeAt("0",0),self::$ct = 0; 9 >= self::$ct; ++self::$ct)
        self::$gt[self::$at++] = self::$ct;
      for (self::$at = $this -> charCodeAt("a",0),self::$ct = 10; 36 > self::$ct; ++self::$ct)
        self::$gt[self::$at++] = self::$ct;
      for (self::$at = $this -> charCodeAt("A",0),self::$ct = 10; 36 > self::$ct; ++self::$ct)
        self::$gt[self::$at++] = self::$ct;
      
      self::$r_ZERO = $this -> f(0);
      self::$r_ONE = $this -> f(1);
      
      if (NULL == self::$ht) {
        self::$ht = array();
        self::$ft = 0;
        $mt;
        while (self::$_bt > self::$ft)
        {
          $mt = floor(65536 * $this -> random());
          self::$ht[self::$ft++] = $this -> shr32($mt,8);
          self::$ht[self::$ft++] = 255 & $mt;
        }
        self::$ft = 0;
        $this -> Z();
      }
      self::$_bt = 256;
    }

    /**
     * [入口]
     */
    function rsa_encrypt($i)
    {
      return $this -> ot($i);
    }

    private function ot($t){
      $e = "e9a815ab9d6e86abbf33a4ac64e9196d5be44a09bd0ed6ae052914e1a865ac8331fed863de8ea697e9a7f63329e5e23cda09c72570f46775b7e39ea9670086f847d3c9c51963b131409b1e04265d9747419c635404ca651bbcbc87f99b8008f7f5824653e3658be4ba73e4480156b390bb73bc1f8b33578e7a4e12440e9396f2552c1aff1c92e797ebacdc37c109ab7bce2367a19c56a033ee04534723cc2558cb27368f5b9d32c04d12dbd86bbd68b1d99b7c349a8453ea75d1b2e94491ab30acf6c46a36a75b721b312bedf4e7aad21e54e9bcbcf8144c79b6e3c05eb4a1547750d224c0085d80e6da3907c3d945051c13c7c1dcefd6520ee8379c4f5231ed";
      $n = "10001";
      $this -> n($e, $n);
      return $this -> p($t);
    }

    private function t($t, $e) {
      $this -> r($t, $e);
      return self::$n_Arr;
    }

    private function r($t, $e = NULL, $i = NULL) {
      if(NULL != $t)
      {
        if(gettype($t) == 'integer')
        {
          //this.fromNumber(t, e, i);
        }else if((NULL == $e) && (gettype($t) != 'string'))
        {
          $this -> m($t, 256);
        }else{
          $this -> m($t, $e);
        }
      }
    }

    private function m($t, $e) {
      $i;
      if (16 == $e) $i = 4;
      else if (8 == $e) $i = 3;
      else if (256 == $e) $i = 8;
      else if (2 == $e) $i = 1;
      else if (32 == $e) $i = 5;
      else {
        if (4 != $e) return false;//void this.fromRadix(t, e);
        $i = 2;
      }
      self::$n_Arr['t'] = 0;
      self::$n_Arr['s'] = 0;
      $o = !1;
      $p = 0;
      for ($n = 'array' == gettype($t) ? count($t) : strlen($t); --$n >= 0;)
      {
        $s = 8 == $i ? 255 & $t[$n] : $this -> g($t, $n);
        if(0 > $s)
        {
          if("-" == $t[$n])
          {
            $o = !0;
          }
        }else
        {
          $o = !1;
          if(0 == $p)
          {
            self::$n_Arr[self::$n_Arr['t']++] = $s;
          }else if($p + $i > self::$r_DB)
          {
            self::$n_Arr[self::$n_Arr['t'] - 1] |= ($s & (1 << self::$r_DB - $p) - 1) << $p;
            self::$n_Arr[self::$n_Arr['t']++] = $s >> self::$r_DB - $p;
          }else
          {
            self::$n_Arr[self::$n_Arr['t'] - 1] |= $s << $p;
          }
        }
        $p += $i;
        if($p >= self::$r_DB)
        {
          $p -= self::$r_DB;
        }
      }
      if(8 == $i)
      {
        if(0 != (128 & $t[0]))
        {
          self::$n_Arr['s'] = -1;
          if($p > 0)
          {
            self::$n_Arr[self::$n_Arr['t'] - 1] |= (1 << self::$r_DB - p) - 1 << $p;
          }
        }
      }
      $this -> a_a();
      $o && $this -> xx(self::$n_Arr, self::$n_Arr,self::$n_Arr);
    }
    
    private function a_a() {
      for ($t = self::$n_Arr['s'] & self::$r_DM; self::$n_Arr['t'] > 0 && self::$n_Arr[self::$n_Arr['t'] - 1] == $t;)
        --self::$n_Arr['t'];
    }
    
    private function g($t, $e) {
      $i = self::$gt[$this -> charCodeAt($t,$e)];
      if(gettype($i) == "integer")
      {
        return $i;
      }else
      {
        return -1;
      }
    }

    private function n($e, $i) {
      if(null != $e && null != $i && strlen($e) > 0 && strlen($i) > 0)
      {
        self::$ot_Arr = $this -> t($e, 16);
        self::$o_Arr['n'] = self::$ot_Arr;
        self::$o_Arr['e'] = intval($i, 16);
      }else{
        //"Invalid RSA public key"
      }
    }

    private function h($t) {
      self::$f_Arr['t'] = 1;
      self::$f_Arr['s'] = 0 > $t ? -1 : 0;
      $t > 0 ? self::$f_Arr[0] = $t : -1 > $t ? self::$f_Arr[0] = $t : self::$f_Arr['t'] = 0;
      return self::$f_Arr;
    }

    private function f($t) {
      return $this -> h($t);
    }

    private function X($t)
    {
      self::$ht[self::$ft++] = 255 & $t;
      self::$ht[self::$ft++] = $t >> 8 & 255;
      self::$ht[self::$ft++] = $t >> 16 & 255;
      self::$ht[self::$ft++] = $t >> 24 & 255;
      self::$ft >= self::$_bt && (self::$ft -= self::$_bt);
    }
    
    private function Z()
    {
      $this -> X($this -> DateGetTime()); //$this -> DateGetTime()
    }

    private function p($t) {
      $i = $this -> e($t, $this -> b() + 7 >> 3);
      if(empty($i)) return null;
      $n = $this -> o();
      if (empty($n)) return null;
      $o = $this -> Fa_b(16,$n);
      return 0 == (1 & strlen($o)) ? $o : "0" + $o;
    }

    private function vv($ThisA) {
      $t = array();
      $this -> xx($ThisA, $t, self::$r_ZERO);
      return $t;
    }

    private function Fa_b($t,$ThisA) {
      if ($ThisA['s'] < 0) return "-" + $this -> Fa_b($t,$this -> vv($ThisA));
      if (16 == $t) $e = 4;
      else if (8 == $t) $e = 3;
      else if (2 == $t) $e = 1;
      else if (32 == $t) $e = 5;
      else {
        if (4 != $t) return false;//return this.toRadix(t);
        $e = 2;
      }
      $n = (1 << $e) - 1;
      $o = !1;
      $p = "";
      $r = $ThisA['t'];
      $s = self::$r_DB - $r * self::$r_DB % $e;
      if ($r-- > 0)
      {
        if($s < self::$r_DB)
        {
          if(($i = $ThisA['r'] >> $s) > 0)
          {
            $o = !0;
            $p = $this -> u($i);
          }
        }
        for (; $r >= 0;)
        {
          if($e > $s)
          {
            $i = ($ThisA[$r] & (1 << $s) - 1) << $e - $s;
            $i |= $ThisA[--$r] >> ($s += self::$r_DB - $e);
          }else{
            $i = $ThisA[$r] >> ($s -= $e) & $n;
            if(0 >= $s)
            {
              $s += self::$r_DB;
              --$r;
            }
          }
          if($i > 0) $o = !0;
          if($o) $p .= $this -> u($i);
        }
      }
      return $o ? $p : "0";
    }

    private function u($t) {
      return self::$ut[$t];
    }

    private function o() {
      return $this -> W(self::$o_Arr['e'], self::$o_Arr['n']);
    }

    private function GG($t, $e) {
      if ($t > 4294967295 || 1 > $t) return self::$r_ONE;
      $i = array();
      $n = array();
      $o = $this -> UU();
      $p = $this -> k($t) - 1;
      $this -> EEd($o,$i);
      for (; --$p >= 0;)
      {
        $this -> RR($i, $n);
        if (($t & 1 << $p) > 0) $this -> FF($n, $o, $i);
        else {
          $l = $i;
          $i = $n;
          $n = $l;
        }
      }
      return $this -> OO($i);
    }

    private function FF($t, $e, &$i) {
      $this -> L($e, $i, $t);
      $this -> BB($i,self::$Wj_Arr);
    }

    function OO($t) {
      $e = array();
      $this -> EEd($t,$e);
      $this -> BB($e,self::$Wj_Arr);
      return $e;
    }

    private function L($t, &$e, $ThisA) {
      $i = $ThisA;
      $n = $t;
      $o = $i['t'];
      for ($e['t'] = $o + $n['t']; --$o >= 0;)
      $e[$o] = 0;
      for ($o = 0; $o < $n['t']; ++$o)
      $e[$o + $i['t']] = $this -> c(0, $n[$o], $e, $o, 0, $i['t'], $i);
      $e['s'] = 0;
      $this -> a_Ta($e);
      if($ThisA['s'] != $t['s']) $this -> xx($e, $e,self::$r_ZERO);
    }

    private function NN(&$t,$ThisA) {
      $e = $ThisA;
      for ($i = $t['t'] = 2 * $e['t']; --$i >= 0;)
        $t[$i] = 0;
      for ($i = 0; $i < $e['t'] - 1; ++$i) {
        $n = $this -> c($i, $e[$i], $t, 2 * $i, 0, 1,$e);
        if(($t[$i + $e['t']] += $this -> c($i + 1, 2 * $e[$i], $t, 2 * $i + 1, $n, $e['t'] - $i - 1, $e)) >= self::$r_DV)
        {
          $t[$i + $e['t']] -= self::$r_DV;
          $t[$i + $e['t'] + 1] = 1;
        }
      }
      if($t['t'] > 0) ($t[$t['t'] - 1] += $this -> c($i, $e[$i], $t, 2 * $i, 0, 1,$e));
      $t['s'] = 0;
      $this -> a_Ta($t);
    }

    private function BB(&$t,$ThisA) {
      for (; $t['t'] <= $ThisA['mt2'];)
      $t[$t['t']++] = 0;
      for ($e = 0; $e < $ThisA['m']['t']; ++$e) {
        $i = 32767 & $t[$e];
        $n = $i * $ThisA['mpl'] + (($i * $ThisA['mph'] + ($t[$e] >> 15) * $ThisA['mpl'] & $ThisA['um']) << 15) & self::$r_DM;
        $i = $e + $ThisA['m']['t'];
        $t[$i] += $this -> c(0, $n, $t, $e, 0, $ThisA['m']['t'],$ThisA['m']);
        for (; $t[$i] >= self::$r_DV;){
          $t[$i] -= self::$r_DV;
          $t[++$i]++;
        }
      }
      $this -> a_Ta($t);
      $this -> S($ThisA['m']['t'], $t, $t);
      if($this -> y($ThisA['m'],$t) >= 0) $this -> xx($ThisA['m'], $t, $t);
    }

    private function RR($t, &$e) {
      $this -> NN($e,$t);
      $this -> BB($e,self::$Wj_Arr);
    }

    private function UU() {
      self::$UU_Arr['e'] = array();
      $this -> q(self::$Wj_Arr['m']['t'],self::$UU_Arr['e'],self::$n_Arr);
      //print_r(self::$UU_Arr['e']);
      $this -> EE(self::$Wj_Arr['m'], null, self::$UU_Arr['e']);
      if(self::$n_Arr['s'] < 0){
        $this -> y(self::$r_ZERO,self::$UU_Arr['e']);
        $this -> xx(self::$UU_Arr['e'],self::$UU_Arr['e'],self::$Wj_Arr['m']);
      }
      return self::$UU_Arr['e'];
    }

    private function d() {
      for ($e = self::$Wj_Arr['m']['t'] - 2; $e >= 0; --$e)
        self::$UU_Arr['e'][$e] = self::$Wj_Arr['m'][$e];
      self::$UU_Arr['e']['t'] = self::$Wj_Arr['m']['t'];
      self::$UU_Arr['e']['s'] = self::$Wj_Arr['m']['s'];
    }

    private function EEd($ae,&$t) {
      for ($e = $ae['t'] - 1; $e >= 0; --$e)
        $t[$e] = $ae[$e];
      $t['t'] = $ae['t'];
      $t['s'] = $ae['s'];
    }

    private function EEh($t) {
      self::$UU_Arr['e']['t'] = 1;
      self::$UU_Arr['e']['s'] = 0 > $t ? -1 : 0;
      $t > 0 ? self::$UU_Arr['e'][0] = $t : -1 > $t ? self::$UU_Arr['e'][0] = $t : self::$UU_Arr['e']['t'] = 0;
      return self::$UU_Arr['e'];
    }

    private function EE($t, $e, &$i) {
      self::$EE_n = $t;
      if (!(self::$EE_n['t'] <= 0))
      {
        self::$EE_o = &self::$UU_Arr['e'];
        if (self::$EE_o['t'] < self::$EE_n['t']) {
          if(null != $e)
          {
            $this -> EEh(0);
          }
          if(!empty($i))
          {
            $this -> d(0);
          }
          return NULL;
        }
        $l = self::$UU_Arr['e']['s'];
        $a = $t['s'];
        $c = self::$r_DB - $this -> k(self::$EE_n[self::$EE_n['t'] - 1]);
        if($c)
        {
          $this -> TaT($c, self::$EE_n, self::$EE_p);//self::$EE_n
          $this -> TaT($c, self::$EE_o, $i);  //self::$EE_o
        }else
        {
          $this -> EEd(self::$EE_n,self::$EE_p['e']);  //self::$EE_n
          $this -> EEd(self::$EE_o,$i['e']);  //self::$EE_o
        }
        $u = self::$EE_p['t'];
        $g = self::$EE_p[$u - 1];
        if (0 != $g) {
          $d = $g * (1 << self::$r_F1) + ($u > 1 ? self::$EE_p[$u - 2] >> self::$r_F2 : 0);
          $h = self::$r_FV / $d;
          $f = (1 << self::$r_F1) / $d;
          $m = 1 << self::$r_F2;
          $a_a_ = $i['t'];
          $a_b = $a_a_ - $u;
          if(null == $e)
          {
            $v = &self::$EE_vv;
          }else
          {
            $v = $e;
          }
          $this -> q($a_b, $v, self::$EE_p);
          if($this -> y($v,$i) >= 0)
          {
            $i[$i['t']++] = 1;
            $ii = $i;
            $this -> xx($v, $ii,$i);
          }
          $ii = $i;
          $this -> xx($v, $ii,$i);
          $this -> q($u, $v,self::$r_ONE);
          $this -> xx(self::$EE_p, self::$EE_p, $v);
          for (;self::$EE_p['t'] < $u;)
            self::$EE_p[self::$EE_p[$t++]] = 0;
          for (; --$a_b >= 0;) {
            $w = $i[--$a_a_] == $g ? self::$r_DM : floor($i[$a_a_] * $h + ($i[$a_a_ - 1] + $m) * $f);
            if (($i[$a_a_] += $this -> c(0, $w, $i, $a_b, 0, $u, self::$EE_p)) < $w)
            {
              $this -> q($a_b, $v, self::$EE_p);
              $this -> xx($v, $i,$i);
              for (; $i[$a_a_] < --$w;)
              {
                $this -> xx($v, $i,$i);
              }
            }
          }
          if(null != $e)
          {
            $this -> S($u, $e, $i);
            if($l != $a) $this -> xx($e, $e, self::$r_ZERO);
          }
          $i['t'] = $u;
          $this -> a_Ta($i);
          if($c > 0) $this -> CC($c, $i, $i);
          if(0 > $l) $this -> xx($i, $i, self::$r_ZERO);
        }
      }
    }

    private function CC($t, &$e, $ThisA) {
      $e['s'] = $ThisA['s'];
      $i = floor($t / self::$r_DB);
      if ($i >= $ThisA['t']) return void ($e['t'] = 0);
      $n = $t % self::$r_DB;
      $o = self::$r_DB - $n;
      $p = (1 << $n) - 1;
      $e[0] = $ThisA[$i] >> $n;
      for ($r = $i + 1; $r < $ThisA['t']; ++$r)
      {
        $e[$r - $i - 1] |= ($ThisA[$r] & $p) << $o;
        $e[$r - $i] = $ThisA[$r] >> $n;
      }
      
      if($n > 0)
      {
        $e[$ThisA['t'] - $i - 1] |= ($ThisA['s'] & $p) << $o;
      }
      $e['t'] = $ThisA['t'] - $i;
      $this -> a_Ta($e);
    }

    private function S($t, &$e, $ThisV) {
      for ($i = $t; $i < $ThisV['t']; ++$i)
        $e[$i - $t] = $ThisV[$i];
      $e['t'] = max($ThisV['t'] - $t, 0);
      $e['s'] = $ThisV['s'];
    }

    private function c($t, $e, &$i, $n, $o, $p,$aa) {
      for ($r = 16383 & $e, $s = $e >> 14; --$p >= 0;) {
        $l = 16383 & $aa[$t];
        $a = $aa[$t++] >> 14;
        $c = $s * $l + $a * $r;
        $l = $r * $l + ((16383 & $c) << 14) + $i[$n] + $o;
        $o = ($l >> 28) + ($c >> 14) + $s * $a;
        $i[$n++] = 268435455 & $l;
      }
      return $o;
    }

    private function y($t,$a) {
      $e = $a['s'] - $t['s'];
      if (0 != $e) return $e;
      $i = $a['t'];
      $e = $i - $t['t'];
      if (0 != $e) return $e;
      for (; --$i >= 0;)
        if (0 != ($e = $a[$i] - $t[$i])) return $e;
      return 0;
    }

    private function xx($t, &$e, $thisa) {
      for ($i = 0, $n = 0, $o = min($t['t'], $thisa['t']); $o > $i;)
      {
        $n += $thisa[$i] - $t[$i];
        $e[$i++] = $n & self::$r_DM;
        $n >>= self::$r_DB;
      }
      if ($t['t'] < $thisa['t']) {
        for ($n -= $t['s']; $i < $thisa['t'];)
        {
          $n += $thisa[$i];
          $e[$i++] = $n & self::$r_DM;
          $n >>= self::$r_DB;
        }
        $n += $thisa['s'];
      } else {
        for ($n += $thisa['s']; $i < $t['t'];)
        {
          $n -= $t[$i];
          $e[$i++] = $n & self::$r_DM;
          $n >>= self::$r_DB;
        }
        $n -= $t['s'];
      }
      $e['s'] = 0 > $n ? -1 : 0;
      -1 > $n ? $e[$i++] = $r_DV + $n : $n > 0 && ($e[$i++] = $n);
      $e['t'] = $i;
      $this -> a_Ta($e);
    }
    private function a_Ta(&$e) {
      for ($t = $e['s'] & self::$r_DM; $e['t'] > 0 && $e[$e['t'] - 1] == $t;)
        --$e['t'];
    }
    private function TaT($t,$aa, &$e) {
      $n = $t % self::$r_DB;
      $o = self::$r_DB - $n;
      $p = (1 << $o) - 1;
      $r = floor($t / self::$r_DB);
      $s = $aa['s'] << $n & self::$r_DM;

      for ($i = $aa['t'] - 1; $i >= 0; --$i)
      {
        $e[$i + $r + 1] = $aa[$i] >> $o | $s;
        $s = ($aa[$i] & $p) << $n;
      }
      for ($i = $r - 1; $i >= 0; --$i)
      {
        $e[$i] = 0;
      }
      $e[$r] = $s;
      $e['t'] = $aa['t'] + $r + 1;
      $e['s'] = $aa['s'];
      $this -> a_Ta($e);
    }

    private function q($t, &$e ,$ti) {
      for ($i = $ti['t'] - 1; $i >= 0; --$i){
        $e[$i + $t] = $ti[$i];
      }
      for ($i = $t - 1; $i >= 0; --$i)
        $e[$i] = 0;
      $e['t'] = $ti['t'] + $t;
      $e['s'] = $ti['s'];
    }

    private function W($t, $e) {
      $i = 256;
      if( $i > $t || $this -> zz())
      {
        return $this -> PP($e);
      }else{
        $this -> jj($e);
        return $this -> GG($t, self::$Wj_Arr);
      }
    }

    private function jj($t) {
      self::$Wj_Arr['m'] = $t;
      self::$Wj_Arr['mp'] = $this -> V();
      self::$Wj_Arr['mpl'] = 32767 & self::$Wj_Arr['mp'];
      self::$Wj_Arr['mph'] = self::$Wj_Arr['mp'] >> 15;
      self::$Wj_Arr['um'] = (1 << self::$r_DB - 15) - 1;
      self::$Wj_Arr['mt2'] = 2 * $t['t'];
    }

    private function V() {
      if (self::$ot_Arr['t'] < 1) return 0;
      $t = self::$ot_Arr[0];
      if (0 == (1 & $t)) return 0;
      $e = 3 & $t;
      $e = $e * (2 - (15 & $t) * $e) & 15;
      $e = $e * (2 - (255 & $t) * $e) & 255;
      $e = $e * (2 - ((65535 & $t) * $e & 65535)) & 65535;
      $e = $e * (2 - $t * $e % self::$r_DV) % self::$r_DV;
      return $e > 0 ? self::$r_DV - $e : -$e;
    }

    private function PP($t) {
      self::$PP_Arr['m'] = $t;
      return self::$PP_Arr;
    }

    private function zz() {
      return 0 == (self::$ot_Arr['t'] > 0 ? 1 & self::$ot_Arr[0] : self::$ot_Arr['s']);
    }

    private function b() {
      return self::$n_Arr['t'] <= 0 ? 0 : self::$r_DB * (self::$n_Arr['t'] - 1) + $this -> k(self::$n_Arr[self::$n_Arr['t'] - 1] ^ self::$n_Arr['s'] & self::$r_DM);
    }

    private function k($t) {
      $e;
      $i = 1;
      0 != ($e = $this -> shr32($t,16)) && ($t = $e and $i += 16);
      0 != ($e = $t >> 8) && ($t = $e and $i += 8);
      0 != ($e = $t >> 4) && ($t = $e and $i += 4);
      0 != ($e = $t >> 2) && ($t = $e and $i += 2);
      0 != ($e = $t >> 1) && ($t = $e and $i += 1);
      return $i;
    }

    private function e($t, $e) {
      //print_r($t);
      //print_r($e);
      if ($e < strlen($t) + 11) return NULL;
      $i = array();
      $n = strlen($t) - 1;
      while ($n >= 0 && $e > 0) {
        $o = $this -> charCodeAt($t, $n--);
        $i[--$e] = $o;
      }
      $i[--$e] = 0;
      while ($e > 2) {
        self::$Y_e[0] = 0;
        while (0 == self::$Y_e[0]){
          $this -> J(self::$Y_e);
        }
        $i[--$e] = self::$Y_e[0];
      }
      $i[--$e] = 2;
      $i[--$e] = 0;
      self::$n_Arr = array();
      $this -> r($i);
      return self::$n_Arr;
    }

    private function J($t) {
      $e;
      for ($e = 0; $e < count($t); ++$e)
        self::$Y_e[$e] = $this -> KK();
    }

    private function KK() {
      if ('' == self::$dt) {
        $this -> Z();
        $this -> tt();
        $this -> et(self::$ht);
        for (self::$ft = 0; self::$ft < count(self::$ht); ++self::$ft)
          self::$ht[self::$ft] = 0;
        self::$ft = 0;
        self::$dt = 'old';
      }
      return $this -> it();
    }

    private function tt() {
      self::$Y_Arr['i'] = 0;
      self::$Y_Arr['j'] = 0;
      self::$Y_Arr['S'] = array();
    }

    private function et($t) {
      $i = 0;
      $n;
      for ($e = 0; 256 > $e; ++$e)
        self::$Y_Arr['S'][$e] = $e;
      for ($e = 0;256 > $e; ++$e){
        $i = $i + self::$Y_Arr['S'][$e] + $t[$e % count($t)] & 255;
        $n = self::$Y_Arr['S'][$e];
        self::$Y_Arr['S'][$e] = self::$Y_Arr['S'][$i];
        self::$Y_Arr['S'][$i] = $n;
      }
      self::$Y_Arr['i'] = 0;
      self::$Y_Arr['j'] = 0;
    }

    private function it() {
      $t;
      self::$Y_Arr['i'] = self::$Y_Arr['i'] + 1 & 255;
      self::$Y_Arr['j'] = self::$Y_Arr['j'] + self::$Y_Arr['S'][self::$Y_Arr['i']] & 255;
      $t = self::$Y_Arr['S'][self::$Y_Arr['i']];
      self::$Y_Arr['S'][self::$Y_Arr['i']] = self::$Y_Arr['S'][self::$Y_Arr['j']];
      self::$Y_Arr['S'][self::$Y_Arr['j']] = $t;
      return self::$Y_Arr['S'][$t + self::$Y_Arr['S'][self::$Y_Arr['i']] & 255];
    }
  }

  class Encryption
  {
    public static $f = "";
    public static $m = 0;
    public static $_a = array();
    public static $_b = array();
    public static $v = 0;
    public static $w = 0;
    public static $y = array();
    public static $k = array();
    public static $b = 0;

    public static $q_arr = array();

    function __construct()
    {
      self::$q_arr['PADCHAR'] = '=';
      self::$q_arr['ALPHA'] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    }
    /**
     * PHP实现JS脚本方法  Start >>>
     */
    private function random($min = 0, $max = 1)
    {
      return $min + mt_rand()/mt_getrandmax()*($max-$min);
    }

    private function JsNumber($s)
    {
      if($s == '0') return 0;
      $num = intval($s);
      if(strlen($num) != strlen($s) || $num == 0)
      {
        $num = 'NaN';
      }
      return $num;
    }

    private function charCodeAt($s,$n){
      $str = substr($s, $n, 1);
      if (strlen($str) == 1)
        return ord($str);
      $str = mb_convert_encoding($str, 'UCS-4BE', 'utf-8');
      $tmp = unpack('N', $str);
      return $tmp[1];
    }

    private function uin2hex($str) {
      $maxLength = 16;
      $str = intval($str);
      for ($hex =  dechex($str), $len = strlen($hex), $i = $len; $maxLength > $i; $i++)
        $hex = "0" . $hex;
      for ($arr = array(), $j = 0; $maxLength > $j; $j += 2)
        array_push($arr,"\\x" . substr($hex,$j, 2));
      $result = join("",$arr);
      eval('$result="' . $result . '";');
      return $result;
    }

    private function shr32($x, $bits){
      if($bits <= 0){
        return $x;
      }
      if($bits >= 32){
        return 0;
      }
      $bin = decbin($x);
      $l = strlen($bin);
      if($l > 32){
        $bin = substr($bin, $l - 32, 32);
      }elseif($l < 32){
        $bin = str_pad($bin, 32, '0', STR_PAD_LEFT);
      }
      return bindec(str_pad(substr($bin, 0, 32 - $bits), 32, '0', STR_PAD_LEFT));
    }
    /**
     * PHP实现JS脚本方法  End <<<
     */
    private function e() {
      return 1;
      //return round(4294967295 * $this->random());
    }

    private function i($t, $e, $i) {
      (!$i || $i > 4) && ($i = 4);
      for ($n = 0, $o = $e; $e + $i > $o; $o++){
        $n <<= 8;
        $n |= $t[$o];
      }
      return (4294967295 & $n) >> 0;
    }

    private function n($t, $e, $i) {
      $t[$e + 3] = $i >> 0 & 255;
      $t[$e + 2] = $i >> 8 & 255;
      $t[$e + 1] = $i >> 16 & 255;
      $t[$e + 0] = $i >> 24 & 255;
      return $t;
    }

    private function o($t) {
      if (!$t) return "";
      for ($e = "", $i = 0; $i < count($t); $i++) {
        $n = dechex($this -> JsNumber($t[$i]));
        if (1 == strlen($n)) $n = "0" . $n;
        $e .= $n;
      }
      return $e;
    }

    private function p($t) {
      /**for ($e = "", $i = 0; $i < strlen($t); $i += 2)
        $e .= chr(parseInt(t.substr(i, 2), 16));
      return e*/
    }

    private function r($t, $e = false) {
      if (!$t) return "";
      $e && ($t = $this -> s($t));
      for ($i = array(), $n = 0; $n < strlen($t); $n++)
        $i[$n] = $this -> charCodeAt($t,$n);
      return $this -> o($i);
    }

    private function s($t) {
      $e = array();
      $i = array();
      $n = array();
      $o = strlen($t);
      for ($e = 0; $o > $e; $e++)
      {
        $i = $this -> charCodeAt($t,$e);
        if($i > 0 && 127 >= $i)
        {
          array_push($n,$t[$e]);
        }else if($i >= 128 && 2047 >= $i){
          array_push($n,chr(192 | $i >> 6 & 31), chr(128 | 63 & $i));
        }else if($i >= 2048 && 65535 >= $i){
          array_push($n, chr(224 | $i >> 12 & 15), chr(128 | $i >> 6 & 63), chr(128 | 63 & $i));
        }
      }
      return join("",$n);
    }

    private function l($t) {
      self::$_a = array();
      self::$_b = array();
      self::$v = $w = 0;
      self::$b = !0;
      self::$m = 0;
      $i = count($t);
      $n = 0;
      self::$m = ($i + 10) % 8;
      0 != self::$m && (self::$m = 8 - self::$m);
      self::$y = array();
      self::$_a[0] = 255 & (248 & $this -> e() | self::$m);
      for ($o = 1; self::$m >= $o; $o++)
        self::$_a[$o] = 255 & $this -> e();
      self::$m++;
      for ($o = 0; 8 > $o; $o++)
        self::$_b[$o] = 0;
      for ($n = 1; 2 >= $n;)
      {
        if(8 > self::$m)
        {
          self::$_a[self::$m++] = 255 & $this -> e();
          $n++;
        }
        if(8 == self::$m)
        {
          $this -> c();
        }
      }
      for ($o = 0; $i > 0;)
      {
        if(8 > self::$m)
        {
          self::$_a[self::$m++] = $t[$o++];
          $i--;
        }
        if(8 == self::$m)
        {
          $this -> c();
        }
      }
      for ($n = 1; 7 >= $n;)
      {
        if(8 > self::$m)
        {
          self::$_a[self::$m++] = 0;
          $n++;
        }
        if(8 == self::$m)
        {
          $this -> c();
        }
      }
      return self::$y;
    }

    private function a($t) {
    }

    private function c() {
      for ($t = 0; 8 > $t; $t++){
        self::$_a[$t] ^= self::$b ? self::$_b[$t] : self::$y[self::$w + $t];
      }
      for ($e = $this -> u(self::$_a), $t = 0; 8 > $t; $t++){
        self::$y[self::$v + $t] = $e[$t] ^ self::$_b[$t];
        self::$_b[$t] = self::$_a[$t];
      }
      self::$w = self::$v;
      self::$v += 8;
      self::$m = 0;
      self::$b = !1;
    }

    private function u($t) {
      for ($e = 16, $o = $this -> i($t, 0, 4), $p = $this -> i($t, 4, 4), $r = $this -> i(self::$f, 0, 4), $s = $this -> i(self::$f, 4, 4), $l = $this -> i(self::$f, 8, 4), $a = $this -> i(self::$f, 12, 4), $c = 0, $u = 2654435769; $e-- > 0;)
      {
        $c += $u;
        $c = $this -> shr32((4294967295 & $c),0);
        $o += ($p << 4) + $r ^ $p + $c ^ ($this -> shr32($p, 5)) + $s;
        $o = $this -> shr32((4294967295 & $o), 0);
        $p += ($o << 4) + $l ^ $o + $c ^ ($this -> shr32($o,5)) + $a;
        $p = $this -> shr32((4294967295 & $p),0);
      }
      $g = array();
      $g = $this -> n($g, 0, $o);
      $g = $this -> n($g, 4, $p);
      return $g;
    }

    private function g($t) {
    }

    private function d($t) {
    }

    private function h($t, $e = false) {
      $i = array();
      if ($e)
      {
        for ($n = 0; $n < strlen($t); $n++)
          $i[$n] = 255 & $this -> charCodeAt($t,$n);
      }else{
        for ($o = 0, $n = 0; $n < strlen($t); $n += 2)
          $i[$o++] = intval(substr($t, $n, 2), 16);
      }
      return $i;
    }

    /**
     * TEA方法
     */
    
    private function t($s) {
        return strtoupper(md5($s));
    }
    private function strToBytes($t,$e = false) {
      return $this -> r($t,$e);
    }
    private function TeaInitkey($t, $e = false) {
      self::$f = $this -> h($t, $e);
      return self::$f;
    }

    private function TeaEncrypt($t, $e = false) {
      $i = $this -> h($t, $e);
      $n = $this -> l($i);
      return $this -> o($n);
    }


    private function Eng($t) {
      for ($e = '', $i = 0; $i < (strlen($t)); $i += 2){
        $e = $e . chr(intval(substr($t, $i, 2), 16));
      }
      return $e;
    }

    private function Qgetbyte($t, $e)
    {
      $i = $this -> charCodeAt($t,$e);
      if ($i > 255) return "INVALID_CHARACTER_ERR: DOM Exception 5";
      return $i;
    }

    private function encode($t) {
      $e;
      $i;
      $n = self::$q_arr['PADCHAR'];
      $o = self::$q_arr['ALPHA'];
      //var p = q.getbyte; ///Qgetbyte
      $r = array();
      $t = "" . $t;
      $s = strlen($t) - strlen($t) % 3;
      if (0 == strlen($t)) return $t;
      for ($e = 0; $s > $e; $e += 3)
      {
        $i = $this -> Qgetbyte($t, $e) << 16 | $this -> Qgetbyte($t, $e + 1) << 8 | $this -> Qgetbyte($t, $e + 2);
        array_push($r,$o[$i >> 18]);
        array_push($r,$o[$i >> 12 & 63]);
        array_push($r,$o[$i >> 6 & 63]);
        array_push($r,$o[63 & $i]);
      }
      switch (strlen($t) - $s) {
        case 1:
          $i = $this -> Qgetbyte($t, $e) << 16;
          array_push($r,$o[$i >> 18] . $o[$i >> 12 & 63] . $n . $n);
          break;
        case 2:
          $i = $this -> Qgetbyte($t, $e) << 16 | $this -> Qgetbyte($t, $e + 1) << 8;
          array_push($r,$o[$i >> 18] . $o[$i >> 12 & 63] . $o[$i >> 6 & 63] . $n);
      }
      return join("",$r);
    }

    function Enh($e = "", $i, $n="", $o) {
      $i = $this -> uin2hex($i);
      $p = $o ? $e : $this -> t($e);
      $r = $this -> Eng($p);
      $s = $this -> t($r . $i);
      $l = $this -> strToBytes(strtoupper($n), !0);
      $a = dechex($this -> JsNumber(strlen($l) / 2));
      while(strlen($a) < 4)
        $a = "0" . $a;
      $TestF = $this -> TeaInitkey($s);
      $c = $this -> TeaEncrypt($p . $this -> strToBytes($i) . $a . $l);
      $TestF = $this -> TeaInitkey("");
      $u = dechex($this -> JsNumber(strlen($c) / 2));
      while (strlen($u) < 4)
        $u = "0" . $u;
      $aa = new RSA();
      $h = $aa -> rsa_encrypt($this -> Eng($u . $c));
      $returnd = $this -> encode($this -> Eng($h));
      $returnd = str_replace('/', '-', $returnd);
      $returnd = str_replace('+', '*', $returnd);
      $returnd = str_replace('=', '_', $returnd);
      return $returnd;
    }

    function test() {
      return $this -> e();
    }
  }
  
/****************************************************************************
上方解析QQ密码的类,到此结束
*****************************************************************************/



function login($uin, $qqpw){
  
  
/****************************************************************************
获得起初的cookie
*****************************************************************************/
$cookie_api0 ='https://xui.ptlogin2.qq.com/cgi-bin/xlogin?proxy_url=http://qzs.qq.com/qzone/v6/portal/proxy.html&daid=5&pt_qzone_sig=1&hide_title_bar=1&low_login=0&qlogin_auto_login=1&no_verifyimg=1&link_target=blank&appid=549000912&style=22&target=self&s_url=http://qzs.qq.com/qzone/v5/loginsucc.html?para=izone&pt_qr_app=手机QQ空间&pt_qr_link=http://z.qzone.com/download.html&self_regurl=http://qzs.qq.com/qzone/v6/reg/index.html&pt_qr_help_link=http://z.qzone.com/download.html';

$cookie_api0_data0 = get_curl_a_qz($cookie_api0,0,0,0,1);

$pt_login_sig = inter($cookie_api0_data0, 'pt_login_sig=', ';');

//print_r($cookie_api0_data0);

preg_match_all("/Set-Cookie: (.*?);/", $cookie_api0_data0, $cookie_api0_arr);

$cookie_api0_arr0 = implode(';',$cookie_api0_arr[1]);




/*************************************************************************************
取cookie  qrsigpt_verifysession
**************************************************************************************/
$cookie_apia ='https://ssl.ptlogin2.qq.com/ptqrshow?appid=549000912&e=2&l=M&s=3&d=72&v=4&t=0.5767074957621456&daid=5&pt_3rd_aid=0';

$cookie_apia_dataa = get_curl_a_qz($cookie_apia,0,0,$cookie_api0_arr0,1);

$pt_login_qrsig = inter($cookie_apia_dataa, 'qrsig=', ';');


$cookie_api0_arr0 .= ';qrsig='.$pt_login_qrsig.';';

//print_r($cookie_api0_arr0);


/********************************************************************************
取pt_verifysession 验证码
*********************************************************************************/

if(empty($uin))return array('saveOK'=>-1,'msg'=>'请先输入QQ号码');
if(!preg_match("/^[1-9][0-9]{4,13}$/",$uin)) exit('{"saveOK":-2,"msg":"QQ号码不正确"}');
$cookie_api1='http://check.ptlogin2.qq.com/check?pt_tea=2&uin='.$uin.'&appid=549000912&ptlang=2052®master=&pt_uistyle=9&r=0.397176'.time();
//$cookie_api1='https://ssl.ptlogin2.qq.com/check?regmaster=&pt_tea=2&pt_vcode=1&uin='.$uin.'&appid=549000912&js_ver=10178&js_type=1&login_sig='.$pt_login_sig.'&u1=http://qzs.qq.com/qzone/v5/loginsucc.html?para=izone&r=0.397176&pt_uistyle=40';


$cookie_api1_data=get_curl_a_qz($cookie_api1,0,0,$cookie_api0_arr0,1);

if(preg_match("/ptui_checkVC\('(.*?)'\)/", $cookie_api1_data, $cookie_api1_arr)){
    $cookie_api1_r=explode("','",$cookie_api1_arr[1]);
      if($cookie_api1_r[0]==0){
        $cookie_api1_data1 = array('saveOK'=>0,'salf'=>$cookie_api1_r[2],'uin'=>$uin,'vcode'=>$cookie_api1_r[1],'pt_verifysession'=>$cookie_api1_r[3]);
      }else{
        $cookie_api1_data1 = array('saveOK'=>1,'uin'=>$uin,'sig'=>$cookie_api1_r[1]);
      }
    }else{
      $cookie_api1_data1 = array('saveOK'=>-3,'msg'=>'获取验证码失败');
}

preg_match_all("/Set-Cookie: (.*?);/", $cookie_api1_data, $cookie_api1_arr);

$cookie_api1_arr1 = implode(';',$cookie_api1_arr[1]);

$cookie_api0_arr0 .= $cookie_api1_arr1.';ptui_loginuin='.$uin;

//print_r($cookie_api0_arr0);




/********************************************************************************
登录QQ

要判断登录异常
*********************************************************************************/

if(strpos('s'.$cookie_api1_data1['vcode'],'!')){
  $cookie_api2_v1=0;
}else{
  $cookie_api2_v1=1;
}
$p = md5($uin);
//$p = md5($uin,$qqpw,$cookie_api1_data1['vcode'],0);
$a = new Encryption();
$p = $a -> Enh($qqpw,$uin,$cookie_api1_data1['vcode'], Null);
$p2 = '"'.$qqpw.'","'.$cookie_api1_data1['salf'].'","'.$cookie_api1_data1['vcode'].'"';
$cookie_api2 ='https://ssl.ptlogin2.qq.com/login?u='.$uin.'&verifycode='.$cookie_api1_data1['vcode'].'&pt_vcode_v1='.$cookie_api2_v1.'&pt_verifysession_v1='.$cookie_api1_data1['pt_verifysession'].'&p='.$p.'&pt_randsalt=2&u1=http://qzs.qq.com/qzone/v5/loginsucc.html?para=izone&ptredirect=0&h=1&t=1&g=1&from_ui=1&ptlang=2052&action=1-21-'.getMillisecond_qqc().'&js_ver=90305&js_type=1&login_sig='.$pt_login_sig.'&pt_uistyle=40&aid=549000912&daid=5&pt_qzone_sig=1&';
$cookie_api2_data2 = get_curl_a_qqc($cookie_api2,0,0,$cookie_api0_arr0,1);
  

$h2_qqcookie_echo['uin'] = inter_qqc($cookie_api2_data2, ': uin=', ';');
$h2_qqcookie_echo['skey'] = inter_qqc($cookie_api2_data2, ': skey=', ';');
$h2_qqcookie_echo['ptcz'] = inter_qqc($cookie_api2_data2, ': ptcz=', ';');
  

/********************************************************************************
登录QQ空间,取p_skey
*********************************************************************************/
  
$cookie_api3 = 'http'.inter_qqc($cookie_api2_data2, 'http', "'").'http://qzs.qq.com/qzone/v5/loginsucc.html?para=izone&f_url=&ptlang=2052&ptredirect=100&aid=549000912&daid=5&j_later=0&low_login_hour=0®master=0&pt_login_type=1&pt_aid=0&pt_aaid=0&pt_light=0&pt_3rd_aid=0';
$cookie_api3_cookie_ptcz = inter_qqc($cookie_api2_data2, 'ptcz=', ';');
$cookie_api3_data3 = get_curl_a_qqc($cookie_api3,0,0,$cookie_api3_cookie_ptcz,1);

$cookie_api3_qz_p_skey = 'p_uin='.inter_qqc($cookie_api3_data3, 'p_uin=', ';').';'; 
$cookie_api3_qz_p_skey .= 'p_skey='.inter_qqc($cookie_api3_data3, 'p_skey=', ';').';'; 
  
$h2_qqcookie_echo['p_uin'] = inter_qqc($cookie_api3_data3, 'p_uin=', ';');
$h2_qqcookie_echo['p_skey'] = inter_qqc($cookie_api3_data3, 'p_skey=', ';');
  
/********************************************************************************
结束取p_skey
*********************************************************************************/
  
  
return $h2_qqcookie_echo;

  
  
}


function getMillisecond_qqc() {
    list($t1, $t2) = explode(' ', microtime());
    return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
}



function get_curl_a_qqc($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0){
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $httpheader[] = "Accept:application/json";
    $httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
    $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
    $httpheader[] = "Connection:close";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
    if($post){
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    }
    if($header){
      curl_setopt($ch, CURLOPT_HEADER, TRUE);
    }
    if($cookie){
      curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    }
    if($referer){
      curl_setopt($ch, CURLOPT_REFERER, "http://ptlogin2.qq.com/");
    }
    if($ua){
      curl_setopt($ch, CURLOPT_USERAGENT,$ua);
    }else{
      curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36');
    }
    if($nobaody){
      curl_setopt($ch, CURLOPT_NOBODY,1);

    }
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $ret = curl_exec($ch);
    curl_close($ch);
    return $ret;
  }





function inter_qqc($str, $start, $end)
{
    $wd2 = '';
    if ($str && $start) {
        $arr = explode($start, $str);
        if (count($arr) > 1) {
            $wd = $arr[1];
            if ($end) {
                $arr2 = explode($end, $wd);
                if (count($arr2) > 1) {
                    $wd2 = $arr2[0];
                } else {
                    $wd2 = $wd;
                }
            } else {
                $wd2 = $wd;
            }
        }
    }
    return $wd2;
}


function xmljc1_qqc($def,$id,$fle1,$fles){
if(!is_readable($fles)){is_file($fles) or mkdir($fles,0777,true);}
if(file_exists($fle1)){
  if(time() - filemtime($fle1) > $def){unlink($fle1);}
  if(file_exists($fle1)){
    $fpp=file_get_contents($fle1);
    return $fpp;
  }
}
}

function xmlsc1_qqc($id,$msg1,$fle1){
$fpp=fopen($fle1,"w+");
fputs($fpp,$msg1);
fclose($fpp);
}
?>

 

打赏

好文章,更需要你的鼓励

本文由 氢设计 创作,除注明转载/出处外,均为本站原创,转载前请务必署名

最后编辑时间为:2021-11-23 10:21:01

本文链接:https://www.h2sheji.com/show-99.html