Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// 发送验证注册请求链接
        /// </summary>
        public void SendRegisterVerifyLink()
        {
            string email = DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower();

            ValidateEmail(email);
            if (IsErr())
            {
                return;
            }

            InviteCodeInfo inviteCode = allowinvite ? ValidateInviteInfo() : null;

            if (IsErr())
            {
                return;
            }

            VerifyRegisterInfo verifyInfo = Users.CreateVerifyRegisterInfo(email, allowinvite ? invitecode : string.Empty);

            if (verifyInfo != null)
            {
                string verifyLink    = string.Format("{0}register.aspx?action=reg&verifycode={1}", Utils.GetRootUrl(forumpath), verifyInfo.VerifyCode);
                string verifyContent = string.Format(config.Verifyregisteremailtemp,
                                                     verifyInfo.Email.Split('@')[0],
                                                     verifyLink);

                EmailMultiThread emt = new EmailMultiThread(verifyInfo.Email.Split('@')[0],
                                                            verifyInfo.Email,
                                                            string.Format("{0} 的安全注册链接,欢迎注册!", config.Forumtitle),
                                                            verifyContent);
                new System.Threading.Thread(new System.Threading.ThreadStart(emt.Send)).Start();
            }
            SetUrl("index.aspx");
            SetShowBackLink(false);
            SetMetaRefresh(2);
            AddMsgLine("请求已经发送,请查收邮箱");
        }
Esempio n. 3
0
 /// <summary>
 /// 创建邀请码
 /// </summary>
 /// <param name="inviteCode"></param>
 /// <returns></returns>
 public static int CreateInviteCode(InviteCodeInfo inviteCode)
 {
     return(DatabaseProvider.GetInstance().CreateInviteCode(inviteCode));
 }
Esempio n. 4
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";
            }
        }
Esempio n. 5
0
        protected override void ShowPage()
        {
            pagetitle = "邀请注册";
            if (!Utils.InArray(config.Regstatus.ToString(), "2,3"))
            {
                AddErrLine("当前站点没有开启邀请功能!");
                return;
            }
            if (userid > 0)
            {
                if (action == "floatwinemail")
                {
                    return;
                }
                userinfo = Users.GetUserInfo(userid);
                if (config.Regstatus == 2)
                {
                    invitecodeinfo = Invitation.GetInviteCodeByUid(userid);
                    if (invitecodeinfo != null)
                    {
                        inviteurl = GetUserInviteUrl(invitecodeinfo.Code, false);
                        userscore = GetUserInviteScore(invitecodeinfo.SuccessCount);
                        usersaid  = string.Format("邀请附言:<div id=\"usersaidinemail\">{0}</div>", usersaid);
                        if (!ispost)
                        {
                            CreateEmailPreview();
                        }
                    }
                }
                else
                {
                    invitecodecount = Invitation.GetUserInviteCodeCount(userid);
                    invitecodelist  = Invitation.GetUserInviteCodeList(userid, pageindex);
                    invitecodeprice = GetInviteCodePrice();
                    pagecount       = ((invitecodecount - 1) / 10) + 1;
                    pagenumber      = Utils.GetPageNumbers(pageindex, pagecount, "invite.aspx", 8);
                }
                if (ispost)
                {
                    switch (action)
                    {
                    case "createcode":
                        CreateInviteCode();    //创建开放式邀请码
                        break;

                    case "convertcode":
                        ConvertInviteCode();    //将开放邀请码兑换为用户积分
                        break;

                    case "buycode":
                        BuyInviteCode();    //购买封闭式邀请码
                        break;

                    case "floatwinemailsend":
                        SendEmail();    //弹窗邮件发送邀请码
                        break;

                    default:
                        return;
                    }
                }
            }
            if (userid == -1 && invitecode != "")
            {
                invitecodeinfo = Invitation.GetInviteCodeByCode(invitecode);
            }
        }
Esempio n. 6
0
        public void Register()
        {
            SetShowBackLink(true);
            InviteCodeInfo inviteCode = allowinvite ? ValidateInviteInfo() : null;

            if (IsErr())
            {
                return;
            }

            string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername);
            string email       = config.Regverify == 1 ? verifyinfo.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);

            //如果开启邮箱验证注册,删除邮箱验证请求信息
            if (config.Regverify == 1)
            {
                Users.DeleteVerifyRegisterInfo(verifyinfo.RegId);
            }

            //若使用了邀请码,更新邀请码相关信息
            if (inviteCode != null)
            {
                Invitation.UpdateInviteCodeSuccessCount(inviteCode.InviteId);
                if (config.Regstatus == 3)
                {
                    if (inviteCode.SuccessCount + 1 >= inviteCode.MaxCount)
                    {
                        Invitation.DeleteInviteCode(inviteCode.InviteId);
                    }
                }
            }

            #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);
            //如果不是需要管理员审核的注册,页面延时刷新为2秒,否则是5秒
            SetMetaRefresh(config.Regverify != 2 ? 2 : 5);
            Statistics.ReSetStatisticsCache();

            if (config.Regverify != 2)
            {
                CreditsFacade.UpdateUserCredits(userInfo.Uid);
                ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey);
                OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout);
                MsgForward("register_succeed");
                AddMsgLine("注册成功, 返回登录页");
            }
            else
            {
                AddMsgLine("注册成功, 但需要系统管理员审核您的帐户后才可登录使用");
            }
            agree = "yes";
        }
Esempio n. 7
0
        /// <summary>
        /// 获取用户id
        /// </summary>
        /// <returns></returns>
        private ShortUserInfo GetShortUserInfo(string postusername, string postpassword, string mobile, string email)
        {
            //postpassword = !Utils.StrIsNullOrEmpty(loginauth) ?
            //        DES.Decode(loginauth.Replace("[", "+"), config.Passwordkey) :
            //        DNTRequest.GetString("password");

            //postusername = Utils.StrIsNullOrEmpty(postusername) ? DNTRequest.GetString("username") : postusername;

            int uid = -1;

            switch (config.Passwordmode)
            {
            case 1:    //动网兼容模式
            {
                if (config.Secques == 1 && (!Utils.StrIsNullOrEmpty(loginauth) || !loginsubmit))
                {
                    uid = Users.CheckDvBbsPasswordAndSecques(postusername, postpassword, DNTRequest.GetFormInt("question", 0), DNTRequest.GetString("answer"));
                }
                else
                {
                    uid = Users.CheckDvBbsPassword(postusername, postpassword);
                }
                break;
            }

            case 0:    //默认模式
            {
                if (config.Secques == 1 && (!Utils.StrIsNullOrEmpty(loginauth) || !loginsubmit))
                {
                    uid = Users.CheckPasswordAndSecques(postusername, postpassword, true, DNTRequest.GetFormInt("question", 0), DNTRequest.GetString("answer"));
                }
                else
                {
                    #region 原始登录
                    //原始的登录
                    // uid = Users.CheckPassword(postusername, postpassword, true);
                    #endregion

                    #region 现在的登录
                    //现在的登录
                    uid = Users.GetUserId(postusername);
                    if (uid > 0)        //更新用户手机号、邮箱
                    {
                        #region 更新用户手机号、邮箱
                        UserInfo oldUserInfo = Users.GetUserInfo(uid);
                        UserInfo userInfo    = oldUserInfo.Clone();
                        //需要判断签名是否修改过
                        string sig = oldUserInfo.Sightml;        //保存旧的签名
                        userInfo.Uid      = uid;
                        userInfo.Username = postusername;        //当前登录的用户名


                        #region 基本资料
                        //userInfo.Realname = DNTRequest.GetString("realname");
                        //userInfo.Gender = DNTRequest.GetInt("gender", 0);
                        //userInfo.Bday = Utils.HtmlEncode(DNTRequest.GetString("bday"));
                        //userInfo.Location = Utils.HtmlEncode(DNTRequest.GetString("location"));
                        //userInfo.Idcard = DNTRequest.GetString("idcard");
                        //userInfo.Nickname = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname")));
                        //userInfo.Bio = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("bio")));
                        #endregion

                        #region 联系方式
                        userInfo.Mobile = mobile;
                        //userInfo.Phone = DNTRequest.GetString("phone");
                        userInfo.Email = email;

                        //if (userInfo.Email != oldUserInfo.Email && !Users.ValidateEmail(userInfo.Email, userid))
                        //{
                        //    AddErrLine("Email: \"" + userInfo.Email + "\" 已经被其它用户注册使用");
                        //    return;
                        //}
                        //userInfo.Showemail = DNTRequest.GetInt("showemail", 1);

                        //if (DNTRequest.GetString("website").IndexOf(".") > -1 && !DNTRequest.GetString("website").ToLower().StartsWith("http"))
                        //    userInfo.Website = Utils.HtmlEncode("http://" + DNTRequest.GetString("website"));
                        //else
                        //    userInfo.Website = Utils.HtmlEncode(DNTRequest.GetString("website"));
                        //userInfo.Msn = Utils.HtmlEncode(DNTRequest.GetString("msn"));
                        //userInfo.Qq = Utils.HtmlEncode(DNTRequest.GetString("qq"));
                        //userInfo.Skype = Utils.HtmlEncode(DNTRequest.GetString("skype"));
                        //userInfo.Icq = Utils.HtmlEncode(DNTRequest.GetString("icq"));
                        //userInfo.Yahoo = Utils.HtmlEncode(DNTRequest.GetString("yahoo"));

                        #endregion


                        //PostpramsInfo postPramsInfo = new PostpramsInfo();
                        //postPramsInfo.Usergroupid = usergroupid;
                        //postPramsInfo.Attachimgpost = config.Attachimgpost;
                        //postPramsInfo.Showattachmentpath = config.Showattachmentpath;
                        //postPramsInfo.Hide = 0;
                        //postPramsInfo.Price = 0;
                        ////获取提交的内容并进行脏字和Html处理
                        ////postPramsInfo.Sdetail = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("signature"))); ;
                        //postPramsInfo.Smileyoff = 1;
                        //postPramsInfo.Bbcodeoff = 1 - usergroupinfo.Allowsigbbcode;
                        //postPramsInfo.Parseurloff = 1;
                        //postPramsInfo.Showimages = usergroupinfo.Allowsigimgcode;
                        //postPramsInfo.Allowhtml = 0;
                        //postPramsInfo.Signature = 1;
                        //postPramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo();
                        //postPramsInfo.Customeditorbuttoninfo = null;
                        //postPramsInfo.Smiliesmax = config.Smiliesmax;
                        //postPramsInfo.Signature = 1;

                        //userInfo.Sightml = UBB.UBBToHTML(postPramsInfo);
                        //if (sig != userInfo.Sightml)
                        //{
                        //    Sync.UpdateSignature(userid, userInfo.Username, userInfo.Sightml, "");
                        //}
                        //if (userInfo.Sightml.Length >= 1000)
                        //{
                        //    AddErrLine("您的签名转换后超出系统最大长度, 请返回修改");
                        //    return;
                        //}

                        //userInfo.Signature = postPramsInfo.Sdetail;
                        //userInfo.Sigstatus = DNTRequest.GetInt("sigstatus", 0) != 0 ? 1 : 0;


                        if (CheckModified(oldUserInfo, userInfo))
                        {
                            Users.UpdateUserProfile(userInfo);
                            Sync.UpdateProfile(userInfo.Uid, userInfo.Username, "");
                        }
                        OnlineUsers.DeleteUserByUid(userid);            //删除在线表中的信息,使之重建该用户在线表信息
                        //ManyouApplications.AddUserLog(userid, UserLogActionEnum.Update);

                        ForumUtils.WriteCookie("sigstatus", userInfo.Sigstatus.ToString());

                        //SetUrl("usercpprofile.aspx");
                        //SetMetaRefresh();
                        //SetShowBackLink(true);
                        //AddMsgLine("修改个人档案完毕");
                        #endregion
                    }
                    else         //注册新用户
                    {
                        #region 注册新用户
                        //如果提交了用户注册信息...
                        InviteCodeInfo inviteCode = null;

                        string tmpUserName = postusername;
                        //string email = email;
                        string tmpBday = string.Empty;


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

                        #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

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

                        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);
                        }
                        #endregion

                        uid = Users.GetUserId(postusername);
                        #endregion
                    }
                    #endregion
                }
                break;
            }

            default:     //第三方加密验证模式
            {
                return((ShortUserInfo)Users.CheckThirdPartPassword(postusername, postpassword, DNTRequest.GetFormInt("question", 0), DNTRequest.GetString("answer")));
            }
            }
            if (uid != -1)
            {
                Users.UpdateTrendStat(TrendType.Login);
            }
            return(uid > 0 ? Users.GetShortUserInfo(uid) : null);
        }