public static string MailCertification(string account) { string site_name = ""; Mmemberdata result = new Mmemberdata(); result = Member.Check_exist(account); string filename = HttpContext.Current.Server.MapPath("/templates/letter.html"); string mailbody = unity.classlib.GetTextString(filename); DataTable dt = unity.classlib.Get_Message(1); unity.classlib.MsgResult m = new unity.classlib.MsgResult(); if (result.Memberid > 0) { m.Id = result.AccountId; string AccountId = MySecurity.EncryptAES256(result.Memberid + DateTime.Now.ToString("yyyyMMddhhmmss")); site_name = HttpContext.Current.Application["site_name"].ToString(); string textbody = dt.Rows[0]["contents"].ToString().Replace("@site_name@", site_name); string subject = dt.Rows[0]["title"].ToString().Replace("@site_name@", site_name); string url = "https://www.culturelaunch.net/resend?activeid=" + AccountId + "&Certification=mail"; mailbody = mailbody.Replace("@title@", subject); textbody = textbody.Replace("@password@", result.Password); textbody = textbody.Replace("@username@", result.Username); mailbody = mailbody.Replace("@mailbody@", textbody); string strsql = @"insert into log_Certification (memberid,accountid,ExpiryDate,status) values (@memberid,@accountid,@ExpiryDate,@status) "; NameValueCollection nvc = new NameValueCollection(); nvc.Add("memberid", result.Memberid.ToString()); nvc.Add("accountid", AccountId); nvc.Add("ExpiryDate", DateTime.Now.AddHours(2).ToString("yyyy-MM-dd HH:mm:ss")); nvc.Add("status", ""); DbControl.Data_add(strsql, nvc); mailbody = mailbody.Replace("@currenttime@", DateTime.Now.AddHours(2).ToString("yyyy-MM-dd HH:mm:ss")); mailbody = mailbody.Replace("@url@", url); m.Msg = unity.classlib.SendsmtpMail(result.Email, subject, mailbody, "gmail"); } m.Id = result.Memberid.ToString(); if (result.Memberid == 0) { m.Msg = "帳號不存在,請重新輸入"; } else if (result.Email.ToString() == "") { m.Id = "0"; m.Msg = "Email未填寫,請至會員中心"; } else { m.Msg = "請收取Email以証證"; } return(new JavaScriptSerializer().Serialize(m));; }
public static string CheckCertification(string activeid) { unity.classlib.MsgResult m = new unity.classlib.MsgResult(); if (activeid != null && activeid != "") { Mmemberdata result = new Mmemberdata(); string strsql = @"select * from Log_Certification where accountid =@accountid and getdate() <= ExpiryDate "; NameValueCollection nvc = new NameValueCollection(); nvc.Add("accountid", activeid); DataTable dt = DbControl.Data_Get(strsql, nvc); if (dt.Rows.Count == 0) { m.Id = "0"; m.Msg = "証認碼不存在或已過期!請重新認証"; } else { m.Id = dt.Rows[0]["memberid"].ToString(); strsql = "update tbl_MemberData set status='Y' where memberid = @memberid"; nvc.Clear(); nvc.Add("memberid", m.Id); DbControl.Data_add(strsql, nvc); strsql = @"update Log_Certification set status='Y' ,CertificationDate=getdate() where accountid = @accountid"; nvc.Clear(); nvc.Add("accountid", activeid); DbControl.Data_add(strsql, nvc); m.Msg = "會員認証通過"; } } else { m.Id = "0"; m.Msg = "証認碼不存在"; } return(new JavaScriptSerializer().Serialize(m));; }