Ejemplo n.º 1
0
        public string ForgetPwd()
        {
            string returnJsonString = string.Empty;
            string UserName = Request["UserName"];
            //string CheckCode = Request["CheckCode"];
            string Email = Request["Email"];
            //验证码校验
            //if (!CheckCode.Equals(Session["checkcode"].ToString()))
            //{
            //    returnJsonString = bll.WriteJsonForReturn(false, "验证码不正确!");
            //}
            //字符串sql注入检测
            if (Tools.IsValidInput(ref UserName, true) && Tools.IsValidInput(ref Email, true))
            {
                //获取用户邮箱

                //邮箱和用户名状态(正确与否)
                bool status = bll.CheckUserNameAndEmail(UserName, Email);
                //随机生成一个6位的新密码
                string NewPwd = bll.CreateNewPwd();
                if (!string.IsNullOrEmpty(Email) && status && bll.UpdatePwd(UserName, NewPwd))
                {
                    RogerSMTP roger = new RogerSMTP(Email, "潮州工艺品平台", "尊敬的" + UserName + "用户:恭喜您,您在" + DateTime.Now.ToString() + "使用找回密码功能重置密码,您的密码:" + NewPwd + ",请尽快修改密码并妥善保管!");
                    if (roger.Send())
                    //SMTP smtp = new SMTP(Email);
                    //if (smtp.sendemail("潮州工艺品平台", "尊敬的" + UserName + "用户:恭喜您,您在" + DateTime.Now.ToString() + "使用找回密码功能重置密码,您的密码:" + NewPwd + ",请尽快修改密码并妥善保管!"))
                    {
                        returnJsonString = bll.WriteJsonForReturn(true, Tools.GetEmail(Email));
                    }
                    else
                    {
                        returnJsonString = bll.WriteJsonForReturn(false, "邮箱发送失败!");
                    }
                }
                else
                {
                    returnJsonString = bll.WriteJsonForReturn(false, "用户名或邮箱不正确!");
                }

            }
            else
            {
                returnJsonString = bll.WriteJsonForReturn(false, "输入非法内容!");
            }

            return returnJsonString;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存大师信息
        /// </summary>
        public string SaveMasterInfo()
        {
            string ReturnJson =string.Empty;
            try
            {
                //表单读取
                string UserName = Request["UserName"];
                string Pwd = Request["Pwd"];
                string Birthday = Request["Birthday"];
                string Name = Request["Name"];
                string Sex = Request["Sex"];
                string MobilePhone = Request["MobilePhone"];
                string TelePhone = Request["TelePhone"];
                string QQ = Request["QQ"];
                string Introduce = Request["Introduce"];
                string Email = Request["Email"];
                //string CheckCode = Request["CheckCode"];
                string PicturePath = Request["Picturepath"];

                //验证码校验
                //if (Tools.IsNullOrEmpty(Session["checkcode"]) || !CheckCode.Equals(Session["checkcode"].ToString()))
                //{
                //    ReturnJson =Tools.WriteJsonForReturn(false, "验证码错误!");
                //}
                //字符串sql注入检测
                if (Tools.IsValidInput(ref UserName, true) && Tools.IsValidInput(ref Pwd, true) && Tools.IsValidInput(ref Email, true))
                {
                    //元素赋值
                    Master info = new Master();
                    info.Username = UserName;
                    info.Email = Email;
                    info.Name = Name;
                    info.Password = Tools.GetMD5(Pwd);
                    info.BirthDay = Convert.ToDateTime(Birthday);
                    info.Introduction = Introduce;
                    info.mobilephone = MobilePhone;
                    info.Picturepath = PicturePath;
                    info.QQ = QQ;
                    info.Nation = "";
                    info.Reward = "";
                    info.appreciation = "";
                    info.Zipcode = "";
                    info.Address = "";
                    info.Sex = Sex;
                    info.rank = 0;
                    info.hit = 0;
                    info.Isrecommend = "0";
                    info.Isshow = "0";
                    info.state = "0";
                    info.state1 = "0";
                    info.Telephone = TelePhone;
                    info.website = ""; //context.Request.Url.Scheme + "://" + context.Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/Master/MasterInfo.aspx?MasterId="+info.Id);
                    //加随机验证码
                    info.VCode = Guid.NewGuid().ToString("N");
                    //验证失效(1小时以内激活有效)
                    info.VTime = DateTime.Now.AddHours(1);

                    //验证用户名
                    if (!masterBLL.CheckExistUserName(info.Username))
                    {
                        ReturnJson = Tools.WriteJsonForReturn(false, "用户名重复");
                    }
                    if (masterBLL.AddNew(info) > 0)
                    {
                         //激活网址生成
                        string webpath = Request.Url.Scheme + "://" + Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/Master/EmailChecking") + "?UserName="******"&YZM=" + info.VCode;
                        string body = "尊敬的" + info.Username + "用户:请点击些链接激活:";
                        body += "<a href=" + webpath + ">" + webpath + "</a>";

                        RogerSMTP roger = new RogerSMTP(info.Email, "大师用户激活", body);
                        if (roger.Send())

                        //SMTP smtp = new SMTP(info.Email);
                        ////激活网址生成
                        //string webpath = Request.Url.Scheme + "://" + Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/MasterZone/EmailChecking.aspx") + "?UserName="******"&YZM=" + info.VCode;
                        ////发送激活邮件
                        //if (smtp.Activation(webpath, info.Username))
                        {

                            ReturnJson = Tools.WriteJsonForReturn(true, Tools.GetEmail(info.Email));

                        }
                        else
                        {
                            ReturnJson = Tools.WriteJsonForReturn(false, "发送激活邮件失败!");
                        }
                    }
                    else
                    {
                        ReturnJson = Tools.WriteJsonForReturn(false, "注册失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                //logger.Error("错误!", ex);
                ReturnJson = Tools.WriteJsonForReturn(false, "系统出错!");
            }
            return ReturnJson;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存用户信息 
        /// </summary>
        /// <param name="context"></param>
        public string SaveMemberInfo()
        {
            string errorString = bll.WriteJsonForReturn(false, "");
            try
            {
                //表单读取
                string txtUserName = Request["txtUserName"];
                string txtPwd = Request["txtPwd"];
                string txtEmail = Request["txtEmail"];
                string txtCheckCode = Request["txtCheckCode"];
                //验证码校验
                //if (!txtCheckCode.Equals(Session["checkcode"].ToString()))
                //{
                //    Response.Write(bll.WriteJsonForReturn(false, ""));
                //}
                //字符串sql注入检测
                if (Tools.IsValidInput(ref txtUserName, true) && Tools.IsValidInput(ref txtPwd, true) && Tools.IsValidInput(ref txtEmail, true))
                {
                    Member info = new Member();
                    info.UserName = txtUserName;
                    info.Password = Tools.GetMD5(txtPwd);
                    info.Email = txtEmail;
                    info.States = "0";

                    //加随机验证码
                    info.VCode = Guid.NewGuid().ToString("N");
                    //验证失效(1小时以内激活有效)
                    info.VTime = DateTime.Now.AddHours(1);

                    //验证用户名
                    if (!bll.CheckExistUserName(info.UserName))
                    {
                        return errorString;
                    }
                    if (bll.AddNew(info))
                    {
                        string activationUrl = Request.Url.Scheme + "://" + Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/Member/EmailChecking") + "?UserName="******"&YZM=" + info.VCode;
                        string body = "尊敬的" + info.UserName + "用户:请点击些链接激活:";
                        body += "<a href=" + activationUrl + ">" + activationUrl + "</a>";

                        //    SMTP smtp = new SMTP(info.Email);
                        //if (smtp.sendemail("用户激活",body))

                        RogerSMTP roger = new RogerSMTP(info.Email, "会员激活", body);
                        if (roger.Send())
                        {
                            return bll.WriteJsonForReturn(true, Tools.GetEmail(info.Email));
                        }
                        else
                        {
                            return errorString;
                        }
                        //SMTP smtp = new SMTP(info.Email);
                        ////激活网址生成
                        //string webpath = Request.Url.Scheme + "://" + Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/Member/EmailChecking.aspx") + "?UserName="******"&YZM=" + info.VCode;
                        ////发送激活邮件
                        //if (smtp.Activation(webpath, info.UserName))
                        //{
                        //    return bll.WriteJsonForReturn(true, Tools.GetEmail(info.Email));

                        //}
                        //else
                        //{
                        //    return errorString;
                        //}
                    }
                    else
                    {
                        return errorString;
                    }
                }
                else
                {
                    return errorString;
                }
            }
            catch (Exception ex)
            {
                //logger.Error("错误!", ex);
                return errorString;
            }
        }