コード例 #1
0
 private string Pr_Security_Ck(string CommandText)
 {
     _Anti.Address = true; _Anti.Email = true; _Anti.FullName = true; _Anti.Password = true;
     _Anti.Url     = true;
     if (_Anti.StringData(CommandText))
     {
         using (SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings[ConfigName].ConnectionString))
         {
             Conn.Open();
             SqlCommand newCmd = new SqlCommand();
             newCmd.Connection  = Conn;
             newCmd.CommandText = CommandText;
             try
             {
                 string returnValue = "Sucessfully";// newCmd.ExecuteScalar().ToString();
                 newCmd.ExecuteNonQuery();
                 Conn.Close();
                 return(returnValue);
             }
             catch (Exception error)
             {
                 Conn.Close();
                 return(error.Message);
             }
         }
     }
     else
     {
         return("Unauthorized Symbol.");
     }
 }
コード例 #2
0
        public bool int32CheckSecurity(string CommandText, int CountNumber)
        {
            AntiInjection _Anti = new AntiInjection();

            _Anti.Address  = true;
            _Anti.Email    = true;
            _Anti.FullName = true;
            _Anti.Password = true;
            _Anti.Url      = true;
            if (_Anti.StringData(CommandText))
            {
                Int32Check = int_Check_PV(CommandText);
                if (Int32Check == CountNumber)
                {
                    Int32CheckError = "Successful";
                    return(true);
                }
                else
                {
                    Int32CheckError = "Not Match";
                    return(false);
                }
            }
            else
            {
                Int32CheckError = "Error: String is not Secure.";
                return(false);
            }
        }
コード例 #3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //dfe3e9
            string UserName = txtUsername.Text;
            string Password = txtPassword.Text;

            lblResult.Text          = "";
            txtUsername.BorderColor = System.Drawing.Color.FromName("dfe3e9");
            txtPassword.BorderColor = System.Drawing.Color.FromName("dfe3e9");


            if (UserName != "" && Password != "")
            {
                if (_anti.StringData(UserName))
                {
                    _anti.Password = true;
                    if (_anti.StringData(Password))
                    {
                        _chk.ConfigarationName = "dbm";
                        string Ui = " from m_login where Username='******' and Password='******'";
                        if (_chk.int32Check("select count(*) " + Ui) == 1)
                        {
                            string Type      = _chk.stringCheck("select Type " + Ui);
                            string Authority = _chk.stringCheck("select Authority " + Ui);
                            if (Type == "Administrator")
                            {
                                Session["m_UserID"] = _chk.stringCheck("select userid " + Ui);
                                Session["m_Type"]   = _chk.stringCheck("select Type " + Ui);
                                Session["m_Name"]   = _chk.stringCheck("select Name " + Ui);
                                Session["m_photo"]  = _chk.stringCheck("select Photo " + Ui);
                                redirection();
                                //Response.Redirect(URL);
                            }
                            else
                            {
                                if (Authority == "True")
                                {
                                    Session["m_UserID"] = _chk.stringCheck("select userid " + Ui);
                                    Session["m_Type"]   = _chk.stringCheck("select Type " + Ui);
                                    Session["m_Name"]   = _chk.stringCheck("select Name " + Ui);
                                    Session["m_photo"]  = _chk.stringCheck("select Photo " + Ui);
                                    //Response.Redirect(URL);
                                }
                                else
                                {
                                    lblResult.Text = "Login Athority Failed. Can't Login!";
                                }
                            }
                        }
                        else
                        {
                            txtUsername.Text = "";
                            txtPassword.Text = "";
                            lblResult.Text   = "Invalid UserName/ Password!";
                        }
                    }
                    else
                    {
                        lblResult.Text = "Please Type Correctly";
                    }
                }
                else
                {
                    lblResult.Text = "Please Type Correctly";
                }
            }
            else
            {
                if (UserName == "")
                {
                    txtUsername.BorderColor = System.Drawing.Color.Red;
                    lblResult.Text         += "* Empty Username <br/>";
                }
                if (Password == "")
                {
                    txtPassword.BorderColor = System.Drawing.Color.Red;
                    lblResult.Text         += "&nbsp;&nbsp;&nbsp;&nbsp;* Empty Password";
                }
            }
        }