public function doreg() { $username = get_safe_replace($_POST['username']); $password = get_safe_replace($_POST['password']); $mobile = get_safe_replace($_POST['mobile']); $verifyCode = $_POST['verifyCode']; if (empty($username) || empty($password) || empty($mobile)) { $this->error(L('empty_username_empty_password_empty_email')); } if ($this->member_config['member_login_verify'] && md5($verifyCode) != $_SESSION['verify']) { $this->error(L('error_verify')); } $status = $this->member_config['member_registecheck'] ? 0 : 1; if ($this->member_config['member_emailcheck']) { $status = 1; $groupid = 5; } $groupid = $groupid ? $groupid : 3; /*-------------------------打入论坛----------------------------*/ import('@.ORG.Uc'); $uc = new Uc(); $bbsuid = $uc->user_regeist($username, $password, $mobile . "@qq.com"); $uc->bbsid_login($bbsuid); /*-----------------------------------------------------------*/ $data = array(); $data['username'] = $username; $data['fatherid'] = intval($_SESSION["uid"]); $data['mobile'] = $mobile; $data['groupid'] = $groupid; $data['login_count'] = 1; $data['createtime'] = time(); $data['updatetime'] = time(); $data['last_logintime'] = time(); $data['reg_ip'] = get_client_ip(); $data['status'] = $status; $data['bbs'] = $bbsuid; $authInfo['password'] = $data['password'] = sysmd5($password); if ($r = $this->dao->create($data)) { if (false !== $this->dao->add()) { $authInfo['id'] = $uid = $this->dao->getLastInsID(); $authInfo['groupid'] = $ru['role_id'] = $data['groupid']; $ru['user_id'] = $uid; $roleuser = M('RoleUser'); $roleuser->add($ru); session_start(); $_SESSION["userid"] = $uid; if ($data['fatherid']) { /*推广id*/ $sm["userid"] = $data['fatherid']; $sm["share_ip"] = get_client_ip(); $sm["share_time"] = time(); $sm["mx"] = MODULE_NAME; $sm["ma"] = ACTION_NAME; $sm["mid"] = $uid; $sm["type"] = 3; //0点击,1,购买,3,注册 M("sharehistory")->add($sm); } /* if($this->member_config['member_emailcheck']){ $yourphp_auth = authcode($uid."-".$username."-".$mobile, 'ENCODE',$this->sysConfig['ADMIN_ACCESS'],3600*24*3);//3天有效期 $url = 'http://'.$_SERVER['HTTP_HOST'].U('User/Login/regcheckemail?code='.$yourphp_auth); $click = "<a href=\"$url\" target=\"_blank\">".L('CLICK_THIS')."</a>"; $message = str_replace(array('{click}','{url}','{sitename}'),array($click,$url,$this->Config['site_name']),$this->member_config['member_emailchecktpl']); $r = sendmail($email,L('USER_REGISTER_CHECKEMAIL').'-'.$this->Config['site_name'],$message,$this->Config); $this->assign('send_ok',1); $this->assign('username',$username); $this->assign('email',$email); $this->display('Login:emailcheck'); exit; }*/ $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); $authInfo['username'] = $data['username']; $authInfo['mobile'] = $data['mobile']; cookie('auth', $yourphp_auth, $cookietime); cookie('username', $authInfo['username'], $cookietime); cookie('groupid', $authInfo['groupid'], $cookietime); cookie('userid', $authInfo['id'], $cookietime); cookie('mobile', $authInfo['mobile'], $cookietime); $this->assign('jumpUrl', $this->forward); $this->success(L('reg_ok')); } else { $this->error(L('reg_error')); } } else { $this->error($this->dao->getError()); } }
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')); } }