//DONE private void uploadPlayerAccess(AdKat_Access access) { DebugWrite("uploadPlayerAccess(Email) starting!", 6); try { this.DebugWrite("NEW Access: " + access.player_name + "|" + access.access_level + "|" + access.player_email, 5); if (access.access_level < 0 || access.access_level > 6) { this.ConsoleError("Desired Access Level for " + access.player_name + " was invalid."); return; } if (!Regex.IsMatch(access.player_email, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")) { this.ConsoleError(access.player_email + " is an invalid email address."); return; } using (MySqlConnection connection = this.getDatabaseConnection()) { AdKat_Access oldAccess = null; this.playerAccessCache.TryGetValue(access.player_name, out oldAccess); using (MySqlCommand command = connection.CreateCommand()) { //Set the insert command structure command.CommandText = "INSERT INTO `" + this.mySqlDatabaseName + "`.`adkats_accesslist` (`player_name`, `player_email`, `access_level`) VALUES (@player_name, @player_email, @access_level) ON DUPLICATE KEY UPDATE `player_email` = @player_email, `access_level` = @access_level"; //Set values command.Parameters.AddWithValue("@player_name", access.player_name); int access_level = -1; if (access.access_level == -1) { if (oldAccess != null && oldAccess.access_level != -1) { access_level = oldAccess.access_level; } else { access_level = 6; } } else { access_level = access.access_level; } command.Parameters.AddWithValue("@access_level", access_level); string player_email = "*****@*****.**"; if (String.IsNullOrEmpty(access.player_email)) { if (oldAccess != null) { player_email = oldAccess.player_email; } else { player_email = "*****@*****.**"; } } else { player_email = access.player_email; } command.Parameters.AddWithValue("@player_email", player_email); this.DebugWrite("Uploading Access: " + access.player_name + "|" + access.access_level + "|" + access.player_email, 5); //Attempt to execute the query command.ExecuteNonQuery(); } } } catch (Exception e) { ConsoleException(e.ToString()); } DebugWrite("uploadPlayerAccess(Email) finished!", 6); }
//DONE private void updateDB_0251_0300() { if (!this.confirmTable("adkat_records")) { this.DebugWrite("No tables from previous versions. No need for database update.", 3); return; } try { //Get record count from current version table int currentRecordCount = 0; //initial record ID. Fetching 250 records at a time. Int64 initial_record_id = 0; Int64 importCount = 0; Int64 uploadCount = 0; using (MySqlConnection connection = this.getDatabaseConnection()) { using (MySqlCommand command = connection.CreateCommand()) { command.CommandText = @" SELECT COUNT(*) AS `record_count` FROM `adkats_records`"; using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { currentRecordCount = reader.GetInt32("record_count"); } else { this.ConsoleException("Unable to fetch current record count."); } } } } if (currentRecordCount == 0) { this.ConsoleWarn("Updating records from previous versions to 0.3.0.0! Do not turn off AdKats until it's finished!"); List<AdKat_Record> newRecords = new List<AdKat_Record>(); do { newRecords = new List<AdKat_Record>(); using (MySqlConnection connection = this.getDatabaseConnection()) { this.ConsoleWrite("creating connection to update records"); using (MySqlCommand command = connection.CreateCommand()) { this.ConsoleWrite("creating fetch command"); command.CommandText = @" SELECT `record_id`, `tbl_server`.`ServerID` AS `server_id`, `command_type`, `command_action`, `record_durationMinutes`, `target_guid`, `target_name`, `source_name`, `record_message`, `record_time` FROM `adkat_records` INNER JOIN `tbl_server` ON `adkat_records`.`server_ip` = `tbl_server`.`IP_Address` WHERE `record_id` > @initial_record_id ORDER BY `record_id` ASC LIMIT 50"; command.Parameters.AddWithValue("@initial_record_id", initial_record_id); this.ConsoleWrite("reading input"); using (MySqlDataReader reader = command.ExecuteReader()) { //Loop through all incoming bans while (reader.Read()) { //Pull record ID to post as new greatest ID initial_record_id = reader.GetInt64("record_id"); AdKat_Record record = new AdKat_Record(); //Get server information record.server_id = reader.GetInt64("server_id"); //Get command information record.command_type = this.getDBCommand(reader.GetString("command_type")); record.command_action = this.getDBCommand(reader.GetString("command_action")); record.command_numeric = reader.GetInt32("record_durationMinutes"); //Get source information record.source_name = reader.GetString("source_name"); //Get target information record.target_player = this.fetchPlayer(-1, reader.GetString("target_name"), reader.GetString("target_guid"), null); //Get general record information record.record_message = reader.GetString("record_message"); record.record_time = reader.GetDateTime("record_time"); //Push to lists newRecords.Add(record); //Increase the import count importCount++; } this.ConsoleWrite(importCount + " records downloaded..."); } } } foreach (AdKat_Record record in newRecords) { this.uploadRecord(record); uploadCount++; } this.ConsoleWrite(uploadCount + " records uploaded..."); } while (newRecords.Count > 0); } this.ConsoleSuccess(uploadCount + " records imported from previous versions of AdKats!"); using (MySqlConnection connection = this.getDatabaseConnection()) { //Get player access count from current version table int currentAccessCount = 0; using (MySqlCommand command = connection.CreateCommand()) { command.CommandText = @" SELECT COUNT(*) AS `access_count` FROM `adkats_accesslist`"; using (MySqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { currentAccessCount = reader.GetInt32("access_count"); } else { this.ConsoleException("Unable to fetch current access count."); } } } if (currentAccessCount == 0) { this.ConsoleWarn("Updating player access from previous versions to 0.3.0.0! Do not turn off AdKats until it's finished!"); List<AdKat_Access> newAccess = new List<AdKat_Access>(); using (MySqlCommand command = connection.CreateCommand()) { command.CommandText = @" SELECT `player_name`, `access_level` FROM `adkat_accesslist`"; using (MySqlDataReader reader = command.ExecuteReader()) { importCount = 0; //Loop through all incoming bans while (reader.Read()) { AdKat_Access access = new AdKat_Access(); access.player_name = reader.GetString("player_name"); access.access_level = reader.GetInt32("access_level"); access.member_id = 0; access.player_email = "*****@*****.**"; //Push to lists newAccess.Add(access); if ((++importCount % 500) == 0) { this.ConsoleWrite(importCount + " access entries downloaded..."); } } this.ConsoleWrite(importCount + " access entries downloaded..."); } } uploadCount = 0; foreach (AdKat_Access access in newAccess) { this.uploadPlayerAccess(access); if ((++uploadCount % 500) == 0) { this.ConsoleWrite(uploadCount + " access entries uploaded..."); } } this.ConsoleSuccess(uploadCount + " access entries imported from previous versions of AdKats!"); //Fetch the updated access list this.fetchAccessList(); } } this.updateSettingPage(); } catch (Exception e) { ConsoleException(e.ToString()); } }
//DONE private void fetchAccessList() { DebugWrite("fetchAccessList starting!", 6); Boolean success = false; Dictionary<String, AdKat_Access> tempAccessCache = new Dictionary<String, AdKat_Access>(); try { using (MySqlConnection connection = this.getDatabaseConnection()) { List<string> namesToGUIDUpdate = new List<string>(); using (MySqlCommand command = connection.CreateCommand()) { command.CommandText = "SELECT `player_name`, `member_id`, `player_email`, `access_level` FROM `" + this.mySqlDatabaseName + "`.`adkats_accesslist` ORDER BY `access_level` ASC"; using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { success = true; AdKat_Access access = new AdKat_Access(); access.player_name = reader.GetString("player_name"); access.member_id = reader.GetInt32("member_id"); access.player_email = reader.GetString("player_email"); access.access_level = reader.GetInt32("access_level"); if (!String.IsNullOrEmpty(access.player_name)) { if (this.soldierNameValid(access.player_name)) { //Add to the access cache tempAccessCache.Add(access.player_name, access); DebugWrite("Admin found: " + access.player_name, 6); } } else { this.ConsoleError("Blank admin name found in database, ignoring that entry."); } } } } } } catch (Exception e) { DebugWrite(e.ToString(), 3); } //Update the access cache this.playerAccessCache = tempAccessCache; //Update the last update time this.lastDBAccessFetch = DateTime.Now; if (success) { this.DebugWrite("Access List Fetched from Database. Access Count: " + this.playerAccessCache.Count, 1); } else { this.ConsoleWarn("No admins in the admin table."); } DebugWrite("fetchAccessList finished!", 6); }
private void queueAccessUpdate(AdKat_Access access) { this.DebugWrite("Preparing to queue player for access update", 6); lock (playerAccessMutex) { this.playerAccessUpdateQueue.Enqueue(access); this.DebugWrite("Player queued for access update", 6); this.dbCommHandle.Set(); } }
public void SetPluginVariable(string strVariable, string strValue) { try { string[] variableParse = CPluginVariable.DecodeStringArray(strVariable); if (strVariable.Equals("UpdateSettings")) { //Do nothing. Settings page will be updated after return. } else if (Regex.Match(strVariable, @"Setting Import").Success) { int tmp = -1; if (int.TryParse(strValue, out tmp)) { if (tmp != -1) this.queueSettingImport(tmp); } else { this.ConsoleError("Invalid Input for Setting Import"); } } else if (Regex.Match(strVariable, @"Using AdKats WebAdmin").Success) { Boolean tmp = false; if (Boolean.TryParse(strValue, out tmp)) { this.usingAWA = tmp; //Update necessary settings for AWA use if (this.usingAWA) { this.useBanEnforcer = true; this.fetchActionsFromDB = true; this.dbCommHandle.Set(); } } else { this.ConsoleError("Invalid Input for Using AdKats WebAdmin"); } } #region debugging else if (Regex.Match(strVariable, @"Command Entry").Success) { //Check if the message is a command if (strValue.StartsWith("@") || strValue.StartsWith("!")) { strValue = strValue.Substring(1); } else if (strValue.StartsWith("/@") || strValue.StartsWith("/!")) { strValue = strValue.Substring(2); } else if (strValue.StartsWith("/")) { strValue = strValue.Substring(1); } AdKat_Record recordItem = new AdKat_Record(); recordItem.command_source = AdKat_CommandSource.Settings; recordItem.source_name = "SettingsAdmin"; this.completeRecord(recordItem, strValue); } else if (Regex.Match(strVariable, @"Debug level").Success) { int tmp = 2; if (int.TryParse(strValue, out tmp)) { if (tmp != this.debugLevel) { this.debugLevel = tmp; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Debug level", typeof(Int32), this.debugLevel)); } } } else if (Regex.Match(strVariable, @"Debug Soldier Name").Success) { if (this.soldierNameValid(strValue)) { if (strValue != this.debugSoldierName) { this.debugSoldierName = strValue; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Debug Soldier Name", typeof(string), this.debugSoldierName)); } } } #endregion #region HTTP settings else if (Regex.Match(strVariable, @"External Access Key").Success) { if (strValue != this.externalCommandAccessKey) { this.externalCommandAccessKey = strValue; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"External Access Key", typeof(string), this.externalCommandAccessKey)); } } else if (Regex.Match(strVariable, @"Fetch Actions from Database").Success) { Boolean fetch; if (fetch = Boolean.Parse(strValue)) { if (fetch != this.fetchActionsFromDB) { this.fetchActionsFromDB = fetch; this.dbCommHandle.Set(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Fetch Actions from Database", typeof(Boolean), this.fetchActionsFromDB)); } } } #endregion #region ban settings else if (Regex.Match(strVariable, @"Use Additional Ban Message").Success) { Boolean use = Boolean.Parse(strValue); if (this.useBanAppend != use) { this.useBanAppend = use; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Use Additional Ban Message", typeof(Boolean), this.useBanAppend)); } } else if (Regex.Match(strVariable, @"Additional Ban Message").Success) { if (strValue.Length > 30) { strValue = strValue.Substring(0, 30); this.ConsoleError("Ban append cannot be more than 30 characters."); } else { if (this.banAppend != strValue) { this.banAppend = strValue; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Additional Ban Message", typeof(string), this.banAppend)); } } } else if (Regex.Match(strVariable, @"Use Ban Enforcer").Success) { Boolean use = Boolean.Parse(strValue); if (this.useBanEnforcer != use) { this.useBanEnforcer = use; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Use Ban Enforcer", typeof(Boolean), this.useBanEnforcer)); if (this.useBanEnforcer) { this.fetchActionsFromDB = true; this.dbCommHandle.Set(); } } } else if (Regex.Match(strVariable, @"Enforce New Bans by NAME").Success) { Boolean enforceName = Boolean.Parse(strValue); if (this.defaultEnforceName != enforceName) { this.defaultEnforceName = enforceName; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Enforce New Bans by NAME", typeof(Boolean), this.defaultEnforceName)); } } else if (Regex.Match(strVariable, @"Enforce New Bans by GUID").Success) { Boolean enforceGUID = Boolean.Parse(strValue); if (this.defaultEnforceGUID != enforceGUID) { this.defaultEnforceGUID = enforceGUID; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Enforce New Bans by GUID", typeof(Boolean), this.defaultEnforceGUID)); } } else if (Regex.Match(strVariable, @"Enforce New Bans by IP").Success) { Boolean enforceIP = Boolean.Parse(strValue); if (this.defaultEnforceIP != enforceIP) { this.defaultEnforceIP = enforceIP; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Enforce New Bans by IP", typeof(Boolean), this.defaultEnforceIP)); } } #endregion #region In-Game Command Settings else if (Regex.Match(strVariable, @"Minimum Required Reason Length").Success) { Int32 required = Int32.Parse(strValue); if (this.requiredReasonLength != required) { this.requiredReasonLength = required; if (this.requiredReasonLength < 1) { this.requiredReasonLength = 1; } //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Minimum Required Reason Length", typeof(Int32), this.requiredReasonLength)); } } else if (Regex.Match(strVariable, @"Confirm Command").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strConfirmCommand != strValue) { this.m_strConfirmCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Confirm Command", typeof(string), this.m_strConfirmCommand)); } } else { this.m_strConfirmCommand = AdKat_CommandType.ConfirmCommand + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Cancel Command").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strCancelCommand != strValue) { this.m_strCancelCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Cancel Command", typeof(string), this.m_strCancelCommand)); } } else { this.m_strCancelCommand = AdKat_CommandType.CancelCommand + " COMMAND BLANK"; } } else if (strVariable.EndsWith(@"Kill Player")) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strKillCommand != strValue) { this.m_strKillCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Kill Player", typeof(string), this.m_strKillCommand)); } } else { this.m_strKillCommand = AdKat_CommandType.KillPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Kick Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strKickCommand != strValue) { this.m_strKickCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Kick Player", typeof(string), this.m_strKickCommand)); } } else { this.m_strKickCommand = AdKat_CommandType.KickPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Temp-Ban Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strTemporaryBanCommand != strValue) { this.m_strTemporaryBanCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Temp-Ban Player", typeof(string), this.m_strTemporaryBanCommand)); } } else { this.m_strTemporaryBanCommand = AdKat_CommandType.TempBanPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Permaban Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strPermanentBanCommand != strValue) { this.m_strPermanentBanCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Permaban Player", typeof(string), this.m_strPermanentBanCommand)); } } else { this.m_strPermanentBanCommand = AdKat_CommandType.PermabanPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Punish Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strPunishCommand != strValue) { this.m_strPunishCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Punish Player", typeof(string), this.m_strPunishCommand)); } } else { this.m_strPunishCommand = AdKat_CommandType.PunishPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Forgive Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strForgiveCommand != strValue) { this.m_strForgiveCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Forgive Player", typeof(string), this.m_strForgiveCommand)); } } else { this.m_strForgiveCommand = AdKat_CommandType.ForgivePlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Mute Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strMuteCommand != strValue) { this.m_strMuteCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Mute Player", typeof(string), this.m_strMuteCommand)); } } else { this.m_strMuteCommand = AdKat_CommandType.MutePlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Round Whitelist Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strRoundWhitelistCommand != strValue) { this.m_strRoundWhitelistCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Round Whitelist Player", typeof(string), this.m_strRoundWhitelistCommand)); } } else { this.m_strRoundWhitelistCommand = AdKat_CommandType.RoundWhitelistPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"OnDeath Move Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strMoveCommand != strValue) { this.m_strMoveCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"OnDeath Move Player", typeof(string), this.m_strMoveCommand)); } } else { this.m_strMoveCommand = AdKat_CommandType.MovePlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Force Move Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strForceMoveCommand != strValue) { this.m_strForceMoveCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Force Move Player", typeof(string), this.m_strForceMoveCommand)); } } else { this.m_strForceMoveCommand = AdKat_CommandType.ForceMovePlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Teamswap Self").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strTeamswapCommand != strValue) { this.m_strTeamswapCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Teamswap Self", typeof(string), this.m_strTeamswapCommand)); } } else { this.m_strTeamswapCommand = AdKat_CommandType.Teamswap + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Report Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strReportCommand != strValue) { this.m_strReportCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Report Player", typeof(string), this.m_strReportCommand)); } } else { this.m_strReportCommand = AdKat_CommandType.ReportPlayer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Call Admin on Player").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strCallAdminCommand != strValue) { this.m_strCallAdminCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Call Admin on Player", typeof(string), this.m_strCallAdminCommand)); } } else { this.m_strCallAdminCommand = AdKat_CommandType.CallAdmin + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Admin Say").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strSayCommand != strValue) { this.m_strSayCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Admin Say", typeof(string), this.m_strSayCommand)); } } else { this.m_strSayCommand = AdKat_CommandType.AdminSay + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Player Say").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strPlayerSayCommand != strValue) { this.m_strPlayerSayCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Player Say", typeof(string), this.m_strPlayerSayCommand)); } } else { this.m_strPlayerSayCommand = AdKat_CommandType.PlayerSay + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Admin Yell").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strYellCommand != strValue) { this.m_strYellCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Admin Yell", typeof(string), this.m_strYellCommand)); } } else { this.m_strYellCommand = AdKat_CommandType.AdminYell + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Player Yell").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strPlayerYellCommand != strValue) { this.m_strPlayerYellCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Player Yell", typeof(string), this.m_strPlayerYellCommand)); } } else { this.m_strPlayerYellCommand = AdKat_CommandType.PlayerYell + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"What Is").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strWhatIsCommand != strValue) { this.m_strWhatIsCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"What Is", typeof(string), this.m_strWhatIsCommand)); } } else { this.m_strWhatIsCommand = AdKat_CommandType.WhatIs + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Restart Level").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strRestartLevelCommand != strValue) { this.m_strRestartLevelCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Restart Level", typeof(string), this.m_strRestartLevelCommand)); } } else { this.m_strRestartLevelCommand = AdKat_CommandType.RestartLevel + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Next Level").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strNextLevelCommand != strValue) { this.m_strNextLevelCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Next Level", typeof(string), this.m_strNextLevelCommand)); } } else { this.m_strNextLevelCommand = AdKat_CommandType.NextLevel + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"End Level").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strEndLevelCommand != strValue) { this.m_strEndLevelCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"End Level", typeof(string), this.m_strEndLevelCommand)); } } else { this.m_strEndLevelCommand = AdKat_CommandType.EndLevel + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Nuke Server").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strNukeCommand != strValue) { this.m_strNukeCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Nuke Server", typeof(string), this.m_strNukeCommand)); } } else { this.m_strNukeCommand = AdKat_CommandType.NukeServer + " COMMAND BLANK"; } } else if (Regex.Match(strVariable, @"Kick All NonAdmins").Success) { if (strValue.Length > 0) { //trim variable if (strValue.ToLower().EndsWith("|log")) { strValue = strValue.Remove(strValue.IndexOf("|log")); } if (this.m_strKickAllCommand != strValue) { this.m_strKickAllCommand = strValue; rebindAllCommands(); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Kick All NonAdmins", typeof(string), this.m_strKickAllCommand)); } } else { this.m_strKickAllCommand = AdKat_CommandType.KickAll + " COMMAND BLANK"; } } #endregion #region punishment settings else if (Regex.Match(strVariable, @"Punishment Hierarchy").Success) { this.punishmentHierarchy = CPluginVariable.DecodeStringArray(strValue); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Punishment Hierarchy", typeof(string), CPluginVariable.EncodeStringArray(this.punishmentHierarchy))); } else if (Regex.Match(strVariable, @"Combine Server Punishments").Success) { Boolean combine = Boolean.Parse(strValue); if (this.combineServerPunishments != combine) { this.combineServerPunishments = combine; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Combine Server Punishments", typeof(Boolean), this.combineServerPunishments)); } } else if (Regex.Match(strVariable, @"Only Kill Players when Server in low population").Success) { Boolean onlyKill = Boolean.Parse(strValue); if (onlyKill != this.onlyKillOnLowPop) { this.onlyKillOnLowPop = onlyKill; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Only Kill Players when Server in low population", typeof(Boolean), this.onlyKillOnLowPop)); } } else if (Regex.Match(strVariable, @"Low Population Value").Success) { Int32 lowPop = Int32.Parse(strValue); if (lowPop != this.lowPopPlayerCount) { this.lowPopPlayerCount = lowPop; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Low Population Value", typeof(Int32), this.lowPopPlayerCount)); } } else if (Regex.Match(strVariable, @"IRO Punishment Overrides Low Pop").Success) { Boolean overrideIRO = Boolean.Parse(strValue); if (overrideIRO != this.IROOverridesLowPop) { this.IROOverridesLowPop = overrideIRO; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"IRO Punishment Overrides Low Pop", typeof(Boolean), this.IROOverridesLowPop)); } } #endregion #region sql settings else if (Regex.Match(strVariable, @"MySQL Hostname").Success) { mySqlHostname = strValue; this.dbSettingsChanged = true; this.dbCommHandle.Set(); } else if (Regex.Match(strVariable, @"MySQL Port").Success) { int tmp = 3306; int.TryParse(strValue, out tmp); if (tmp > 0 && tmp < 65536) { mySqlPort = strValue; this.dbSettingsChanged = true; this.dbCommHandle.Set(); } else { ConsoleException("Invalid value for MySQL Port: '" + strValue + "'. Must be number between 1 and 65535!"); } } else if (Regex.Match(strVariable, @"MySQL Database").Success) { this.mySqlDatabaseName = strValue; this.dbSettingsChanged = true; this.dbCommHandle.Set(); } else if (Regex.Match(strVariable, @"MySQL Username").Success) { mySqlUsername = strValue; this.dbSettingsChanged = true; this.dbCommHandle.Set(); } else if (Regex.Match(strVariable, @"MySQL Password").Success) { mySqlPassword = strValue; this.dbSettingsChanged = true; this.dbCommHandle.Set(); } #endregion #region email settings else if (strVariable.CompareTo("Send Emails") == 0) { //Disabled this.useEmail = false;// Boolean.Parse(strValue); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable("Send Emails", typeof(Boolean), this.useEmail)); } else if (strVariable.CompareTo("Admin Request Email?") == 0) { //this.blNotifyEmail = Boolean.Parse(strValue); //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("Admin Request Email?", typeof(string), strValue)); } else if (strVariable.CompareTo("Use SSL?") == 0) { this.emailHandler.blUseSSL = Boolean.Parse(strValue); //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("Use SSL?", typeof(Boolean), this.emailHandler.blUseSSL)); } else if (strVariable.CompareTo("SMTP-Server address") == 0) { this.emailHandler.strSMTPServer = strValue; //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("SMTP-Server address", typeof(string), strValue)); } else if (strVariable.CompareTo("SMTP-Server port") == 0) { int iPort = Int32.Parse(strValue); if (iPort > 0) { this.emailHandler.iSMTPPort = iPort; //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("SMTP-Server port", typeof(Int32), iPort)); } } else if (strVariable.CompareTo("Sender address") == 0) { if (strValue == null || strValue == String.Empty) { this.emailHandler.strSenderMail = "SENDER_CANNOT_BE_EMPTY"; this.ConsoleError("No sender for email was given! Canceling Operation."); } else { this.emailHandler.strSenderMail = strValue; //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("Sender address", typeof(string), strValue)); } } else if (strVariable.CompareTo("SMTP-Server username") == 0) { if (strValue == null || strValue == String.Empty) { this.emailHandler.strSMTPUser = "******"; this.ConsoleError("No username for SMTP was given! Canceling Operation."); } else { this.emailHandler.strSMTPUser = strValue; //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("SMTP-Server username", typeof(string), strValue)); } } else if (strVariable.CompareTo("SMTP-Server password") == 0) { if (strValue == null || strValue == String.Empty) { this.emailHandler.strSMTPPassword = "******"; this.ConsoleError("No password for SMTP was given! Canceling Operation."); } else { this.emailHandler.strSMTPPassword = strValue; //Once setting has been changed, upload the change to database //this.queueSettingForUpload(new CPluginVariable("SMTP-Server password", typeof(string), strValue)); } } #endregion #region mute settings else if (Regex.Match(strVariable, @"On-Player-Muted Message").Success) { if (this.mutedPlayerMuteMessage != strValue) { this.mutedPlayerMuteMessage = strValue; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"On-Player-Muted Message", typeof(string), this.mutedPlayerMuteMessage)); } } else if (Regex.Match(strVariable, @"On-Player-Killed Message").Success) { if (this.mutedPlayerKillMessage != strValue) { this.mutedPlayerKillMessage = strValue; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"On-Player-Killed Message", typeof(string), this.mutedPlayerKillMessage)); } } else if (Regex.Match(strVariable, @"On-Player-Kicked Message").Success) { if (this.mutedPlayerKickMessage != strValue) { this.mutedPlayerKickMessage = strValue; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"On-Player-Kicked Message", typeof(string), this.mutedPlayerKickMessage)); } } if (Regex.Match(strVariable, @"# Chances to give player before kicking").Success) { int tmp = 5; int.TryParse(strValue, out tmp); if (this.mutedPlayerChances != tmp) { this.mutedPlayerChances = tmp; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"# Chances to give player before kicking", typeof(Int32), this.mutedPlayerChances)); } } #endregion #region teamswap settings else if (Regex.Match(strVariable, @"Require Whitelist for Access").Success) { Boolean require = Boolean.Parse(strValue); if (this.requireTeamswapWhitelist != require) { this.requireTeamswapWhitelist = require; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Require Whitelist for Access", typeof(Boolean), this.requireTeamswapWhitelist)); } } else if (Regex.Match(strVariable, @"Auto-Whitelist Count").Success) { int tmp = 1; int.TryParse(strValue, out tmp); if (tmp != this.playersToAutoWhitelist) { if (tmp < 0) tmp = 0; this.playersToAutoWhitelist = tmp; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Auto-Whitelist Count", typeof(Int32), this.playersToAutoWhitelist)); } } else if (Regex.Match(strVariable, @"Ticket Window High").Success) { int tmp = 2; int.TryParse(strValue, out tmp); if (tmp != this.teamSwapTicketWindowHigh) { this.teamSwapTicketWindowHigh = tmp; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Ticket Window High", typeof(Int32), this.teamSwapTicketWindowHigh)); } } else if (Regex.Match(strVariable, @"Ticket Window Low").Success) { int tmp = 2; int.TryParse(strValue, out tmp); if (tmp != this.teamSwapTicketWindowLow) { this.teamSwapTicketWindowLow = tmp; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Ticket Window Low", typeof(Int32), this.teamSwapTicketWindowLow)); } } #endregion #region Admin Assistants else if (Regex.Match(strVariable, @"Enable Admin Assistant Perk").Success) { Boolean enableAA = Boolean.Parse(strValue); if (this.enableAdminAssistants != enableAA) { this.enableAdminAssistants = enableAA; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Enable Admin Assistant Perk", typeof(Boolean), this.enableAdminAssistants)); } } else if (Regex.Match(strVariable, @"Minimum Confirmed Reports Per Week").Success) { Int32 weeklyReports = Int32.Parse(strValue); if (this.minimumRequiredWeeklyReports != weeklyReports) { this.minimumRequiredWeeklyReports = weeklyReports; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Minimum Confirmed Reports Per Week", typeof(Int32), this.minimumRequiredWeeklyReports)); } } #endregion #region Messaging Settings else if (Regex.Match(strVariable, @"Yell display time seconds").Success) { Int32 yellTime = Int32.Parse(strValue); if (this.m_iShowMessageLength != yellTime) { this.m_iShowMessageLength = yellTime; this.m_strShowMessageLength = m_iShowMessageLength + ""; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Yell display time seconds", typeof(Int32), this.m_iShowMessageLength)); } } else if (Regex.Match(strVariable, @"Pre-Message List").Success) { this.preMessageList = new List<string>(CPluginVariable.DecodeStringArray(strValue)); //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Pre-Message List", typeof(string), CPluginVariable.EncodeStringArray(this.preMessageList.ToArray()))); } else if (Regex.Match(strVariable, @"Require Use of Pre-Messages").Success) { Boolean require = Boolean.Parse(strValue); if (require != this.requirePreMessageUse) { this.requirePreMessageUse = require; //Once setting has been changed, upload the change to database this.queueSettingForUpload(new CPluginVariable(@"Require Use of Pre-Messages", typeof(Boolean), this.requirePreMessageUse)); } } #endregion #region access settings else if (Regex.Match(strVariable, @"Add Access").Success) { if (this.soldierNameValid(strValue)) { //Create the access object AdKat_Access access = new AdKat_Access(); access.player_name = strValue; access.access_level = 6; //Queue it for processing this.queueAccessUpdate(access); } } else if (Regex.Match(strVariable, @"Remove Access").Success) { this.queueAccessRemoval(strValue); } else if (this.playerAccessCache.ContainsKey(variableParse[0])) { this.DebugWrite("Preparing for access change", 5); AdKat_Access access = this.playerAccessCache[variableParse[0]]; if (variableParse[1] == "Access Level") { this.DebugWrite("Changing access level", 5); access.access_level = Int32.Parse(strValue); } else if (variableParse[1] == "Email Address") { this.DebugWrite("Changing email", 5); access.player_email = strValue; } this.queueAccessUpdate(access); } #endregion } catch (Exception e) { this.ConsoleException(e.ToString()); } }