Пример #1
0
 /**
  * 验证二维码
  * @return string
  */
 public function tdCodeCheck()
 {
     //存储临时cookie
     $tdCodeTmp = session("tdCodeTmp");
     //13位时间戳
     $microTime = explode(" ", microtime());
     $url = "http://ptlogin2.qq.com/ptqrlogin?u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone&ptredirect=0&h=1&t=1&g=1&from_ui=1&ptlang=2052&action=0-0-" . $microTime[1] . ceil($microTime[0] * 1000) . "&js_ver=10141&js_type=1&login_sig=&pt_uistyle=32&aid=549000912&daid=5&";
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_REFERER, '');
     curl_setopt($curl, CURLOPT_COOKIEFILE, $tdCodeTmp);
     // 发送初始Cookie
     curl_setopt($curl, CURLOPT_COOKIEJAR, $tdCodeTmp);
     //    存储cookie
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($curl);
     curl_close($curl);
     if (strpos($result, "'66'")) {
         return jsonObject(array("status" => 0, "msg" => "二维码未失效"));
     } else {
         if (strpos($result, "'65'")) {
             return jsonObject(array("status" => 1, "msg" => "二维码已失效"));
         } else {
             if (strpos($result, "'67'")) {
                 return jsonObject(array("status" => 2, "msg" => "二维码认证中"));
             } else {
                 if (strpos($result, "http://ptlogin4.qzone.qq.com")) {
                     //验证成功 获取相关cookie值
                     preg_match("/ptuiCB\\('0','0','(.*?)\\'/", $result, $res);
                     $url = $res[1];
                     preg_match("/&uin=(\\d+)&service/", $url, $qq);
                     $qq = $qq[1];
                     $curl = curl_init($url);
                     curl_setopt($curl, CURLOPT_REFERER, '');
                     curl_setopt($curl, CURLOPT_COOKIEFILE, $tdCodeTmp);
                     // 发送初始Cookie
                     curl_setopt($curl, CURLOPT_COOKIEJAR, $tdCodeTmp);
                     //    存储cookie
                     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                     $result = curl_exec($curl);
                     curl_close($curl);
                     $exp = IS_WIN ? "\r\n" : "\n";
                     //linux 没有\r
                     $result = explode($exp, file_get_contents($tdCodeTmp));
                     //挂服务器不知道为毛少了.qq.com	TRUE	/	FALSE	0	ptisp	ctc  这玩意干嘛的?
                     if (count($result) == 21) {
                         //有ptcz
                         $uinRes = explode("\t", $result[6]);
                         $sKeyRes = explode("\t", $result[7]);
                         $ptczRes = explode("\t", $result[16]);
                         $pUinRes = explode("\t", $result[17]);
                         $pSkeyRes = explode("\t", $result[18]);
                         $pt4TokenRes = explode("\t", $result[19]);
                     } else {
                         //无ptcz
                         $uinRes = explode("\t", $result[6]);
                         $sKeyRes = explode("\t", $result[7]);
                         $ptczRes = explode("\t", $result[15]);
                         $pUinRes = explode("\t", $result[16]);
                         $pSkeyRes = explode("\t", $result[17]);
                         $pt4TokenRes = explode("\t", $result[18]);
                     }
                     $uin = $uinRes[6];
                     $sKey = $sKeyRes[6];
                     $pUin = $pUinRes[6];
                     $pSkey = $pSkeyRes[6];
                     $pt4Token = $pt4TokenRes[6];
                     $ptcz = $ptczRes[6];
                     //根据sKey获取gtk
                     $gtk = getGTK($sKey);
                     $gtk2 = getGTK($pSkey);
                     $data = array("uin" => $uin, "sKey" => $sKey, "pUin" => $pUin, "pSkey" => $pSkey, "pt4Token" => $pt4Token, "ptcz" => $ptcz, "gtk" => $gtk, "gtk2" => $gtk2);
                     //存储信息.
                     $data['qq'] = $qq;
                     $accredit = M('accredit');
                     $row = $accredit->where("qq=" . $qq)->find();
                     if ($row) {
                         $r = $accredit->where('qq=' . $qq)->save($data);
                     } else {
                         $r = $accredit->add($data);
                         file_put_contents("a.txt", $result);
                     }
                     if ($r) {
                         session("loginType", "tdCode");
                         session("qq", $data);
                         return jsonObject(array("status" => 3, "msg" => "ok"));
                     } else {
                         return jsonObject(array("status" => 4, "msg" => "授权失败,请重试"));
                     }
                 }
             }
         }
     }
 }
Пример #2
0
Файл: del.php Проект: sembrono/1
    $hash = 5381;
    for ($i = 0; $i < $len; $i++) {
        $hash += ($hash << 5) + ord($skey[$i]);
    }
    return $hash & 0x7fffffff;
    //计算g_tk
}
header("Content-type: text/html; charset=utf-8");
$uin = $_POST["uin"];
//$sid = $_POST["sid"];
$skey = $_POST["skey"];
$touin = $_POST["touin"];
if (!$uin || !$skey || !$touin) {
    exit;
}
$gtk = getGTK($skey);
$cookie = 'uin=o0' . $uin . '; skey=' . $skey . ';';
$ua = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36';
$url = 'http://w.qzone.qq.com/cgi-bin/tfriend/friend_delete_qqfriend.cgi?g_tk=' . $gtk;
$post = 'uin=' . $uin . '&fupdate=1&num=1&fuin=' . $touin . '&qzreferrer=http://user.qzone.qq.com/' . $uin . '/myhome/friends';
$data = get_curl($url, $post, 0, $cookie, 0, $ua);
preg_match('/callback\\((.*?)\\)\\;/is', $data, $json);
$arr = json_decode($json[1], true);
if (@array_key_exists('code', $arr) && $arr['code'] == 0) {
    if ($arr['data']['ret'] == 0) {
        exit('{"code":0}');
    } else {
        exit('{"code":-2,"msg":"' . $arr["message"] . '"}');
    }
} elseif ($arr['code'] == -3000) {
    exit('{"code":-1,"msg":"SKEY已过期!"}');
Пример #3
0
function checksid($uin, $skey)
{
    $gtk = getGTK($skey);
    $cookie = 'uin=o0' . $uin . '; skey=' . $skey . ';';
    $url = get_curl('http://user.qzone.qq.com/p/base.s2/cgi-bin/user/cgi_userinfo_get_all?uin=' . $uin . '&vuin=' . $uin . '&fupdate=1&format=json&rd=0.516339' . time() . '&g_tk=' . $gtk, 0, 0, $cookie);
    $arr = json_decode($url, true);
    if ($arr['code'] == -3000) {
        return false;
    } else {
        return true;
    }
}