ApplicationInstance()
 {
     //Monitor.Enter(m_RealmPlayersMutex);
     //try
     //{
     //    if (System.IO.File.Exists(Constants.RPPDbDir + "VF_UsersOnSite.dat") == true)
     //    {
     //        VF_RealmPlayersDatabase.Utility.LoadSerialize(Constants.RPPDbDir + "VF_UsersOnSite.dat", out m_UsersOnSite);
     //    }
     //}
     //catch (Exception)
     //{}
     //if(m_UsersOnSite == null)
     //    m_UsersOnSite = new Dictionary<string, List<Tuple<DateTime, string>>>();
     //Monitor.Exit(m_RealmPlayersMutex);
     Constants.AssertInitialize();
     (new System.Threading.Tasks.Task(() =>
     {
         try
         {
             GetItemInfoCache(WowVersionEnum.Vanilla, true);
             GetItemInfoCache(WowVersionEnum.TBC, true);
         }
         catch (Exception ex)
         {
             Logger.LogException(ex);
         }
     })).Start();
     ContributorDB.Initialize(Constants.DevMode);
     while (ContributorDB.GetMongoDB() == null)
     {
         ContributorDB.Initialize(Constants.DevMode);
         System.Threading.Thread.Sleep(1000);
     }
 }
        public static User LoginUser(System.Web.UI.Page _CurrentPage, string _UserID)
        {
            if (_CurrentPage.Session["User"] != null)
            {
                return(null); //Måste logga ut användare innan man kan logga in igen
            }
            if (ContributorDB.CheckContributor(_UserID, _CurrentPage.Request.UserHostAddress) != ContributorDB.CheckContributorResult.UserID_Success_Login)
            {
                return(null);
            }
            var contributor = ContributorDB.GetContributor(_UserID);

            if (contributor == null)
            {
                return(null);
            }

            //Skapa User klassen och returnera eftersom inloggningen lyckades!
            User newUser = new User(contributor);

            _CurrentPage.Session["User"]   = newUser;                              //Spara undan usern i sessionen så att vi kommer ihåg den
            _CurrentPage.Session["UserIP"] = _CurrentPage.Request.UserHostAddress; //Spara undan IP på den som loggade in. endast denna IP är nu valid med denna Sessionen!
            SetIsUserCookie(_CurrentPage.Response, true);
            return(newUser);
        }
Exemple #3
0
        protected void btnCreateUserID_Click(object sender, EventArgs e)
        {
            string userID;

            if (ContributorUtility.GenerateUserID(txtCreateUserID.Text, out userID) == true)
            {
                if (ContributorDB.AddVIPContributor(userID, m_ThisContributor.UserID) == true)
                {
                    if (PageUtility.GetQueryString(Request, "redirect", "null") == "null")
                    {
                        Response.Redirect(Request.RawUrl);
                    }
                    else
                    {
                        txtStatus.Text = "Added: " + userID;
                    }
                }
                else
                {
                    txtStatus.Text = "Error: Could not create UserID, internal server issue, try again later!";
                }
            }
            else
            {
                txtStatus.Text = "Error: Could not create UserID, invalid Username format!";
            }
        }
 public static void Initialize()
 {
     ContributorDB.Initialize();
     try
     {
         if (ContributorDB.GetMongoDB().IsConnected() == false)
         {
             System.Threading.Thread.Sleep(500);
             ContributorDB.GetMongoDB().IsConnected();
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Exemple #5
0
 public static void Initialize()
 {
     ContributorDB.Initialize(RealmPlayersServer.Constants.DevMode);
     try
     {
         if (ContributorDB.GetMongoDB() == null || ContributorDB.GetMongoDB().IsConnected() == false)
         {
             System.Threading.Thread.Sleep(500);
             ContributorDB.GetMongoDB().IsConnected();
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Exemple #6
0
        public static void HandleUnhandledFiles(string _AddonName)
        {
            string uploadDataFolder = g_AddonUploadDataFolder + _AddonName + "\\Contributions\\";

            if (System.IO.Directory.Exists(uploadDataFolder) == false)
            {
                return;
            }

            string[] files = System.IO.Directory.GetFiles(uploadDataFolder);
            foreach (var file in files)
            {
                Logger.ConsoleWriteLine("Added unhandled file: \"" + file + "\"", ConsoleColor.Cyan);
                if (_AddonName == "VF_RealmPlayers")
                {
                    string[] fileName = System.IO.Path.GetFileNameWithoutExtension(file).Split('_');
                    if (fileName.Length == 9)
                    {
                        string userID          = fileName[0];
                        string userIP          = fileName[1];
                        var    currContributor = ContributorDB.GetContributor(userID, System.Net.IPAddress.Parse(userIP), false);
                        Program.g_RPPDatabaseHandler.AddContribution(new RPPContribution(currContributor, file));
                    }
                }
                else if (_AddonName == "VF_RealmPlayersTBC")
                {
                    string[] fileName = System.IO.Path.GetFileNameWithoutExtension(file).Split('_');
                    if (fileName.Length == 9)
                    {
                        string userID          = fileName[0];
                        string userIP          = fileName[1];
                        var    currContributor = ContributorDB.GetContributor(userID, System.Net.IPAddress.Parse(userIP), false);
                        Program.g_RPPDatabaseHandler.AddContribution(new RPPContribution(currContributor, file));
                    }
                }
                else if (_AddonName == "VF_RaidDamage")
                {
                    Program.g_RDDatabaseHandler.AddContribution(file);
                }
                else if (_AddonName == "VF_RaidStatsTBC")
                {
                    Program.g_RDDatabaseHandler.AddContribution(file);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "Contributors | RealmPlayers";
            //var statisticsData = DatabaseAccess.GetContributorStatistics();
            //if (statisticsData == null)
            //{
            //    PageUtility.RedirectErrorLoading(this, "contributors");
            //    return;
            //}
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome() + PageUtility.BreadCrumb_AddFinish("Contributors"));

            var statsRealms = new WowRealm[] { WowRealm.Emerald_Dream, WowRealm.Warsong, WowRealm.Al_Akir, WowRealm.Rebirth, WowRealm.Nostalrius, WowRealm.Kronos, WowRealm.Archangel };

            Dictionary <WowRealm, int> totalRealmInspects = new Dictionary <WowRealm, int>();

            string realmInspectsHeaderColumns = "";

            foreach (var statsRealm in statsRealms)
            {
                realmInspectsHeaderColumns += PageUtility.CreateTableColumnHead(StaticValues.ConvertRealmViewing(statsRealm));
                totalRealmInspects.Add(statsRealm, 0);
            }

            m_TableHeadHTML = new MvcHtmlString(PageUtility.CreateTableRow("", PageUtility.CreateTableColumnHead("#Nr")
                                                                           + PageUtility.CreateTableColumnHead("Name")
                                                                           + PageUtility.CreateTableColumnHead("Total inspects")
                                                                           + realmInspectsHeaderColumns
                                                                           + PageUtility.CreateTableColumnHead("Active since")
                                                                           + PageUtility.CreateTableColumnHead("Last active")));

            SortedList <int, string> tableRows = new SortedList <int, string>();
            string tableBody = "";

            using (VF.SQLComm comm = new VF.SQLComm())
            {
                var contributors = ContributorDB.GetAllTrustWorthyContributors();
                foreach (var statRealm in statsRealms)
                {
                    totalRealmInspects[statRealm] = comm.GetRealmInspectsTotal(statRealm);
                }

                //return DynamicReloader.GetData<ContributorStatistics>(() =>
                //{
                //    VF_RPDatabase.GuildSummaryDatabase summaryDB = null;
                //    summaryDB = VF_RPDatabase.GuildSummaryDatabase.LoadSummaryDatabase(Constants.RPPDbDir);
                //    return summaryDB;
                //}, (_ContributorStatistics, _LastLoadTime) => { return (DateTime.UtcNow - _LastLoadTime).TotalMinutes > 30; });

                //DynamicReloader.GetData(() => { }, () => { return true; }, TimeSpan.FromMinutes(30), false)
                int contributorCounter = 0;
                if (false)
                {
                    foreach (var data in contributors)
                    {
                        var contributor = data.GetAsContributor();

                        DateTime earliestActive;
                        DateTime latestActive;
                        int      totalInspects;
                        if (comm.GetInspectsInfoForContributor(contributor, out earliestActive, out latestActive, out totalInspects) == true)
                        {
                            string realmInspectsColumns = "";

                            if (totalInspects > 0 && data.Name != "Unknown" &&
                                ((DateTime.UtcNow - latestActive).TotalDays < 15 ||
                                 (totalInspects > 5000 && (DateTime.UtcNow - latestActive).TotalDays < 60)))
                            {
                                foreach (var statRealm in statsRealms)
                                {
                                    int inspects = comm.GetRealmInspectsForContributor(contributor, statRealm);
                                    realmInspectsColumns += PageUtility.CreateTableColumn(inspects.ToString());
                                }

                                int keyToUse = int.MaxValue - totalInspects * 100;
                                while (tableRows.ContainsKey(keyToUse) == true)
                                {
                                    keyToUse += 1;
                                }


                                tableRows.Add(keyToUse, PageUtility.CreateTableColumn(data.Name)
                                              + PageUtility.CreateTableColumn(totalInspects.ToString())
                                              + realmInspectsColumns
                                              + PageUtility.CreateTableColumn(earliestActive.ToString("yyy-MM-dd"))
                                              + PageUtility.CreateTableColumn(StaticValues.GetTimeSinceLastSeenUTC(latestActive)));
                            }
                        }


                        if (contributorCounter++ % 100 == 0)
                        {
                            Logger.ConsoleWriteLine("Generated Contributor Inspects Info for Contributor Nr " + contributorCounter);
                        }
                    }
                }
            }
            int    totalALLInspects         = 0;
            string totalRealmInspectsColumn = "";

            foreach (var statRealm in statsRealms)
            {
                totalRealmInspectsColumn += PageUtility.CreateTableColumn(totalRealmInspects[statRealm].ToString());
                totalALLInspects         += totalRealmInspects[statRealm];
            }
            tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#ALL") + PageUtility.CreateTableColumn("TOTAL")
                                                    + PageUtility.CreateTableColumn(totalALLInspects.ToString())
                                                    + totalRealmInspectsColumn
                                                    + PageUtility.CreateTableColumn("-")
                                                    + PageUtility.CreateTableColumn("-"));
            int i = 1;

            foreach (var tableRow in tableRows)
            {
                tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#" + i++) + tableRow.Value);
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);

            m_ContributorsInfoHTML = new MvcHtmlString(
                "<h1>Contributors<span class='badge badge-inverse'>" + tableRows.Count() + " Players</span></h1>"
                + "<p>List displays the persons that contribute data to this project. Sorted by the amount of inspects they have contributed with.</p>"
                + "<br/><p>The more contributors the better! If you are interested in being a contributor to help out the project please do not hesitate contacting <a href='http://forum.realmplayers.com/memberlist.php?mode=viewprofile&u=51'>Sethzer</a> on RealmPlayers forums. Make sure you also read the thread: <a href='http://realmplayers.com:5555/viewtopic.php?f=14&t=15'>About Data Contribution</a>.</p><br/>");
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string userStr = Request.QueryString.Get("user");
            string passStr = Request.QueryString.Get("pass");

            int maxCount = PageUtility.GetQueryInt(Request, "count", 0);

            if (userStr == null || passStr == null)
            {
                Response.Redirect("Index.aspx");
            }

            System.Text.StringBuilder infoHTMLStrBuilder = new System.Text.StringBuilder(10000);
            if (userStr == "Admin" && passStr == VF.HiddenStrings.CreateUserID_AdminPassword)
            {
                //Admin
                infoHTMLStrBuilder.Append("<h2>Logged in as Admin</h2>");
                m_ThisContributor        = new ContributorDB.ContributorDBElement();
                m_ThisContributor.Key    = "Admin";
                m_ThisContributor.UserID = VF.HiddenStrings.DilatazuUserID;
            }
            else if (passStr == VF.HiddenStrings.CreateUserID_UserIDCreaterPassword)
            {
                m_ThisContributor = ContributorDB.GetContributor(userStr);
                if (m_ThisContributor == null)
                {
                    Response.Redirect("Index.aspx");
                }

                //Admin Contributor
                infoHTMLStrBuilder.Append("<h2>Logged in as " + m_ThisContributor.Name + "</h2>");
            }
            else
            {
                Response.Redirect("Index.aspx");
            }

            if (m_ThisContributor.Key == "Admin") //Admin
            {
                var addedBys       = ContributorDB.GetMongoDB().MongoDBCollection.FindAll();
                var addedBysSorted = addedBys.OrderByDescending(_Value => _Value.ContributorID);
                Dictionary <string, List <ContributorDB.ContributorDBElement> > addedByGroups = new Dictionary <string, List <ContributorDB.ContributorDBElement> >();
                foreach (var addedBy in addedBysSorted)
                {
                    if (addedBy.ContributorID >= VF_RealmPlayersDatabase.Contributor.ContributorTrustworthyIDBound)
                    {
                        addedByGroups.AddToList("Temp", addedBy);
                    }
                    else
                    {
                        addedByGroups.AddToList(addedBy.AddedBy, addedBy);
                    }
                }
                var addedByGroupsSorted = addedByGroups.OrderBy(_Value => _Value.Value.Count);
                foreach (var addedByGroup in addedByGroupsSorted)
                {
                    int count = 0;
                    infoHTMLStrBuilder.Append("<h3>Created UserIDs by " + addedByGroup.Key + "</h3><table><tr>");
                    infoHTMLStrBuilder.Append("<th>UserID</th><th>ContributorID</th><th>IP</th><th>Key</th></tr>");
                    foreach (var addedBy in addedByGroup.Value)
                    {
                        infoHTMLStrBuilder.Append("<tr>");
                        infoHTMLStrBuilder.Append("<td>" + addedBy.UserID + "</td>");
                        infoHTMLStrBuilder.Append("<td>" + addedBy.ContributorID + "</td>");
                        infoHTMLStrBuilder.Append("<td>" + addedBy.IP + "</td>");
                        infoHTMLStrBuilder.Append("<td>" + addedBy.Key + "</td>");
                        infoHTMLStrBuilder.Append("</tr>");
                        if (maxCount > 0 && ++count >= maxCount)
                        {
                            break;
                        }
                    }
                    infoHTMLStrBuilder.Append("</table>");
                }
            }
            else
            {
                infoHTMLStrBuilder.Append("<h3>Created UserIDs</h3>");
                var addedBys       = ContributorDB.GetMongoDB().MongoDBCollection.Find(Query.EQ("AddedBy", userStr));
                var addedBysSorted = addedBys.OrderByDescending(_Value => _Value.ContributorID);
                foreach (var addedBy in addedBysSorted)
                {
                    infoHTMLStrBuilder.Append(addedBy.UserID + "<br/>");
                    if (maxCount > 0 && --maxCount == 0)
                    {
                        break;
                    }
                }
            }
            m_InfoHTML = infoHTMLStrBuilder.ToString();
        }
Exemple #9
0
        public static void UploadData(System.Net.IPAddress _UploaderIP, WLN_UploadPacket_AddonData _Data)
        {
            var currContributor = ContributorDB.GetContributor(_Data.UserID, _UploaderIP, false);

            if (currContributor == null)
            {
                Logger.ConsoleWriteLine("User(" + _UploaderIP.ToString() + ") tried to access using UserID(" + _Data.UserID + ")");
            }
            else if (currContributor.UserID != _Data.UserID)
            {
                Logger.ConsoleWriteLine("User(" + _UploaderIP.ToString() + ") tried to access UserID(" + currContributor.UserID + ") using UserID(" + _Data.UserID + ")");
                currContributor = null;
            }
            string userID            = _Data.UserID;
            string userIP            = _UploaderIP.ToString();
            string uploadDataFolder  = g_AddonUploadDataFolder + _Data.AddonName + "\\";
            string uploadStatsFolder = g_AddonUploadStatsFolder + _Data.AddonName + "\\";

            if (currContributor == null)
            {
                userID = "Unknown_" + userID;
            }
            else if (currContributor.IsVIP() == false)
            {
                userID = "NotVIP_" + userID;
            }

            string contributionsFolder = "Contributions\\";

            if (currContributor == null)
            {
                contributionsFolder = "Unknown" + contributionsFolder;
                userID = "Unknown_" + userID;
            }
            else if (currContributor.IsVIP() == false)
            {
                contributionsFolder = "NotVIP" + contributionsFolder;
                userID = "NotVIP_" + userID;
            }

            long   fileFID  = System.Threading.Interlocked.Increment(ref g_FileCounter);
            string fileName = userID + "_" + userIP + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + "_FID" + fileFID.ToString("0000");

            string debugResult    = "";
            var    temperedResult = DetermineTempered(_Data, out debugResult);
            string uploadStats    = fileName + " @ Result: " + temperedResult.ToString() + ", Details: " + debugResult;

            Utility.AssertDirectory(uploadStatsFolder);
            System.IO.File.AppendAllText(uploadStatsFolder + userID + ".txt", uploadStats + "\r\n");

            if (temperedResult == TemperedStatus.OK)
            {
                Logger.ConsoleWriteLine("Data Received \"" + fileName + "\"", ConsoleColor.Green);
            }
            else if (temperedResult == TemperedStatus.Possibly_Tempered)
            {
                Logger.ConsoleWriteLine("Possibly Tempered Data Received \"" + fileName + "\"", ConsoleColor.Yellow);
            }
            else//if (temperedResult == TemperedStatus.Tempered)
            {
                contributionsFolder = "Tempered" + contributionsFolder;
                Logger.ConsoleWriteLine("Tempered Data Received \"" + fileName + "\"", ConsoleColor.Red);
            }

            string fullFilename = uploadDataFolder + contributionsFolder + fileName + ".txt";

            Utility.AssertFilePath(fullFilename);
            System.IO.File.WriteAllText(fullFilename, _Data.Data);

            if (currContributor != null && currContributor.IsVIP() == true && temperedResult != TemperedStatus.Tempered)
            {
                if (_Data.AddonName == "VF_RealmPlayers")
                {
                    Program.g_RPPDatabaseHandler.AddContribution(new RPPContribution(currContributor, fullFilename));
                }
                else if (_Data.AddonName == "VF_RaidDamage")
                {
                    Program.g_RDDatabaseHandler.AddContribution(fullFilename);
                }
                else if (_Data.AddonName == "VF_RealmPlayersTBC")
                {
                    Program.g_RPPDatabaseHandler.AddContribution(new RPPContribution(currContributor, fullFilename));
                }
                else if (_Data.AddonName == "VF_RaidStatsTBC")
                {
                    Program.g_RDDatabaseHandler.AddContribution(fullFilename);
                }
            }
        }
Exemple #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "Contributors | RealmPlayers";
            var statisticsData = DatabaseAccess.GetContributorStatistics();

            if (statisticsData == null)
            {
                PageUtility.RedirectErrorLoading(this, "contributors");
                return;
            }
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome() + PageUtility.BreadCrumb_AddFinish("Contributors"));

            var statsRealms = new WowRealm[] { WowRealm.Emerald_Dream, WowRealm.Warsong, WowRealm.Al_Akir, WowRealm.Rebirth, WowRealm.Nostalrius, WowRealm.Kronos, WowRealm.Archangel };

            Dictionary <WowRealm, int> totalRealmInspects = new Dictionary <WowRealm, int>();

            string realmInspectsHeaderColumns = "";

            foreach (var statsRealm in statsRealms)
            {
                realmInspectsHeaderColumns += PageUtility.CreateTableColumnHead(StaticValues.ConvertRealmViewing(statsRealm));
                totalRealmInspects.Add(statsRealm, 0);
            }

            m_TableHeadHTML = new MvcHtmlString(PageUtility.CreateTableRow("", PageUtility.CreateTableColumnHead("#Nr")
                                                                           + PageUtility.CreateTableColumnHead("Name")
                                                                           + PageUtility.CreateTableColumnHead("Total inspects")
                                                                           + realmInspectsHeaderColumns
                                                                           + PageUtility.CreateTableColumnHead("Active since")
                                                                           + PageUtility.CreateTableColumnHead("Last active")));

            SortedList <int, string> tableRows = new SortedList <int, string>();
            string tableBody = "";

            var contributors = ContributorDB.GetAllTrustWorthyContributors();

            foreach (var data in contributors)
            {
                DateTime earliestActive       = DateTime.MaxValue;
                DateTime latestActive         = DateTime.MinValue;
                int      totalInspects        = 0;
                string   realmInspectsColumns = "";
                foreach (var statRealm in statsRealms)
                {
                    int inspects = 0;
                    Code.ContributorStatisticItem stats = null;
                    if (statisticsData[statRealm].TryGetValue(data.ContributorID, out stats) == false)
                    {
                        stats = new Code.ContributorStatisticItem(-1);
                    }
                    earliestActive = (stats.m_EarliestActiveUTC < earliestActive ? stats.m_EarliestActiveUTC : earliestActive);
                    latestActive   = (stats.m_LatestActiveUTC > latestActive ? stats.m_LatestActiveUTC : latestActive);

                    foreach (var inspection in stats.m_PlayerInspects)
                    {
                        inspects += inspection.Value;
                    }
                    totalInspects += inspects;
                    totalRealmInspects[statRealm] += inspects;
                    realmInspectsColumns          += PageUtility.CreateTableColumn(inspects.ToString());
                }

                if (totalInspects > 0 && data.Name != "Unknown" &&
                    ((DateTime.UtcNow - latestActive).TotalDays < 15 ||
                     (totalInspects > 5000 && (DateTime.UtcNow - latestActive).TotalDays < 60)))
                {
                    int keyToUse = int.MaxValue - totalInspects * 100;
                    while (tableRows.ContainsKey(keyToUse) == true)
                    {
                        keyToUse += 1;
                    }


                    tableRows.Add(keyToUse, PageUtility.CreateTableColumn(data.Name)
                                  + PageUtility.CreateTableColumn(totalInspects.ToString())
                                  + realmInspectsColumns
                                  + PageUtility.CreateTableColumn(earliestActive.ToString("yyy-MM-dd"))
                                  + PageUtility.CreateTableColumn(StaticValues.GetTimeSinceLastSeenUTC(latestActive)));
                }
            }
            int    totalALLInspects         = 0;
            string totalRealmInspectsColumn = "";

            foreach (var statRealm in statsRealms)
            {
                totalRealmInspectsColumn += PageUtility.CreateTableColumn(totalRealmInspects[statRealm].ToString());
                totalALLInspects         += totalRealmInspects[statRealm];
            }
            tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#ALL") + PageUtility.CreateTableColumn("TOTAL")
                                                    + PageUtility.CreateTableColumn(totalALLInspects.ToString())
                                                    + totalRealmInspectsColumn
                                                    + PageUtility.CreateTableColumn("-")
                                                    + PageUtility.CreateTableColumn("-"));
            int i = 1;

            foreach (var tableRow in tableRows)
            {
                tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#" + i++) + tableRow.Value);
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);

            m_ContributorsInfoHTML = new MvcHtmlString(
                "<h1>Contributors<span class='badge badge-inverse'>" + tableRows.Count() + " Players</span></h1>"
                + "<p>List displays the persons that contribute data to this project. Sorted by the amount of inspects they have contributed with.</p>"
                + "<br/><p>The more contributors the better! If you are interested in being a contributor to help out the project please do not hesitate contacting <a href='http://forum.realmplayers.com/memberlist.php?mode=viewprofile&u=51'>Sethzer</a> on RealmPlayers forums. Make sure you also read the thread: <a href='http://realmplayers.com:5555/viewtopic.php?f=14&t=15'>About Data Contribution</a>.</p><br/>");
        }