private void Start_Routine() { main = this; LogAction(LOG_STATE.INFO, "Initializing database"); if (!sql.IsConnected()) { LogAction(LOG_STATE.ERROR, "Couldnt create .sqlite-Database! Application could not start."); } else { sql.ReturnQuery("CREATE TABLE IF NOT EXISTS settings (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), val VARCHAR(50));"); sql.ReturnQuery("CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, ip VARCHAR(39), requesttime BIGINT(10));"); sql.ReturnQuery("CREATE TABLE IF NOT EXISTS bans (id INTEGER PRIMARY KEY AUTOINCREMENT, ip VARCHAR(39));"); LogAction(LOG_STATE.INFO, "Loaded .sqlite-Database!"); SQLRecord record = sql.ReturnQuery("SELECT * FROM settings"); for (int row = 0; row < record.NumRows(); row++) { string val = record.GetValue(row, "val"); switch (record.GetValue(row, "name")) { case "autoban_enabled": metroToggle1.Checked = (val == "1") ? true : false; break; case "apicheck": metroCheckBox1.Checked = (val == "1") ? true : false; break; case "apikey": metroTextBox_APIKEY.Text = val; break; case "banattempts": numericUpDown_BanAttempts.Value = decimal.Parse(val); oldBanAttempts = decimal.Parse(val); break; case "attemptminutes": numericUpDown_AttemptObserve.Value = decimal.Parse(val); oldAttemptMinutes = decimal.Parse(val); break; case "banduration": numericUpDown_BanDuration.Value = decimal.Parse(val); oldBanDuration = decimal.Parse(val); break; } } eventInstance = new Events(); } }
private static string GET_AbuseIPDB_KEY() { try { string apiKey = ""; SQLRecord record = Form1.sql.ReturnQuery("SELECT * FROM settings WHERE name = 'apikey' LIMIT 1"); if (record.NumRows() == 1) { apiKey = record.GetValue(0, "val"); } return(apiKey); } catch { Form1.main.LogAction(Form1.LOG_STATE.ERROR, "Could not retrieve APIKEY from database"); return(""); } }