开启新用户注册的Email验证:
进入站点后台->全局->注册与访问下,找到新用户注册验证,选择Email验证方式。
向用户发送验证邮件分析:
找到source\class\class_member.php文件,在362行附近- $groupinfo = array();
- if($this->setting['regverify']) {
- $groupinfo['groupid'] = 8;
- } else {
- $groupinfo['groupid'] = $this->setting['newusergroupid'];
- }
复制代码 此段代码为如果开启了新用户注册验证的话,那么注册后用户的用户组为待验证用户组(groupid=8),否则为新手用户组。
在782行附近- switch($this->setting['regverify']) {
- case 1:
- $idstring = random(6);
- $authstr = $this->setting['regverify'] == 1 ? "$_G[timestamp]\t2\t$idstring" : '';
- DB::query("UPDATE ".DB::table('common_member_field_forum')." SET authstr='$authstr' WHERE uid='$_G[uid]'");
- $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$_G[uid]}&id=$idstring";
- $email_verify_message = lang('email', 'email_verify_message', array(
- 'username' => $_G['member']['username'],
- 'bbname' => $this->setting['bbname'],
- 'siteurl' => $_G['siteurl'],
- 'url' => $verifyurl
- ));
- sendmail("$username <$email>", lang('email', 'email_verify_subject'), $email_verify_message);
- $message = 'register_email_verify';
- $locationmessage = 'register_email_verify_location';
- $url_forward = dreferer();
- break;
复制代码 case:1为Email验证方式。
$idstring为随机生成的6位字符串。
$authstr为根据规则生成的对应该用户的验证串。
$verifyurl为生成的该用户的验证url链接。- sendmail("$username <$email>", lang('email', 'email_verify_subject'), $email_verify_message);
复制代码 向该用户发送验证邮件(邮件内容包含验证链接)。
用户点击邮件里的链接进行验证分析:
找到source\module\member\member_activate.php文件- $query = DB::query("SELECT m.uid, m.username, m.credits, mf.authstr FROM ".DB::table('common_member')." m, ".DB::table('common_member_field_forum')." mf
- WHERE m.uid='$_G[gp_uid]' AND mf.uid=m.uid AND m.groupid='8'");
- $member = DB::fetch($query);
- list($dateline, $operation, $idstring) = explode("\t", $member['authstr']);
复制代码 从数据库里查询对应这个用户的验证串(authstr)。- if($operation == 2 && $idstring == $_G['gp_id']) {
- $query = DB::query("SELECT groupid FROM ".DB::table('common_usergroup')." WHERE type='member' AND '$member[credits]'>=creditshigher AND '$member[credits]'<creditslower LIMIT 1");
- DB::query("UPDATE ".DB::table('common_member')." SET groupid='".DB::result($query, 0)."', emailstatus='1' WHERE uid='$member[uid]'");
- DB::query("UPDATE ".DB::table('common_member_field_forum')." SET authstr='' WHERE uid='$member[uid]'");
- showmessage('activate_succeed', 'index.php', array('username' => $member['username']));
- } else {
- showmessage('activate_illegal', 'index.php');
- }
复制代码 如果$operation == 2,同时通过数据库里查询出来的随机串($idstring)和传参过来的id($_G['gp_id'])一致:- $query = DB::query("SELECT groupid FROM ".DB::table('common_usergroup')." WHERE type='member' AND '$member[credits]'>=creditshigher AND '$member[credits]'<creditslower LIMIT 1");
复制代码 根据积分查询此用户的用户组。- DB::query("UPDATE ".DB::table('common_member')." SET groupid='".DB::result($query, 0)."', emailstatus='1' WHERE uid='$member[uid]'");
复制代码 更新用户表(common_member)中此用户的用户组(groupid)和Email验证状态(emailstatus)。- showmessage('activate_succeed', 'index.php', array('username' => $member['username']));
复制代码 提示验证成功,否则提示验证失败。- showmessage('activate_illegal', 'index.php');
复制代码 |