Ejemplo n.º 1
0
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            // Login with specified account data
            sqlFunctions sql = new sqlFunctions();

            if (sql.login(textBox1.Text, textBox2.Text) == true)
            {
                // This will trigger a successfull login
                string appPath = Path.GetDirectoryName(Application.ExecutablePath);

                System.IO.StreamWriter file = new System.IO.StreamWriter(appPath + "/lastuser.txt");
                file.WriteLine(textBox1.Text);
                file.Close();

                // Open the main GUI
                Main main = new Main();
                main.Show();
                this.Hide();
            }
            else
            {
                // The login failed, since the user doesn't match anything in the database.
                label3.Visible = true;
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            sqlFunctions sql = new sqlFunctions();

            if (sql.login(textBox1.Text, textBox2.Text) == true)
            {
                toolStripStatusLabel1.ForeColor = Color.DarkGreen;
                toolStripStatusLabel1.Text      = "Logged In As:";
                toolStripStatusLabel2.Text      = textBox1.Text;
                sqlFunctions    sql2     = new sqlFunctions();
                WebClient       client   = new WebClient();
                string          ip       = client.DownloadString("http://www.merrimentgamestudio.com/smurfrp/srvtool/1.txt");
                string          usr      = client.DownloadString("http://www.merrimentgamestudio.com/smurfrp/srvtool/2.txt");
                string          pw       = client.DownloadString("http://www.merrimentgamestudio.com/smurfrp/srvtool/3.txt");
                string          ip2      = client.DownloadString("http://www.merrimentgamestudio.com/smurfrp/srvtool/4.txt");
                string          usr2     = client.DownloadString("http://www.merrimentgamestudio.com/smurfrp/srvtool/5.txt");
                string          pw2      = client.DownloadString("http://www.merrimentgamestudio.com/smurfrp/srvtool/6.txt");
                MySqlConnection conn2    = new MySqlConnection("server=" + ip + ";userid=" + usr + ";password="******";database=114794-donations");
                MySqlConnection conn4    = new MySqlConnection("server=" + ip + ";userid=" + usr + ";password="******";database=114794-donations");
                MySqlConnection conn3    = new MySqlConnection("server=" + ip2 + ";userid=" + usr2 + ";password="******";database=114794-drpbans");
                MySqlCommand    getauth2 = new MySqlCommand("SELECT * FROM users WHERE username = '******';");
                MySqlCommand    getauth4 = new MySqlCommand("SELECT * FROM users");
                MySqlCommand    getauth3 = new MySqlCommand("SELECT * FROM u_globalbans");
                getauth2.Parameters.AddWithValue("username", textBox1.Text);
                getauth2.Connection = conn2;
                getauth3.Connection = conn3;
                getauth4.Connection = conn4;
                conn2.Open();
                conn3.Open();
                conn4.Open();
                MySqlDataReader Reader2 = getauth2.ExecuteReader();
                MySqlDataReader Reader3 = getauth3.ExecuteReader();
                MySqlDataReader Reader4 = getauth4.ExecuteReader();
                // Set 'last login'
                sql.writeLastLogin(DateTime.Now.ToString(), textBox1.Text);

                // Lastly, set form title
                this.Text = ("SmurfRP Server Tool :: " + textBox1.Text);

                // Hide login panel
                panel1.Visible = false;

                // Show logout panel
                panel10.Visible = true;

                while (Reader2.Read())
                {
                    // Set some shit.
                    pictureBox2.ImageLocation = (sql.GetDBString("avatar", Reader2));
                    label7.Text    = textBox1.Text;
                    label9.Text    = (sql.GetDBString("registerdate", Reader2));
                    label10.Text   = (sql.GetDBString("lastlogin", Reader2));
                    label15.Text   = "You Last Logged In: " + (sql.GetDBString("lastlogin", Reader2));
                    textBox6.Text  = (sql.GetDBString("avatar", Reader2));
                    label13.Text   = "Logged in as " + textBox1.Text;
                    panel7.Visible = true;

                    button6.Enabled = true;
                    button7.Enabled = true;
                    button8.Enabled = true;

                    // Show Ban Label
                    label24.Visible = true;

                    // Remember User?
                    if (checkBox1.Checked == true)
                    {
                        using (StreamWriter sw = File.CreateText("lastuser.txt"))
                        {
                            sw.WriteLine(textBox1.Text);
                        }
                    }
                    else
                    {
                        if (File.Exists("lastuser.txt"))
                        {
                            File.Delete("lastuser.txt");
                        }
                    }
                }

                while (Reader4.Read())
                {
                    // Populate the new tab with even more shit!
                    ListViewItem userlist;
                    userlist = new ListViewItem(Reader4.GetString("username"));
                    userlist.SubItems.Add(Reader4.GetString("registerdate"));
                    userlist.SubItems.Add(sql.GetDBString("lastlogin", Reader4));
                    userlist.SubItems.Add(Reader4.GetString("isadmin"));
                    userlist.SubItems.Add(Reader4.GetString("canuseremote"));
                    userlist.SubItems.Add(Reader4.GetString("isbanned"));
                    listView2.Items.Add(userlist);
                }


                while (Reader3.Read())
                {
                    ListViewItem item;
                    item = new ListViewItem(Reader3.GetString("_SteamID"));
                    item.UseItemStyleForSubItems = false;
                    if (Reader3.IsDBNull(1) == true)
                    {
                        item.SubItems.Add("Unknown", Color.Maroon, Color.White, new Font(label1.Font.Name, 8.0F, FontStyle.Bold));
                    }
                    else
                    {
                        item.SubItems.Add(Convert.ToString(Reader3.GetValue(1)));
                    }
                    if (Reader3.GetString("_Reason") == "")
                    {
                        item.SubItems.Add("No Reason Given", Color.Gray, Color.White, new Font(label1.Font.Name, 8.0F, FontStyle.Italic));
                    }
                    else
                    {
                        item.SubItems.Add(Reader3.GetString("_Reason").Replace(@"\", ""));
                    }

                    if (Reader3.GetString("_Length") == "0")
                    {
                        item.SubItems.Add("Permanently", Color.Maroon, Color.White, new Font(label1.Font.Name, 8.0F, FontStyle.Bold));
                    }
                    else
                    {
                        TimeSpan t2 = TimeSpan.FromSeconds(Convert.ToDouble(Reader3.GetString("_Length")));


                        item.SubItems.Add(string.Format("{0:D2}h {1:D2}m {2:D2}s",
                                                        t2.Hours,
                                                        t2.Minutes,
                                                        t2.Seconds));
                    }


                    TimeSpan t = TimeSpan.FromSeconds(Convert.ToDouble(Reader3.GetString("_Time")));


                    item.SubItems.Add(string.Format("{0:D2}h {1:D2}m {2:D2}s",
                                                    t.Hours,
                                                    t.Minutes,
                                                    t.Seconds));



                    item.SubItems.Add(Reader3.GetString("_ASteamName"));
                    item.SubItems.Add("lol");
                    listView1.Items.Add(item);
                }
                Reader2.Close();
                conn2.Close();
                Reader3.Close();
                conn3.Close();
                conn4.Close();
                Reader4.Close();
                label24.Text = ("Total Bans: ") + listView1.Items.Count.ToString();
            }
            else
            {
                label4.Text    = "Authentication Failed. Check Username/Password.";
                label4.Visible = true;
            }
        }