Ejemplo n.º 1
0
        public string SignIn()
        {
            string message = "";

            try
            {
                string userName = WebBase.GetFormString("username", "");
                string userPwd  = WebBase.GetFormString("password", "");
                string ispass   = WebBase.GetFormString("ckbsavepass", "");
                string code     = WebBase.GetFormString("imycode", "");

                if (string.IsNullOrEmpty(code))
                {
                    message = ("请输入验证码!");
                }
                else if (string.IsNullOrEmpty(userName))
                {
                    message = ("请输入商户名!");
                }
                else if (string.IsNullOrEmpty(userPwd))
                {
                    message = ("请输入商户密码!");
                }
                else
                {
                    message = WebUtility.CheckValiDateCode(code);
                }

                if (string.IsNullOrEmpty(message))
                {
                    string lastLoginIp      = ServerVariables.TrueIP;
                    string lastLoginAddress = WebUtility.GetIPAddress(lastLoginIp);

                    message = viviapi.BLL.User.Login.SignIn(0, 0, userName, Cryptography.MD5(userPwd), lastLoginIp, lastLoginAddress);

                    if (message == "success")
                    {
                        if (ispass != null)
                        {
                            HttpCookie hc = new HttpCookie("yklm_user");
                            DateTime   dt = DateTime.Now;
                            TimeSpan   ts = new TimeSpan(90, 0, 0, 0, 0); //过期时间为1分钟
                            hc.Expires = dt.Add(ts);                      //设置过期时间

                            //hc.Values.Add("username", userName);
                            hc.Values.Add("userpass", Cryptography.MD5(userPwd));
                            Response.AppendCookie(hc);
                        }
                        else
                        {
                            HttpCookie hc = new HttpCookie("yklm_user");
                            hc.Expires = DateTime.Now.AddMonths(-24);
                            Response.Cookies.Add(hc);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.HandleException(exception);
                message = exception.Message;
            }

            return(message);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void iBtnSubmit1_Click(object sender, EventArgs e)
        {
            KeyValuePair <string, string> pair;
            string vCode = GetPostValue("txtvcode");

            ;
            string errMsg = WebUtility.CheckValiDateCode(vCode);

            if (!string.IsNullOrEmpty(errMsg))
            {
                pair = new KeyValuePair <string, string>("mobilecode", errMsg);
                ShowError(pair);
                return;
            }

            //用户类型
            int userclassid = 0;

            string username  = GetPostValue("newusername").Trim();
            string password1 = GetPostValue("password1").Trim();
            string password2 = GetPostValue("password2").Trim();
            string mobile    = GetPostValue("newemail").Trim();
            string sitename  = GetPostValue("newsitename").Trim();
            string siteurl   = GetPostValue("newsiteurl").Trim();
            string email     = GetPostValue("J_mobile").Trim();
            string idcard    = string.Empty;
            string fullname  = GetPostValue("newfullname").Trim();
            string qq        = GetPostValue("newqq").Trim();
            string question  = string.Empty;
            string answer    = string.Empty;

            string fBank        = GetPostValue("fBank").Trim();
            string fAccountName = GetPostValue("fAccountName").Trim();
            string fAccount     = GetPostValue("fAccount").Trim();
            string fProvince    = GetPostValue("fProvince").Trim();
            string fCity        = GetPostValue("fCity").Trim();
            string fSubBranch   = GetPostValue("fSubBranch").Trim();

            #region check
            if (string.IsNullOrEmpty(username))
            {
                errMsg = "用户名不能为空!";
            }
            else if (!Regex.IsMatch(username, UserNameRegex))
            {
                errMsg = "用户名格式不正确!";
            }
            else if (Factory.Exists(username))
            {
                errMsg = "用户名已注册!";
            }
            if (!string.IsNullOrEmpty(errMsg))
            {
                pair = new KeyValuePair <string, string>("Span1", errMsg);
                ShowError(pair);
                return;
            }


            if (string.IsNullOrEmpty(errMsg))
            {
                if (string.IsNullOrEmpty(password1))
                {
                    errMsg = "密码不能为空!";
                }
                else if (password1.Length < 6 || password1.Length > 32)
                {
                    errMsg = "密码长度不正确!";
                }
                else if (!password1.Equals(password2))
                {
                    errMsg = "密码与重复密码输入不一致!";
                }
            }
            if (!string.IsNullOrEmpty(errMsg))
            {
                pair = new KeyValuePair <string, string>("Span2", errMsg);
                ShowError(pair);
                return;
            }

            if (string.IsNullOrEmpty(errMsg))
            {
                if (string.IsNullOrEmpty(email))
                {
                    errMsg = "安全邮箱不能为空!";
                }
                else if (!Regex.IsMatch(email, EmailRegex))
                {
                    errMsg = "安全邮箱格式不正确";
                }
                else if (Factory.EmailExists(email) != 999)
                {
                    errMsg = "安全邮箱已注册";
                }
            }

            if (!string.IsNullOrEmpty(errMsg))
            {
                pair = new KeyValuePair <string, string>("J_mobile_info", errMsg);
                ShowError(pair);
                return;
            }


            if (string.IsNullOrEmpty(errMsg))
            {
                if (string.IsNullOrEmpty(fullname))
                {
                    errMsg = "真实姓名不能不空!";
                }
                else if (!Regex.IsMatch(fullname, ChineseRegex))
                {
                    errMsg = "真实姓名格式不正确";
                }
            }
            if (!string.IsNullOrEmpty(errMsg))
            {
                pair = new KeyValuePair <string, string>("contact_name", errMsg);
                ShowError(pair);
                return;
            }
            if (string.IsNullOrEmpty(errMsg))
            {
                if (string.IsNullOrEmpty(qq))
                {
                    errMsg = "联系QQ不能不空!";
                }
                else if (!Regex.IsMatch(qq, QQRegex))
                {
                    errMsg = "QQ格式不正确";
                }
            }
            if (!string.IsNullOrEmpty(errMsg))
            {
                pair = new KeyValuePair <string, string>("Span5", errMsg);
                ShowError(pair);
                return;
            }


            #endregion

            var userinfo = new UserInfo
            {
                UserName      = username,
                Password      = Cryptography.MD5(password1),
                Email         = email,
                QQ            = qq,
                Tel           = mobile,
                SiteName      = sitename,
                SiteUrl       = siteurl,
                IdCard        = idcard,
                CPSDrate      = RegisterSettings.DefaultCPSDrate,
                PMode         = 1,
                PayeeBank     = fBank,
                LinkMan       = fullname,
                full_name     = fullname,
                Status        = RegisterSettings.RequiredAudit ? 1 : 2,
                LastLoginIp   = ServerVariables.TrueIP,
                LastLoginTime = DateTime.Now,
                RegTime       = DateTime.Now,
                Settles       = 0,
                IsEmailPass   = 1
            };

            userinfo.UserLevel = RegisterSettings.DefaultUserLevel;
            //提现方案
            userinfo.MaxDayToCashTimes = SettleSettings.DefaultScheme;

            //默认结算模式 0:T+0 1:T+1
            //默认扣量比例
            userinfo.CPSDrate = RegisterSettings.DefaultCPSDrate;

            userinfo.AgentId    = 0;
            userinfo.APIAccount = 0;
            userinfo.APIKey     = viviapi.BLL.User.Factory.GenerateAPIKey(); //WebUtility.GenerateAPIKey();
            userinfo.question   = question;
            userinfo.answer     = answer;
            userinfo.classid    = userclassid;

            if (this.SalesmanId > 0)
            {
                userinfo.manageId = SalesmanId;
            }
            userinfo.cardversion = RegisterSettings.DefaultCardVersion;

            string area     = "";
            string province = "";
            string city     = "";

            WebUtility.GetAreaInfo(out area, out province, out city);

            userinfo.province = province;
            userinfo.city     = city;
            userinfo.Desc     = area;

            int userId = Factory.Add(userinfo);
            if (userId > 0)
            {
                var config = new UserSettingInfo
                {
                    userid      = userId,
                    RiskWarning = (byte)(TransactionSettings.RiskWarning ? 1 : 0)
                };

                viviapi.BLL.User.UserSetting.Instance.Insert(config);

                //UserPayBankAppInfo model = new UserPayBankAppInfo();
                //model.pmode = 1;
                //model.payeeBank = fBank;
                //model.bankProvince = fProvince;
                //model.bankCity = fCity;
                //model.bankAddress = fSubBranch;
                //model.account = fAccount;
                //model.payeeName = fAccountName;
                //model.AddTime = DateTime.Now;
                //model.userid = userId;
                //model.status = AcctChangeEnum.审核成功;
                //int infoId = BLL.User.UserPayBankApp.Add(model);
                //if (infoId > 0)
                //{
                //    model.id = infoId;
                //    model.status = AcctChangeEnum.审核成功;
                //    model.SureTime = DateTime.Now;
                //    model.SureUser = 0;

                //    BLL.User.UserPayBankApp.Check(model);
                //}

                if (AgentId > 0)
                {
                    #region
                    var promUser = new Promoter
                    {
                        PID        = AgentId,
                        Prices     = 0.5M,
                        RegId      = userId,
                        PromTime   = DateTime.Now,
                        PromStatus = 1
                    };

                    viviapi.BLL.Promotion.Factory.Insert(promUser);
                    #endregion
                }
                //if (RegisterSettings.ActivationByEmail)
                //{
                //    errMsg = SendMail(username, userId, email);

                //    AlertAndRedirect2(errMsg, "/login.aspx");
                //}
                //else
                //{
                if (userinfo.Status == 2)
                {
                    AlertAndRedirect2("注册成功,无须审核请登陆后直接使用", "/login.aspx");
                }
                else
                {
                    AlertAndRedirect2("注册成功,请等待管理员审核", "/Login.aspx");
                }
                //}
            }
            else
            {
                pair = new KeyValuePair <string, string>("Span7", "注册失败");
                ShowError(pair);
            }
        }
Ejemplo n.º 3
0
        private void SignIn()
        {
            string message = "";

            string userName   = XRequest.GetString("username");
            string passWord   = XRequest.GetString("password");
            string code       = XRequest.GetString("CCode");
            string RememberMe = WebBase.GetFormString("RememberMe", "");

            if (string.IsNullOrEmpty(code))
            {
                message = ("请输入验证码!");
            }
            else if (string.IsNullOrEmpty(userName))
            {
                message = ("请输入代理账号!");
            }
            else if (string.IsNullOrEmpty(passWord))
            {
                message = ("请输入代理密码!");
            }
            else
            {
                message = WebUtility.CheckValiDateCode(code);
            }

            if (string.IsNullOrEmpty(message))
            {
                string lastLoginIp      = ServerVariables.TrueIP;
                string lastLoginAddress = WebUtility.GetIPAddress(lastLoginIp);

                message = viviapi.BLL.User.Login.SignIn(0, 1, userName, Cryptography.MD5(passWord), lastLoginIp,
                                                        lastLoginAddress);

                if (message == "success")
                {
                    if (viviapi.BLL.User.Login.CurrentMember.UserType == UserTypeEnum.代理)
                    {
                        if (RememberMe != null)
                        {
                            HttpCookie hc = new HttpCookie("yklm_agent");
                            DateTime   dt = DateTime.Now;
                            TimeSpan   ts = new TimeSpan(90, 0, 0, 0, 0); //过期时间为1分钟
                            hc.Expires = dt.Add(ts);                      //设置过期时间

                            hc.Values.Add("username", userName);

                            Response.AppendCookie(hc);
                        }
                        else
                        {
                            HttpCookie hc = new HttpCookie("yklm_agent");
                            hc.Expires = DateTime.Now.AddMonths(-24);
                            Response.Cookies.Add(hc);
                        }
                    }
                    else
                    {
                        message = ("非代理权限,无法登录!");
                    }
                }
            }

            if (message == "success")
            {
                Response.Redirect("main.aspx");
            }
            else
            {
                ShowMessageBox(message);
            }
        }