function dologin($openid = "") { if (empty($openid)) { $username = get_safe_replace($_POST['username']); $password = get_safe_replace($_POST['password']); $verifyCode = get_safe_replace($_POST['verifyCode']); if (empty($username) || empty($password)) { $this->error(L('empty_username_empty_password')); } if ($this->member_config['member_login_verify'] && md5($verifyCode) != $_SESSION['verify']) { $this->error(L('password_error')); } $authInfo = $this->dao->getByUsername($username); } else { $authInfo = $this->dao->getByopenid($openid); } session_start(); $_SESSION["userid"] = $authInfo['id']; //anywn缓存登陆用户id2014年4月2日2:35:46 $_SESSION["uid"] = $authInfo['id']; $this->_userid = $authInfo['id']; //使用用户名、密码和状态的方式进行认证 if (empty($authInfo)) { $this->error(L('empty_userid')); } else { if (!$authInfo['status']) { $this->error("还未通过审核!"); } if (empty($openid)) { //手工方式验证密码 if ($authInfo['password'] != sysmd5($_POST['password'])) { $this->error(L('password_error')); } //查看是否论坛有用户/////////////////////////////////////// import('@.ORG.Uc'); $uc = new Uc(); if ($authInfo['bbs'] > 0) { $uc->bbs_login($username, $password); echo $uc->bbsid_login($authInfo['bbs']); } else { $uid = $uc->bbs_login($username, $password); //登陆 if ($uid <= 0) { if ($uid == -1) { $info = "用户不存在,或者被删除"; $uid = $uc->user_regeist($username, $password, $authInfo['email']); //注册 } elseif ($uid == -2) { $info = "密码错误!"; } elseif ($uid == -3) { $info = "安全提问错!"; } } if ($uid) { M("user")->where("id=" . $authInfo['id'])->setField("bbs", $uid); } } //查看是否论坛有用户////////////////////////////////////// } else { //车牌号和手机为空转到填写手机页面 if ($authInfo['username'] == "" || $authInfo['city'] <= 0 || $authInfo['province'] <= 0 || $authInfo['area'] <= 0) { $this->success('首次登陆成功,请完善信息!', "/index.php?g=User&m=Login&a=guest&frist=1"); exit; } } if ($authInfo['status'] != 1) { $this->error(L('ACCOUNT_DISABLE')); } $cookietime = intval($_REQUEST['cookietime']); $cookietime = $cookietime ? $cookietime : 0; $yourphp_auth_key = sysmd5($this->sysConfig['ADMIN_ACCESS'] . $_SERVER['HTTP_USER_AGENT']); $yourphp_auth = authcode($authInfo['id'] . "-" . $authInfo['groupid'] . "-" . $authInfo['password'], 'ENCODE', $yourphp_auth_key); cookie('auth', $yourphp_auth, $cookietime); if ($authInfo['username']) { cookie('username', $authInfo['username'], $cookietime); } else { cookie('username', $authInfo['realname'], $cookietime); } cookie('groupid', $authInfo['groupid'], $cookietime); cookie('userid', $authInfo['id'], $cookietime); cookie('email', $authInfo['email'], $cookietime); //保存登录信息 $dao = M('User'); $data = array(); $data['id'] = $authInfo['id']; $data['last_logintime'] = time(); $data['last_ip'] = get_client_ip(); $data['login_count'] = array('exp', 'login_count+1'); $dao->save($data); //$forward = $_POST['forward'] ? $_POST['forward'] :$this->forward ; $forward = "index.php?g=User&m=Index&a=index"; //切换到用户地带 if ($authInfo['avatar'] == "") { $this->success('请完善资料!', "/index.php?g=User&m=Index&a=index"); exit; } if ($authInfo['qq'] == "") { $this->success('请完善用户信息!', "/index.php?g=User&m=Index&a=profile"); //切换到用户地带 } if ($authInfo['password'] == "") { $this->success('设置密码更安全,首次设置默认密码不填!', "/index.php?g=User&m=Index&a=index"); //切换到用户地带 } $this->assign('jumpUrl', $forward); $this->success(L('login_ok')); } }