河南高级会员
专心做事,诚信做人
posts - 14,  comments - 1,  trackbacks - 0
 1 function token(){
 2     $path = 'cookie.txt';//cookie文件
 3     if(file_exists($path)){
 4         $fp=fopen($path,"r");
 5         while(!(feof($fp)))
 6         {
 7          $text=fgets($fp);
 8             if(preg_match("/(;)skey=(.*)(;)RK=/", $text, $matches)){
 9                 $str = trim($matches[2]);
10                 break;
11             }
12         }
13     }else{
14         echo 'cookie文件不存在';
15         die();
16     }
17     $hash = 5381;
18     for($i=0,$l=mb_strlen($str,'utf-8');$i<$l;++$i){        
19             $hash = $hash + uniord(mb_substr($str,$i,1,'utf-8'))+($hash<<5);
20             
21     }
22     $g_tk = $hash&0x7fffffff;
23     return $g_tk;
24 }

 

posted on 2014-06-16 20:57  河南高级会员  阅读(...)  评论(...编辑  收藏