示例#1
0
        private void button14_Click(object sender, EventArgs e)
        {
            string userToDelete = c_txtBetaUserID.Text;

            if (MessageBox.Show("Delete UserID: \"" + userToDelete + "\"?", "Are you sure?", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                c_txtBetaUserID.Text = "";
                ContributorDB.DeleteContributorFromDB(userToDelete);
            }
        }
示例#2
0
        public string GetUploaderName()
        {
            Contributor contributor = ContributorDB.GetContributor(Uploader);

            if (contributor != null)
            {
                return(ContributorDB.GetContributor(Uploader).Name);
            }

            return("null");
        }
示例#3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool debugMode = false;

            if (System.IO.Directory.Exists(g_RPPDBFolder) == false)
            {
                g_RPPDBFolder = g_RPPDBFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                g_RDDBFolder  = g_RDDBFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                AddonDatabaseService.g_AddonUploadDataFolder        = AddonDatabaseService.g_AddonUploadDataFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                AddonDatabaseService.g_AddonUploadStatsFolder       = AddonDatabaseService.g_AddonUploadStatsFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                RPPDatabaseHandler.g_AddonContributionsBackupFolder = RPPDatabaseHandler.g_AddonContributionsBackupFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);

                RDDatabaseHandler.g_AddonContributionsBackupFolder = RDDatabaseHandler.g_AddonContributionsBackupFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                debugMode = true;
            }
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            VF_WoWLauncher.ConsoleUtility.CreateConsole();


            //if (debugMode == false)
            {
                Console.WriteLine("Waiting for ContributorDB to load");
                ContributorDB.Initialize(debugMode);
                while (ContributorDB.GetMongoDB() == null)
                {
                    ContributorDB.Initialize(debugMode);
                    System.Threading.Thread.Sleep(100);
                    Console.Write(".");
                }
                Console.WriteLine("ContributorDB loaded!");
            }

            //VF_RealmPlayersDatabase.Deprecated.ContributorHandler.Initialize(g_RPPDBFolder + "Database\\");
            g_RPPDatabaseHandler = new RPPDatabaseHandler(g_RPPDBFolder);
            g_RDDatabaseHandler  = new RDDatabaseHandler(g_RDDBFolder, g_RPPDatabaseHandler, DatabaseHandlerMode.Disabled);
            AddonDatabaseService.HandleUnhandledFiles("VF_RealmPlayers");
            AddonDatabaseService.HandleUnhandledFiles("VF_RaidDamage");
            AddonDatabaseService.HandleUnhandledFiles("VF_RealmPlayersTBC");
            AddonDatabaseService.HandleUnhandledFiles("VF_RaidStatsTBC");
            try
            {
                Application.Run(new MainWindow());
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                g_RDDatabaseHandler.Shutdown();
                g_RPPDatabaseHandler.Shutdown();
            }
        }
示例#4
0
        private void UpdateContributorsList()
        {
            var contributors = ContributorDB.GetAllTrustWorthyContributors();

            var contributorsSorted = contributors.OrderByDescending((_Value) => _Value.ContributorID);

            c_lsContributors.Items.Clear();
            foreach (var contributor in contributorsSorted)
            {
                c_lsContributors.Items.Add(contributor.Key);
            }
        }
示例#5
0
        private void SendResponse()
        {
            if (Header.Command == "RPUpload")
            {
                byte[] standardSuccessResponse = System.Text.Encoding.UTF8.GetBytes("VF_RPP_Success=true;");
                if (Header.UploaderVersion >= 1.3f)
                {
                    if (Header.UploaderVersion < 1.7f)
                    {
                        Header.FileType = FileUploadType.RealmPlayers;
                    }

                    if (Header.FileType == FileUploadType.RealmPlayers)
                    {
                        byte[] responseBytes = System.Text.Encoding.UTF8.GetBytes(
                            AddonHandler.CreateAddonUpdate(Header.Contributor, Header.AddonVersion) //"" om inget behövs uppdateras
                            + "VF_RPP_Success=true;");
                        TCPSocket.Send(responseBytes);
                    }
                    else if (Header.FileType == FileUploadType.RaidDamage)
                    {
                        TCPSocket.Send(standardSuccessResponse);
                    }
                }
                else if (Header.UploaderVersion >= 1.2f)
                {
                    byte[] extraResponse = System.Text.Encoding.UTF8.GetBytes("Message=There is a newer version of the uploader available;");
                    TCPSocket.Send(extraResponse);
                    TCPSocket.Send(standardSuccessResponse);
                }
                else
                {
                    throw new Exception("Uploader version is too old");
                }
            }
            else if (Header.Command == "UserCheck")
            {
                var result = ContributorDB.CheckContributor(Header.UserIDStr, (System.Net.IPEndPoint)TCPSocket.RemoteEndPoint);
                if (result == ContributorDB.CheckContributorResult.UserID_Success_Login ||
                    result == ContributorDB.CheckContributorResult.UserID_Success_Registered)
                {
                    TCPSocket.Send(System.Text.Encoding.UTF8.GetBytes("VF_RPP_Success=true;"));
                }
                else
                {
                    TCPSocket.Send(System.Text.Encoding.UTF8.GetBytes("VF_RPP_Success=false;"));
                }
            }
        }
示例#6
0
        private void c_btnAddContributor_Click(object sender, EventArgs e)
        {
            string userID = "";

            if (ContributorUtility.GenerateUserID(c_txtAddContributorName.Text, out userID) == true)
            {
                if (ContributorDB.AddVIPContributor(userID, VF.HiddenStrings.DilatazuUserID) == true)
                {
                    UpdateContributorsList();
                }
                else
                {
                    MessageBox.Show("UserID could not be generated from \"" + c_txtAddContributorName.Text + "\", Username allready exists!");
                }
            }
            else
            {
                MessageBox.Show("UserID could not be generated from \"" + c_txtAddContributorName.Text + "\"");
            }
        }
示例#7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool debugMode = false;

            if (System.IO.Directory.Exists(g_RPPDBFolder) == false)
            {
                g_RPPDBFolder = g_RPPDBFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                g_RDDBFolder  = g_RDDBFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                AddonDatabaseService.g_AddonUploadDataFolder        = AddonDatabaseService.g_AddonUploadDataFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                AddonDatabaseService.g_AddonUploadStatsFolder       = AddonDatabaseService.g_AddonUploadStatsFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                RPPDatabaseHandler.g_AddonContributionsBackupFolder = RPPDatabaseHandler.g_AddonContributionsBackupFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);

                RDDatabaseHandler.g_AddonContributionsBackupFolder = RDDatabaseHandler.g_AddonContributionsBackupFolder.Replace(VF_RealmPlayersDatabase.Utility.DefaultServerLocation, VF_RealmPlayersDatabase.Utility.DefaultDebugLocation);
                debugMode = true;
            }
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

            VF_WoWLauncher.ConsoleUtility.CreateConsole();

            /*Some Testing*/
#if false
            WowRealm[] ALL_REALMS = new WowRealm[] {
                WowRealm.Kronos,
                WowRealm.NostalGeek,
                WowRealm.Al_Akir,
                WowRealm.Valkyrie,
                WowRealm.VanillaGaming,
                WowRealm.Nefarian,
                WowRealm.Rebirth,
                WowRealm.Archangel,
                WowRealm.Nostalrius,
                WowRealm.NostalriusPVE,
                WowRealm.Emerald_Dream,
                WowRealm.Warsong,
                WowRealm.WarsongTBC
            };

            SQLDatabaseMigration.Migrate(SQLDatabaseMigration.MigrationChoice.TestOnly, ALL_REALMS);
#endif
            /*Some Testing*/

            //if (debugMode == false)
            {
                Console.WriteLine("Waiting for ContributorDB to load");
                ContributorDB.Initialize(debugMode);
                while (ContributorDB.GetMongoDB() == null)
                {
                    ContributorDB.Initialize(debugMode);
                    System.Threading.Thread.Sleep(100);
                    Console.Write(".");
                }
                Console.WriteLine("ContributorDB loaded!");
            }

            //VF_RealmPlayersDatabase.Deprecated.ContributorHandler.Initialize(g_RPPDBFolder + "Database\\");
            g_RPPDatabaseHandler = new RPPDatabaseHandler(g_RPPDBFolder);
            g_RDDatabaseHandler  = new RDDatabaseHandler(g_RDDBFolder, g_RPPDatabaseHandler);
            AddonDatabaseService.HandleUnhandledFiles("VF_RealmPlayers");
            AddonDatabaseService.HandleUnhandledFiles("VF_RaidDamage");
            AddonDatabaseService.HandleUnhandledFiles("VF_RealmPlayersTBC");
            AddonDatabaseService.HandleUnhandledFiles("VF_RaidStatsTBC");
            try
            {
                Application.Run(new MainWindow());
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                g_RDDatabaseHandler.Shutdown();
                g_RPPDatabaseHandler.Shutdown();
            }
        }
示例#8
0
        public RPPCommunicator(int _Port) //18374
        {
            if (System.IO.Directory.Exists("RPPContributions\\") == true)
            {
                string[] files = System.IO.Directory.GetFiles("RPPContributions\\");
                foreach (var file in files)
                {
                    try
                    {
                        if (file.StartsWith("RPPContributions\\RealmPlayersData") == true)
                        {
                            //Old version
                            string contributorUserID = file.Split('_').Last().Replace(".txt", "");
                            Logger.ConsoleWriteLine("RPP File: " + file + ", was uploaded by UserID: " + contributorUserID, ConsoleColor.Yellow);
                            Contributor contributor = ContributorDB.GetContributor(contributorUserID, new System.Net.IPEndPoint(System.Net.IPAddress.Loopback, 18374), false);
                            if (contributor != null)
                            {
                                m_DownloadedData.Enqueue(new RPPContribution(contributor, file));
                            }
                            else
                            {
                                Logger.ConsoleWriteLine("Contributor: " + contributorUserID + " was not found", ConsoleColor.Red);
                            }
                        }
                        else if (file.StartsWith("RPPContributions\\RPP_") == true)
                        {
                            string contributorUserID = file.Split('_')[1];
                            string contributorUserIP = file.Split('_')[2];
                            Logger.ConsoleWriteLine("RPP File: " + file + ", was uploaded by UserID: " + contributorUserID + ", on IP: " + contributorUserIP, ConsoleColor.Yellow);
                            Contributor contributor = ContributorDB.GetContributor(contributorUserID, new System.Net.IPEndPoint(System.Net.IPAddress.Parse(contributorUserIP), 18374), false);
                            if (contributor != null)
                            {
                                m_DownloadedData.Enqueue(new RPPContribution(contributor, file));
                            }
                            else
                            {
                                Logger.ConsoleWriteLine("Contributor: " + contributorUserID + " was not found", ConsoleColor.Red);
                            }
                        }
                        else
                        {
                            Logger.ConsoleWriteLine("Skipping file: " + file + ", does not seem to be a RPP file");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                }
            }
            if (System.IO.Directory.Exists("RDContributions\\") == true)
            {
                string[] files = System.IO.Directory.GetFiles("RDContributions\\");
                foreach (var file in files)
                {
                    try
                    {
                        if (file.StartsWith("RDContributions\\RD_") == true)
                        {
                            string contributorUserID = file.Split('_')[1];
                            string contributorUserIP = file.Split('_')[2];
                            Logger.ConsoleWriteLine("RD File: " + file + ", was uploaded by UserID: " + contributorUserID + ", on IP: " + contributorUserIP, ConsoleColor.Yellow);
                            Contributor contributor = ContributorDB.GetContributor(contributorUserID, new System.Net.IPEndPoint(System.Net.IPAddress.Parse(contributorUserIP), 18374), false);
                            if (contributor != null)
                            {
                                m_DownloadedDataRD.Enqueue(new RPPContribution(contributor, file));
                            }
                            else
                            {
                                Logger.ConsoleWriteLine("Contributor: " + contributorUserID + " was not found", ConsoleColor.Red);
                            }
                        }
                        else
                        {
                            Logger.ConsoleWriteLine("Skipping file: " + file + ", does not seem to be a RD file");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                }
            }

            m_ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            m_ServerSocket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Any, _Port));
            //m_TCPListener = new TcpListener(System.Net.IPAddress.Any, _Port);
            m_ListenerThread = new System.Threading.Thread(new System.Threading.ThreadStart(ListenerThread));
            m_ListenerThread.Start();
        }
示例#9
0
        private void ProcessHeaderData(string _Header)
        {
            string[] headerData = _Header.Split(new char[] { ';' });

            if (headerData[0].Contains('=') == true)
            {
                Header = new HeaderData();

                foreach (string currHeader in headerData)
                {
                    if (currHeader.Contains('='))
                    {
                        string[] currHeaderSplit = currHeader.Split('=');
                        if (currHeaderSplit[0] == "VF_RPP_Version")
                        {
                            Header.UploaderVersion = Utility.ParseSingle(currHeaderSplit[1]);
                        }
                        else if (currHeaderSplit[0] == "Command")
                        {
                            Header.Command = currHeaderSplit[1];
                        }
                        else if (currHeaderSplit[0] == "FileSize")
                        {
                            Header.FileTotalSize = int.Parse(currHeaderSplit[1]);
                        }
                        else if (currHeaderSplit[0] == "FileType")
                        {
                            Header.FileType = (FileUploadType)Enum.Parse(typeof(FileUploadType), currHeaderSplit[1], true);
                        }
                        else if (currHeaderSplit[0] == "UserID")
                        {
                            Header.UserIDStr = currHeaderSplit[1].ToLower();
                            Header.UserIDStr = Header.UserIDStr[0].ToString().ToUpper() + Header.UserIDStr.Substring(1);
                            if (Header.Command == "UserCheck")
                            {
                                Header.Contributor = new Contributor(int.MaxValue, Header.UserIDStr);
                                Header.Contributor.SetUserIP((System.Net.IPEndPoint)TCPSocket.RemoteEndPoint);
                                try
                                {
                                    Logger.ConsoleWriteLine("UserCheck for " + Header.Contributor.IP + " tried UserID(" + Header.UserIDStr + ") raw(" + currHeaderSplit[1] + ")");
                                }
                                catch (Exception)
                                {}
                            }
                            else
                            {
                                Header.Contributor = ContributorDB.GetContributor(Header.UserIDStr, (System.Net.IPEndPoint)TCPSocket.RemoteEndPoint /*Client.Client.RemoteEndPoint*/);
                                if (Header.Contributor.UserID != Header.UserIDStr)
                                {
                                    Logger.ConsoleWriteLine("User(" + Header.Contributor.IP + ") tried to access using UserID(" + Header.UserIDStr + ") raw(" + currHeaderSplit[1] + ")");
                                }
                            }
                        }
                        else if (currHeaderSplit[0] == "AddonVersion")
                        {
                            Header.AddonVersion = Utility.ParseSingle(currHeaderSplit[1]);
                        }
                        else if (currHeaderSplit[0] == "Flags")
                        {
                            Header.Flags = currHeaderSplit[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("Old uploader version that is not supported anymore");
            }
        }