Beispiel #1
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            Classes.tBan bans = new tBan();
            using (var client = new HttpClient())
            {
                //client.BaseAddress = new Uri("http://192.223.30.108:55071/");
                client.BaseAddress = new Uri("http://localhost:55071/");

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = null;
                try
                {
                    tBan ban = new Classes.tBan();
                    ban.GuidOrIP = schGUID.Text;

                    string serializedBan = JsonConvert.SerializeObject(ban);

                    StringContent content = new StringContent(serializedBan, Encoding.UTF8, "application/json");

                    response = client.PostAsync("A3Bans/SearchBan", content).Result;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Player ban does not exist");
                }


                if (response.IsSuccessStatusCode)
                {
                    string strResponse = response.Content.ReadAsStringAsync().Result;
                    try
                    {
                        banReponse = JsonConvert.DeserializeObject <Classes.tBan>(strResponse);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                //   banReponse.BanReason = schReason.Text;
                //ID OWNER GUID REASON PROOF
                schBanID.Text  = banReponse.BanID;
                schGUID.Text   = banReponse.GuidOrIP;
                schReason.Text = banReponse.BanReason;
                schProof.Text  = banReponse.Proof;
                //schOwnerID.Text = banReponse.OwnerID;
            }
        }
Beispiel #2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (txtReason.Text.Length < 10)
            {
                MessageBox.Show("Please Enter a Valid Reason, Ensure you add your Appeal Process to the reason. I.E. ''Hacking | Appeal your ban @ www.yoursitehere.com''");
                return;
            }
            if (txtProof.Text.Length < 10)
            {
                MessageBox.Show("Please Enter Valid Proof, I.E. Script Logs, Youtube Link, Sound File Link, etc...");
                return;
            }
            // if ((guidMatch.Success && charMatch) || ipMatch.Success)
            var ipMatch   = Regex.Match(txtID.Text, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
            var guidMatch = Regex.Match(txtID.Text, @"[a-z,A-Z,0-9]{32}");
            var charMatch = (txtID.Text.Any(Char.IsLetter) && txtID.Text.Any(Char.IsDigit));

            if ((guidMatch.Success && charMatch) || ipMatch.Success)
            {
                string str1 = "Banning this Player may result in the player NOT being able to play on many servers!@@If Bans are falsified, your user and all bans applied by you are subject to be removed from the database which will result in all bans being removed from any server using this tool.@@Are you sure you want to do this?";
                str1 = str1.Replace("@", " " + System.Environment.NewLine);
                var confirmResult = MessageBox.Show(str1, "CONFIRM BAN!!", MessageBoxButton.YesNo);
                if (confirmResult == MessageBoxResult.Yes)
                {
                    MessageBox.Show("Sending response to WEB API");
                }

                Classes.tBan authenticationResult = new Classes.tBan();

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:55071/");

                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                    tBan submit = new Classes.tBan();
                    submit.GuidOrIP  = txtID.Text;
                    submit.BanType   = cmbBanType.Text;
                    submit.BanTime   = txtBan.Text;
                    submit.BanReason = txtReason.Text;
                    submit.Proof     = txtProof.Text;
                    submit.Proof     = System.Net.WebUtility.HtmlEncode(submit.Proof);
                    //submit.Proof = submit.Proof.Replace("quot;", "    ");
                    //submit.Proof = submit.Proof.Replace("&lt;", "<");
                    //submit.Proof = submit.Proof.Replace("&", "``");
                    //submit.Proof = submit.Proof.Replace("gt;", ">");
                    //submit.Proof = submit.Proof.Replace("#39;", "|");
                    submit.Proof = submit.Proof.Replace(System.Environment.NewLine, "");


                    //Json convert takes a C# object/class and makes a Json string, server automatically takes the json string and gives you back a C# object
                    //Seamless integration that PHP cant do, yep
                    //This is just a helper library
                    string serializedBan = JsonConvert.SerializeObject(submit);

                    //application/json is content type
                    StringContent content = new StringContent(serializedBan, Encoding.UTF8, "application/json");
                    try
                    {
                        HttpResponseMessage response = client.PostAsync("A3Bans/SubmitBan", content).Result;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        MessageBox.Show("Your Ban Has Succesfully Posted");
                    }
                }
            }
        }
Beispiel #3
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            {
                Login SqlLogin = new Login();
                SqlLogin.ShowDialog();
                {
                    tAuthenticationResponse authenticationResult = new Classes.tAuthenticationResponse();

                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri("http://localhost:55071/");

                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                        tCredential credential = new Classes.tCredential();
                        credential.Username = SqlLogin.txtSqlUserName.Text;
                        credential.Password = SqlLogin.txtSqlPassword.Password;

                        string serializedBan = JsonConvert.SerializeObject(credential);

                        StringContent content = new StringContent(serializedBan, Encoding.UTF8, "application/json");


                        HttpResponseMessage response = client.PostAsync("A3Bans/LogIn", content).Result;

                        if (response.IsSuccessStatusCode)
                        {
                            string strResponse = response.Content.ReadAsStringAsync().Result;
                            authenticationResult = JsonConvert.DeserializeObject <tAuthenticationResponse>(strResponse);
                        }
                    }

                    if (authenticationResult.AuthenticationSuccess)
                    {
                        this.Hide();
                        Classes.tBan bans = new tBan();
                        using (var client = new HttpClient())
                        {
                            //client.BaseAddress = new Uri("http://192.223.30.108:55071/");
                            client.BaseAddress = new Uri("http://localhost:55071/");

                            client.DefaultRequestHeaders.Accept.Clear();
                            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                            HttpResponseMessage response = null;
                            try
                            {
                                tBan ban = new Classes.tBan();
                                ban.GuidOrIP = schGUID.Text;

                                string serializedBan = JsonConvert.SerializeObject(ban);

                                StringContent content = new StringContent(serializedBan, Encoding.UTF8, "application/json");

                                response = client.PostAsync("A3Bans/deleteBan", content).Result;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Player ban does not exist");
                            }


                            if (response.IsSuccessStatusCode)
                            {
                                string strResponse = response.Content.ReadAsStringAsync().Result;
                                try
                                {
                                    banReponse = JsonConvert.DeserializeObject <Classes.tBan>(strResponse);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(authenticationResult.Message);
                    }
                }
            }
        }