Пример #1
0
        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);
        }
Пример #2
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);
                }
            }
        }
Пример #3
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();
        }
Пример #4
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);
                }
            }
        }