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();
    }
Exemple #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();
        }
    }
Exemple #3
0
 protected Base(int id)
 {
     string procedureName = String.Format("get_{0}ByID", this.GetType().Name);
     SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);
     sql.AddParameter("@ID", SqlDbType.Int, 4, ParameterDirection.Input, id);
     DataSet dsItem = sql.ExecuteDataSet();
     this.MapColumnsToProperties(dsItem.Tables[0]);
 }
Exemple #4
0
        public DataTable GetPolaznikTecajaSOcjenom(int polaznikTecajaId)
        {
            string procedureName = "get_InfoPolaznikaTecaja";

            SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);

            sql.AddParameter("@PolaznikTecajaID", SqlDbType.Int, 4, ParameterDirection.Input, polaznikTecajaId);

            return sql.ExecuteDataSet().Tables[0];
        }
Exemple #5
0
 public Korisnik GetKorisnikByKorisnickoImeILozinka(string korisnickoIme, string lozinka)
 {
     string procedureName = "get_KorisnikByKorisnickoImeILozinka";
     SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);
     sql.AddParameter("@korisnickoIme", SqlDbType.NVarChar, 20, ParameterDirection.Input, korisnickoIme);
     sql.AddParameter("@lozinka", SqlDbType.NVarChar, 20, ParameterDirection.Input, lozinka);
     DataSet ds = sql.ExecuteDataSet();
     Korisnik k = null;
     DataTable dt = ds.Tables[0];
     if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
     {
         //k = new Korisnik(Convert.ToInt32(dt.Rows[0]["KorisnikID"]));
         k = new Korisnik();
         k.MapColumnsToProperties(dt);
     }
     return k;
 }
Exemple #6
0
        public DataTable GetPolaznici(string OIB, string ime, string prezime, DateTime? datumRodjenja, int? rankId, string brojIskaznice, int? tecajId, DateTime? terminTecajaOd, DateTime? terminTecajaDo)
        {
            string procedureName = "get_Polaznici";

            SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);

            if (!String.IsNullOrEmpty(OIB))
                sql.AddParameter("@OIB", SqlDbType.NVarChar, 20, ParameterDirection.Input, OIB);

            if (!String.IsNullOrEmpty(ime))
                sql.AddParameter("@Ime", SqlDbType.NVarChar, 50, ParameterDirection.Input, ime);

            if (!String.IsNullOrEmpty(prezime))
                sql.AddParameter("@Prezime", SqlDbType.NVarChar, 50, ParameterDirection.Input, prezime);

            if (datumRodjenja.HasValue)
                sql.AddParameter("@DatumRodjenja", SqlDbType.DateTime, null, ParameterDirection.Input, datumRodjenja.Value);

            if (rankId.HasValue)
                sql.AddParameter("@RankID", SqlDbType.Int, 4, ParameterDirection.Input, rankId.Value);

            if (!String.IsNullOrEmpty(brojIskaznice))
                sql.AddParameter("@BrojIskaznice", SqlDbType.NVarChar, 20, ParameterDirection.Input, brojIskaznice);

            if (tecajId.HasValue)
                sql.AddParameter("@TecajID", SqlDbType.Int, 4, ParameterDirection.Input, tecajId.Value);

            if (terminTecajaOd.HasValue)
                sql.AddParameter("@TerminTecajaOd", SqlDbType.DateTime, null, ParameterDirection.Input, terminTecajaOd.Value);

            if (terminTecajaDo.HasValue)
                sql.AddParameter("@TerminTecajaDo", SqlDbType.DateTime, null, ParameterDirection.Input, terminTecajaDo.Value);

            DataSet ds = sql.ExecuteDataSet();
            DataTable dtPolaznici = ds.Tables[0];
            //DataTable dtTecajevi = ds.Tables[1];

            //DataRelation Datatablerelation = new DataRelation("PolazniciTecajevi", dtPolaznici.Columns["PolaznikID"], dtTecajevi.Columns["PolaznikID"], true);
            //ds.Relations.Add(Datatablerelation);

            return dtPolaznici;
        }
    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;
        }
    }
Exemple #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 | 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();
    }
Exemple #9
0
        public static void loadIntoDatabase(SQLWrapper sql, string table, string filePath, bool dropTable, bool createTable, bool firstRowHeaders, char delimiter, bool removeQuotes)
        {
            System.IO.StreamReader inputFile = new System.IO.StreamReader(filePath);

            string[] cols2;
            int      maxcols2 = 0;

            if (dropTable)
            {
                try { sql.execStmt("DROP TABLE " + table); } catch (Exception e) { }
            }

            try
            {
                string line = inputFile.ReadLine();

                if (firstRowHeaders == true || createTable == true)
                {
                    cols2 = parseColumns(line, delimiter);

                    if (removeQuotes == true)
                    {
                        for (int j = 0; j < cols2.Length; j++)
                        {
                            if (cols2[j].StartsWith("\""))
                            {
                                cols2[j] = cols2[j].Substring(1);
                                cols2[j] = cols2[j].Substring(0, cols2[j].Length - 1);
                                cols2[j] = cols2[j].Replace("\"\"", "\"");
                            }
                        }
                    }

                    if (createTable == true)
                    {
                        string temp = "";

                        temp += "[source_path] VARCHAR(MAX)";
                        temp += ",[source_datetime] DATETIME";

                        maxcols2 = cols2.Length;

                        for (int i = 0; i < cols2.Length; i++)
                        {
                            temp += ",[" + cols2[i] + "] VARCHAR(MAX)";
                        }

                        sql.execStmt("CREATE TABLE " + table + " (" + temp + ")");
                    }
                }

                int           batch = 0;
                StringBuilder query = new StringBuilder(8192);

                if (firstRowHeaders == true)
                {
                    line = inputFile.ReadLine();
                }

                int  numrows = 0;
                long perf    = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

                string source_path     = "'" + filePath.Replace("'", "''") + "'";
                string source_datetime = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'";

                for (; line != null; line = inputFile.ReadLine())
                {
                    cols2 = parseColumns(line, delimiter);

                    if (removeQuotes == true)
                    {
                        for (int j = 0; j < cols2.Length; j++)
                        {
                            if (cols2[j].StartsWith("\""))
                            {
                                cols2[j] = cols2[j].Substring(1);
                                cols2[j] = cols2[j].Substring(0, cols2[j].Length - 1);
                                cols2[j] = cols2[j].Replace("\"\"", "\"");
                            }
                        }
                    }

                    numrows++;

                    query.Append("INSERT INTO " + table + " VALUES");
                    query.Append('(');
                    query.Append(source_path);
                    query.Append(source_datetime);

                    for (int j = 0; j < maxcols2; j++)
                    {
                        query.Append(',');
                        query.Append('\'');

                        if (j < cols2.Length)
                        {
                            query.Append(cols2[j].Replace("'", "''"));
                        }

                        query.Append('\'');
                    }

                    query.Append(')');
                    query.Append(';');

                    batch++;

                    if (query.Length >= 6144)
                    {
                        sql.execStmt(query.ToString());

                        query.Length = 0;
                        batch        = 0;
                    }
                }

                if (batch != 0)
                {
                    sql.execStmt(query.ToString());
                }

                inputFile.Close();
            }
            catch (Exception e)
            {
                if (inputFile != null)
                {
                    inputFile.Close();
                }

                throw e;
            }
        }
    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);
        }
    }
    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);
        }
    }
Exemple #12
0
 public long LogFile(SQLWrapper sql)
 {
     f_id = sql.LongScalar("exec Automation..spLogExacTracFile "
         + "'" +  File + "','" +  CreatedDateTime.ToString()
         + "','" +  ProcessedDateTime.ToString() + "'," +  RecordCount.ToString()
     + "," +  RecordsProcessed.ToString() + "," +  ErrorCount.ToString()
     + "," +  FileType.ToString());
     return f_id;
 }
Exemple #13
0
        public DataTable GetTecajeviPolaznika(int polaznikID)
        {
            string procedureName = "get_TecajeviPolaznika";

            SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);

            sql.AddParameter("@PolaznikID", SqlDbType.Int, 4, ParameterDirection.Input, polaznikID);

            return sql.ExecuteDataSet().Tables[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;
        }
    }
Exemple #15
0
        public void UpdatePolaznik(int id,string ime, string prezime, DateTime datumRodjenja, string OIB, bool gradjaninRH, int? rankId, string brojIskaznice, string komentar, string kontakt)
        {
            string procedureName = "upd_Polaznik";

            SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);

            sql.AddParameter("@ID", SqlDbType.Int, 4, ParameterDirection.Input, id);

            sql.AddParameter("@Ime", SqlDbType.NVarChar, 50, ParameterDirection.Input, ime);

            sql.AddParameter("@Prezime", SqlDbType.NVarChar, 50, ParameterDirection.Input, prezime);

            sql.AddParameter("@DatumRodjenja", SqlDbType.DateTime, null, ParameterDirection.Input, datumRodjenja);

            sql.AddParameter("@OIB", SqlDbType.NVarChar, 15, ParameterDirection.Input, OIB);

            sql.AddParameter("@GradjaninRH", SqlDbType.Bit, null, ParameterDirection.Input, gradjaninRH);

            if (rankId.HasValue && rankId.Value != -1)
                sql.AddParameter("@RankID", SqlDbType.Int, 4, ParameterDirection.Input, rankId);

            if (!String.IsNullOrEmpty(brojIskaznice))
                sql.AddParameter("@BrojIskaznice", SqlDbType.NVarChar, 20, ParameterDirection.Input, brojIskaznice);

            if (!String.IsNullOrEmpty(komentar))
                sql.AddParameter("@Komentar", SqlDbType.NVarChar, 500, ParameterDirection.Input, komentar);

            if (!String.IsNullOrEmpty(kontakt))
                sql.AddParameter("@Kontakt", SqlDbType.NVarChar, 50, ParameterDirection.Input, kontakt);

            sql.ExecuteNonQuery();
        }
Exemple #16
0
        public void UpdateOcjena(int ocjenaId, int sadrzaj, int predavac, int trajanje, int brzina, int literatura, int korisnost)
        {
            string procedureName = "upd_Ocjena";

            SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);

            sql.AddParameter("@OcjenaID", SqlDbType.Int, 4, ParameterDirection.Input, ocjenaId);
            sql.AddParameter("@Sadrzaj", SqlDbType.Int, 4, ParameterDirection.Input, sadrzaj);
            sql.AddParameter("@Predavac", SqlDbType.Int, 4, ParameterDirection.Input, predavac);
            sql.AddParameter("@Trajanje", SqlDbType.Int, 4, ParameterDirection.Input, trajanje);
            sql.AddParameter("@Brzina", SqlDbType.Int, 4, ParameterDirection.Input, brzina);
            sql.AddParameter("@Literatura", SqlDbType.Int, 4, ParameterDirection.Input, literatura);
            sql.AddParameter("@Korisnost", SqlDbType.Int, 4, ParameterDirection.Input, korisnost);

            sql.ExecuteNonQuery();
        }
Exemple #17
0
        public int InsertPolaznik(string ime, string prezime, DateTime datumRodjenja, string OIB, bool gradjaninRH, int? rankId, string brojIskaznice, string komentar, string kontakt)
        {
            int id = 0;

            string procedureName = "ins_Polaznik";

            SQLWrapper sql = new SQLWrapper(CommandType.StoredProcedure, procedureName);

            sql.AddParameter("@Ime", SqlDbType.NVarChar, 50, ParameterDirection.Input, ime);

            sql.AddParameter("@Prezime", SqlDbType.NVarChar, 50, ParameterDirection.Input, prezime);

            sql.AddParameter("@DatumRodjenja", SqlDbType.DateTime, null, ParameterDirection.Input, datumRodjenja);

            sql.AddParameter("@OIB", SqlDbType.NVarChar, 15, ParameterDirection.Input, OIB);

            sql.AddParameter("@GradjaninRH", SqlDbType.Bit, null, ParameterDirection.Input, gradjaninRH);

            if (rankId.HasValue && rankId.Value != -1)
                sql.AddParameter("@RankID", SqlDbType.Int, 4, ParameterDirection.Input, rankId);

            if (!String.IsNullOrEmpty(brojIskaznice))
                sql.AddParameter("@BrojIskaznice", SqlDbType.NVarChar, 20, ParameterDirection.Input, brojIskaznice);

            if (!String.IsNullOrEmpty(komentar))
                sql.AddParameter("@Komentar", SqlDbType.NVarChar, 500, ParameterDirection.Input, komentar);

            if (!String.IsNullOrEmpty(kontakt))
                sql.AddParameter("@Kontakt", SqlDbType.NVarChar, 50, ParameterDirection.Input, kontakt);

            id = Convert.ToInt32(sql.ExecuteScalar());

            return id;
        }
Exemple #18
0
        public DataTable GetTecajevi(bool firstItemEmpty)
        {
            DataTable dt;

            string command = "SELECT TecajId, Sifra FROM dbo.Tecaj WHERE Aktivan = 1";

            SQLWrapper sql = new SQLWrapper(CommandType.Text, command);

            dt = sql.ExecuteDataSet().Tables[0];

            if (firstItemEmpty)
            {
                DataRow emptyRow = dt.NewRow();
                emptyRow["TecajID"] = -1;
                emptyRow["Sifra"] = "Odaberi";
                dt.Rows.InsertAt(emptyRow, 0);
            }

            return dt;
        }
Exemple #19
0
        public DataTable GetPredavaci()
        {
            string command = "SELECT PredavacID, Ime + ' ' + Prezime as Naziv FROM Predavac";

            SQLWrapper sql = new SQLWrapper(CommandType.Text, command);

            return sql.ExecuteDataSet().Tables[0];
        }
Exemple #20
0
        public DataTable GetRankovi(bool firstItemEmpty)
        {
            DataTable dt;

            string command = "SELECT RankID, Rank FROM dbo.Rank";

            SQLWrapper sql = new SQLWrapper(CommandType.Text, command);

            dt = sql.ExecuteDataSet().Tables[0];

            if (firstItemEmpty)
            {
                DataRow emptyRow = dt.NewRow();
                emptyRow["RankID"] = -1;
                emptyRow["Rank"] = "Odaberi";
                dt.Rows.InsertAt(emptyRow, 0);
            }

            return dt;
        }
    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;
        }
    }
    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>");
        }
    }