if (strlen($match[1][0]) > 1) {
$m = str_replace("'", '', $match[1][0]);
$g = explode(',', $m);
if (count($g) == 3) {
return array('saltUin' => $g[2], 'verifycode' => $g[1], 'RSAKey' => $g[2] ? false : true);
}
}
return array();
}
public static function getLoginInfo($content)
{
$s = preg_replace('/.*?pt\.ptui\s*=\s*\{(.*?)\}\s*;.*/s', '$1', $content);
$e = preg_split('/,\s*/', trim($s));
$info = array();
foreach ($e as $t) {
$t = trim($t);
$p = strpos($t, ':');
$key = trim(substr($t, 0, $p));
$value = trim(substr($t, $p + 1));
if (preg_match('/encodeURIComponent/', $value)) {
$value = preg_replace('/^encodeURIComponent\s*\(\s*"(.*)?"\s*\)\s*,?$/', '$1', $value);
} else {
$value = trim($value, '",');
}
if ($key) {
$info[$key] = urldecode($value);
}
}
return $info;
}
}
class QQVisitorCapture extends QQVisitorRequest
{
public function __construct($user, $password, $cookie_file, $request_timeout, $debug, $end_line)
{
parent:: __construct($user, $password, $cookie_file, $request_timeout, $debug, $end_line);
}
public function trace($content, $title)
{
if ($this->debug = true) {
Trace:: write($content, $this->end_line, $title);
}
}
public function error($message)
{
$this->trace($message, 'login error ');
return false;
}
public function success()
{
return true;
}
public function getGTKEncryption()
{
return Utils ::getGTK($this->getCookie('skey', true));
}
public function getCookies($refresh = false)
{
return $this->getAllCookies($refresh);
}
public function clearCookies($refresh = false)
{
return $this->clearAllCookies($refresh);
}
public function login()
{
$login_submit_info_url = null;
$login_submit_info_url = $this->visitQzone();
$this->setCookies(array(
'pgv_pvid' => array(
'value' => Utils::getUTCMilliseconds(), 'path' => 'https://www.jb51.net/', 'domain' => '.qq.com', 'expires' => '0'
),
'pgv_info' => array(
'value' => 'ssid=s' . Utils::getUTCMilliseconds(), 'path' => 'https://www.jb51.net/', 'domain' => '.qq.com', 'expires' => '0'
),
'_qz_referrer' => array(
'value' => 'qzone.qq.com', 'path' => 'https://www.jb51.net/', 'domain' => '.qq.com', 'expires' => '0'
),
));
//log
$this->trace('', 'login begin');
//log
$this->trace($login_submit_info_url, '$login_submit_info_url===');
$login_submit_info = $this->getLoginSubmitInfo($login_submit_info_url);
//log
$this->trace($login_submit_info, '$login_submit_info===');
if (empty($login_submit_info)) {
$this->error('err-001');
}
$this->report();
//log
$this->trace('', 'getLoginJs');
$js_arr = $this->getLoginJs();
//log
$this->trace($js_arr, '$getLoginJs===');
if (empty($js_arr)) {
$this->error('err-002');
}