示例#1
0
        /// <summary>
        /// 创建邀请码信息
        /// </summary>
        /// <param name="userInfo">创建用户信息</param>
        /// <returns></returns>
        public static int CreateInviteCode(ShortUserInfo userInfo)
        {
            InvitationConfigInfo configInfo = InvitationConfigs.GetConfig();
            InviteCodeInfo       inviteCode = new InviteCodeInfo();

            inviteCode.CreatorId = userInfo.Uid;
            inviteCode.Creator   = userInfo.Username;

            inviteCode.Code = BuildInviteCode();
            while (IsInviteCodeExist(inviteCode.Code))//生成的邀请码code是否存在于数据库中
            {
                inviteCode.Code = BuildInviteCode();
            }

            inviteCode.CreateTime = Utils.GetDateTime();
            inviteCode.InviteType = GeneralConfigs.GetConfig().Regstatus;
            inviteCode.ExpireTime = Utils.GetDateTime(configInfo.InviteCodeExpireTime);
            if (inviteCode.InviteType == 3)
            {
                inviteCode.MaxCount = configInfo.InviteCodeMaxCount > 1 ? configInfo.InviteCodeMaxCount : 1;
            }
            else
            {
                inviteCode.MaxCount = configInfo.InviteCodeMaxCount;
            }
            return(Data.Invitation.CreateInviteCode(inviteCode));
        }
        public void LoadConfigInfo()
        {
            #region 加载配置信息

            GeneralConfigInfo    configInfo           = GeneralConfigs.GetConfig();
            InvitationConfigInfo invitationConfigInfo = InvitationConfigs.GetConfig();

            regstatus.SelectedValue = configInfo.Regstatus.ToString();

            censoruser.Text           = configInfo.Censoruser;
            doublee.SelectedValue     = configInfo.Doublee.ToString();
            emaillogin.SelectedValue  = configInfo.Emaillogin.ToString();
            regverify.SelectedValue   = configInfo.Regverify.ToString();
            accessemail.Text          = configInfo.Accessemail;
            censoremail.Text          = configInfo.Censoremail;
            hideprivate.SelectedValue = configInfo.Hideprivate.ToString();
            ipdenyaccess.Text         = configInfo.Ipdenyaccess;
            ipaccess.Text             = configInfo.Ipaccess;
            regctrl.Text                      = configInfo.Regctrl.ToString();
            ipregctrl.Text                    = configInfo.Ipregctrl;
            adminipaccess.Text                = configInfo.Adminipaccess;
            welcomemsg.SelectedValue          = configInfo.Welcomemsg.ToString();
            welcomemsgtxt.Text                = configInfo.Welcomemsgtxt;
            rules.SelectedValue               = configInfo.Rules.ToString();
            rulestxt.Text                     = configInfo.Rulestxt;
            newbiespan.Text                   = configInfo.Newbiespan.ToString();
            realnamesystem.SelectedValue      = configInfo.Realnamesystem.ToString();
            invitecodeexpiretime.Text         = invitationConfigInfo.InviteCodeExpireTime.ToString();
            invitecodemaxcount.Text           = invitationConfigInfo.InviteCodeMaxCount.ToString();
            addextcreditsline.Text            = invitationConfigInfo.InviteCodePayCount.ToString();
            invitationuserdescription.Text    = invitationConfigInfo.InvitationLoginUserDescription;//配置项赋值给textarea的innnerhtml能保证显示出来的是所见即所得的效果
            invitationvisitordescription.Text = invitationConfigInfo.InvitationVisitorDescription;
            invitationemailmodel.Text         = invitationConfigInfo.InvitationEmailTemplate;
            invitecodeusermaxbuy.Text         = invitationConfigInfo.InviteCodeMaxCountToBuy.ToString();
            invitecodeusercreateperday.Text   = invitationConfigInfo.InviteCodeUserCreatePerDay.ToString();
            passwordmode.SelectedValue        = configInfo.Passwordmode.ToString();
            CookieDomain.Text                 = configInfo.CookieDomain.ToString();
            string[] extCredits = Utils.SplitString(invitationConfigInfo.InviteCodePrice, ",");
            extCreditsUnits = Scoresets.GetValidScoreUnit();
            DataTable extCreditsTable = Scoresets.GetScorePaySet(0);

            //初始化邀请码价格显示界面,全部为隐藏
            for (int count = 0; count < 8; count++)
            {
                extCreditsName[count] = "";
                TextBox textbox = this.FindControl("invitecodeprice" + count.ToString()) as TextBox;
                textbox.Text    = extCredits[count];
                textbox.Visible = false;
            }

            //根据邀请码相关信息,将有效的信息显示在界面中
            foreach (DataRow dr in extCreditsTable.Rows)
            {
                extCreditsName[Utils.StrToInt(dr["id"].ToString(), 0) - 1] = dr["name"].ToString() + ":";
                TextBox textbox = this.FindControl("invitecodeprice" + (Utils.StrToInt(dr[0].ToString(), 0) - 1).ToString()) as TextBox;
                textbox.Visible = true;
            }

            #endregion
        }
示例#3
0
        /// <summary>
        /// 验证邀请码是否可用
        /// </summary>
        /// <param name="inviteCode">邀请码信息</param>
        /// <returns></returns>
        public static bool CheckInviteCode(InviteCodeInfo inviteCode)
        {
            GeneralConfigInfo configInfo = GeneralConfigs.GetConfig();

            if (inviteCode == null)
            {
                return(false);
            }

            if (inviteCode.InviteType != configInfo.Regstatus)
            {
                return(false);
            }

            if (inviteCode.CreateTime != inviteCode.ExpireTime)  //如果创建时间等于失效时间,则表示该邀请码永不失效
            {
                if (Utils.StrDateDiffHours(inviteCode.ExpireTime, 0) > 0)
                {
                    return(false);
                }
            }

            //如果邀请类型为邀请链接式,且全局邀请设置中链接最大使用次数不是0(无数次),则校验该邀请链接的次数合法性
            //否则如果邀请码的最大使用次数不是0,则校验该邀请码的次数合法性
            int maxCount = inviteCode.InviteType == 2 ? InvitationConfigs.GetConfig().InviteCodeMaxCount : inviteCode.MaxCount;

            if (maxCount > 0 && inviteCode.SuccessCount >= maxCount)
            {
                return(false);
            }

            return(true);
        }
        private void SaveInfo_Click(object sender, EventArgs e)
        {
            #region 保存设置信息

            if (this.CheckCookie())
            {
                GeneralConfigInfo    configInfo           = GeneralConfigs.GetConfig();
                InvitationConfigInfo invitationConfigInfo = InvitationConfigs.GetConfig();

                if (Convert.ToInt16(regverify.SelectedValue) == 1 && DNTRequest.GetString("verifyemailtempmessage_hidden").IndexOf("{1}") == -1)
                {
                    base.RegisterStartupScript("erro", "<script>alert('验证请求信息邮件内容模板中必须包含\"{1}\"');</script>");
                    return;
                }

                configInfo.Regstatus               = Convert.ToInt16(regstatus.SelectedValue);
                configInfo.Censoruser              = DelNullRowOrSpace(censoruser.Text);
                configInfo.Doublee                 = Convert.ToInt16(doublee.SelectedValue);
                configInfo.Emaillogin              = Convert.ToInt16(emaillogin.SelectedValue);
                configInfo.Regverify               = Convert.ToInt16(regverify.SelectedValue);
                configInfo.Accessemail             = accessemail.Text;
                configInfo.Censoremail             = censoremail.Text;
                configInfo.Hideprivate             = Convert.ToInt16(hideprivate.SelectedValue);
                configInfo.Ipdenyaccess            = ipdenyaccess.Text;
                configInfo.Ipaccess                = ipaccess.Text;
                configInfo.Regctrl                 = Convert.ToInt16(regctrl.Text);
                configInfo.Ipregctrl               = ipregctrl.Text;
                configInfo.Adminipaccess           = adminipaccess.Text;
                configInfo.Welcomemsg              = Convert.ToInt16(welcomemsg.SelectedValue);
                configInfo.Welcomemsgtxt           = welcomemsgtxt.Text;
                configInfo.Rules                   = Convert.ToInt16(rules.SelectedValue);
                configInfo.Rulestxt                = rulestxt.Text;
                configInfo.Newbiespan              = Convert.ToInt16(newbiespan.Text);
                configInfo.Realnamesystem          = Convert.ToInt16(realnamesystem.SelectedValue);
                configInfo.Passwordmode            = Convert.ToInt16(passwordmode.SelectedValue);
                configInfo.CookieDomain            = CookieDomain.Text;
                configInfo.Verifyregisterexpired   = Convert.ToInt16(verifyregisterexpired.Text);
                configInfo.Verifyregisteremailtemp = RepairEmailTemplateCodeParameter(DNTRequest.GetString("verifyemailtempmessage_hidden"));

                invitationConfigInfo.InviteCodePayCount             = Utils.StrToInt(addextcreditsline.Text, 0);
                invitationConfigInfo.InviteCodeExpireTime           = Utils.StrToInt(invitecodeexpiretime.Text, 0);
                invitationConfigInfo.InviteCodeMaxCount             = Utils.StrToInt(invitecodemaxcount.Text, 0);
                invitationConfigInfo.InviteCodePrice                = CreateInviteCodePriceString();
                invitationConfigInfo.InvitationLoginUserDescription = DNTRequest.GetString("invitationuserdescriptionmessage_hidden");//保存的时候取textarea的value值可以保证前台显示正常
                invitationConfigInfo.InvitationVisitorDescription   = DNTRequest.GetString("invitationvisitordescriptionmessage_hidden");
                invitationConfigInfo.InvitationEmailTemplate        = RepairEmailTemplateCodeParameter(DNTRequest.GetString("invitationemailmodelmessage_hidden"));
                invitationConfigInfo.InviteCodeMaxCountToBuy        = Convert.ToInt16(invitecodeusermaxbuy.Text);
                invitationConfigInfo.InviteCodeUserCreatePerDay     = Convert.ToInt16(invitecodeusercreateperday.Text);

                Hashtable IPHash = new Hashtable();
                IPHash.Add("特殊 IP 注册限制", ipregctrl.Text);
                IPHash.Add("IP 禁止访问列表", ipdenyaccess.Text);
                IPHash.Add("IP 访问列表", ipaccess.Text);
                IPHash.Add("管理员后台IP访问列表", adminipaccess.Text);

                string ipkey = "";
                if (Utils.IsRuleTip(IPHash, "ip", out ipkey) == false)
                {
                    base.RegisterStartupScript("erro", "<script>alert('" + ipkey.ToString() + ",IP格式错误');</script>");
                    return;
                }

                Hashtable Emailhash = new Hashtable();
                Emailhash.Add("Email 允许地址", accessemail.Text);
                Emailhash.Add("Email 禁止地址", censoremail.Text);

                string key = "";
                if (Utils.IsRuleTip(Emailhash, "email", out key) == false)
                {
                    base.RegisterStartupScript("erro", "<script>alert('" + key.ToString() + ",Email格式错误');</script>");
                    return;
                }

                GeneralConfigs.Serialiaze(configInfo, Server.MapPath("../../config/general.config"));
                InvitationConfigs.Serialiaze(invitationConfigInfo, Server.MapPath("../../config/invitation.config"));

                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "注册与访问控制设置", "");
                base.RegisterStartupScript("PAGE", "window.location.href='global_registerandvisit.aspx';");
            }

            #endregion
        }