Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        this.Title = "LegacyPlayers | Queue";

        SQLWrapper db = App.GetDB(1);

        MySqlDataReader dr = db.Query("SELECT b.userid, a.timestamp, a.instanceid, a.progress FROM `RPLL_VANILLA`.rs_progress a LEFT JOIN `RPLL_VANILLA`.gn_uploader b ON a.uploaderid = b.id " +
                                      "UNION " +
                                      "SELECT d.userid, c.timestamp, c.instanceid, c.progress FROM `RPLL_TBC`.rs_progress c LEFT JOIN `RPLL_TBC`.gn_uploader d ON c.uploaderid = d.id").ExecuteReaderRpll();

        int count   = 1;
        var imgType = Utility.GetImageType(Request, "png");

        while (dr.Read())
        {
            sb.Append("<tr><td class=\"tnum tsmallvalue\">" + count + "</td><td>Normal</td><td>" + App.GetUser(dr.GetInt32(0)).Name +
                      "</td><td>" +
                      DateTimeOffset.FromUnixTimeSeconds(dr.GetInt32(1)).UtcDateTime
                      .ToString(CultureInfo.CurrentCulture) + "</td><td><div class=\"sp" +
                      " bbdesign\" style=\"background-image:url(/Assets/raids/" + dr.GetInt32(2) + "." + imgType + ")\"><div>" + (dr.GetInt32(2) == 0 ? "Armory" : App.m_Instances[dr.GetInt32(2)].Name) +
                      "</div></div></td><td><div class=\"tstatusbar bgcolor-\" style=\"width: " + dr.GetInt16(3) +
                      "%;\"><div>" + dr.GetInt16(3) + "%</div><div></div></div></td></tr>");
            ++count;
        }
        dr.CloseRpll();
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        this.Title = "LegacyPlayers | Loot";

        if (Utility.GetQueryString(Request, "i", "") != "" && pmItem.Value == "")
        {
            pmItem.Value = Utility.GetQueryString(Request, "i", "");
        }

        if (IsPostBack)
        {
            Utility.SetCookie(Response, Request, "Loot_Item", pmItem.Value);
        }
        else
        {
            if (pmItem.Value == "")
            {
                pmItem.Value = Utility.GetCookie(Request, "Loot_Item", "");
            }
        }

        if (pmItem.Value == "")
        {
            return;
        }

        for (int i = 0; i < 2; ++i)
        {
            List <int> ItemIds = App.m_Items[i].Where(x => x.Value.Name.Contains(pmItem.Value))
                                 .Select(x => x.Key).ToList();

            if (ItemIds.Count == 0)
            {
                return;
            }

            SQLWrapper db = App.GetDB(i + 1);
            m_CurPage = int.Parse(Utility.GetQueryString(Request, "page", "0"));
            var             imgType2 = Utility.GetImageType(Request);
            MySqlDataReader dr       = db.Query("SELECT itemid FROM rs_loot WHERE itemid IN (" + string.Join(",", ItemIds) +
                                                ") GROUP BY itemid LIMIT " + m_CurPage * 10 + ", 10").ExecuteReaderRpll();
            while (dr.Read())
            {
                DBItems item = App.m_Items[i][dr.GetInt32(0)];
                m_Table.Append(
                    "<tr><td><div class=\"icon-26 bbdesign qe" + item.Quality +
                    "\" style=\"background-image: url(\'/Assets/icons/" + item.IconName + "." + imgType2 + "\')\">" +
                    "<div><a href=\"/Raids/Loot/Item/?item=" + dr.GetInt32(0) + "\" class=\"q" + item.Quality +
                    "\" onmouseover=\"tt_show(this, 1," + dr.GetInt32(0) + ",[])\">[" + item.Name +
                    "]</a></div></div></td></tr>");
            }
            dr.CloseRpll();
        }
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Int32.TryParse(Utility.GetQueryString(Request, "page", "0"), out m_CurPage);
        int toLeft = 0;

        if (m_CurPage >= 10)
        {
            toLeft = m_CurPage - 10;
        }
        for (int i = toLeft; i < toLeft + 22; ++i) // Sometimes there may not that many pages
        {
            if (i != m_CurPage)
            {
                m_PageBar.Append("<a href=\"?page=" + i + "\"><div class=\"bbdesign placeholder\" >" + (i + 1) +
                                 "</div></a>");
            }
            else
            {
                m_PageBar.Append("<a href=\"?page=" + i + "\"><div class=\"bbdesign placeholder\" style=\"color:#f28f45\">" + (i + 1) +
                                 "</div></a>");
            }
        }

        MySqlDataReader dr    = DB.Query("SELECT name, type, date, amount, id FROM gn_supporters ORDER BY id DESC LIMIT " + (m_CurPage * 20) + ", 20").ExecuteReaderRpll();
        int             Count = 1 + m_CurPage * 20;

        while (dr.Read())
        {
            m_Table.Append("<tr><td class=\"tnum tsmallvalue\">" + Count + "</td><td>" + dr.GetString(0) + "</td><td class=\"ttinytext\">" + ((dr.GetInt16(1) == 0) ? "Donation" : "Patreon") + "</td>" +
                           "<td class=\"tsmalltext\">" + DateTimeOffset.FromUnixTimeSeconds(dr.GetInt32(2)).UtcDateTime.ToString(CultureInfo.CurrentCulture) + "</td><td class=\"tnum tmiddlevalue\">" + (dr.GetInt32(3) / 100.0) + "$</td></tr>");
            ++Count;
        }
        dr.CloseRpll();
        this.Title = "LegacyPlayers | Donators";
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        this.Title = "LegacyPlayers | Home";
        if (Utility.GetCookie(Request, "RPLL_user") != "")
        {
            m_LoggedIn = true;
        }


        MySqlDataReader dr = App.GetDB().Query(@"SELECT name, amount, date FROM gn_supporters ORDER BY id DESC LIMIT 5").ExecuteReaderRpll();

        while (dr.Read())
        {
            m_Table.Append("<tr><td>" + dr.GetString(0) + "</td><td>" + (dr.GetInt32(1) / 100.0) + "$</td><td>" + DateTimeOffset.FromUnixTimeSeconds(dr.GetInt32(2)).UtcDateTime.ToShortDateString() + "</td></tr>");
        }
        dr.CloseRpll();
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "LegacyPlayers | Sign Up";

        if (!IsPostBack)
        {
            return;
        }
        try
        {
            string Username    = Utility.SecureInput(pmName.Value);
            string Password    = Utility.SecureInput(pmPass.Value);
            string PasswordCon = Utility.SecureInput(pmPassCon.Value);
            string Mail        = Utility.SecureInput(pmMail.Value);
            string MailCon     = Utility.SecureInput(pmMailCon.Value);

            if (Username != pmName.Value ||
                Password != pmPass.Value ||
                PasswordCon != pmPassCon.Value ||
                Mail != pmMail.Value ||
                MailCon != pmMailCon.Value
                )
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Invalid input!", 2);
                return;
            }

            if (Password != PasswordCon)
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Passwords do not match!", 1);
                return;
            }

            if (Mail != MailCon)
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Mails do not match!", 1);
                return;
            }

            if (!Mail.Contains("@") || !Mail.Contains("."))
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Invalid email format!", 1);
                return;
            }

            if (Username.Length > 51)
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Username is too long!", 2);
                return;
            }

            if (Mail.Length > 120)
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Mail is too long!", 2);
                return;
            }

            var encodedResponse = Request.Form["g-recaptcha-response"];
            var isCaptchaValid  = ReCaptcha.Validate(encodedResponse);
            if (!isCaptchaValid)
            {
                (this.Master as RPLL.MasterPage).setNotifaction("Invalid capture!", 2);
                return;
            }

            Password = BCryptHelper.HashPassword(Password,
                                                 "obscurred");
            SQLWrapper db = App.GetDB();

            var exists = db.CreateCommand();
            exists.CommandText = "SELECT id FROM gn_user WHERE LOWER(name)=? OR LOWER(mail)=?";
            exists.Parameters.AddWithValue("@name", Username.ToLower());
            exists.Parameters.AddWithValue("@mail", Mail.ToLower());
            MySqlDataReader dr = exists.ExecuteReaderRpll();
            if (dr.HasRows)
            {
                dr.CloseRpll();
                (this.Master as RPLL.MasterPage).setNotifaction("Username or Mail is already in use!", 2);
                return;
            }
            dr.CloseRpll();

            Utility.SendMail("*****@*****.**", Mail, "Legacyplayers account verification",
                             "Hello there! <br /> In order to verify your account now, you are required to click this link. <br /> You will be automatically redirected to your accountpanel then! <br /> Link: https://legacyplayers.com/Account/?verify=" +
                             Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(Username, "obscurred"))) + "<br /> cheers!");

            var cmd = db.CreateCommand();
            cmd.CommandText = "INSERT INTO gn_user (name, pass, mail, registerd, uhash) VALUES (?,?,?,UNIX_TIMESTAMP(),?)";
            cmd.Parameters.AddWithValue("@name", Username);
            cmd.Parameters.AddWithValue("@pass", Password);
            cmd.Parameters.AddWithValue("@mail", Mail);
            cmd.Parameters.AddWithValue("@uhash", Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(Username + Password,
                                                                                                                             "obscurred"))));
            cmd.ExecuteNonQuery();
            //db.Kill();

            // Inserting user into the table
            DBUser usr = new DBUser()
            {
                Name             = Username,
                Amount           = 0,
                LastContribution = 0,
                Level            = 0,
                Patreon          = 0,
                Registerd        = 0,
                uHash            = Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(Username + Password,
                                                                                                              "obscurred")))
            };
            App.m_User.TryAdd(App.m_User.Max(x => x.Key) + 1, usr);

            (this.Master as RPLL.MasterPage).setNotifaction("Success! A mail has been send to you!", 3);
            return;
        }
        catch (Exception ex)
        {
            (this.Master as RPLL.MasterPage).setNotifaction("Something went wrong, please try again later!\n Error: " + ex.Message, 1);
            return;
        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "LegacyPlayers | Account";

        if (Utility.GetQueryString(Request, "logout", "0") != "0")
        {
            Utility.SetCookie(Response, Request, "RPLL_username", "");
            Utility.SetCookie(Response, Request, "RPLL_user", "");
            Response.Redirect("/");
            return;
        }

        if (Utility.GetQueryString(Request, "verify", "0") != "0")
        {
            SQLWrapper DB     = App.GetDB();
            string     token  = Utility.GetQueryString(Request, "verify", "0");
            byte[]     buffer = Base32.Decode(token);
            token = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);
            MySqlDataReader der = DB.Query("SELECT name, id, pass FROM gn_user WHERE accepted = 0").ExecuteReaderRpll();
            int             id  = 0;
            while (der.Read())
            {
                if (BCryptHelper.HashPassword(der.GetString(0), "obscurred") ==
                    token)
                {
                    id = der.GetInt32(1);
                    Utility.SetCookie(Response, Request, "RPLL_username", der.GetString(0));
                    Utility.SetCookie(Response, Request, "RPLL_user", Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(der.GetString(0) + der.GetString(2), "obscurred"))));
                    break;
                }
            }
            der.CloseRpll();
            if (id > 0)
            {
                DB.Query("UPDATE gn_user SET accepted = 1 WHERE id = " + id).ExecuteNonQuery();
                //DB.Kill();
                Response.Redirect("/Account/?uid=" + id);
                return;
            }
            Response.Redirect("/404/");
            return;
        }

        if (Utility.GetQueryString(Request, "verifyMail", "0") != "0")
        {
            SQLWrapper DB     = App.GetDB();
            string     token  = Utility.GetQueryString(Request, "verifyMail", "0");
            byte[]     buffer = Base32.Decode(token);
            token = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);
            MySqlDataReader der = DB.Query("SELECT name, mail, id FROM gn_user WHERE requestmail = 1").ExecuteReaderRpll();
            int             id  = 0;
            while (der.Read())
            {
                if (BCryptHelper.HashPassword(der.GetString(0) + der.GetString(1), "obscurred") ==
                    token)
                {
                    id = der.GetInt32(2);
                    break;
                }
            }
            der.CloseRpll();
            if (id > 0)
            {
                DB.Query("UPDATE gn_user SET requestmail = 0, mail=requestedmail WHERE id = " + id).ExecuteNonQuery();
                //DB.Kill();
                Response.Redirect("/Account/?uid=" + id);
                return;
            }
            Response.Redirect("/404/");
            return;
        }

        if (!int.TryParse(Utility.GetQueryString(Request, "uid", "0"), out m_UID) || m_UID == 0)
        {
            Response.Redirect("/404/");
            return;
        }

        if (!short.TryParse(Utility.GetQueryString(Request, "mode", "0"), out m_Mode))
        {
            Response.Redirect("/404/");
            return;
        }


        SQLWrapper      db = App.GetDB();
        MySqlDataReader dr = db.Query("SELECT name, patreon, registerd, mail, level, pass, disableads, defaultpriv FROM gn_user WHERE id=" + m_UID).ExecuteReaderRpll();

        if (!dr.HasRows)
        {
            dr.CloseRpll();
            Response.Redirect("/404/");
            return;
        }
        dr.Read();
        m_Name      = dr.GetString(0);
        m_Patreon   = (uint)dr.GetInt64(1);
        m_Registerd = (uint)dr.GetInt64(2);
        m_Mail      = dr.GetString(3);
        m_Level     = dr.GetInt16(4);
        m_Pass      = dr.GetString(5);
        m_Ads       = dr.GetInt16(6) == 1;
        m_Private   = dr.GetInt16(7) == 1;
        dr.CloseRpll();

        if (Utility.GetCookie(Request, "RPLL_user", "") != Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(m_Name + m_Pass, "obscurred"))))
        {
            Response.Redirect("/404/");
            return;
        }

        if (m_Mode == 1 && m_Level < 1)
        {
            m_Mode = 0;
        }
        if (m_Mode == 4 && m_Level < 6)
        {
            m_Mode = 0;
        }
        switch (m_Mode)
        {
        case 1:
            if (Request["ads"] != null)
            {
                db.Query("UPDATE gn_user SET disableads = " + (Request["ads"] == "Disable advertisements" ? "1" : "0") + " WHERE id = " + m_UID + ";").ExecuteNonQuery();
                m_Ads = Request["ads"] == "Disable advertisements";
            }
            m_Table.Append("<form action=\"\" method=\"post\"><input type=\"submit\" value=\"" + (!m_Ads ? "Disable advertisements" : "Enable advertisements") + "\" name=\"ads\" style=\"width: 200px\" /></form>");
            break;

        case 2:
            if (IsPostBack)
            {
                string pass    = Utility.SecureInput(pmPass.Value);
                string passCon = Utility.SecureInput(pmPassCon.Value);
                string oldPass = Utility.SecureInput(pmOldPass.Value);

                if (pass == "" || passCon == "" || oldPass == "")
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Input is empty!", 2);
                    return;
                }

                if (pass != pmPass.Value ||
                    passCon != pmPassCon.Value ||
                    oldPass != pmOldPass.Value
                    )
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Invalid characters!", 2);
                    return;
                }

                if (pmPass.Value != pmPassCon.Value)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Passwords do not match!", 2);
                    return;
                }

                if (BCryptHelper.HashPassword(oldPass, "obscurred") != m_Pass)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Password incorrect!", 1);
                    return;
                }

                string newPass = BCryptHelper.HashPassword(pmPass.Value, "obscurred");
                db.Query("UPDATE gn_user SET pass = \"" + newPass + "\", uhash=\"" + Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(m_Name + newPass, "obscurred"))) + "\" WHERE id=" + m_UID).ExecuteNonQuery();
                //db.Kill();
                (this.Master as RPLL.MasterPage).setNotifaction("Password has been changed! Make sure to redownload the config.txt!", 3);
            }
            break;

        case 3:
            if (IsPostBack)
            {
                string mail    = Utility.SecureInput(pmMail.Value);
                string mailCon = Utility.SecureInput(pmMailCon.Value);
                string oldPass = Utility.SecureInput(pmPassMail.Value);

                if (mail == "" || mailCon == "" || oldPass == "")
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Input is empty!", 2);
                    return;
                }

                if (mail != pmMail.Value ||
                    mailCon != pmMailCon.Value ||
                    oldPass != pmPassMail.Value
                    )
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Invalid characters!", 2);
                    return;
                }

                if (mail != mailCon)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Mails do not match!", 2);
                    return;
                }

                if (BCryptHelper.HashPassword(pmPassMail.Value, "obscurred") != m_Pass)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Password incorrect!", 1);
                    return;
                }

                if (!mail.Contains("@") || !mail.Contains("."))
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Invalid mail format!", 2);
                    return;
                }

                try
                {
                    Utility.SendMail("*****@*****.**", m_Mail, "Legacyplayers account mail verification",
                                     "Hey there! <br />In order to verify your identity, you need to click on this link. Once this is done, your mail is changed. <br />Link: https://legacyplayers.com/Account/?verifyMail=" +
                                     Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(m_Name + m_Mail,
                                                                                                                "obscurred"))) + " <br />cheers!");
                }
                catch (Exception ex)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Error sending the mail: " + ex.Message, 1);
                    break;
                }

                var cmd = db.CreateCommand();
                cmd.CommandText = "UPDATE gn_user SET requestmail=1, requestedmail=? WHERE id=" + m_UID;
                cmd.Parameters.AddWithValue("@requestedmail", mail);
                cmd.ExecuteNonQuery();
                //db.Kill();

                (this.Master as RPLL.MasterPage).setNotifaction("Please verfiy it at your old mail!", 3);
            }
            break;

        case 4:
            m_Table.Append("<table class=\"table noborder bbdesign\"><tbody>");
            dr = db.Query("SELECT name, mail, timestamp, subject, content FROM gn_contact ORDER BY id DESC").ExecuteReaderRpll();
            while (dr.Read())
            {
                m_Table.Append("<tr><td>" + dr.GetString(0) + "</td><td>" + dr.GetString(1) + "</td><td>" + DateTimeOffset.FromUnixTimeSeconds(dr.GetInt64(2)).UtcDateTime + "</td></tr>" +
                               "<tr><td colspan=\"3\">" + dr.GetString(3) + "</td></tr>" +
                               "<tr><td colspan=\"3\">" + dr.GetString(4) + "</td></tr>" +
                               "<tr><td colspan=\"3\"></td></tr>");
            }

            m_Table.Append("</tbody></table>");
            dr.CloseRpll();
            break;

        case 5:
            if (IsPostBack)
            {
                string name    = Utility.SecureInput(pmUsername.Value);
                string nameOld = Utility.SecureInput(pmUsernameOld.Value);
                string oldPass = Utility.SecureInput(pmOldPassUN.Value);

                if (name == "" || nameOld == "" || oldPass == "")
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Input is empty!", 2);
                    return;
                }

                if (name != pmUsername.Value ||
                    nameOld != pmUsernameOld.Value ||
                    oldPass != pmOldPassUN.Value ||
                    nameOld != m_Name
                    )
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Invalid characters!", 2);
                    return;
                }

                if (BCryptHelper.HashPassword(oldPass, "obscurred") != m_Pass)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Password incorrect!", 1);
                    return;
                }

                string newPass = BCryptHelper.HashPassword(pmPass.Value, "obscurred");
                db.Query("UPDATE gn_user SET name = \"" + name + "\", uhash=\"" + Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(name + m_Pass, "obscurred"))) + "\" WHERE id=" + m_UID).ExecuteNonQuery();
                //db.Kill();
                if (App.m_User.ContainsKey(m_UID))
                {
                    App.m_User[m_UID].Name = name;
                }
                (this.Master as RPLL.MasterPage).setNotifaction("Username has been changed! Make sure to redownload the config.txt!", 3);
            }
            break;

        case 6:
            m_Table.Append("<table class=\"table noborder bbdesign\"><thead>" +
                           "<tr>" +
                           "<th>Time</th>" +
                           "<th>Type</th>" +
                           "<th>Link</th>" +
                           "</tr>" +
                           "</thead><tbody>");
            dr = db.Query(
                "SELECT * FROM (SELECT a.timestamp, IFNULL(c.instanceid, IFNULL(IF(d.uploaderid > 0, 1, 0), 0)), IFNULL(c.id, 0), IFNULL(b.id, 0), (0) AS EXPANSION, a.userid FROM RPLL_VANILLA.gn_uploader a LEFT JOIN RPLL_VANILLA.rs_instance_uploader b ON a.id = b.uploaderid LEFT JOIN RPLL_VANILLA.rs_instances c ON b.instanceid = c.id LEFT JOIN RPLL_VANILLA.rs_progress d ON d.uploaderid = a.id UNION ALL SELECT a.timestamp, IFNULL(c.instanceid, IFNULL(IF(d.uploaderid > 0, 1, 0), 0)), IFNULL(c.id, 0), IFNULL(b.id, 0), (1) AS EXPANSION, a.userid FROM RPLL_TBC.gn_uploader a LEFT JOIN RPLL_TBC.rs_instance_uploader b ON a.id = b.uploaderid LEFT JOIN RPLL_TBC.rs_instances c ON b.instanceid = c.id LEFT JOIN RPLL_TBC.rs_progress d ON d.uploaderid = a.id) qq WHERE qq.userid = " + m_UID + " ORDER BY qq.timestamp DESC LIMIT 50")
                 .ExecuteReaderRpll();
            while (dr.Read())
            {
                m_Table.Append("<tr>" +
                               "<td>" + DateTimeOffset.FromUnixTimeMilliseconds(dr.GetInt64(0)).UtcDateTime.ToString() + " (" + dr.GetInt64(0) + ")</td>" +
                               "<td>" + (dr.GetInt16(1) == 0 ? "Dismissed or Armory only" : (dr.GetInt16(1) == 1) ? "Processing" : App.m_Instances[dr.GetInt16(1)].Name) + "</td>" +
                               "<td>" + (dr.GetInt32(2) == 0 ? "None" : "<a href=\"/Raids/Viewer/?id=" + dr.GetInt32(2) + "&upl=" + dr.GetInt32(3) + "&exp=" + dr.GetInt16(4) + "\">click</a>") + "</td>" +
                               "</tr>");
            }
            dr.CloseRpll();
            m_Table.Append("</tbody></table>");
            break;

        case 7:
            if (Request["default"] != null)
            {
                db.Query("UPDATE gn_user SET defaultpriv = " + (Request["default"] == "Make private" ? "1" : "0") + " WHERE id = " + m_UID + ";").ExecuteNonQuery();
                m_Private = Request["default"] == "Make private";
            }
            foreach (string key in Request.Form)
            {
                if (key == "default")
                {
                    break;
                }
                var value = Request[key];
                if (value != null)
                {
                    var  token  = key.Split(',');
                    int  exp    = int.Parse(token[1]);
                    int  upid   = int.Parse(token[2]);
                    bool result = value == "Make private";
                    KeyValuePair <int, bool> srch = new KeyValuePair <int, bool>(upid, !result);

                    var inst = App.mRSInstances[exp].Where(x => x.mPrivate.Contains(srch)).First();

                    int index = 0;
                    foreach (var upl in inst.mPrivate)
                    {
                        if (upl.Key == srch.Key && upl.Value == srch.Value)
                        {
                            break;
                        }
                        ++index;
                    }

                    inst.mPrivate[index] = new KeyValuePair <int, bool>(upid, result);

                    db.Query("UPDATE " + (exp == 0 ? "RPLL_VANILLA" : "RPLL_TBC") + ".rs_instance_uploader SET private = " + (result ? "1" : "0") + " WHERE id = " + upid + ";").ExecuteNonQuery();
                    break;
                }
            }

            m_Table.Append("<form action=\"\" method=\"post\">");
            // Private logs
            dr = db.Query("SELECT * FROM (SELECT a.id, a.instanceid as inida, (0) as exp, c.instanceid as inidb, c.end, a.private FROM RPLL_VANILLA.rs_instance_uploader a JOIN RPLL_VANILLA.gn_uploader b ON a.uploaderid = b.id JOIN RPLL_VANILLA.rs_instances c ON a.instanceid = c.id WHERE b.userid = " + m_UID +
                          " UNION ALL " +
                          "SELECT d.id, d.instanceid as inidc, (1) as exp, f.instanceid as inidd, f.end, d.private FROM RPLL_TBC.rs_instance_uploader d JOIN RPLL_TBC.gn_uploader e ON d.uploaderid = e.id JOIN RPLL_TBC.rs_instances f ON d.instanceid = f.id WHERE e.userid = " + m_UID + ") a ORDER BY a.end DESC").ExecuteReaderRpll();
            m_Table.Append("Default: <input type=\"submit\" value=\"" + (!m_Private ? "Make private" : "Make public") + "\" name=\"default\" /><br /><br />");
            m_Table.Append("<table class=\"table noborder bbdesign\" id=\"privateLogs\">" +
                           "<thead><tr><td>ID</td><td>Instance</td><td>Date</td><td>Toggle</td></tr></thead>" +
                           "<tbody>");

            while (dr.Read())
            {
                m_Table.Append("<tr><td><a href=\"/Raids/Viewer/?id=" + dr.GetInt32(0) + "&upl=" + dr.GetInt32(1) + "&exp=" + dr.GetInt16(2) + "\">" + dr.GetInt32(0) + "</a></td><td>" + App.m_Instances[dr.GetInt16(3)].Name + "</td><td>" + DateTimeOffset.FromUnixTimeMilliseconds(dr.GetInt64(4)).UtcDateTime
                               .ToString(CultureInfo.CurrentCulture) + "</td><td><input type=\"submit\" name=\"t," + dr.GetInt32(2) + "," + dr.GetInt32(0) + "\" value=\"" + (dr.GetInt16(5) == 0 ? "Make private" : "Make public") + "\" /></td></tr>");
            }

            m_Table.Append("</tbody></table>");
            m_Table.Append("</form>");
            dr.CloseRpll();
            break;

        case 8:
            // Poll participation
            foreach (string key in Request.Form)
            {
                var value = Request[key];
                if (value == null)
                {
                    continue;
                }

                var token = key.Split(',');
                int id    = int.Parse(token[1]);

                db.Query("UPDATE gn_user SET pollselection = " + id + " WHERE id=" + m_UID + ";").ExecuteNonQuery();
                break;
            }

            // Potentially slow
            dr = db.Query("SELECT item, (SELECT COUNT(*) FROM gn_user WHERE pollselection = a.id) AS votes, id FROM gn_poll a").ExecuteReaderRpll();
            m_Table.Append("<form action=\"\" method=\"post\">" +
                           "<h1 style=\"margin-top: 0;\">What should I focus on next?</h1>" +
                           "<table class=\"table noborder bbdesign\" id=\"poll\">" +
                           "<thead><tr><td>Question</td><td>Votes</td><td></td></tr></thead>" +
                           "<tbody>");
            while (dr.Read())
            {
                m_Table.Append("<tr>" +
                               "<td>" + dr.GetString(0) + "</td>" +
                               "<td>" + dr.GetInt32(1) + "</td>" +
                               "<td><input type=\"submit\" name=\"t," + dr.GetInt32(2) + "\" value=\"Vote\" /></td>" +
                               "</tr>");
            }
            m_Table.Append("</tbody>" +
                           "</table></form>");
            dr.CloseRpll();
            break;

        default:
            m_Table.Append(
                "<table class=\"noborder\" style=\"font-size: 18px;\"><tbody>" +
                "<tr><td>Name:</td><td>" + m_Name + "</td></tr> " +
                "<tr><td>E-Mail:</td><td>" + m_Mail + "</td></tr>" +
                "<tr><td>Level:</td><td>" + m_Levels[m_Level] + "</td></tr>" +
                "<tr><td>Registered:</td><td>Since " + DateTimeOffset.FromUnixTimeSeconds(m_Registerd).UtcDateTime + "</td></tr>" +
                ((m_Patreon > 0) ? "<tr><td>Patreon:</td><td>Since " + DateTimeOffset.FromUnixTimeSeconds(m_Patreon).UtcDateTime + "</td></tr>" : "<tr><td>Patreon:</td><td><a href=\"https://www.patreon.com/legacyplayers\">Become one now</a></td></tr>") +
                "<tr><td>Launcher-UID:</td><td>" + m_UID.ToString("X") + "</td></tr>" +
                "<tr><td><a href=\"?logout=true\">Log Out</a></td><td></td></tr>" +
                "</tbody></table>");
            break;
        }
    }
Exemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        this.Title = "LegacyPlayers | Raids";

        m_CurPage = Int32.Parse(Utility.GetQueryString(Request, "page", "0"));
        m_CharID  = Int32.Parse(Utility.GetQueryString(Request, "charid", "0"));

        if (!App.m_Chars.ContainsKey(m_CharID))
        {
            Response.Redirect("/404/");
            return;
        }

        int toLeft = 0;

        if (m_CurPage >= 10)
        {
            toLeft = m_CurPage - 10;
        }
        for (int i = toLeft; i < toLeft + 22; ++i) // Sometimes there may not that many pages
        {
            if (i != m_CurPage)
            {
                m_PageBar.Append("<a href=\"?page=" + i + "&charid=" + m_CharID + "\"><div class=\"bbdesign placeholder\" >" + (i + 1) +
                                 "</div></a>");
            }
            else
            {
                m_PageBar.Append("<a href=\"?page=" + i + "&charid=" + m_CharID + "\"><div class=\"bbdesign placeholder\" style=\"color:#f28f45\">" + (i + 1) +
                                 "</div></a>");
            }
        }

        var             expansion = App.GetChar(m_CharID).Expansion();
        SQLWrapper      DB        = App.GetDB(expansion + 1);
        MySqlDataReader dr        =
            DB.Query(
                "SELECT b.instanceid FROM rs_participants a " +
                "LEFT JOIN rs_instance_uploader b ON a.uploaderid = b.id " +
                "WHERE a.charid = " + m_CharID + " GROUP BY b.instanceid ORDER BY b.instanceid DESC LIMIT " + (m_CurPage * 20) + ", 20").ExecuteReaderRpll();
        var imgType = Utility.GetImageType(Request, "png");

        while (dr.Read())
        {
            // Finding the raid
            // Note: I could also have used linq and removed the loop :/
            foreach (var raid in App.mRSInstances[expansion])
            {
                if (raid.mId != dr.GetInt32(0))
                {
                    continue;
                }
                m_Table.Append("<tr><td><div class=\"sp bbdesign\" style=\"background:url(/Assets/raids/" + raid.mInstanceId +
                               "." + imgType + ")\"><div><a href=\"/Raids/Viewer/?id=" + raid.mId + "&exp=" +
                               expansion + "\">" + App.m_Instances[raid.mInstanceId].Name + "</a></div></div></td>" +
                               "<td><div class=\"sp\" style=\"background:url(/Assets/general/fac" +
                               App.GetChar(m_CharID).Faction + "_32." + imgType + ")\"><div>" +
                               App.GetGuild(raid.mGuildId).Name + "</div></div></td>" +
                               "<td>" + DateTimeOffset.FromUnixTimeMilliseconds(raid.mEnd).UtcDateTime +
                               "</td></tr>");
                break;
            }
        }
        dr.CloseRpll();
    }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        this.Title = "LegacyPlayers | Bosses";
        //App.UpdateRaidSpecificData();
        //App.GetChar(0, true);
        //App.GetGuild(0, true);
        Utility.GetClassList(ref pmClass);
        Utility.GetFactionList(ref pmFaction);
        Utility.GetExpansionList(ref pmExpansion);

        if (IsPostBack)
        {
            Utility.SetCookie(Response, Request, "Bosses_Class", pmClass.Value);
            Utility.SetCookie(Response, Request, "Bosses_Faction", pmFaction.Value);
            Utility.SetCookie(Response, Request, "Bosses_Realm", pmRealm.Value);
            Utility.SetCookie(Response, Request, "Bosses_Expansion", pmExpansion.Value);
        }
        else
        {
            pmClass.Value     = Utility.GetCookie(Request, "Bosses_Class", "0");
            pmFaction.Value   = Utility.GetCookie(Request, "Bosses_Faction", "0");
            pmRealm.Value     = Utility.GetCookie(Request, "Bosses_Realm", "0");
            pmExpansion.Value = Utility.GetCookie(Request, "Bosses_Expansion", "0");
        }

        int expansion = Int32.Parse(pmExpansion.Value);

        Utility.GetRealmList(ref pmRealm, false, expansion);

        var db = App.GetDB(expansion + 1);
        // TODO improve query
        MySqlDataReader dr      = db.Query("SELECT a.npcid, c.instanceid, MIN((a.end-a.start)), MAX(a.id), COUNT(a.id) FROM rs_attempts a JOIN rs_instance_uploader b ON a.uploaderid = b.id JOIN rs_instances c ON b.instanceid = c.id WHERE a.killed=1 GROUP BY a.npcid ORDER BY c.instanceid, a.npcid").ExecuteReaderRpll();
        var             query   = App.m_Rankings.AsQueryable();
        var             skQuery = App.m_SpeedkillRankings.AsQueryable();

        if (pmRealm.Value != "0")
        {
            short id = 0;
            if (short.TryParse(pmRealm.Value, out id) && id != 0)
            {
                query   = query.Where(x => App.GetChar(x.CharID, false).ServerID == id);
                skQuery = skQuery.Where(x => App.GetGuild(x.GuildID, false).ServerID == id);
            }
        }
        if (pmFaction.Value != "0")
        {
            short id = 0;
            if (short.TryParse(pmFaction.Value, out id) && id != 0)
            {
                query   = query.Where(x => App.GetChar(x.CharID, false).Faction == id);
                skQuery = skQuery.Where(x => App.GetGuild(x.GuildID, false).Faction == id);
            }
        }
        if (pmClass.Value != "0")
        {
            short id = 0;
            if (short.TryParse(pmClass.Value, out id) && id != 0)
            {
                query = query.Where(x => App.GetChar(x.CharID, false).RefMisc.Class == id - 1);
            }
        }

        var npcspecific   = query.GroupBy(x => x.NpcID).ToDictionary(x => x.Key, x => x.ToArray());
        var spkillspecifc = skQuery.GroupBy(x => x.NpcID).ToDictionary(x => x.Key, x => x.OrderBy(y => y.Best.Time).ToArray());

        while (dr.Read())
        {
            try
            {
                var _id = dr.GetInt32(0);
                if (!npcspecific.ContainsKey(_id))
                {
                    continue;
                }
                var dpsArr = npcspecific[_id].Where(x => x.Type == 0)
                             .OrderByDescending(x => 1000.0 * x.Best.Value / x.Best.Time);
                var hpsArr = npcspecific[_id].Where(x => x.Type == 1)
                             .OrderByDescending(x => 1000.0 * x.Best.Value / x.Best.Time);

                DB_Rankings          dps = dpsArr.Any() ? dpsArr.First() : App.m_Rankings[0];
                DB_Rankings          hps = hpsArr.Any() ? hpsArr.First() : App.m_Rankings[0];
                DB_SpeedkillRankings sk  = spkillspecifc.ContainsKey(_id) ? spkillspecifc[_id].First() : App.m_SpeedkillRankings[0];
                var imgType = Utility.GetImageType(Request, "png");
                m_Table.Append(
                    "<tr><td><div class=\"sp bbdesign\" style=\"background-image:url(/Assets/raids/" + dr.GetInt16(1) + "." + imgType + ")\"><div>" +
                    App.m_Instances[dr.GetInt16(1)].Name +
                    "</div></div></td><td>" + App.GetNpc(dr.GetInt32(0), expansion).Name + "</td>" +
                    "<td><a href=\"/Raids/Viewer/?atmt=" + dps.Best.Attempt + "&exp=" + expansion + "\" onmouseover=\"tt_show(this, 5, " +
                    dps.CharID + ", [])\" class=\"color-c" + App.GetChar(dps.CharID, false).RefMisc.Class + "\">" + App.GetChar(dps.CharID, false).Name + " (" +
                    Math.Round(1000.0 * dps.Best.Value / dps.Best.Time, 1) +
                    ")</a></td><td><a href=\"/Raids/Viewer/?atmt=" + hps.Best.Attempt +
                    "&exp=" + expansion + "\" onmouseover=\"tt_show(this, 5, " + hps.CharID + ", [])\" class=\"color-c" + App.GetChar(hps.CharID, false).RefMisc.Class + "\">" +
                    App.GetChar(hps.CharID, false).Name + " (" +
                    Math.Round(1000.0 * hps.Best.Value / hps.Best.Time, 1) + ")</a></td>" +
                    "<td><a href=\"/Raids/Viewer/?atmt=" +
                    sk.Best.Attempt + "&exp=" + expansion + "\">" + Math.Round(sk.Best.Time / 1000.0, 2) +
                    " seconds</a></td><td><a href=\"/Raids/?atmt=" + dr.GetInt32(3) + "&exp=" + expansion + "\">" + dr.GetInt32(4) +
                    "</a></td></tr>");
            }
            catch (ArgumentOutOfRangeException ee)
            {
                Response.Write(ee.Message + "<br /><br />");
            }
        }

        dr.CloseRpll();
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "LegacyPlayers | Forgot Password";

        string token = Utility.GetQueryString(Request, "token", "");

        if (!string.IsNullOrEmpty(token))
        {
            byte[] buffer = Base32.Decode(token);
            token = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);
            var             tempDB = App.GetDB();
            MySqlDataReader der    = tempDB.Query("SELECT id, name, mail FROM gn_user WHERE requestForgot = 1").ExecuteReaderRpll();
            while (der.Read())
            {
                int id = der.GetInt32(0);
                if (token == BCryptHelper.HashPassword(id.ToString(), "obscurred"))
                {
                    string      newPass  = Utility.RandomString(12);
                    string      username = der.GetString(1);
                    string      from     = "*****@*****.**";
                    MailMessage message  = new MailMessage(from, der.GetString(2));
                    der.CloseRpll();
                    message.Subject = "Legacyplayers forgot password";
                    message.Body    =
                        @"Hey " + username + "!\nThis is your new password: "******" \nPlease change it in the account panel.";
                    SmtpClient client = new SmtpClient("smtp.legacyplayers.com");
                    client.Send(message);

                    newPass = BCryptHelper.HashPassword(newPass, "obscurred");
                    // Setting flag in DB
                    SQLWrapper dbb = App.GetDB();
                    dbb.Query("UPDATE gn_user SET requestforgot=0, pass=\"" + newPass + "\", uhash=\"" + Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(username + newPass, "obscurred"))) + "\" WHERE id=" + id).ExecuteNonQuery();
                    // Updating user data
                    App.m_User[id].uHash =
                        Base32.Encode(System.Text.Encoding.UTF8.GetBytes(
                                          BCryptHelper.HashPassword(username + newPass, "obscurred")));
                    //dbb.Kill();
                    (this.Master as RPLL.MasterPage).setNotifaction("Your new password has been send to your mail account!", 3);
                    return;
                }
            }
            der.CloseRpll();
            return;
        }

        if (!IsPostBack)
        {
            return;
        }

        pmMail.Value = Utility.SecureInput(pmMail.Value);

        if (!pmMail.Value.Contains("@") || !pmMail.Value.Contains("."))
        {
            return;
        }

        SQLWrapper db     = App.GetDB();
        var        exists = db.CreateCommand();

        exists.CommandText = "SELECT id FROM gn_user WHERE mail=?";
        exists.Parameters.AddWithValue("@mail", pmMail.Value);
        MySqlDataReader dr = exists.ExecuteReaderRpll();

        if (!dr.HasRows)
        {
            dr.CloseRpll();
            (this.Master as RPLL.MasterPage).setNotifaction("A mail has been send to " + pmMail.Value + "!", 3);
            return;
        }
        if (dr.Read())
        {
            var id = dr.GetInt32(0);
            dr.CloseRpll();
            Utility.SendMail("*****@*****.**", pmMail.Value, "Legacyplayers forgot password utility",
                             "Hey there! <br />You need to verify your identity before we can reset your password. <br />To do so, please click this link. <br />Link: https://legacyplayers.com/Account/Forgot/?token=" +
                             Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(id.ToString(),
                                                                                                        "obscurred"))) + " <br />cheers!");

            // Setting flag in DB
            // TODO: Add DB support
            db.Query("UPDATE gn_user SET requestforgot=1 WHERE id=" + id).ExecuteNonQuery();
            //db.Kill();
            (this.Master as RPLL.MasterPage).setNotifaction("A mail has been send to " + pmMail.Value + "!", 3);
        }
    }
Exemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        if ((this.Master as MasterPage).ValidForAds())
        {
            mAds = "<ins class=\"adsbygoogle\" style=\"display:inline-block;width:336px; height: 280px; margin: 0 auto;\" data-ad-client=\"ca-pub-5192077039791210\" data-ad-slot=\"1818372262\"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>";
        }

        Utility.GetTypeList(ref pmMode);
        imgType    = Utility.GetImageType(Request, "png");
        imgType2   = Utility.GetImageType(Request);
        this.Title = "LegacyPlayers | Armory";
        //App.UpdateRaidSpecificData();
        m_CharID = Int32.Parse(Utility.GetQueryString(Request, "charid", "0"));
        //m_GearID = Int32.Parse(Utility.GetQueryString(Request, "gearid", "0"));

        if (!App.m_Chars.ContainsKey(m_CharID))
        {
            Response.Redirect("/404/");
            return;
        }

        m_Me = App.GetChar(m_CharID);
        var preSorted = App.m_AmData[m_Me.Expansion()].Where(x => x.Value.CharID == m_CharID).OrderByDescending(x => x.Value.Uploaded);
        var amData    = preSorted.Select(x => x.Value);

        // Professions
        if (m_Me.Expansion() > 0)
        {
            // Current spec
            string[] current    = m_Me.RefMisc.Talents.Split(';');
            int      specIndex1 = 0;
            if (current.Length >= 4)
            {
                int s1 = 0;
                int s2 = 0;
                int s3 = 0;
                int.TryParse(current[1], out s1);
                int.TryParse(current[2], out s2);
                int.TryParse(current[3], out s3);
                if (s1 > s2 && s1 > s3)
                {
                    specIndex1 = m_Me.RefMisc.Class * 3;
                }
                else if (s2 > s1 && s2 > s3)
                {
                    specIndex1 = m_Me.RefMisc.Class * 3 + 1;
                }
                else if (s3 > s2 && s3 > s1)
                {
                    specIndex1 = m_Me.RefMisc.Class * 3 + 2;
                }
            }

            // Finding a second one that is not the first one
            int      specIndex2 = 0;
            string[] lastOne    = null;
            if (preSorted.Count() > 1)
            {
                var first            = preSorted.First().Key;
                var otherThanCurrent = preSorted.Where(x => x.Key != first);
                if (otherThanCurrent.Any())
                {
                    lastOne = App.m_RefMisc[m_Me.Expansion()][otherThanCurrent.First().Value.Ref_Misc].Talents.Split(';');

                    if (lastOne.Length >= 4)
                    {
                        int l1 = 0;
                        int l2 = 0;
                        int l3 = 0;
                        int.TryParse(lastOne[1], out l1);
                        int.TryParse(lastOne[2], out l2);
                        int.TryParse(lastOne[3], out l3);
                        if (l1 > l2 && l1 > l3)
                        {
                            specIndex2 = m_Me.RefMisc.Class * 3;
                        }
                        else if (l2 > l1 && l2 > l3)
                        {
                            specIndex2 = m_Me.RefMisc.Class * 3 + 1;
                        }
                        else if (l3 > l2 && l3 > l1)
                        {
                            specIndex2 = m_Me.RefMisc.Class * 3 + 2;
                        }
                    }
                }
            }

            mTalents =
                "<table class=\"table noborder bbdesign bigger\"> <thead> <tr>" +
                "<td colspan=\"2\">Talent specialization</td> </tr> </thead> <tbody> <tr> " +
                (current.Length < 4 ? "<td><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/inv_misc_questionmark.jpg\')\"><div>Unknown</div></div></td>" :
                 "<td><a href=\"/Tools/Talents/#" + current[0] + "\"><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/" + mSpecIcons[specIndex1] + ".jpg\')\"><div>" + mSpecs[specIndex1] + " (" + current[1] + "|" + current[2] + "|" + current[3] + ")</div></div></a></td> ") +
                "<td>" +
                (lastOne == null || lastOne.Length < 4 ?
                 "<div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/inv_misc_questionmark.jpg\')\"><div>Unknown</div></div>"
                :
                 "<a href=\"/Tools/Talents/#" + lastOne[0] + "\"><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/" + mSpecIcons[specIndex2] + ".jpg\')\"><div>" + mSpecs[specIndex2] + " (" + lastOne[1] + "|" + lastOne[2] + "|" + lastOne[3] + ")</div></div></a>") +
                "</td> </tr> </tbody> </table>";
        }
        else
        {
            int    cur              = 1;
            int    last             = 1;
            string current          = m_Me.RefMisc.Talents;
            var    first            = preSorted.First().Key;
            var    otherThanCurrent = preSorted.Where(x => x.Key != first);
            string lastOne          = "0";
            if (otherThanCurrent.Any())
            {
                lastOne = otherThanCurrent.First().Value.Ref_Misc == 0
                    ? "0"
                    : App.m_RefMisc[m_Me.Expansion()][otherThanCurrent.First().Value.Ref_Misc].Talents;
            }
            int.TryParse(lastOne, out last);
            int.TryParse(current, out cur);
            mTalents =
                "<table class=\"table noborder bbdesign bigger\"> <thead> <tr>" +
                "<td colspan=\"2\">Talent specialization</td> </tr> </thead> <tbody> <tr> " +
                (current == "0" ? "<td><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/inv_misc_questionmark.jpg\')\"><div>Unknown</div></div></td>" :
                 "<td><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/" + mSpecIcons[cur - 1] + ".jpg\')\"><div>" + mSpecs[cur - 1] + "</div></div></td> ") +
                "<td>" +
                (lastOne == "0" ?
                 "<div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/inv_misc_questionmark.jpg\')\"><div>Unknown</div></div>"
                    :
                 "<div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/" + mSpecIcons[last - 1] + ".jpg\')\"><div>" + mSpecs[last - 1] + "</div></div>") +
                "</td> </tr> </tbody> </table>";
        }


        // Professions
        mProfs =
            "<table class=\"table noborder bbdesign bigger\"> <thead> <tr> " +
            "<td colspan=\"2\">Professions</td> </tr> </thead> <tbody> <tr> " +
            "<td><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/" + mProfIconList[m_Me.Prof1] + ".jpg\')\"><div>" + mProfNameList[m_Me.Prof1] + "</div></div></td> " +
            "<td><div class=\"sp icon-32 bbdesign\" style=\"background-image: url(\'/Assets/icons/" + mProfIconList[m_Me.Prof2] + ".jpg\')\"><div>" + mProfNameList[m_Me.Prof2] + "</div></div></td> " +
            "</tr> </tbody> </table>";

        m_GearID = m_Me.RefGear.GearId;

        // Getting the last 3 itemsets
        int rankingMode = 0;

        if (IsPostBack)
        {
            Int32.TryParse(itemsets.Value, out m_GearID);
            Int32.TryParse(pmMode.Value, out rankingMode);
        }

        itemsets.Items.Clear();
        var sets = amData.GroupBy(x => x.Ref_Gear).Take(5)
                   .ToArray();

        for (int i = 0; i < sets.Length; ++i)
        {
            itemsets.Items.Add(new ListItem("Itemset " + i, sets[i].Key.ToString()));
        }
        itemsets.SelectedIndex = itemsets.Items.IndexOf(itemsets.Items.FindByValue(m_GearID.ToString()));

        if (m_GearID == 0 || !App.m_RefGear[m_Me.Expansion()].ContainsKey(m_GearID))
        {
            m_Gear = m_Me.RefGear;
        }
        else
        {
            m_Gear = App.m_RefGear[m_Me.Expansion()][m_GearID];
        }

        int[] itemparts = Utility.GetCookie(Request, "viewhead", "0") != "true" ? new[] { 0, 2, 4, 3, 18, 8, 9, 5, 6, 7, 15, 16 } : new[] { 2, 4, 3, 18, 8, 9, 5, 6, 7, 15, 16 };
        foreach (int i in itemparts)
        {
            if (m_Gear.Slots[i].ItemID <= 0)
            {
                continue;
            }
            // [3, 58860], [16, 48190], [5, 60895], [19, 58700], [9, 61476], [10, 60915], [6, 61471], [7, 60898], [8, 61473], [13, 30606], [14, 51721]
            if (m_ItemDisplayArr == "")
            {
                m_ItemDisplayArr = "[" + (i + 1) + "," + App.m_ItemDisplayID[m_Gear.Slots[i].ItemID] + "]";
            }
            else
            {
                m_ItemDisplayArr += ", [" + (i + 1) + "," + App.m_ItemDisplayID[m_Gear.Slots[i].ItemID] + "]";
            }
        }

        // Guild history
        var guilds = amData.Where(x => x.Ref_Guild > 0).GroupBy(x => x.Ref_Guild).Take(5);

        foreach (IGrouping <int, DB_am_data> t in guilds)
        {
            m_GuildHistory.Append("<tr><td><div class=\"sp icon-32\" style=\"background-image: url('/Assets/raids/fac" + App.m_Guilds[App.m_RefGuild[m_Me.Expansion()][t.Key].GuildID].Faction + "." + imgType + "')\"><div>" + App.m_Guilds[App.m_RefGuild[m_Me.Expansion()][t.Key].GuildID].Name + "</div></div></td>");
            m_GuildHistory.Append("<td>" + App.m_RefGuild[m_Me.Expansion()][t.Key].GrankName + " (" + App.m_RefGuild[m_Me.Expansion()][t.Key].GrankIndex + ")</td></tr>");
        }

        // Attended raids
        SQLWrapper      DB = App.GetDB(m_Me.Expansion() + 1);
        MySqlDataReader dr =
            DB.Query(
                "SELECT b.instanceid FROM rs_participants a " +
                "LEFT JOIN rs_instance_uploader b ON a.uploaderid = b.id " +
                "WHERE a.charid = " + m_CharID + " GROUP BY b.instanceid ORDER BY b.instanceid DESC LIMIT 5").ExecuteReaderRpll();

        while (dr.Read())
        {
            // Finding the raid
            foreach (var raid in App.mRSInstances[m_Me.Expansion()])
            {
                if (raid.mId != dr.GetInt32(0))
                {
                    continue;
                }
                m_AttendedRaidsTable.Append("<tr><td>" + App.m_Instances[raid.mInstanceId].Name + "</td>" +
                                            "<td><a href=\"/Raids/Viewer/?id=" + raid.mId + "&exp=" +
                                            m_Me.Expansion() + "\">" +
                                            DateTimeOffset.FromUnixTimeMilliseconds(raid.mEnd).UtcDateTime +
                                            "</a></td></tr>");
                break;
            }
        }
        dr.CloseRpll();

        // Item history
        // This might be very slow the more data gets added, gotta watch this!
        Dictionary <int, bool> tempDone          = new Dictionary <int, bool>();
        Dictionary <int, bool> tempDone2         = new Dictionary <int, bool>();
        List <string>          m_HackItemHistory = new List <string>();
        var amDataAsc = amData.Where(x => x.Ref_Gear > 0).OrderBy(x => x.Uploaded).ToArray();

        foreach (DB_am_data t in amDataAsc)
        {
            if (tempDone.ContainsKey(t.Ref_Gear))
            {
                continue;
            }
            var    date        = DateTimeOffset.FromUnixTimeMilliseconds(t.Uploaded).UtcDateTime;
            string someHackStr = "";
            for (int p = 0; p < 19; ++p)
            {
                var item = App.m_RefGear[m_Me.Expansion()][t.Ref_Gear].Slots[p];
                if (item.ItemID <= 0 || tempDone2.ContainsKey(item.ItemID))
                {
                    continue;
                }
                someHackStr += "<div class=\"item-template-32 qe" + item.Item(m_Me.Expansion()).Quality +
                               "\" style=\"background-image: url('/Assets/icons/" + item.Item(m_Me.Expansion()).IconName +
                               "." + imgType2 + "');\"><a href=\"/Armory/Item/?i=" + item.ItemID + "&exp=" + m_Me.Expansion() + "\">" + item.Item(m_Me.Expansion()).Quantity(m_Me.ServerID) + "</a><a href=\"/Raids/Loot/?i=" +
                               item.ItemID + "&exp=" + m_Me.Expansion() + "\"><div onmouseover=\"tt_show(this, 1, " + item.ItemID +
                               ",[]," + m_Me.Expansion() + ")\"></div></a></div>";
                tempDone2[item.ItemID] = true;
            }
            if (someHackStr != "")
            {
                someHackStr = "<tr><td>" + someHackStr + "</td><td>" + date.Month + "/" + date.Day + "/" + date.Year + "</td></tr>";
                m_HackItemHistory.Add(someHackStr);
            }
            tempDone[t.Ref_Gear] = true;
        }
        for (int i = m_HackItemHistory.Count - 1; i >= 0 && i > m_HackItemHistory.Count - 10; --i)
        {
            m_ItemHistoryTable.Append(m_HackItemHistory[i]);
        }


        // Rankings
        var   rankingData  = App.m_Rankings.Where(x => x.Type == rankingMode && x.CharID == m_CharID).OrderByDescending(x => x.InstanceID).ThenBy(x => x.NpcID);
        short someInstance = 0;

        foreach (var row in rankingData)
        {
            if (someInstance != row.InstanceID && someInstance != 0)
            {
                m_Rankings.Append("</tbody></table>");
            }
            if (someInstance != row.InstanceID)
            {
                m_Rankings.Append("<table class=\"table noborder bbdesign\"><thead><tr><td colspan=\"6\">" + App.m_Instances[row.InstanceID].Name + "<div class=\"arrowdown\" onclick=\"ToggleRecordMenu('inst" + row.InstanceID + "')\">" +
                                  "</div></td></tr><tr><td>All</td><td>Class</td><td>Type</td><td>Best</td><td>Avg</td><td>Encounter</td></tr></thead>" +
                                  "<tbody id=\"inst" + row.InstanceID + "\" " + ((someInstance == 0) ? "style=\"display: table-header-group;\">" : ""));
            }
            someInstance = row.InstanceID;
            if (row.Best.Value > 5000)
            {
                m_Rankings.Append("<tr><td><a href=\"/Raids/Ranking/?npc=" + row.NpcID + "&exp=" + m_Me.Expansion() + "\">" + row.GetRank() + "</a></td><td><a href=\"/Raids/Ranking/?npc=" + row.NpcID + "&class=" + m_Me.RefMisc.Class + "&exp=" + m_Me.Expansion() + "\">" + row.GetClassRank() + "</a></td>" +
                                  "<td>" + ((row.Type == 0) ? "DPS" : row.Type == 1 ? "HPS" : "TPS") + "</td><td><a href=\"/Raids/Viewer/?atmt=" + row.Best.Attempt + "&exp=" + m_Me.Expansion() + "\">" + Math.Round(1000.0 * row.Best.Value / (row.Best.Time * (row.Type == 2 ? 100.0 : 1.0)), 1) + "</a></td>" +
                                  "<td>" + Math.Round(row.GetAverage() / (1000.0 * (row.Type == 2 ? 100.0 : 1.0)), 1) + "</td><td>" + App.m_Npcs[m_Me.Expansion()][row.NpcID].Name + "</td></tr>");
            }
        }
        m_Rankings.Append("</tbody></table>");


        // PvP Information
        if (m_Me.RefHonor == null)
        {
            return;
        }
        // Lifetime rank
        m_LifeTimeRank = m_Me.LifeTimeRank;
        // Today
        if (DateTimeOffset.FromUnixTimeMilliseconds(App.GetArmoryData(m_Me.LatestUpdate).Uploaded).Date == DateTime.Today)
        {
            foreach (var data in amData)
            {
                TimeSpan span = DateTime.Today - DateTimeOffset.FromUnixTimeMilliseconds(data.Uploaded).Date;
                if (span == TimeSpan.FromDays(1) && App.m_RefHonor[m_Me.Expansion()].ContainsKey(data.Ref_Honor))
                {
                    m_Today.HK    = m_Me.RefHonor.HK - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].HK;
                    m_Today.DK    = m_Me.RefHonor.DK - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].DK;
                    m_Today.Honor = m_Me.RefHonor.Honor - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].Honor;
                    break;
                }
                if (span > TimeSpan.FromDays(1))
                {
                    break;
                }
            }
        }
        // Yesterday
        DB_am_data yesterday = null;

        foreach (var data in amData)
        {
            TimeSpan span = DateTime.Today - DateTimeOffset.FromUnixTimeMilliseconds(data.Uploaded).Date;
            if (yesterday == null && span == TimeSpan.FromDays(2))
            {
                yesterday = data;
                continue;
            }
            if (yesterday != null && span == TimeSpan.FromDays(3) && App.m_RefHonor[m_Me.Expansion()].ContainsKey(yesterday.Ref_Honor) && App.m_RefHonor[m_Me.Expansion()].ContainsKey(data.Ref_Honor))
            {
                m_Yesterday.HK    = App.m_RefHonor[m_Me.Expansion()][yesterday.Ref_Honor].HK - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].HK;
                m_Yesterday.DK    = App.m_RefHonor[m_Me.Expansion()][yesterday.Ref_Honor].DK - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].DK;
                m_Yesterday.Honor = App.m_RefHonor[m_Me.Expansion()][yesterday.Ref_Honor].Honor - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].Honor;
                break;
            }
            if (yesterday == null && span > TimeSpan.FromDays(2))
            {
                break;
            }
        }
        // This week
        long lastReset = Utility.ConvertToTimestamp(DateTime.Today
                                                    .AddDays(-(int)DateTime.Today.DayOfWeek - 7 + App.m_Server[m_Me.ServerID].PvPReset).ToUniversalTime());
        DB_am_data thisWeekMark = null;

        foreach (var data in amData)
        {
            if (data.Uploaded >= lastReset && App.m_RefHonor[m_Me.Expansion()].ContainsKey(data.Ref_Honor))
            {
                m_ThisWeek.HK    = m_Me.RefHonor.HK - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].HK;
                m_ThisWeek.DK    = m_Me.RefHonor.DK - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].DK;
                m_ThisWeek.Honor = m_Me.RefHonor.Honor - App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].Honor;
            }
            else
            {
                thisWeekMark = data;
                break;
            }
        }
        // last week
        if (thisWeekMark != null)
        {
            long lastReset2 = Utility.ConvertToTimestamp(DateTime.Today
                                                         .AddDays(-(int)DateTime.Today.DayOfWeek - 7 + App.m_Server[m_Me.ServerID].PvPReset).ToUniversalTime());
            foreach (var data in amData)
            {
                if (m_LastWeek.Honor == 0 && data.Uploaded >= lastReset2 && data.Uploaded < lastReset && App.m_RefHonor[m_Me.Expansion()].ContainsKey(data.Ref_Honor))
                {
                    m_LastWeek          = App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor];
                    m_CurrentWeekChange = (int)(m_Me.RefHonor.Rank * 5000.0 + 5000.0 * m_Me.RefHonor.Progress / 1000.0 -
                                                m_LastWeek.Rank * 5000 +
                                                5000.0 * m_LastWeek.Progress / 1000.0);
                    continue;
                }
                if (data.Uploaded < lastReset2 && App.m_RefHonor[m_Me.Expansion()].ContainsKey(data.Ref_Honor))
                {
                    m_LastWeekChange = (int)(m_LastWeek.Rank * 5000.0 + 5000.0 * m_LastWeek.Progress / 1000.0 -
                                             App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].Rank * 5000 +
                                             5000.0 * App.m_RefHonor[m_Me.Expansion()][data.Ref_Honor].Progress / 1000.0);
                    break;
                }
            }
        }
        if (m_CurrentWeekChange == 0)
        {
            m_CurrentWeekChange = (int)(m_Me.RefHonor.Progress / 1000.0 * 5000.0);
        }
    }
Exemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "LegacyPlayers | Log In";

        if (!IsPostBack)
        {
            return;
        }
        try
        {
            string Username = Utility.SecureInput(pmName.Value);
            string Password = Utility.SecureInput(pmPass.Value);

            if (pmName.Value != Username || Password != pmPass.Value)
            {
                (this.Master as RPLL.MasterPage).setNotifaction("The username or password may be wrong.", 2);
                return;
            }

            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                (this.Master as RPLL.MasterPage).setNotifaction("The username or password may be wrong.", 2);
                return;
            }

            Password = BCryptHelper.HashPassword(Password,
                                                 "obscurred");

            SQLWrapper db = App.GetDB();

            var cmd = db.CreateCommand();
            cmd.CommandText = "SELECT accepted, id FROM gn_user WHERE BINARY name=? AND BINARY pass = ?";
            cmd.Parameters.AddWithValue("@name", Username);
            cmd.Parameters.AddWithValue("@pass", Password);
            MySqlDataReader dr = cmd.ExecuteReaderRpll();

            if (dr.Read())
            {
                if (dr.GetInt16(0) == 0)
                {
                    (this.Master as RPLL.MasterPage).setNotifaction("Please check your mail for a verification link!.", 2);
                    return;
                }
                Utility.SetCookie(Response, Request, "RPLL_username", Username);
                Utility.SetCookie(Response, Request, "RPLL_user", Base32.Encode(System.Text.Encoding.UTF8.GetBytes(BCryptHelper.HashPassword(Username + Password, "obscurred"))));

                // Redirect to account page
                int uid = dr.GetInt32(1);
                dr.CloseRpll();
                Response.Redirect("/Account/?uid=" + uid); // Should we really reveal this kind of data?
                return;
            }
            dr.CloseRpll();
            // Didnt find someone!
            (this.Master as RPLL.MasterPage).setNotifaction("The username or password may be wrong.", 2);
            return;
        }
        catch (Exception)
        {
            (this.Master as RPLL.MasterPage).setNotifaction("Some error occured, please try it later again!", 1);
            return;
        }
    }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!App.loaded && !Server.MapPath(".").ToLower().Contains("loading"))
        {
            try { Response.Redirect("/Loading/", false); Context.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return;
        }

        this.Title = "LegacyPlayers | Loot: Item";
        var imgType = Utility.GetImageType(Request, "png");

        m_CurPage = Int32.Parse(Utility.GetQueryString(Request, "page", "0"));
        int.TryParse(Utility.GetQueryString(Request, "item", "0"), out m_ItemID);

        int toLeft = 0;

        if (m_CurPage >= 10)
        {
            toLeft = m_CurPage - 10;
        }
        for (int i = toLeft; i < toLeft + 22; ++i) // Sometimes there may not that many pages
        {
            if (i != m_CurPage)
            {
                m_PageBar.Append("<a href=\"?page=" + i + "&item=" + m_ItemID + "\"><div class=\"bbdesign placeholder\" >" + (i + 1) +
                                 "</div></a>");
            }
            else
            {
                m_PageBar.Append("<a href=\"?page=" + i + "&item=" + m_ItemID + "\"><div class=\"bbdesign placeholder\" style=\"color:#f28f45\">" + (i + 1) +
                                 "</div></a>");
            }
        }

        if (m_ItemID == 0)
        {
            return;
        }

        for (int i = 0; i < 2; ++i)
        {
            SQLWrapper      db = App.GetDB(i + 1);
            MySqlDataReader dr = db
                                 .Query(
                "SELECT a.targetid, d.`guildid`, b.`npcid`, ROUND((d.start + b.end)/1000), a.`attemptid`, d.instanceid FROM rs_loot a " +
                "LEFT JOIN rs_attempts b ON a.`attemptid` = b.`id` " +
                "LEFT JOIN rs_instance_uploader c ON a.`uploaderid` = b.`uploaderid` " +
                "LEFT JOIN rs_instances d ON c.`instanceid` = d.`id`" +
                "WHERE a.itemid = " + m_ItemID).ExecuteReaderRpll();
            while (dr.Read())
            {
                m_Loot.Add(new DB_Loot()
                {
                    CharID     = dr.GetInt32(0),
                    GuildID    = dr.GetInt32(1),
                    NpcID      = dr.GetInt32(2),
                    TimeStamp  = (uint)dr.GetInt64(3),
                    AttemptID  = dr.GetInt32(4),
                    InstanceID = dr.GetInt16(5)
                });
            }
            dr.CloseRpll();
        }

        var query = m_Loot.OrderByDescending(x => x.TimeStamp).Skip(m_CurPage * 20).Take(20);

        foreach (var recent in query)
        {
            DBChars cr = App.GetChar(recent.CharID);
            m_RecentTable.Append("<tr class=\"tabf" + App.GetGuild(recent.GuildID).Faction + "\"><td><div class=\"sp bbdesign\" style=\"background-image:url(/Assets/raids/" + recent.InstanceID + "." + imgType + ")\">" +
                                 "<div>" + App.GetNpc(recent.NpcID, recent.InstanceID > 31 ? 1 : 0).Name + "</div></div></td>" +
                                 "<td><a href=\"/Armory/Guild/?guilid=" + recent.GuildID + "\" onmouseover=\"tt_show(this, 4, " + recent.GuildID + ",[])\">" + App.GetGuild(recent.GuildID).Name + "</a></td>" +
                                 "<td><a href=\"/Raids/?atmt=" + recent.AttemptID + "\">" + DateTimeOffset.FromUnixTimeSeconds(recent.TimeStamp).UtcDateTime + "</a></td></tr>");

            m_PlayerTable.Append("<tr class=\"tabf" + App.GetGuild(recent.GuildID).Faction + "\"><td><div class=\"sp bbdesign\" style=\"background-image:url(/Assets/racegender/" + cr.RefMisc.Gender + "-" + cr.RefMisc.Race + "." + imgType + ")\"></div><div class=\"sp bbdesign\" style=\"background-image:url(/Assets/classes/ccc" + cr.RefMisc.Class + "." + imgType + ")\">" +
                                 "<div><a href=\"/Armory/?charid=" + recent.CharID + "\" class=\"color-c" + cr.RefMisc.Class + "\" onmouseover=\"tt_show(this, 5, " + recent.CharID + ",[])\">" + cr.Name + "</div></div></td>" +
                                 "<td><a href=\"/Armory/Guild/?guilid=" + cr.RefGuild.GuildID + "\" onmouseover=\"tt_show(this, 4, " + cr.RefGuild.GuildID + ",[])\">" + App.GetGuild(cr.RefGuild.GuildID).Name + "</a></td>" +
                                 "<td>" + App.m_Server[cr.ServerID].Name + "</td>" +
                                 "<td><a href=\"/Raids/?atmt=" + recent.AttemptID + "\">" + DateTimeOffset.FromUnixTimeSeconds(recent.TimeStamp).UtcDateTime + "</a></td></tr>");
        }
    }
Exemplo n.º 13
0
        public static RaidData GetRaidData(int _RSInstanceID, int _RSUploaderID = 0, bool _PostVanilla = false)
        {
            var index = _PostVanilla ? 1 : 0;

            if (IsRequeusted(index, _RSInstanceID, _RSUploaderID))
            {
                var data = GetReuquestedData(index, _RSInstanceID, _RSUploaderID);
                if (data != null) // To integrate the timeout
                {
                    return(data);
                }
            }

            var tempDB = App.GetDB(index + 1);

            if (m_RaidData[index].ContainsKey(_RSInstanceID))
            {
                if (m_RaidData[index][_RSInstanceID].ContainsKey(_RSUploaderID))
                {
                    CachingController.RegisterRaidData(_RSInstanceID, index);
                    return(m_RaidData[index][_RSInstanceID][_RSUploaderID]);
                }

                if (_RSUploaderID > 0)
                {
                    MySqlDataReader dr = tempDB.Query("SELECT a.instanceid, a.guildid, a.start, a.end, b.lookupspace, a.id FROM rs_instances a LEFT JOIN rs_instance_uploader b ON a.id = b.instanceid WHERE b.id=" + _RSUploaderID).ExecuteReaderRpll();
                    if (dr.Read())
                    {
                        m_RaidData[index][_RSInstanceID][_RSUploaderID] = new RaidData(dr.GetInt32(0), dr.GetInt32(1), dr.GetInt64(2), dr.GetInt64(3), dr.GetString(4), dr.GetInt32(5), _RSUploaderID, index);
                        dr.CloseRpll();
                        CachingController.RegisterRaidData(_RSInstanceID, index);
                        return(m_RaidData[index][_RSInstanceID][_RSUploaderID]);
                    }
                    dr.CloseRpll();
                }

                CachingController.RegisterRaidData(_RSInstanceID, index);

                // Take the first non private log
                var LogInfo = App.mRSInstances[index].Where(x => x.mId == _RSInstanceID).First();
                if (LogInfo != null)
                {
                    var sth = m_Uploader[_RSInstanceID]
                              .Where(x => LogInfo.mPrivate.Where(y => !y.Value && y.Key == x.Key).Count() >= 1).ToArray();
                    if (sth.Length > 0)
                    {
                        if (m_RaidData[index][_RSInstanceID].ContainsKey(sth[0].Key))
                        {
                            return(m_RaidData[index][_RSInstanceID][sth[0].Key]);
                        }
                    }
                }

                try { HttpContext.Current.Response.Redirect("/Private/", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
                return(null);
            }
            MySqlDataReader drr = tempDB.Query("SELECT b.id, a.instanceid, a.guildid, a.start, a.end, b.lookupspace, a.id FROM rs_instances a LEFT JOIN rs_instance_uploader b ON a.id = b.instanceid WHERE a.id=" + _RSInstanceID).ExecuteReaderRpll();
            ConcurrentDictionary <int, RaidData> newData = new ConcurrentDictionary <int, RaidData>();

            var LogInfo2 = App.mRSInstances[index].Where(x => x.mId == _RSInstanceID).First();

            while (!drr.IsClosed && drr.Read()) // ?!
            {
                if (LogInfo2 != null)
                {
                    if (LogInfo2.mPrivate.Where(y => y.Value && y.Key == drr.GetInt32(0)).Count() >= 1)
                    {
                        continue;
                    }
                }

                newData[drr.GetInt32(0)] = new RaidData(drr.GetInt32(1), drr.GetInt32(2), drr.GetInt64(3), drr.GetInt64(4), drr.GetString(5), drr.GetInt32(6), drr.GetInt32(0), index);
                break; // Just load first one!
            }
            drr.CloseRpll();
            m_RaidData[index][_RSInstanceID] = newData;
            CachingController.RegisterRaidData(_RSInstanceID, index);

            // Take the first non private log
            if (LogInfo2 != null)
            {
                var sth2 = m_Uploader[_RSInstanceID]
                           .Where(x => LogInfo2.mPrivate.Where(y => !y.Value && y.Key == x.Key).Count() >= 1).ToArray();
                if (sth2.Length > 0)
                {
                    if (m_RaidData[index][_RSInstanceID].ContainsKey(sth2[0].Key))
                    {
                        return(m_RaidData[index][_RSInstanceID][sth2[0].Key]);
                    }
                }
            }

            try { HttpContext.Current.Response.Redirect("/Private/", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (System.Threading.ThreadAbortException) { }
            return(null);
        }
Exemplo n.º 14
0
        private RaidData(int _InstanceID, int _GuildID, long _Start, long _End, string _LookUpSpace, int _Id, int _Uploader, int _Index = 0)
        {
            RequestData(_Index, _Id, _Uploader);
            m_InstanceId = _Id;
            m_UploaderId = _Uploader;
            m_DB         = App.GetDB(_Index + 1);

            string[] Tokens = _LookUpSpace.Split('&');

            m_Instance = App.m_Instances[_InstanceID].Name;
            m_Guild    = App.GetGuild(_GuildID);
            m_Server   = App.m_Server[m_Guild.ServerID];
            m_Start    = _Start;
            m_End      = _End;

            string[] Offset = Tokens[0].Split(',');
            try
            {
                MySqlDataReader dr = m_DB
                                     .Query("SELECT id, npcid, start, end, killed FROM rs_attempts WHERE id>=" + Offset[0] +
                                            " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Attempts[dr.GetInt32(0)] = new RS_Attempts()
                    {
                        NpcId  = dr.GetInt32(1),
                        Start  = dr.GetInt32(2),
                        End    = dr.GetInt32(3),
                        Killed = dr.GetInt16(4) == 1
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "Attempts: " + ex.Message + "<br /><br />";
            }

            // TODO: Optimize these
            try
            {
                if (!m_Uploader.ContainsKey(_Id))
                {
                    m_Uploader[_Id] = new List <KeyValuePair <int, int> >();
                }

                MySqlDataReader dr = m_DB.Query("SELECT a.id, b.userid FROM rs_instance_uploader a LEFT JOIN gn_uploader b ON a.uploaderid = b.id WHERE a.instanceid=" + _Id).ExecuteReaderRpll();
                while (dr.Read())
                {
                    var kvp = new KeyValuePair <int, int>(dr.GetInt32(0), dr.GetInt32(1));
                    if (!m_Uploader[_Id].Contains(kvp))
                    {
                        m_Uploader[_Id].Add(kvp);
                    }
                }

                dr.CloseRpll();

                dr = m_DB.Query("SELECT charid FROM rs_participants WHERE uploaderid=" + _Uploader).ExecuteReaderRpll();
                while (!dr.IsClosed && dr.Read())
                {
                    m_Participants.Add(App.GetChar(dr.GetInt32(0)));
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_instance_uploader: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset           = Tokens[1].Split(',');
                m_SaReference[0] = new RS_Sa_Reference()
                {
                    SourceId  = 0,
                    AbilityId = 0
                };
                MySqlDataReader dr = m_DB.Query("SELECT id, sourceid, abilityid FROM rs_sa_reference WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_SaReference[dr.GetInt32(0)] = new RS_Sa_Reference()
                    {
                        SourceId  = dr.GetInt32(1),
                        AbilityId = dr.GetInt32(2)
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "RS_sa_reference: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset            = Tokens[2].Split(',');
                m_SatReference[0] = new RS_Sat_Reference()
                {
                    SourceId  = 0,
                    AbilityId = 0,
                    TargetId  = 0
                };
                MySqlDataReader dr = m_DB.Query("SELECT id, targetid, said FROM rs_sat_reference WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_SatReference[dr.GetInt32(0)] = new RS_Sat_Reference()
                    {
                        TargetId  = dr.GetInt32(1),
                        AbilityId = m_SaReference[dr.GetInt32(2)].AbilityId,
                        SourceId  = m_SaReference[dr.GetInt32(2)].SourceId,
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_sat_reference: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset             = Tokens[3].Split(',');
                m_SataReference[0] = new RS_Sata_Reference()
                {
                    SourceId        = 0,
                    AbilityId       = 0,
                    TargetId        = 0,
                    TargetAbilityId = 0
                };
                MySqlDataReader dr = m_DB.Query("SELECT id, targetabilityid, satid FROM rs_sata_reference WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_SataReference[dr.GetInt32(0)] = new RS_Sata_Reference()
                    {
                        TargetAbilityId = dr.GetInt32(1),
                        AbilityId       = m_SatReference[dr.GetInt32(2)].AbilityId,
                        SourceId        = m_SatReference[dr.GetInt32(2)].SourceId,
                        TargetId        = m_SatReference[dr.GetInt32(2)].TargetId
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_sata_reference: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset = Tokens[4].Split(',');
                MySqlDataReader dr = m_DB.Query("SELECT id, said, gained, faded FROM rs_auras WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Auras[dr.GetInt32(0)] = new RS_Auras()
                    {
                        SaRefId = dr.GetInt32(1),
                        Gained  = dr.GetInt32(2),
                        Faded   = dr.GetInt32(3)
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_auras: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset = Tokens[5].Split(',');
                MySqlDataReader dr = m_DB.Query("SELECT id, sourceid, timestamp FROM rs_deaths WHERE id>=" + Offset[0] + " AND id<" +
                                                Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Deaths[dr.GetInt32(0)] = new RS_Deaths()
                    {
                        SourceId  = dr.GetInt32(1),
                        TimeStamp = dr.GetInt32(2)
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_deaths: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset = Tokens[6].Split(',');
                MySqlDataReader dr = m_DB.Query("SELECT id, sataid, timestamp FROM rs_dispels WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Dispels[dr.GetInt32(0)] = new RS_Dispels()
                    {
                        SataRefId = dr.GetInt32(1),
                        TimeStamp = dr.GetInt32(2)
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_dispels: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset = Tokens[7].Split(',');
                MySqlDataReader dr = m_DB.Query("SELECT id, sataid, timestamp FROM rs_interrupts WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Interrupts[dr.GetInt32(0)] = new RS_Interrupts()
                    {
                        SataRefId = dr.GetInt32(1),
                        TimeStamp = dr.GetInt32(2)
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_interrupts: " + ex.Message + "<br /><br />";
            }

            try{
                Offset = Tokens[8].Split(',');
                if (Tokens.Length >= 14)
                {
                    MySqlDataReader dr = m_DB
                                         .Query("SELECT a.id, a.satid, a.hittype, a.timestamp, a.amount, IFNULL(b.amount,0) FROM rs_damage a LEFT JOIN rs_damage_threat b ON a.id = b.dmgid WHERE a.id>=" + Offset[0] +
                                                " AND a.id<" + Offset[1]).ExecuteReaderRpll();
                    while (dr.Read())
                    {
                        m_Damage[dr.GetInt32(0)] = new RS_Damage()
                        {
                            SatRefId  = dr.GetInt32(1),
                            HitType   = dr.GetInt16(2),
                            TimeStamp = dr.GetInt32(3),
                            Amount    = dr.GetInt32(4),
                            MitGated  = new int[3]
                        };
                        m_Threat.Add(new RS_Threat()
                        {
                            SatRefId  = dr.GetInt32(1),
                            HitType   = dr.GetInt16(2),
                            TimeStamp = dr.GetInt32(3),
                            Amount    = dr.GetInt32(5),
                        });
                    }

                    dr.CloseRpll();
                }
                else
                {
                    MySqlDataReader dr = m_DB
                                         .Query("SELECT id, satid, hittype, timestamp, amount FROM rs_damage WHERE id>=" + Offset[0] +
                                                " AND id<" + Offset[1]).ExecuteReaderRpll();
                    while (dr.Read())
                    {
                        m_Damage[dr.GetInt32(0)] = new RS_Damage()
                        {
                            SatRefId  = dr.GetInt32(1),
                            HitType   = dr.GetInt16(2),
                            TimeStamp = dr.GetInt32(3),
                            Amount    = dr.GetInt32(4),
                            MitGated  = new int[3]
                        };
                    }

                    dr.CloseRpll();
                }

                if (_Index >= 1)
                {
                    MySqlDataReader dr = m_DB.Query("SELECT dmgid, type, amount FROM rs_damage_mitgated WHERE dmgid>=" + Offset[0] +
                                                    " AND dmgid<" + Offset[1]).ExecuteReaderRpll();
                    while (dr.Read())
                    {
                        m_Damage[dr.GetInt32(0)].MitGated[dr.GetInt32(1)] = dr.GetInt32(2);
                    }
                    dr.CloseRpll();
                }
                else
                {
                    MySqlDataReader dr = m_DB.Query("SELECT dmgid, amount FROM rs_damage_mitgated WHERE dmgid>=" + Offset[0] +
                                                    " AND dmgid<" + Offset[1]).ExecuteReaderRpll();
                    while (dr.Read())
                    {
                        m_Damage[dr.GetInt32(0)].MitGated[0] = dr.GetInt32(1);
                    }
                    dr.CloseRpll();
                }
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_damage: " + ex.Message + "<br /><br />";
            }

            try
            {
                if (Tokens.Length < 14)
                {
                    Offset = Tokens[9].Split(',');
                    MySqlDataReader dr = m_DB
                                         .Query("SELECT id, satid, hittype, timestamp, amount FROM rs_healing WHERE id>=" + Offset[0] +
                                                " AND id<" + Offset[1]).ExecuteReaderRpll();
                    while (dr.Read())
                    {
                        m_Healing[dr.GetInt32(0)] = new RS_Healing()
                        {
                            SatRefId  = dr.GetInt32(1),
                            HitType   = dr.GetInt16(2),
                            TimeStamp = dr.GetInt32(3),
                            Amount    = dr.GetInt32(4)
                        };
                    }

                    dr.CloseRpll();
                }
                else
                {
                    Offset = Tokens[9].Split(',');
                    MySqlDataReader dr = m_DB
                                         .Query("SELECT a.id, a.satid, a.hittype, a.timestamp, a.amount, IFNULL(b.amount, 0) FROM rs_healing a LEFT JOIN rs_healing_threat b ON a.id = b.healid WHERE a.id>=" + Offset[0] +
                                                " AND a.id<" + Offset[1]).ExecuteReaderRpll();
                    while (dr.Read())
                    {
                        m_Healing[dr.GetInt32(0)] = new RS_Healing()
                        {
                            SatRefId  = dr.GetInt32(1),
                            HitType   = dr.GetInt16(2),
                            TimeStamp = dr.GetInt32(3),
                            Amount    = dr.GetInt32(4)
                        };
                        if (dr.GetInt32(5) > 0)
                        {
                            m_Threat.Add(new RS_Threat()
                            {
                                SatRefId  = dr.GetInt32(1),
                                HitType   = (short)(60 + dr.GetInt16(2)),
                                TimeStamp = dr.GetInt32(3),
                                Amount    = dr.GetInt32(5),
                            });
                        }
                    }

                    dr.CloseRpll();
                }
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_healing: " + ex.Message + "<br /><br />";
            }

            try
            {
                Offset = Tokens[10].Split(',');
                MySqlDataReader dr = m_DB.Query("SELECT id, targetid, itemid, attemptid FROM rs_loot WHERE id>=" + Offset[0] + " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Loot[dr.GetInt32(0)] = new RS_Loot()
                    {
                        TargetId  = dr.GetInt32(1),
                        ItemId    = dr.GetInt32(2),
                        AttemptId = dr.GetInt32(3)
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_loot: " + ex.Message + "<br /><br />";
            }

            if (Tokens.Length >= 14)
            {
                try
                {
                    Offset = Tokens[13].Split(',');
                    MySqlDataReader dr = m_DB
                                         .Query("SELECT said, amount, timestamp FROM rs_gained_threat WHERE id>=" + Offset[0] +
                                                " AND id<" + Offset[1]).ExecuteReaderRpll();
                    int maxSatRef = m_SatReference.Max(x => x.Key) + 1;
                    Dictionary <int, int> keyMapper = new Dictionary <int, int>();
                    while (dr.Read())
                    {
                        // Creating custom satrefids to make integration easier
                        // Source == Target
                        int saId = dr.GetInt32(0);
                        if (!keyMapper.ContainsKey(saId))
                        {
                            m_SatReference[maxSatRef] = new RS_Sat_Reference()
                            {
                                SourceId  = m_SaReference[saId].SourceId,
                                AbilityId = m_SaReference[saId].AbilityId,
                                TargetId  = m_SaReference[saId].SourceId
                            };
                            keyMapper[saId] = maxSatRef;
                            ++maxSatRef;
                        }

                        m_Threat.Add(new RS_Threat()
                        {
                            SatRefId  = keyMapper[saId],
                            Amount    = dr.GetInt32(1),
                            TimeStamp = dr.GetInt32(2),
                            HitType   = 20,
                        });
                    }

                    dr.CloseRpll();
                }
                catch (KeyNotFoundException ex)
                {
                    Error += "rs_threat: " + ex.Message + "<br /><br />";
                }
            }

            try
            {
                Offset = Tokens[11].Split(',');
                MySqlDataReader dr = m_DB
                                     .Query("SELECT id, satid, timestamp FROM rs_casts WHERE id>=" + Offset[0] +
                                            " AND id<" + Offset[1]).ExecuteReaderRpll();
                while (dr.Read())
                {
                    m_Casts[dr.GetInt32(0)] = new RS_Casts()
                    {
                        SatRefId  = dr.GetInt32(1),
                        TimeStamp = dr.GetInt32(2),
                        Amount    = 1
                    };
                }
                dr.CloseRpll();
            }
            catch (KeyNotFoundException ex)
            {
                Error += "rs_casts: " + ex.Message + "<br /><br />";
            }

            // Sorting the crap for good measure
            m_Attempts   = m_Attempts.OrderBy(x => x.Value.Start).ToDictionary();
            m_Auras      = m_Auras.OrderBy(x => x.Value.Gained).ToDictionary();
            m_Deaths     = m_Deaths.OrderBy(x => x.Value.TimeStamp).ToDictionary();
            m_Dispels    = m_Dispels.OrderBy(x => x.Value.TimeStamp).ToDictionary();
            m_Interrupts = m_Interrupts.OrderBy(x => x.Value.TimeStamp).ToDictionary();
            m_Damage     = m_Damage.OrderBy(x => x.Value.TimeStamp).ToDictionary();
            m_Healing    = m_Healing.OrderBy(x => x.Value.TimeStamp).ToDictionary();
            m_Casts      = m_Casts.OrderBy(x => x.Value.TimeStamp).ToDictionary();
            m_Threat     = m_Threat.OrderBy(x => x.TimeStamp).ToList();

            // TODO: Boss yells

            FinishRequestData(_Index, _Id, _Uploader);
        }