$usename = "kkkkkkk" ;
$password = "123456" ;
$result = userlogin($usename, $password, null, null, 'username', $_G['clientip']);
//$result['status'] > 0 代表账号密码正确
$uid = $result['ucresult']['uid'];
require libfile("function/member");
$result['member'] = getuserbyuid(1);
setloginstatus($result['member'], 2592000); //记录登陆状态保存在cookie或session中
账号密码验证正确,调用setloginstatus就能设置登陆状态了
验证密码是检验pre_ucenter_members表中的password,而不是pre_common_member中的password
密码验证方式 md5(md5(用户输入).salt) 是否中pre_ucenter_members.password是否一致
salt在pre_ucenter_members表中的salt字段
$auth = authcode("{$member['password']}\t{$member['uid']}", 'ENCODE') ;
dsetcookie('auth',$auth, $cookietime, 1, true);
setloginstatus会把password和uid加密后,放在cookie中,用于在discuz_application中判断用户是否已经登陆
如以下代码
if($auth = getglobal('auth', 'cookie')) {
$auth = daddslashes(explode("\t", authcode($auth, 'DECODE')));
}
list($discuz_pw, $discuz_uid) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
if($discuz_uid) {
$user = getuserbyuid($discuz_uid, 1);
}
if(!empty($user) && $user['password'] == $discuz_pw) {
if(isset($user['_inarchive'])) {
C::t('common_member_archive')->move_to_master($discuz_uid);
}
$this->var['member'] = $user;
$nickname = getuserprofile("nickname") ;
$this->var['member']['nickname'] = $nickname ;
} else {
$user = array();
$this->_init_guest();
}