//同步登陆
function StrCode($uidstr, $pwd, $safecv, $action='ENCODE'){
global $_SGLOBAL, $_SC;
$pwd = empty($pwd) ? '' : md5($_SERVER['HTTP_USER_AGENT'].$pwd.$_SC['bbs_dbhash']);
$bbsv = intval($_SC['bbs_ver']);
if( $bbsv > 5) {
$string = empty($pwd) ? $uidstr : $uidstr."\t".$pwd."\t".$safecv;
} else {
$string = empty($pwd) ? $uidstr : $uidstr."\t".$pwd;
}
$action != 'ENCODE' && $string = base64_decode($string);
$code = '';
$key = substr(md5($_SERVER['HTTP_USER_AGENT'].$_SC['bbs_dbhash']),8,18);
$keylen = strlen($key);
$strlen = strlen($string);
for ($i=0;$i<$strlen;$i++) {
$k = $i % $keylen;
$code .= $string[$i] ^ $key[$k];
}
return ($action!='DECODE' ? base64_encode($code) : $code);
} |