示例#1
0
        /// <summary>
        /// 验证注册邀请码
        /// </summary>
        /// <returns></returns>
        private InviteCodeInfo ValidateInviteInfo()
        {
            errorControlId = "invitecode";
            InviteCodeInfo inviteCodeInfo = null;

            if (config.Regstatus == 3 && string.IsNullOrEmpty(invitecode))
            {
                AddErrLine("邀请码不能为空!");
                return(inviteCodeInfo);
            }
            if (!string.IsNullOrEmpty(invitecode))
            {
                inviteCodeInfo = Invitation.GetInviteCodeByCode(invitecode.ToUpper());
                if (!Invitation.CheckInviteCode(inviteCodeInfo))
                {
                    AddErrLine("邀请码不合法或已过期!");
                    return(null);
                }
            }
            return(inviteCodeInfo);
        }
示例#2
0
        protected override void ShowPage()
        {
            pagetitle = "用户注册";

            if (userid != -1)
            {
                SetUrl(BaseConfigs.GetForumPath);
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("不能重复注册用户");
                ispost     = true;
                createuser = "******";
                agree      = "yes";
                return;
            }


            if (config.Regstatus < 1)
            {
                AddErrLine("论坛当前禁止新用户注册");
                return;
            }

            allowinvite = Utils.InArray(config.Regstatus.ToString(), "2,3");

            #region 用户IP判断
            string msg = Users.CheckRegisterDateDiff(DNTRequest.GetIP());
            if (msg != null)
            {
                AddErrLine(msg);
                return;
            }
            //if (config.Regctrl > 0)
            //{
            //    ShortUserInfo userinfo = Users.GetShortUserInfoByIP(DNTRequest.GetIP());
            //    if (userinfo != null)
            //    {
            //        int Interval = Utils.StrDateDiffHours(userinfo.Joindate, config.Regctrl);
            //        if (Interval <= 0)
            //        {
            //            AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + (Interval * -1) + " 小时后才可以注册");
            //            return;
            //        }
            //    }
            //}

            //if (config.Ipregctrl.Trim() != "")
            //{
            //    string[] regctrl = Utils.SplitString(config.Ipregctrl, "\n");
            //    if (Utils.InIPArray(DNTRequest.GetIP(), regctrl))
            //    {
            //        ShortUserInfo userinfo = Users.GetShortUserInfoByIP(DNTRequest.GetIP());
            //        if (userinfo != null)
            //        {
            //            int Interval = Utils.StrDateDiffHours(userinfo.Joindate, 72);
            //            if (Interval < 0)
            //            {
            //                AddErrLine("抱歉, 系统设置了特殊IP注册限制, 您必须在 " + (Interval * -1) + " 小时后才可以注册");
            //                return;
            //            }
            //        }
            //    }
            //}
            #endregion

            //如果提交了用户注册信息...
            if (!Utils.StrIsNullOrEmpty(createuser) && ispost)
            {
                SetShowBackLink(true);
                InviteCodeInfo inviteCode = null;
                if (allowinvite)
                {
                    if (config.Regstatus == 3 && invitecode == "")
                    {
                        AddErrLine("邀请码不能为空!");
                        return;
                    }
                    if (invitecode != "")
                    {
                        inviteCode = Invitation.GetInviteCodeByCode(invitecode.ToUpper());
                        if (!Invitation.CheckInviteCode(inviteCode))
                        {
                            AddErrLine("邀请码不合法或已过期!");
                            return;
                        }
                    }
                }

                string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername);
                string email       = DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower();
                string tmpBday     = DNTRequest.GetString("bday").Trim();

                if (tmpBday == "")
                {
                    tmpBday = string.Format("{0}-{1}-{2}", DNTRequest.GetString("bday_y").Trim(),
                                            DNTRequest.GetString("bday_m").Trim(), DNTRequest.GetString("bday_d").Trim());
                }
                tmpBday = (tmpBday == "--" ? "" : tmpBday);

                ValidateUserInfo(tmpUserName, email, tmpBday);

                if (IsErr())
                {
                    return;
                }

                //如果用户名符合注册规则, 则判断是否已存在
                if (Users.GetUserId(tmpUserName) > 0)
                {
                    AddErrLine("请不要重复提交!");
                    return;
                }

                UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday);

                #region 发送欢迎信息
                if (config.Welcomemsg == 1)
                {
                    // 收件箱
                    PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo();
                    privatemessageinfo.Message      = config.Welcomemsgtxt;
                    privatemessageinfo.Subject      = "欢迎您的加入! (请勿回复本信息)";
                    privatemessageinfo.Msgto        = userInfo.Username;
                    privatemessageinfo.Msgtoid      = userInfo.Uid;
                    privatemessageinfo.Msgfrom      = PrivateMessages.SystemUserName;
                    privatemessageinfo.Msgfromid    = 0;
                    privatemessageinfo.New          = 1;
                    privatemessageinfo.Postdatetime = Utils.GetDateTime();
                    privatemessageinfo.Folder       = 0;
                    PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0);
                }
                #endregion

                //发送同步数据给应用程序
                Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, "");



                SetUrl("index.aspx");
                SetShowBackLink(false);
                SetMetaRefresh(config.Regverify == 0 ? 2 : 5);
                Statistics.ReSetStatisticsCache();

                if (inviteCode != null)
                {
                    Invitation.UpdateInviteCodeSuccessCount(inviteCode.InviteId);
                    if (config.Regstatus == 3)
                    {
                        if (inviteCode.SuccessCount + 1 >= inviteCode.MaxCount)
                        {
                            Invitation.DeleteInviteCode(inviteCode.InviteId);
                        }
                    }
                }

                if (config.Regverify == 0)
                {
                    UserCredits.UpdateUserCredits(userInfo.Uid);
                    ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey);
                    OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout);
                    MsgForward("register_succeed");
                    AddMsgLine("注册成功, 返回登录页");
                }
                else
                {
                    if (config.Regverify == 1)
                    {
                        AddMsgLine("注册成功, 请您到您的邮箱中点击激活链接来激活您的帐号");
                    }
                    else if (config.Regverify == 2)
                    {
                        AddMsgLine("注册成功, 但需要系统管理员审核您的帐户后才可登录使用");
                    }
                }
                //ManyouApplications.AddUserLog(userInfo.Uid, UserLogActionEnum.Add);
                agree = "yes";
            }
        }