protected void btnLogin_Click(object sender, EventArgs e) { TextBox txtUserName = (TextBox)FindControl("txtUserName"); TextBox txtPassword = (TextBox)FindControl("txtPassword"); Label lblInfo = (Label)FindControl("lblInfo"); CheckBox cbRememberMe = (CheckBox)FindControl("cbRememberMe"); BSUser user = BSUser.GetUser(txtUserName.Text, BSHelper.GetMd5Hash(txtPassword.Text)); if (user != null) { Session.Timeout = 129600; Blogsa.ActiveUser = user; Roles.AddUserToRole(Blogsa.ActiveUser.UserName, Blogsa.ActiveUser.Role); user.LastLoginDate = DateTime.Now; user.Save(); FormsAuthentication.RedirectFromLoginPage(Blogsa.ActiveUser.UserName, cbRememberMe.Checked); } else { lblInfo.Text = Language.Get["ErrorUserPassword"]; } }
protected void btnSendPassword_Click(object sender, EventArgs e) { TextBox txtEmail = (TextBox)FindControl("txtEmail"); Label lblInfo = (Label)FindControl("lblInfo"); try { if (BSHelper.CheckEmail(txtEmail.Text) & BSUser.ValidateEmail(txtEmail.Text)) { BSUser user = BSUser.GetUserByEmail(txtEmail.Text); string strNewPassword = BSHelper.GetRandomStr(8); string strMessage = Language.Get["YourNewPassword"].Replace("%", strNewPassword); string strMail = Blogsa.Settings["admin_email"].Value; user.Password = BSHelper.GetMd5Hash(strNewPassword); user.Save(); if (BSHelper.SendMail("Blogsa - Password Reminder", strMail, Blogsa.Settings[0].Value, user.Email, user.Name, strMail, true)) { lblInfo.Text = Language.Get["PasswordMailSend"]; } else { lblInfo.Text = "Mail not send! Please check your mail settings!"; } } else { lblInfo.Text = Language.Get["ErrorMail"]; } } catch (Exception ex) { lblInfo.Text = ex.Message; } }
private void SaveAllData() { XmlRootAttribute root = new XmlRootAttribute(); root.ElementName = "Data"; root.IsNullable = true; XmlSerializer dataSerializer = new XmlSerializer(typeof(BSData), root); using (TextReader reader = new StreamReader(Server.MapPath(String.Format("~/Setup/Data/{0}.xml", Session["lang"])))) { BSData data = (BSData)dataSerializer.Deserialize(reader); if (data != null) { if (data.Sites != null) { foreach (BSSite bsSite in data.Sites) { bsSite.Save(); } } if (data.Settings != null) { foreach (BSSetting bsSetting in data.Settings) { bsSetting.Save(); } } if (data.Posts != null) { foreach (BSPost bsPost in data.Posts) { bsPost.Save(); } } if (data.MenuGroups != null) { foreach (BSMenuGroup bsMenuGroup in data.MenuGroups) { bsMenuGroup.Save(); } } if (data.Menus != null) { foreach (BSMenu bsMenu in data.Menus) { bsMenu.Save(); } } if (data.Users != null) { foreach (BSUser bsUser in data.Users) { bsUser.Save(); } } if (data.Widgets != null) { foreach (BSWidget bsWidget in data.Widgets) { bsWidget.Save(); } } if (data.Links != null) { foreach (BSLink bsLink in data.Links) { bsLink.Save(); } } if (data.Terms != null) { foreach (BSTerm bsTerm in data.Terms) { bsTerm.Save(); } } Blogsa.Settings = null; } } if (Session["Password"] == null) { string password = BSHelper.GetRandomStr(8); BSUser user = BSUser.GetUserByUserName("admin"); user.Password = BSHelper.GetMd5Hash(password); user.Save(); Session["Password"] = password; } Session["Step"] = "Finish"; Response.Redirect("Completed.aspx"); }