private void LoadData() { DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider(); using (DataView dv = new DataView(data.GetBadWords())) { dv.Sort = ViewState["Column"].ToString() + " " + ViewState["Direction"].ToString(); GridView1.DataSource = dv; GridView1.DataBind(); } }
private bool CheckPage() { bool tempCheckPage = false; tempCheckPage = true; DataTable dtinfo = null; string Words = ""; StringBuilder sb = new StringBuilder(); // Get bad words from the database DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider(); dtinfo = data.GetBadWords(); // Loop through the bad words and construct the RegEx expression foreach (DataRow dr in dtinfo.Rows) { if (b.LanguageFilter == "Strict") { Words += Convert.ToString(dr[1].ToString() + "|"); } else { Words += string.Format(" {0} |", dr[1]); } } // Add a space to the beginning and end of message to be able to search first and last word string Message = string.Format(" {0} ", inMessage.Content.Trim); // Check for match against regex expression if (Regex.IsMatch(Message, Words.TrimEnd('|')) == true) { sb.Append("<li>"); sb.Append(Lang.BadLanguage); sb.Append("</li>"); tempCheckPage = false; } if (b.RequireFullName == true) { // Check the full Name if (inFullName.Text.Trim().Length == 0) { sb.Append("<li>"); sb.Append(Lang.EnterFullName); sb.Append("</li>"); tempCheckPage = false; } } if (b.RequireCountry == true) { if (!(lstCountries.SelectedIndex > 0)) { sb.Append("<li>"); sb.Append(Lang.SelectCountry); sb.Append("</li>"); tempCheckPage = false; } } if (b.RequireState == true) { if (!(lstStates.SelectedIndex > 0)) { sb.Append("<li>"); sb.Append(Lang.SelectState); sb.Append("</li>"); tempCheckPage = false; } } if (b.RequireEmail) { // Check the Email if provided if (inEmail.Text.Trim().Length > 0) { // Check to make sure the email address entered is valid if (Regex.IsMatch(inEmail.Text.Trim(), "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*") == false) { sb.Append("<li>"); sb.Append(Lang.ValidEmailAddress); sb.Append("</li>"); tempCheckPage = false; } } else { sb.Append("<li>"); sb.Append(Lang.EnterEmailAddress); sb.Append("</li>"); } } if (b.RequireHomepage == true) { if (!(this.inHomePage.Text.Trim().Length > 7)) { sb.Append("<li>"); sb.Append(Lang.EnterHomepage); sb.Append("</li>"); tempCheckPage = false; } } if (b.RequireGuestbook == true) { if (!(this.inGuestbookURL.Text.Trim().Length > 7)) { sb.Append("<li>"); sb.Append(Lang.EnterGuestbook); sb.Append("</li>"); tempCheckPage = false; } } // Check to see if user entered a homepage if (this.inHomePage.Text.Trim().Length > 7) { // check to make sure the homepage entered is a valid url if (Regex.IsMatch(inHomePage.Text.Trim(), "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?") == false) { sb.Append("<li>"); sb.Append(Lang.ValidHomepageURL); sb.Append("</li>"); tempCheckPage = false; } } // Check to see if the user entered a guestbook if (this.inGuestbookURL.Text.Length > 7) { // check to make sure the guestbook entered is a valid url if (Regex.IsMatch(inGuestbookURL.Text.Trim(), "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?") == false) { sb.Append("<li>"); sb.Append(Lang.ValidGuestbookURL); sb.Append("</li>"); tempCheckPage = false; } } // check to make sure a message is provided if admin requires messages with posts if (b.RequireMessage == true) { if (inMessage.Content.Trim.Length == 0) { sb.Append("<li>"); sb.Append(Lang.EnterMessage); sb.Append("</li>"); tempCheckPage = false; } } // Make sure the user provided the Verification Number if (inVerify.Text.Trim().Length == 0) { sb.Append("<li>"); sb.Append(Lang.EnterVerificationImage); sb.Append("</li>"); tempCheckPage = false; } else { // Make sure that the number provided is in fact the number in the image if (!(string.Compare(inVerify.Text.Trim(), Session["NewID"].ToString()) == 0)) { sb.Append("<li>"); sb.Append(Lang.VerificationDidNotMatch); sb.Append("</li>"); tempCheckPage = false; } } // Check to see if there was any errors and if so display out to the user if (sb.ToString().Trim().Length > 0) { lblError.Text = string.Format("<ul>{0}</ul>", sb.ToString()); } return(tempCheckPage); }