Ejemplo n.º 1
0
        private void button15_Click(object sender, EventArgs e)
        {
            ArrayList alreadyBanned = new ArrayList();

            alreadyBanned.AddRange(ArrayList.Adapter(ConfigLoadFunc.TimeBanLoad("banned.xml")));
            Int64  unix_timebanned = (Int64)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
            string connectionString;

            connectionString = "Data Source=" + databaseHost + ";User Id=" + databaseUser + ";Password="******";Database=" + realmDatabase;
            MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
            conn.Open();
            string query = "UPDATE account SET banned = \"1\" WHERE username = \"" + Convert.ToString(listBox1.SelectedItem) + "\"";

            MySql.Data.MySqlClient.MySqlCommand resQuery = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            resQuery.ExecuteNonQuery();
            conn.Close();
            string tobeBanned = Convert.ToString(listBox1.SelectedItem);
            Int64  timeBan    = unix_timebanned + (Convert.ToInt64(timebanBox.Text) * 60);

            alreadyBanned.Add(tobeBanned + @"%" + timeBan + @";");
            if ((string)alreadyBanned[0] == "none")
            {
                alreadyBanned.RemoveAt(0);
            }
            MainFunctions.WriteBans((string[])alreadyBanned.ToArray(typeof(string)));
            WriteLog("Account: " + listBox1.SelectedItem + " BANNNED FOR " + timebanBox.Text + " minutes!", Color.Red);
            button12_Click(null, null);
        }
Ejemplo n.º 2
0
        private void generalTimer_Tick(object sender, EventArgs e)
        {
            button3_Click(null, null);
            label17.Text = Convert.ToString(oCount);
            if (oCount > maxoCount)
            {
                label16.Text = Convert.ToString(oCount);
            }
            //Check TimeBans
            string[] Banned = null;
            Banned = ConfigLoadFunc.TimeBanLoad("banned.xml");
            ArrayList toBanList = new ArrayList();

            foreach (string s in Banned)
            {
                int       a          = 0;
                string    bannedname = "";
                string    bantime    = "";
                Int64     unix_time  = (Int64)((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds);
                ArrayList indvBans   = new ArrayList();
                indvBans = ArrayList.Adapter(s.Split(Convert.ToChar(";")));
                foreach (string i in indvBans)
                {
                    a = i.IndexOf(@"%");
                    if (a != -1)
                    {
                        bannedname = i.Substring(0, a);
                        bantime    = i.Substring(a + 1);
                        bantime.Remove(bantime.Length - 1);

                        if (Convert.ToInt64(bantime) < unix_time)
                        {
                            string connectionString;
                            connectionString = "Data Source=" + databaseHost + ";User Id=" + databaseUser + ";Password="******";Database=" + realmDatabase;
                            MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
                            conn.Open();
                            string query = "UPDATE account SET banned = \"0\" WHERE username = \"" + bannedname + "\"";
                            MySql.Data.MySqlClient.MySqlCommand resQuery = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
                            resQuery.ExecuteNonQuery();
                            conn.Close();
                            WriteLog("Time ban on " + bannedname + " removed!", Color.Red);
                        }
                        else
                        {
                            toBanList.Add(i);
                        }
                    }
                }
                MainFunctions.WriteBans((string[])(toBanList.ToArray(typeof(string))));
            }
        }