|
发表于 2014-8-21 17:53:19
|
显示全部楼层
湖南省长沙市
<?php
function getGTK($cookie){
preg_match_all("/=(.*?);/is",$cookie,$skey); //正则取skey
//print_r($skey);
$str = $skey[1][1];
$hash = 5381;
$len = strlen($str);
for($i = 0;$i < $len;$i++){
$h = ($hash << 5) + utf8_unicode($str[$i]);
$hash+=$h;
}
return $hash & 0x7fffffff;
}
function utf8_unicode($c) {
switch(strlen($c)) {
case 1:
return ord($c);
case 2:
$n = (ord($c[0]) & 0x3f) << 6;
$n += ord($c[1]) & 0x3f;
return $n;
case 3:
$n = (ord($c[0]) & 0x1f) << 12;
$n += (ord($c[1]) & 0x3f) << 6;
$n += ord($c[2]) & 0x3f;
return $n;
case 4:
$n = (ord($c[0]) & 0x0f) << 18;
$n += (ord($c[1]) & 0x3f) << 12;
$n += (ord($c[2]) & 0x3f) << 6;
$n += ord($c[3]) & 0x3f;
return $n;
}
}
$cookie = ' uin='.$_POST['uin'].'; skey='.$_POST['skey'].'; '; //cookie !!!!!求解,此处cookie如何改成用 POST或者GET 提交?
$G_tk = getGTK($cookie); //计算G_tk
echo $G_tk;
?>
不知道这样是不是楼主想要的
|
|