php使用curl抓取qq空间的访客信息示例(2)

public static function  getGTK($str)
    {
        $hash = 5381;
        for ($i = 0, $len = strlen($str); $i < $len; ++$i) {
            $hash += ($hash << 5) + self::utf8_unicode($str[$i]);
        }
        return $hash & 2147483647;
    }

protected static function hexchar2bin($str)
    {
        $arr = '';
        $temp = null;
        for ($i = 0; $i < strlen($str); $i = $i + 2) {
            $arr .= "\\x" . substr($str, $i, 2);
        }
        eval('$temp="' . $arr . '";');
        return $temp;
    }

protected static function getUid($uid)
    {
        $temp = null;
        eval('$temp="' . $uid . '";');
        return $temp;
    }

public static function getEncryption($password, $uin, $vcode)
    {
        $uin = self::getUid($uin);
        $str1 = self::hexchar2bin(strtoupper(md5($password)));
        $str2 = strtoupper(md5($str1 . $uin));
        return strtoupper(md5($str2 . strtoupper($vcode)));
    }

}

class CookieFileExtract
{
    protected $cookie_file;
    protected $cookie_list;

protected function  __construct($cookie_file)
    {
        $this->cookie_file = $cookie_file;

$this->cookie_list = $this->extractFile();
    }

protected function isValidateCookieFile()
    {
        if ($this->cookie_file && file_exists($this->cookie_file)) {
            return true;
        } else {
            return false;
        }
    }

protected function extractFile()
    {
        $cookie_list = array();

if ($this->isValidateCookieFile($this->cookie_file)) {
            $content = file($this->cookie_file);
            if (is_array($content)) {
                foreach ($content as $line) {
                    $line = trim($line);
                    if (strlen($line) > 0 && $line[0] != '#') {
                        $cookie = (preg_split("/\s+/", $line));
                        if (count($cookie) == 7) {
                            $cookie_list[$cookie[5]] = $cookie[6];
                        } else {
                            $cookie_list[$cookie[5]] = '';
                        }
                    }
                }
            }
        }

return $cookie_list;
    }

protected function buildCookieStr($cookies)
    {
        $arr = array();

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/6a3b396fe61b016e0da9eb2453f6669b.html