//密码重置阶段,第二个对话框 protected void btnpwdr_Click(object sender, ImageClickEventArgs e) { string newpwd = this.newpwd.Text; string conf = this.newconf.Text; if (newpwd == "") { aptips2.InnerText = "请输入新密码!"; } else if (conf == "") { aptips2.InnerText = "请确认新密码!"; } else if (newpwd != conf) { aptips2.InnerText = "两次输入的新密码不一致!"; } else { string confs = Encryption.Auth(conf); string connectionString = ConfigurationManager.ConnectionStrings["lijunConnectionString"].ConnectionString; SqlConnection cnn = new SqlConnection(connectionString); string st = "update Admin set adpwd='" + @confs + "',code=null where adname='" + Session["fgpwd"] + "'"; cnn.Open(); SqlCommand cmd = new SqlCommand(st, cnn); cmd.ExecuteNonQuery(); cnn.Close(); Response.Write("<script type='text/javascript'>alert('设置成功,请重新登录!');window.location.href='adminlogin.aspx';</script>"); } }
protected void mailvs() { string mail = Server.UrlEncode(Request.QueryString["key"]); if (mail == "" || mail == null) { Label1.Text = "验证失败……"; Image1.ImageUrl = "~/imgs/x.gif"; } else { string connectionString = ConfigurationManager.ConnectionStrings["lijunConnectionString"].ConnectionString; SqlConnection cnn = new SqlConnection(connectionString); //查询 string st = "select * from Guest"; cnn.Open(); SqlDataAdapter da = new SqlDataAdapter(st, cnn); DataSet ds = new DataSet(); da.Fill(ds); bool flag = false; for (int k = 0; k < ds.Tables[0].Rows.Count; k++)//遍历DataTable { string mailv = ds.Tables[0].Rows[k]["gname"].ToString(); string namev = ds.Tables[0].Rows[k]["gmail"].ToString(); if (Encryption.Auth("黑我网站速度死!" + Encryption.Auth(mailv)) + Encryption.Auth(namev) == mail) { //这是为了避免重复发送验证邮件 if (ds.Tables[0].Rows[k]["mailv"].ToString() == "False") { //通过验证 string p = ds.Tables[0].Rows[k]["gname"].ToString(); string st2 = "update Guest set mailv=1 where gname='" + p + "'"; DBHelp.cn(st2).ExecuteNonQuery(); mailno();//通过验证才发送通知 } Label1.Text = "验证成功!"; Image1.ImageUrl = "~/imgs/v.gif"; flag = true; break; } else { continue; } } if (flag == false) { //验证失败 Label1.Text = "验证失败……"; Image1.ImageUrl = "~/imgs/x.gif"; } ds.Clear(); cnn.Close(); } }
//发送验证邮件 protected void mailv(string mailto, string usr) { MailAddress MessageFrom = new MailAddress("*****@*****.**"); //发件人邮箱地址 string mailtoe = Encryption.Decode(mailto); string MessageTo = mailtoe; //收件人邮箱地址 string MessageSubject = "[丽军数码]验证邮箱地址"; //邮件主题 string user = Encryption.Auth(usr); //MD5 string mail = Encryption.Auth(mailto); //MD5 string url = "http://lijun0772.com/mailv.aspx?key=" + Encryption.Auth("黑我网站速度死!" + user) + mail; string MessageBody = "<p>" + Encryption.Decode(usr) + ",你好:<br/>请点击以下链接完成验证:<br/><a href=\"" + url + "\" target=\"_blank\">验证链接</a><br />如果你没有在本站评论或留言,请不要理会。</p><p align=\"right\">丽军数码</p>"; //邮件内容 Send(MessageFrom, MessageTo, MessageSubject, MessageBody); }
//修改邮箱后 //发送验证邮件 protected void mailv(string mailto, string usr) { MailAddress MessageFrom = new MailAddress("*****@*****.**"); //发件人邮箱地址 string mailtoe = Encryption.Decode(mailto); string MessageTo = mailtoe; //收件人邮箱地址 string MessageSubject = "[丽军数码]验证邮箱地址"; //邮件主题 string user = Encryption.Auth(usr); //MD5 string mail = Encryption.Auth(mailto); //MD5 string url = "http://lijun0772.com/mailv.aspx?uid=" + user + "&tn=" + mail; string MessageBody = "<p>请点击以下链接完成验证:<br/>" + url + "</p><p align=\"right\">丽军数码</p>"; //邮件内容 Send(MessageFrom, MessageTo, MessageSubject, MessageBody); }
protected void btnInsert_Click(object sender, ImageClickEventArgs e) { string txtname = Encryption.Encode(yhm.Text.Trim()); string txtpwd = Encryption.Auth(mima.Text.Trim()); string txtcfpwd = Encryption.Auth(mimaqu.Text.Trim()); string txtylyx = Encryption.Encode(ylyx.Text.Trim()); int chaoji = 0; if (cksuper.Checked == true) { chaoji = 1; } if (txtname == "") { aptips.InnerText = "请输入用户名! "; } else if (txtpwd == "") { aptips.InnerText = "请输入新密码!"; } else if (txtcfpwd == "") { aptips.InnerText = "请确认新密码!"; } else if (txtpwd != txtcfpwd) { aptips.InnerText = "两次输入的新密码不一致!"; } else if (!this.isname())//用户名判断函数的调用 { aptips.InnerText = "用户名已存在!"; } else { string connectionString = ConfigurationManager.ConnectionStrings["lijunConnectionString"].ConnectionString; SqlConnection cnn = new SqlConnection(connectionString); string st = "insert into Admin(adname,adpwd,suadmin,admail) values('" + @txtname + "','" + @txtpwd + "','" + @chaoji + "','" + @txtylyx + "') "; SqlCommand cmd = new SqlCommand(st, cnn); cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('添加成功!');window.location.href=window.location.href; </script>"); yhm.Text = ""; } }
protected void btnLogin_click(object sender, ImageClickEventArgs e) { string adname = Encryption.Encode(admin.Text.Trim()); string adpwd = Encryption.Auth(pwd.Text); if (adname.Trim() == "") { aptips.InnerText = "请输入用户名! "; } else if (adpwd.Trim() == "") { aptips.InnerText = "请输入密码!"; } else { string connectionString = ConfigurationManager.ConnectionStrings["lijunConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(connectionString); string st = "select * from Admin where adname='" + @adname + "'and adpwd='" + @adpwd + "'"; con.Open(); SqlCommand cmd = new SqlCommand(st, con); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { Session["issuper"] = reader["adname"].ToString(); Session["ispwd"] = reader["adpwd"].ToString(); Session["suadmin"] = reader["suadmin"].ToString(); con.Close(); Response.Redirect("adminweb.aspx"); } else { Response.Write("<script type='text/javascript'>alert('请检查您输入的用户名和密码!');window.location.href='adminlogin.aspx';</script>"); con.Close(); } } }