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();