Esempio n. 1
0
    private bool SaveData()
    {
        bool bRet = false;

        if (b.DemoMode == false)
        {
            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            string password = Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(inRePassword.Text.Trim()));
            data.AddNewUser(this.inFullName.Text.Trim(), this.inEmail.Text.Trim(), password);

            if (data.SQLError == null)
            {
                bRet = true;
            }
            else
            {
                DisplayError(data.SQLError.Message);
            }
        }
        else
        {
            Alert("You are not allowed to make changes in demo mode.");
        }
        return(bRet);
    }
Esempio n. 2
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    protected void btnLogin_Click(object sender, System.EventArgs e)
    {
        // Check user input
        if (CheckUserInput() == true)
        {
            string UserID = "";

            // Encrypt password
            string EncPass = Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(inPassword.Text.Trim()));

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            // Validate against database
            UserID = data.AuthenticateUser(inUserName.Text.Trim(), EncPass);

            if (data.SQLError != null)
            {
                lblerror.Text = data.SQLError.Message;
                return;
            }

            if (UserID.Length > 0)
            {
                // Redirect to requested page
                FormsAuthentication.RedirectFromLoginPage(UserID, false);
            }
            else
            {
                // User Login error so display the error to the user
                Alert("Please check your user name and / or password.");
            }
        }
    }
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        if (b.DemoMode == false)
        {
            b.MetaDescription      = inDescription.Text;
            b.GuestbookGridSize    = Convert.ToInt16(inGridSize.Text);
            b.GuestBookTitle       = inGuestBookTitle.Text;
            b.MetaKeywords         = inKeywords.Text;
            b.SiteTitle            = inSiteTitle.Text;
            b.AdminEmail           = inAdminEmail.Text;
            b.MailServer           = inMailServer.Text;
            b.DemoMode             = chkDemoMode.Checked;
            b.ShowPoweredBy        = chkPoweredBy.Checked;
            b.RequireApproval      = chkRequireApproval.Checked;
            b.SendEmailWithNewPost = chkSendEmail.Checked;
            b.EnableErrorTracking  = chkTrackErrors.Checked;
            b.LanguageFilter       = rblFilter.SelectedValue;

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            if (data.UpdatingSiteSettings(b) == true)
            {
                Cache["SiteSettings"] = b;
                lblMessage.Text       = "Your settings have been saved";
            }
            else
            {
                lblerror.Text = "An error occured while saving your settings";
            }
        }
        else
        {
            lblerror.Text = "You are not allowed to change these settings in demo mode.";
        }
    }
Esempio n. 4
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
    protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
    {
        if (b.DemoMode == false)
        {
            string Email    = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim();
            string FullName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim();

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.UpdataUserInformation(Email, FullName, GridView1.DataKeys[e.RowIndex].Values[0].ToString());

            if (data.SQLError == null)
            {
                GridView1.EditIndex = -1;
                LoadData();
            }
            else
            {
                DisplayError(data.SQLError.Message);
            }
        }
        else
        {
            Alert("You are not allowed to make changes in demo mode.");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Load Site Settings
        b = (SiteSettings)Cache["SiteSettings"];

        // Load Language File
        Lang = (LanguageFile)Cache["LanguageFile"];

        lblError.Text   = "";
        lblSuccess.Text = "";

        if (User.Identity.IsAuthenticated == true)
        {
            trDate.Visible = true;
            inSubDate.Text = DateTime.Now.ToShortDateString();
        }
        else
        {
            trDate.Visible = false;
        }

        SetRequiredFields();

        // Check to see if this user is on the blocked IP List
        DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();

        if (data.CheckForBlockedIP(Request.UserHostAddress) == true)
        {
            // Users IP has been blocked so disable form
            btnSubmit.Visible = false;
            Alert(Lang.BlockedIP);
        }

        if (!Page.IsPostBack)
        {
            rblGender.Items.Add(new ListItem(Lang.Male, Lang.Male));
            rblGender.Items.Add(new ListItem(Lang.Female, Lang.Female));
            rblGender.Items.Add(new ListItem(Lang.Unspecified, Lang.Unspecified));

            LoadCountries();
            LoadStates();

            lblSignOurGuestbook.Text  = Lang.SignOurGuestbook;
            lnkBackToGuestbook.Text   = Lang.BacktoGuestbook;
            lblBoldField.Text         = "*" + Lang.Boldfield;
            lblFullname.Text          = Lang.FullName;
            lblCountry.Text           = Lang.Country;
            lblState.Text             = Lang.State;
            lblEmail.Text             = Lang.Email;
            lblHomepage.Text          = Lang.Homepage;
            lblGuestbook.Text         = Lang.Guestbook;
            lblGender.Text            = Lang.Gender;
            lblMessage.Text           = Lang.Message;
            lblSubmissionDate.Text    = Lang.SubmissionDate;
            lblVerificationImage.Text = Lang.VerificationImage;
            lblFormError.Text         = Lang.CompleteThisForm;
            btnCancel.Text            = Lang.Cancel;
            btnSubmit.Text            = Lang.Submit;
        }
    }
Esempio n. 6
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub btnSaveChanges_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveChanges.Click
    protected void btnSaveChanges_Click(object sender, System.EventArgs e)
    {
        if (b.DemoMode == false)
        {
            LanguageFile b = new LanguageFile();
            b.BacktoGuestbook         = this.inBacktoGuestbook.Text;
            b.BadLanguage             = this.inBadLanguage.Text;
            b.BlockedIP               = this.inBlockedIP.Text;
            b.Boldfield               = this.inBoldFields.Text;
            b.Cancel                  = this.inCancel.Text;
            b.CompleteThisForm        = this.inCompleteForm.Text;
            b.Country                 = this.inCountry.Text;
            b.Email                   = this.inEmail.Text;
            b.EnterEmailAddress       = this.inEnterEmailAddress.Text;
            b.EnterFullName           = this.inEnterFullName.Text;
            b.EnterGuestbook          = this.inEnterGuestbook.Text;
            b.EnterHomepage           = this.inEnterHomepage.Text;
            b.EnterMessage            = this.inEnterMessage.Text;
            b.EnterNosHere            = this.inEnterNos.Text;
            b.EnterVerificationImage  = this.inEnterVerificationText.Text;
            b.Female                  = this.inFemale.Text;
            b.FullName                = this.inFullName.Text;
            b.Guestbook               = this.inGuestbook.Text;
            b.Gender                  = this.inGender.Text;
            b.Homepage                = this.inHomepage.Text;
            b.VerificationDidNotMatch = this.inInvalidVerification.Text;
            b.Male              = this.inMale.Text;
            b.Message           = this.inMessage.Text;
            b.SelectCountry     = this.inSelectCountry.Text;
            b.SelectState       = this.inSelectState.Text;
            b.SignOurGuestbook  = this.inSignBook.Text;
            b.State             = this.inState.Text;
            b.SubmissionDate    = this.inSubmissionDate.Text;
            b.SubmissionMessage = this.inSubmissionMessage.Text;
            b.Submit            = this.inSubmit.Text;
            b.Unspecified       = this.inUnspecified.Text;
            b.ValidEmailAddress = this.inValidEmail.Text;
            b.ValidGuestbookURL = this.inValidGuestbook.Text;
            b.ValidHomepageURL  = this.inValidHomepage.Text;
            b.VerificationImage = this.inVerificationImage.Text;
            b.YourGuestbook     = this.inYourGuestbook.Text;
            b.YourHomepage      = this.inYourHomepage.Text;

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            if (data.UpdateLanguageFile(b) == true)
            {
                Cache["LanguageFile"] = b;
                Response.Redirect("LanguageFile.aspx");
            }
            else
            {
                lblerror.Text = "Error while updating lanaguage file.";
            }
        }
        else
        {
            lblerror.Text = "You are not allowed to change these settings in demo mode.";
        }
    }
Esempio n. 7
0
 private void LoadStates()
 {
     DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
     lstState.DataTextField  = "Name";
     lstState.DataValueField = "ID";
     lstState.DataSource     = data.GetStates();
     lstState.DataBind();
 }
Esempio n. 8
0
 private void LoadData()
 {
     DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
     using (DataView dv = new DataView(data.GetUsers()))
     {
         dv.Sort = ViewState["Column"].ToString() + " " + ViewState["Direction"].ToString();
         GridView1.DataSource = dv;
         GridView1.DataBind();
     }
 }
Esempio n. 9
0
    private void LoadDetails(string id)
    {
        DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
        DataTable dtinfo = data.GetGuestbookDataByID(id);

        if (dtinfo.Rows.Count > 0)
        {
            System.Data.DataRow tempVar = dtinfo.Rows[0];
            inFullName.Text     = tempVar["FullName"].ToString();
            inIPAddress.Text    = tempVar["IPAddress"].ToString();
            inEmail.Text        = tempVar["Email"].ToString();
            inMessage.Text      = tempVar["Message"].ToString();
            inDate.Text         = tempVar["SubmissionDate"].ToString();
            inGender.Text       = tempVar["Gender"].ToString();
            chkApproved.Checked = tempVar["Approved"];
            lstCountry.Items.FindByValue(tempVar["Country"].ToString()).Selected = true;
            lstState.Items.FindByValue(tempVar["State"].ToString()).Selected     = true;
            inHomepage.Text  = tempVar["HomePageURL"].ToString();
            inGuestbook.Text = tempVar["GuestBookURL"].ToString();
        }
    }
Esempio n. 10
0
    private bool SaveData()
    {
        bool bRet = true;

        if (b.DemoMode == false)
        {
            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.InsertsNewIPAddress(this.inIPAddress.Text.Trim());

            if (data.SQLError != null)
            {
                bRet = false;
                DisplayError(data.SQLError.Message);
            }
        }
        else
        {
            Alert("You are not allowed to make changes in demo mode.");
        }
        return(bRet);
    }
    private bool SaveData()
    {
        bool bRet = true;

        if (b.DemoMode == false)
        {
            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.AddNewBadWord(this.inBadWord.Text.Trim());
            if (data.SQLError != null)
            {
                Alert(data.SQLError.Message);
                bRet = false;
            }
        }
        else
        {
            Alert("You are not allowed to make changes in demo mode.");
        }

        return(bRet);
    }
Esempio n. 12
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
    protected void GridView1_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
    {
        if (b.DemoMode == false)
        {
            string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.DeleteBadWord(id);

            if (data.SQLError != null)
            {
                DisplayError(data.SQLError.Message);
            }
            else
            {
                LoadData();
            }
        }
        else
        {
            Alert("You are not allowed to make changes in demo mode.");
        }
    }
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        if (b.DemoMode == false)
        {
            SiteSettings ss = b;

            ss.RequireFullName  = chkFullName.Checked;
            ss.RequireCountry   = chkCountry.Checked;
            ss.RequireState     = chkState.Checked;
            ss.RequireEmail     = chkEmail.Checked;
            ss.RequireHomepage  = chkHomePage.Checked;
            ss.RequireGuestbook = chkGuestbook.Checked;
            ss.RequireGender    = chkGender.Checked;
            ss.RequireMessage   = chkMessage.Checked;

            ss.DisplayFullName  = chkDisplayFullName.Checked;
            ss.DisplayCountry   = chkDisplayCountry.Checked;
            ss.DisplayState     = chkDisplayState.Checked;
            ss.DisplayEmail     = chkDisplayEmail.Checked;
            ss.DisplayHomepage  = chkDisplayHomePage.Checked;
            ss.DisplayGuestbook = chkDisplayGuestbook.Checked;
            ss.DisplayGender    = chkDisplayGender.Checked;
            ss.DisplayMessage   = chkDisplayMessage.Checked;

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            if (data.UpdatingSiteSettings(ss) == true)
            {
                lblMessage.Text = "Settings Saved";
            }
            else
            {
                lblerror.Text = "Error while saving settings";
            }
        }
        else
        {
            lblerror.Text = "You are not allowed to change these settings in demo mode.";
        }
    }
Esempio n. 14
0
    private void LoadGrid()
    {
        DataTable dtinfo = null;

        // Get items from Guestbook
        DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
        dtinfo = data.GetGuestbookDataByApprovalType(true);

        if (data.SQLError == null)
        {
            if (dtinfo.Rows.Count > 0)
            {
                // Bind items to grid
                GridView1.DataSource = dtinfo;
                GridView1.DataBind();
            }
        }
        else
        {
            lblError.Text = data.SQLError.Message;
        }
    }
Esempio n. 15
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        if (b.DemoMode == false)
        {
            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            // Update row with new values
            data.UpdateGuestBookEntry(inFullName.Text.Trim(), Convert.ToInt32(lstCountry.SelectedValue), lstState.SelectedValue, inIPAddress.Text, inEmail.Text, inHomepage.Text, inGuestbook.Text, inGender.Text, inMessage.Text, inDate.Text, chkApproved.Checked, Convert.ToInt32(Request.Params["ID"]));

            if (data.SQLError == null)
            {
                RefreshOpenerAndClose();
            }
            else
            {
                DisplayError(data.SQLError.Message);
            }
        }
        else
        {
            Alert("Sorry, you are not allowed to update in demo mode.");
        }
    }
Esempio n. 16
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
    protected void GridView1_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
    {
        if (b.DemoMode == false)
        {
            string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.DeleteUserByID(id);

            if (data.SQLError == null)
            {
                LoadData();
            }
            else
            {
                DisplayError("An Error occured while deleting this user.");
            }
        }
        else
        {
            Alert("Sorry, but you are not allowed to delete users in demo mode");
        }
    }
Esempio n. 17
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
    protected void GridView1_SelectedIndexChanging(object sender, System.Web.UI.WebControls.GridViewSelectEventArgs e)
    {
        string id   = GridView1.DataKeys[e.NewSelectedIndex].Values[0].ToString();
        string Pass = "";

        DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
        Pass = data.ForgotPassword(id);

        Pass = System.Text.Encoding.Default.GetString(Convert.FromBase64String(Pass));

        try
        {
            using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["AdminEmail"], GridView1.Rows[e.NewSelectedIndex].Cells[2].Text, "Your password for the Guestbook", "Your password is: " + Pass))
            {
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings["MailServer"]);
                smtp.Send(mail);
            }
        }
        catch (Exception ex)
        {
            DisplayError(ex.Message);
        }
    }
Esempio n. 18
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
    protected void GridView1_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
    {
        if (b.DemoMode == false)
        {
            string id = GridView1.DataKeys(e.RowIndex).Value.ToString();

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.DeleteGuestbookEntry(id);

            if (data.SQLError == null)
            {
                Alert("Post Deleted.");
                LoadData();
            }
            else
            {
                Alert("An Error occured while deleting post.");
            }
        }
        else
        {
            Alert("You are not allowed to delete while in demo mode.");
        }
    }
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
    protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
    {
        if (b.DemoMode == false)
        {
            string IPAddress = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text;

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            data.UpdateIPAddress(IPAddress, Convert.ToString(GridView1.DataKeys[e.RowIndex].Value));

            if (data.SQLError == null)
            {
                GridView1.EditIndex = -1;
                LoadData();
            }
            else
            {
                DisplayError(data.SQLError.Message);
            }
        }
        else
        {
            Alert("You are not allowed to make changes in demo mode.");
        }
    }
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        // I check all my forms manaully because a user can have
        // javascript turned off and bypass .Net Validation controls
        if (CheckPage() == true)
        {
            // Check if Require Message is Turned on
            bool Required = false;

            // If admin allows posts to pass through without checking first
            if (b.RequireApproval == true)
            {
                Required = true;
            }

            string HomePage      = "";
            string GuestBookPage = "";

            // Check to see if the user entered a homepage url
            if (inHomePage.Text.Length > 7)
            {
                HomePage = inHomePage.Text.Trim();
            }

            // Check to see if the user entered a guestbook url
            if (inGuestbookURL.Text.Length > 7)
            {
                GuestBookPage = inGuestbookURL.Text.Trim();
            }

            bool Approved = false;
            // Have to do some reverse logic for post approval based on require approval
            if (Required == false)
            {
                Approved = true;
            }

            // Remove single quote to prevent script injection
            string Message = inMessage.Content.Trim;
            Message = Message.Replace("'", "");

            DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
            // Insert new record into the database
            data.InsertNewGuestbookEntry(inFullName.Text.Trim(), Convert.ToInt32(lstCountries.SelectedValue), Convert.ToInt32(lstStates.SelectedValue), Request.UserHostAddress, inEmail.Text.Trim(), HomePage, GuestBookPage, rblGender.SelectedValue, Message, DateTime.Now, Approved);

            if (data.SQLError == null)
            {
                if (b.SendEmailWithNewPost == true)
                {
                    SendEmailToAdmin();
                }

                // Check if posts require admin approval
                if (Required == false)
                {
                    // Invalidate Guestbook cache so new entry will show up in Guestbook
                    Cache.Remove("dsGuestbook");

                    // Send back to Guestbook page
                    Response.Redirect("GuestBook.aspx");
                }
                else
                {
                    // Post need approval so display to user so they don't get confused.
                    lblSuccess.Text = string.Format("<ul><li>{0}</li></ul>", Lang.SubmissionMessage);
                    ClearForm();
                }
            }
            else
            {
                // Something happened so let the user know.
                DisplayError(data.SQLError.Message);
            }
        }
    }
    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);
    }
Esempio n. 22
0
 private void LoadData()
 {
     DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
     GridView1.DataSource = data.GetGuestbookDataByApprovalType(rblStatus.SelectedValue);
     GridView1.DataBind();
 }