Beispiel #1
0
 /// <summary>
 /// 添加验证码
 /// </summary>
 /// <param name="vdc">验证码</param>
 /// <returns>返回是否添加成功</returns>
 public Boolean AddValiDateCode(validatecode vdc)
 {
     try
     {
         string sql = "insert into validatecode(userid,type,code,sendtime,email,phone)values " +
             "(@userid,@type,@code,@sendtime,@email,@phone)";
         SqlParameter[] sp = new SqlParameter[]
         {
             new SqlParameter("@userid",vdc.userid),
             new SqlParameter("@type",vdc.type),
             new SqlParameter("@code",vdc.code),
             new SqlParameter("@sendtime",vdc.sendtime),
             new SqlParameter("@email",vdc.email),
             new SqlParameter("@phone",string.IsNullOrEmpty(vdc.phone)?"":vdc.phone)
         };
         return db.ExecuteNonQuery(sql, sp);
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
 }
        public string DoFindPwd()
        {
            string UserName = Request["UserName"];
            string Code = Request["Code"];
            try
            {
                if (string.IsNullOrEmpty(UserName.Trim()))
                {
                    return "请输入用户名|Error";
                }
                if (!gum.IsGameUser(UserName))
                {
                    return "您填写的用户名不存在!|Error";
                }
                if (string.IsNullOrEmpty(Code.Trim()))
                {
                    return "请输入验证码!|Error";
                }
                if (Session[Keys.SESSION_CODE] == null)
                {
                    return "验证码已过期,请重新获取验证码!|Error";
                }
                if (Code.ToLower() != Session[Keys.SESSION_CODE].ToString().ToLower())
                {
                    return "验证码错误!|Error";
                }

                GameUser gu = new GameUser();
                gu = gum.GetGameUser(UserName);
                int userid = gu.Id;
                DateTime dt1 = DateTime.Now.AddHours(-47);
                validatecode vcode = new validatecode();
                if (string.IsNullOrEmpty(gu.Email))
                {
                    return "您还未绑定邮箱!请联系客服!|Error";
                }
                if (vdcm.ExitValiDateCode(userid, 2, dt1))
                {
                    vcode = vdcm.GetValiDateCode(userid, 2);
                    string ucode = DESEncrypt.encryptstring1(vcode.userid.ToString());
                    string tcode = DESEncrypt.encryptstring1(vcode.type.ToString());
                    string scode = vcode.code.ToString();
                    string vicode = vcode.sendtime.ToString("yyyy-MM-ddHH:mm:ss");
                    string email = ConfigurationManager.AppSettings["email"].ToString();
                    string pwd = ConfigurationManager.AppSettings["password"].ToString();
                    string emailserver = ConfigurationManager.AppSettings["emailserver"].ToString();
                    string emailuser = ConfigurationManager.AppSettings["emailuser"].ToString();
                    string content_email = "Email 密码找回<br/><br/>" +
                                       "这封信是由 『5577游戏平台』 发送的。<br/><br/>" +

                                       "您收到这封邮件,是由于在 『5577游戏平台』 进行了密码找回操作。如果您并没有访问过 『乐扣游戏平台』,或没有进行上述操作,请忽略这封邮件。您不需要退订或进行其他进一步的操作。<br/><br/>" +

                                       "----------------------------------------------------------------------<br/>" +
                                       "密码找回说明<br/>" +
                                       "----------------------------------------------------------------------<br/><br/>" +

                                       "如果您是 『5577游戏平台』 的新用户,或在找回密码时使用了本地址,我们需 要对您的地址有效性进行验证以避免垃圾邮件或地址被滥用。<br/><br/>" +

                                       "您只需点击下面的链接即可修改您的帐号密码:<br/>" +
                                       "<a href=\"http://www.5577yx.com/UserCenter/ValiDateCode?ucode=" + ucode + "&tcode=" + tcode + "&scode=" + scode + "&vicode=" + vicode + "\">http://www.5577yx.com/UserCenter/ValiDateCodeucode=" + ucode + "&tcode=" + tcode + "&scode=" + scode + "&vicode=" + vicode + "</a><br/>" +
                                       "(如果上面不是链接形式,请将该地址手工粘贴到浏览器地址栏再访问)<br/><br/>" +

                                       "感谢您的访问,祝您使用愉快!<br/><br/>" +

                                       "此致<br/>" +
                                       "『5577游戏平台』 管理团队.<br/>";

                    new SendHelper().SendEmail(vcode.email, "5577yx邮箱密码找回", content_email);
                }
                else
                {
                    vdcm.DelValiDateCode(userid, 2);
                    vcode.type = 2;
                    vcode.userid = userid;
                    vcode.sendtime = DateTime.Now;
                    vcode.code = Guid.NewGuid().ToString() + DateTime.Now.Minute + DateTime.Now.Millisecond;
                    vcode.email = gu.Email;
                    vdcm.AddValiDateCode(vcode);
                    string ucode = DESEncrypt.encryptstring1(userid.ToString());
                    string tcode = DESEncrypt.encryptstring1("2");
                    string scode = vcode.code.ToString();
                    string vicode = vcode.sendtime.ToString("yyyy-MM-ddHH:mm:ss");
                    string email = ConfigurationManager.AppSettings["email"].ToString();
                    string pwd = ConfigurationManager.AppSettings["password"].ToString();
                    string emailserver = ConfigurationManager.AppSettings["emailserver"].ToString();
                    string emailuser = ConfigurationManager.AppSettings["emailuser"].ToString();
                    string content_email = "Email 密码找回<br/><br/>" +
                                       "这封信是由 『5577游戏平台』 发送的。<br/><br/>" +

                                       "您收到这封邮件,是由于在 『5577游戏平台』 进行了密码找回操作。如果您并没有访问过 『乐扣游戏平台』,或没有进行上述操作,请忽略这封邮件。您不需要退订或进行其他进一步的操作。<br/><br/>" +

                                       "----------------------------------------------------------------------<br/>" +
                                       "密码找回说明<br/>" +
                                       "----------------------------------------------------------------------<br/><br/>" +

                                       "如果您是 『5577游戏平台』 的新用户,或在找回密码时使用了本地址,我们需 要对您的地址有效性进行验证以避免垃圾邮件或地址被滥用。<br/><br/>" +

                                       "您只需点击下面的链接即可修改您的帐号密码:<br/>" +
                                       "<a href=\"http://www.5577yx.com/UserCenter/ValiDateCode?ucode=" + ucode + "&tcode=" + tcode + "&scode=" + scode + "&vicode=" + vicode + "\">http://www.5577yx.com/UserCenter/ValiDateCodeucode=" + ucode + "&tcode=" + tcode + "&scode=" + scode + "&vicode=" + vicode + "</a><br/>" +
                                       "(如果上面不是链接形式,请将该地址手工粘贴到浏览器地址栏再访问)<br/><br/>" +

                                       "感谢您的访问,祝您使用愉快!<br/><br/>" +

                                       "此致<br/>" +
                                       "『5577游戏平台』 管理团队.<br/>";

                    new SendHelper().SendEmail(vcode.email, "5577yx邮箱密码找回", content_email);
                }
            }
            catch (Exception ex)
            {
                return ex.Message + "|Error";
            }
            return "已成功发送邮件,请前往邮箱找回密码!|Success";
        }
Beispiel #3
0
 public string DoReg()
 {
     GameUser gu = new GameUser();
     string UserName = Request["UserName"].Trim();
     string Pwd = Request["PWD"].Trim();
     string Card = Request["Card"].Trim();
     string Email = Request["Email"].Trim();
     string Code = Request["Code"].Trim();
     if (!DevRegHel.RegName(UserName))
     {
         return "您输入的用户名不可用!";
     }
     if (!DevRegHel.RegPwd(Pwd))
     {
         return "您输入的密码不可用!";
     }
     if (!DevRegHel.RegCard(Card))
     {
         return "您输入的身份证不可用!";
     }
     if (!DevRegHel.RegEmail(Email))
     {
         return "您输入的邮箱不可用!";
     }
     if (gum.IsGameUser(UserName))
     {
         return "您输入的用户名已被注册!";
     }
     if (Session[Keys.SESSION_CODE] == null)
     {
         return "验证码已过期,请刷新验证码!";
     }
     if (Session[Keys.SESSION_CODE].ToString().ToUpper() != Code.ToUpper())
     {
         return "您输入的验证码不正确!";
     }
     if (Request["Ck"].Trim() != "on")
     {
         return "请务必确认您已经阅读服务条款!";
     }
     if (alm.IsLock(BBRequest.GetIP()))
     {
         return "您暂时不能注册!";
     }
     if (gum.ExitEmail(Request["Email"]))
     {
         return "您的邮箱已经注册过!";
     }
     gu = new GameUser(0, Request["UserName"], DESEncrypt.Md5(Request["PWD"], 32), "", Request["Sex"], "", "", Request["RealName"], Request["Email"]
         , "", Request["Birthday"], Request["Card"], "1", 0, "", 0, 0, 0, 0, 0, 0, DateTime.Now, DateTime.Now, 0, 0, 0, 0, BBRequest.GetIP(),
         "", 0, "", "");
     try
     {
         if (gum.AddUser(gu))
         {
             int Id = gum.GetGameUser(UserName).Id;
             sysmsg sm = new sysmsg();
             sm.title = "注册成功消息";
             sm.type = 2;
             sm.userid = Id;
             sm.fromid = 0;
             sm.msg = "恭喜您成功注册5577游戏账号,您可凭借此账号登录5577游戏旗下任何一款游戏,祝您游戏愉快。如果您在游戏过程中遇到任何问题,欢迎您致电客服咨询。";
             smm.AddSysMsg(sm);
             Session[Keys.SESSION_USER] = Id;
             Session.Timeout = 120;
             validatecode vdc = new validatecode();
             vdcm.DelValiDateCode(Id, 1);
             vdc.type = 1;
             vdc.userid = Id;
             vdc.sendtime = DateTime.Now;
             vdc.code = Guid.NewGuid().ToString() + DateTime.Now.Minute + DateTime.Now.Millisecond;
             vdc.email = gu.Email.Trim();
             vdcm.AddValiDateCode(vdc);
             //string ucode = DESEncrypt.encryptstring1(vdc.userid.ToString());
             //string tcode = DESEncrypt.encryptstring1(vdc.type.ToString());
             //string scode = vdc.code.ToString();
             //string vicode = vdc.sendtime.ToString("yyyy-MM-ddHH:mm:ss");
             return "True";
         }
         else
         {
             return "注册失败!";
         }
     }
     catch (Exception ex)
     {
         gu.IsLock = 1;
         gu.UserDesc = "此用户为注册失败用户!失败原因:" + ex.Message;
         gum.UpdateUser(gu);
         //gum.DelGameUser(UserName);
         return "注册失败!错误:" + ex.Message;
     }
 }
Beispiel #4
0
 /// <summary>
 /// 添加验证码
 /// </summary>
 /// <param name="vdc">验证码</param>
 /// <returns>返回是否添加成功</returns>
 public Boolean AddValiDateCode(validatecode vdc)
 {
     return vdcs.AddValiDateCode(vdc);
 }
Beispiel #5
0
 /// <summary>
 /// 获取验证码
 /// </summary>
 /// <param name="UserId">用户Id</param>
 /// <param name="Type">类型</param>
 /// <returns>返回验证码</returns>
 public validatecode GetValiDateCode(int UserId, int Type)
 {
     validatecode vdc = new validatecode();
     try
     {
         string sql = "select top 1 * from validatecode where userid=@UserId and type=@Type";
         SqlParameter[] sp = new SqlParameter[]
         {
             new SqlParameter("@UserId",UserId),
             new SqlParameter("@Type",Type)
         };
         using (SqlDataReader reader = db.GetReader(sql, sp))
         {
             while (reader.Read())
             {
                 vdc.id = (int)reader["id"];
                 vdc.type = (int)reader["type"];
                 vdc.userid = (int)reader["userid"];
                 vdc.code = reader["code"].ToString();
                 vdc.sendtime = (DateTime)reader["sendtime"];
                 vdc.email = reader["type"].ToString();
                 vdc.phone = reader["phone"].ToString();
             }
         };
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
     return vdc;
 }