为了方便大家升级,我来介绍一下近几天global.func.php(论坛根目录include/)这个文件的演变历程:
最初:- function authcode($string, $operation, $key = '') {
- $key = $key ? $key : $GLOBALS['discuz_auth_key'];
- $coded = '';
- $keylength = strlen($key);
- $string = $operation == 'DECODE' ? base64_decode($string) : $string;
- for($i = 0; $i < strlen($string); $i += $keylength) {
- $coded .= substr($string, $i, $keylength) ^ $key;
- }
- $coded = $operation == 'ENCODE' ? str_replace('=', '', base64_encode($coded)) : $coded;
- return $coded;
- }
复制代码 25号做过一次修改- function authcode ($string, $operation, $key = '') {
-
- $key = bin2hex($key ? $key : $GLOBALS['discuz_auth_key']);
- $key_length = strlen($key);
-
- $string = $operation == 'DECODE' ? base64_decode($string) : $string;
- $string_length = strlen($string);
-
- $rndkey = $box = array();
- $result = '';
-
- for ($i = 0; $i <= 255; $i++) {
- $rndkey[$i] = ord($key[$i % $key_length]);
- $box[$i] = $i;
- }
- for ($j = $i = 0; $i < 256; $i++) {
- $j = ($j + $box[$i] + $rndkey[$i]) % 256;
- $tmp = $box[$i];
- $box[$i] = $box[$j];
- $box[$j] = $tmp;
- }
-
- for ($a = $j = $i = 0; $i < $string_length; $i++) {
- $a = ($a + 1) % 256;
- $j = ($j + $box[$a]) % 256;
- $tmp = $box[$a];
- $box[$a] = $box[$j];
- $box[$j] = $tmp;
- $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
- }
- return ($operation == 'ENCODE' ? str_replace('=', '', base64_encode($result)) : $result);
- }
复制代码 27号又修改(目前的最终版)- function authcode ($string, $operation, $key = '') {
- $key = md5($key ? $key : $GLOBALS['discuz_auth_key']);
- $key_length = strlen($key);
- $string = $operation == 'DECODE' ? base64_decode($string) : substr(md5($string.$key), 0, 8).$string;
- $string_length = strlen($string);
- $rndkey = $box = array();
- $result = '';
- for($i = 0; $i <= 255; $i++) {
- $rndkey[$i] = ord($key[$i % $key_length]);
- $box[$i] = $i;
- }
- for($j = $i = 0; $i < 256; $i++) {
- $j = ($j + $box[$i] + $rndkey[$i]) % 256;
- $tmp = $box[$i];
- $box[$i] = $box[$j];
- $box[$j] = $tmp;
- }
- for($a = $j = $i = 0; $i < $string_length; $i++) {
- $a = ($a + 1) % 256;
- $j = ($j + $box[$a]) % 256;
- $tmp = $box[$a];
- $box[$a] = $box[$j];
- $box[$j] = $tmp;
- $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
- }
- if($operation == 'DECODE') {
- if(substr($result, 0, 8) == substr(md5(substr($result, 8).$key), 0, 8)) {
- return substr($result, 8);
- } else {
- return '';
- }
- } else {
- return str_replace('=', '', base64_encode($result));
- }
- }
复制代码
如果没有修改过或者只修改到25号的,那么仍不能实现论坛个人空间同步登陆,也就是你必须修改成27号的版本!
[ 本帖最后由 joykiller 于 2006-10-27 19:13 编辑 ] |