Esempio n. 1
0
    public static void Start()
    {
        client = new DatabaseClient(new BasicHttpBinding(), new EndpointAddress(
                        new System.Uri("http://localhost:8733/Design_Time_Addresses/Service/Database/1")));

        client.BDOpen();
    }
Esempio n. 2
0
 public void FixtureSetup()
 {
     Console.WriteLine("Connecting");
     var client = new DatabaseClient("*****@*****.**", "password");
     const string dbName = "IntegrationTests";
     Console.WriteLine("Opening or creating database");
     db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
     const string tableName = "IntegrationTests";
     Console.WriteLine("Opening or creating table");
     table = db.GetTable<IntegrationEntity>(tableName) ?? db.CreateTable<IntegrationEntity>(tableName);
 }
Esempio n. 3
0
		public void FixtureSetup() {
			Console.WriteLine("Connecting");
            var client = new DatabaseClient(
                clientEmail: "*****@*****.**",
                privateKey: File.ReadAllBytes(@"xxx.p12"));

            const string dbName = "IntegrationTests";
			Console.WriteLine("Opening or creating database");
			db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
			const string tableName = "IntegrationTests";
			Console.WriteLine("Opening or creating table");
			table = db.GetTable<IntegrationEntity>(tableName) ?? db.CreateTable<IntegrationEntity>(tableName);
		}
Esempio n. 4
0
    void Start()
    {
        Debug.Log("Connecting");

        const string account = "*****@*****.**";
        const string password = "******";
        var client = new DatabaseClient(account, password);

        const string dbName = "spreadsheet-test";
        var db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);

        const string tableName = "test_table";
        var t = db.GetTable<Entity>(tableName) ?? db.CreateTable<Entity>(tableName);

        Debug.Log("Feed url for this table is : " + t.GetFeedUrl());

        var all = t.FindAll();

        var r = all.Count > 0 ? all[0] : t.Add(new Entity {Conteudo = "some content", Amount = 5});
        r.Element.Conteudo = "nothing at all";
        r.Update();

        Debug.Log("Now there are " + t.FindAll().Count + "elements");
        {
            Debug.Log("executing a few queries");
            foreach (var q in new[] { "amount=5", "amount<6", "amount>0", "amount!=6", "amount<>6", "conteudo=\"nothing at all\"" }) {
                Debug.Log("querying: " + q);
                var rows = t.FindStructured(q);
                Debug.Log("elements found: " + rows.Count);
            }
        }
        {
            Debug.Log("Linq queries");
            var rows = from e in t.AsQueryable()
                                 where e.Conteudo == r.Element.Conteudo
                                 orderby e.Amount
                                 select e;
            Debug.Log("elements found : " + rows.ToList().Count());
        }

        //r.Delete();
        //t.Delete();
        //db.Delete();
    }
Esempio n. 5
0
        public void parse(GameClient Session, ClientMessage message)
        {
            ServerMessage response = new ServerMessage(950);

            Session.GetHabbo().GetHabboData.UpdateFriendStream();

            int streamCount = Session.GetHabbo().GetHabboData.GetFriendStream.Rows.Count;

            response.AppendInt32(streamCount);

            DataTable dataTable_ = Session.GetHabbo().GetHabboData.GetFriendStream;

            foreach (DataRow row in dataTable_.Rows)
            {
                int type = (int)row["type"];

                if (type >= 0 && type <= 4)
                {
                    uint id = (uint)row["id"];

                    int  likes   = 0;
                    bool canlike = false;

                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        likes = adapter.ReadInt32("SELECT COUNT(friend_stream_id) FROM friend_stream_likes WHERE friend_stream_id = '" + id + "' LIMIT 1");

                        DataRow datarow = adapter.ReadDataRow("SELECT id FROM friend_stream_likes WHERE friend_stream_id = '" + id + "' AND userid = '" + Session.GetHabbo().Id + "' LIMIT 1");

                        if (datarow == null)
                        {
                            canlike = true;
                        }
                        else
                        {
                            canlike = false;
                        }
                    }

                    uint   userid   = (uint)row["userid"];
                    string username = PhoenixEnvironment.GetGame().GetClientManager().GetNameById(userid);

                    string gender = (string)row["gender"].ToString().ToLower();
                    string look   = (string)row["look"];

                    int time = (int)((PhoenixEnvironment.GetUnixTimestamp() - (double)row["time"]) / 60);

                    string data = (string)row["data"];

                    response.AppendUInt(id);
                    response.AppendInt32(type);
                    response.AppendStringWithBreak(userid.ToString());
                    response.AppendStringWithBreak(username);
                    response.AppendStringWithBreak(gender);
                    //response.AppendStringWithBreak("http://localhost/swfphx/head.php?figure=" + look);
                    response.AppendStringWithBreak("http://localhost/swfphx/c_images/album1584/ADM.gif");
                    response.AppendInt32(time);

                    if (type == 0)
                    {
                        string data_extra = (string)row["data_extra"];

                        //uint friend_id = uint.Parse(data, CustomCultureInfo.GetCustomCultureInfo());

                        //if (Session.GetHabbo().Id == friend_id || Session.GetHabbo().GetMessenger().UserInFriends(friend_id))
                        {
                            response.AppendInt32(0);
                        }
                        //else
                        {
                            response.AppendInt32(5);
                        }
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);
                        response.AppendStringWithBreak(data);
                        response.AppendStringWithBreak(data_extra);
                    }
                    else if (type == 1)
                    {
                        response.AppendInt32(2);
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);

                        uint roomId;

                        RoomData RoomData;

                        if (uint.TryParse(data, out roomId))
                        {
                            RoomData = PhoenixEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId);
                        }
                        else
                        {
                            RoomData = PhoenixEnvironment.GetGame().GetRoomManager().GenerateRoomData(0);
                        }

                        if (RoomData != null)
                        {
                            response.AppendStringWithBreak(RoomData.Id.ToString()); //data
                            response.AppendStringWithBreak(RoomData.Name);          //extra data
                        }
                        else
                        {
                            response.AppendStringWithBreak("");
                            response.AppendStringWithBreak("Room deleted");
                        }
                    }
                    else if (type == 2)
                    {
                        response.AppendInt32(3);
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);
                        response.AppendStringWithBreak(data);
                    }
                    else if (type == 3)
                    {
                        response.AppendInt32(4);
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);
                        response.AppendStringWithBreak(data);
                    }
                }
            }

            Session.SendMessage(response);
        }
        public void Handle(GameClient Session, ClientMessage Event)
        {
            uint    num     = Event.PopWiredUInt();
            DataRow dataRow = null;

            using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
            {
                dataRow = @class.ReadDataRow("SELECT state, timestamp, total_price, extra_data, item_id, furni_id FROM catalog_marketplace_offers WHERE offer_id = '" + num + "' LIMIT 1");
            }
            if (dataRow == null || (string)dataRow["state"] != "1" || (double)dataRow["timestamp"] <= GoldTree.GetGame().GetCatalog().method_22().method_3())
            {
                Session.SendNotification(GoldTreeEnvironment.GetExternalText("marketplace_error_expired"));
            }
            else
            {
                Item class2 = GoldTree.GetGame().GetItemManager().method_2((uint)dataRow["item_id"]);
                if (class2 != null)
                {
                    if ((int)dataRow["total_price"] >= 1)
                    {
                        if (Session.GetHabbo().Credits < (int)dataRow["total_price"])
                        {
                            Session.SendNotification(GoldTreeEnvironment.GetExternalText("marketplace_error_credits"));
                            return;
                        }
                        Session.GetHabbo().Credits -= (int)dataRow["total_price"];
                        Session.GetHabbo().UpdateCredits(true);
                    }
                    GoldTree.GetGame().GetCatalog().method_9(Session, class2, 1, (string)dataRow["extra_data"], false, (uint)dataRow["furni_id"]);
                    using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
                    {
                        @class.ExecuteQuery("UPDATE catalog_marketplace_offers SET state = '2' WHERE offer_id = '" + num + "' LIMIT 1");
                        int num2 = 0;
                        try
                        {
                            num2 = @class.ReadInt32("SELECT Id FROM catalog_marketplace_data WHERE daysago = 0 AND sprite = " + class2.Sprite + " LIMIT 1;");
                        }
                        catch
                        {
                        }
                        if (num2 > 0)
                        {
                            @class.ExecuteQuery(string.Concat(new object[]
                            {
                                "UPDATE catalog_marketplace_data SET sold = sold + 1, avgprice = (avgprice + ",
                                (int)dataRow["total_price"],
                                ") WHERE Id = ",
                                num2,
                                " LIMIT 1;"
                            }));
                        }
                        else
                        {
                            @class.ExecuteQuery(string.Concat(new object[]
                            {
                                "INSERT INTO catalog_marketplace_data (sprite, sold, avgprice, daysago) VALUES ('",
                                class2.Sprite,
                                "', 1, ",
                                (int)dataRow["total_price"],
                                ", 0)"
                            }));
                        }
                        if (GoldTree.GetGame().GetCatalog().method_22().dictionary_0.ContainsKey(class2.Sprite) && GoldTree.GetGame().GetCatalog().method_22().dictionary_1.ContainsKey(class2.Sprite))
                        {
                            int num3 = GoldTree.GetGame().GetCatalog().method_22().dictionary_1[class2.Sprite];
                            int num4 = GoldTree.GetGame().GetCatalog().method_22().dictionary_0[class2.Sprite];
                            num4 += (int)dataRow["total_price"];
                            GoldTree.GetGame().GetCatalog().method_22().dictionary_0.Remove(class2.Sprite);
                            GoldTree.GetGame().GetCatalog().method_22().dictionary_0.Add(class2.Sprite, num4);
                            GoldTree.GetGame().GetCatalog().method_22().dictionary_1.Remove(class2.Sprite);
                            GoldTree.GetGame().GetCatalog().method_22().dictionary_1.Add(class2.Sprite, num3 + 1);
                        }
                        else
                        {
                            if (!GoldTree.GetGame().GetCatalog().method_22().dictionary_0.ContainsKey(class2.Sprite))
                            {
                                GoldTree.GetGame().GetCatalog().method_22().dictionary_0.Add(class2.Sprite, (int)dataRow["total_price"]);
                            }
                            if (!GoldTree.GetGame().GetCatalog().method_22().dictionary_1.ContainsKey(class2.Sprite))
                            {
                                GoldTree.GetGame().GetCatalog().method_22().dictionary_1.Add(class2.Sprite, 1);
                            }
                        }
                    }
                    ServerMessage Message = new ServerMessage(67u);
                    Message.AppendUInt(class2.UInt32_0);
                    Message.AppendStringWithBreak(class2.Name);
                    Message.AppendInt32((int)dataRow["total_price"]);
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                    Message.AppendInt32(1);
                    Message.AppendStringWithBreak(class2.Type.ToString());
                    Message.AppendInt32(class2.Sprite);
                    Message.AppendStringWithBreak("");
                    Message.AppendInt32(1);
                    Message.AppendInt32(-1);
                    Message.AppendStringWithBreak("");
                    Session.SendMessage(Message);
                    Session.SendMessage(GoldTree.GetGame().GetCatalog().method_22().method_5(-1, -1, "", 1));
                }
            }
        }
        public void Handle(GameClient Session, ClientMessage Event)
        {
            Room @class = GoldTree.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (@class != null && @class.method_26(Session))
            {
                int    num    = Event.PopWiredInt32();
                int    num2   = Event.PopWiredInt32();
                string text   = Event.PopFixedString();
                string text2  = Event.PopFixedString();
                string text3  = Event.PopFixedString();
                string text4  = Event.PopFixedString();
                string text5  = Event.PopFixedString();
                string text6  = Event.PopFixedString();
                string text7  = Event.PopFixedString();
                string text8  = Event.PopFixedString();
                string text9  = Event.PopFixedString();
                string text10 = Event.PopFixedString();
                string text11 = "";
                if (num2 == 10 || num2 == 8)
                {
                    text11 = string.Concat(new object[]
                    {
                        text,
                        "=",
                        text2,
                        Convert.ToChar(9),
                        text3,
                        "=",
                        text4,
                        Convert.ToChar(9),
                        text5,
                        "=",
                        text6,
                        Convert.ToChar(9),
                        text7,
                        "=",
                        text8
                    });
                    if (text9 != "")
                    {
                        text11 = string.Concat(new object[]
                        {
                            text11,
                            Convert.ToChar(9),
                            text9,
                            "=",
                            text10
                        });
                    }
                    using (DatabaseClient class2 = GoldTree.GetDatabase().GetClient())
                    {
                        class2.AddParamWithValue("extradata", text11);
                        class2.ExecuteQuery("UPDATE items_extra_data SET extra_data = @extradata WHERE item_id = '" + num + "' LIMIT 1");
                    }
                    ServerMessage Message = new ServerMessage(88u);
                    Message.AppendStringWithBreak(num.ToString());
                    Message.AppendStringWithBreak(text11);
                    @class.SendMessage(Message, null);
                    @class.method_28((uint)num).ExtraData = text11;
                    @class.method_28((uint)num).UpdateState(true, false);
                }
            }
        }
        public void Handle(GameClient Session, ClientMessage Event)
        {
            int num = Event.PopWiredInt32();

            if (num > 0 && (Session != null && Session.GetHabbo() != null))
            {
                GroupsManager @class = Groups.smethod_2(num);
                if (@class != null)
                {
                    ServerMessage Message = new ServerMessage(311u);
                    Message.AppendInt32(@class.int_0);
                    Message.AppendStringWithBreak(@class.string_0);
                    Message.AppendStringWithBreak(@class.string_1);
                    Message.AppendStringWithBreak(@class.string_2);
                    if (@class.uint_0 > 0u)
                    {
                        Message.AppendUInt(@class.uint_0);
                        if (GoldTree.GetGame().GetRoomManager().GetRoom(@class.uint_0) != null)
                        {
                            Message.AppendStringWithBreak(GoldTree.GetGame().GetRoomManager().GetRoom(@class.uint_0).Name);
                            goto IL_15A;
                        }
                        using (DatabaseClient class2 = GoldTree.GetDatabase().GetClient())
                        {
                            try
                            {
                                DataRow dataRow_ = class2.ReadDataRow("SELECT * FROM rooms WHERE Id = " + @class.uint_0 + " LIMIT 1;");
                                string  string_  = GoldTree.GetGame().GetRoomManager().method_17(@class.uint_0, dataRow_).Name;
                                Message.AppendStringWithBreak(string_);
                            }
                            catch
                            {
                                Message.AppendInt32(-1);
                                Message.AppendStringWithBreak("");
                            }
                            goto IL_15A;
                        }
                    }
                    Message.AppendInt32(-1);
                    Message.AppendStringWithBreak("");
IL_15A:
                    bool flag = false;
                    foreach (DataRow dataRow in Session.GetHabbo().dataTable_0.Rows)
                    {
                        if ((int)dataRow["groupid"] == @class.int_0)
                        {
                            flag = true;
                        }
                    }
                    if (Session.GetHabbo().list_0.Contains(@class.int_0))
                    {
                        Message.AppendInt32(2);
                    }
                    else
                    {
                        if (flag)
                        {
                            Message.AppendInt32(1);
                        }
                        else
                        {
                            if (@class.string_3 == "closed")
                            {
                                Message.AppendInt32(1);
                            }
                            else
                            {
                                if (@class.list_0.Contains((int)Session.GetHabbo().Id))
                                {
                                    Message.AppendInt32(1);
                                }
                                else
                                {
                                    Message.AppendInt32(0);
                                }
                            }
                        }
                    }
                    Message.AppendInt32(@class.list_0.Count);
                    if (Session.GetHabbo().int_0 == @class.int_0)
                    {
                        Message.AppendBoolean(true);
                    }
                    else
                    {
                        Message.AppendBoolean(false);
                    }
                    Session.SendMessage(Message);
                }
            }
        }
Esempio n. 9
0
        public void ParsePacket(string data)
        {
            string text = data.Split(new char[]
            {
                Convert.ToChar(1)
            })[0];

            string text2 = data.Split(new char[]
            {
                Convert.ToChar(1)
            })[1];

            GameClient client  = null;
            DataRow    dataRow = null;

            string text3 = text.ToLower();

            if (text3 != null)
            {
                if (MusCommands.dictionary_0 == null)
                {
                    MusCommands.dictionary_0 = new Dictionary <string, int>(29)
                    {
                        {
                            "update_items",
                            0
                        },

                        {
                            "update_catalogue",
                            1
                        },

                        {
                            "update_catalog",
                            2
                        },

                        {
                            "updateusersrooms",
                            3
                        },

                        {
                            "senduser",
                            4
                        },

                        {
                            "updatevip",
                            5
                        },

                        {
                            "giftitem",
                            6
                        },

                        {
                            "giveitem",
                            7
                        },

                        {
                            "unloadroom",
                            8
                        },

                        {
                            "roomalert",
                            9
                        },

                        {
                            "updategroup",
                            10
                        },

                        {
                            "updateusersgroups",
                            11
                        },

                        {
                            "shutdown",
                            12
                        },

                        {
                            "update_filter",
                            13
                        },

                        {
                            "refresh_filter",
                            14
                        },

                        {
                            "updatecredits",
                            15
                        },

                        {
                            "updatesettings",
                            16
                        },

                        {
                            "updatepixels",
                            17
                        },

                        {
                            "updatepoints",
                            18
                        },

                        {
                            "reloadbans",
                            19
                        },

                        {
                            "update_bots",
                            20
                        },

                        {
                            "signout",
                            21
                        },

                        {
                            "exe",
                            22
                        },

                        {
                            "alert",
                            23
                        },

                        {
                            "sa",
                            24
                        },

                        {
                            "ha",
                            25
                        },

                        {
                            "hal",
                            26
                        },

                        {
                            "updatemotto",
                            27
                        },
                        {
                            "update_badges",
                            29
                        },
                        {
                            "update_navigator",
                            40
                        },
                        {
                            "startquestion",
                            31
                        },
                        {
                            "roomkick",
                            37
                        },
                        {
                            "setinapp",
                            38
                        },
                        {
                            "lockroom",
                            39
                        },
                        {
                            "updatelook",
                            28
                        },
                        {
                            "infobuspoll",
                            34
                        },
                        {
                            "givebadge",
                            32
                        },
                        {
                            "update_permissions",
                            33
                        },
                        {
                            "update_catalogid",
                            35
                        },
                        {
                            "addFriend",
                            36
                        },
                        {
                            "ref_websocket",
                            50
                        },
                        {
                            "eventha",
                            51
                        }
                    };
                }

                int num;

                if (MusCommands.dictionary_0.TryGetValue(text3, out num))
                {
                    uint   num2;
                    uint   uint_2;
                    Room   class4;
                    uint   num3;
                    string text5;

                    switch (num)
                    {
                    case 0:
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().GetItemManager().Initialize(class2);

                            goto IL_C70;
                        }

                    case 1:
                    case 2:
                        break;

                    case 3:
                    {
                        Habbo class3 = Essential.GetGame().GetClientManager().GetClient(Convert.ToUInt32(text2)).GetHabbo();
                        if (class3 != null)
                        {
                            using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                            {
                                class3.method_1(class2);
                                goto IL_C70;
                            }
                        }
                        goto IL_C70;
                    }

                    case 4:
                        goto IL_34E;

                    case 5:
                    {
                        Habbo class3 = Essential.GetGame().GetClientManager().GetClient(Convert.ToUInt32(text2)).GetHabbo();
                        if (class3 != null)
                        {
                            class3.UpdateRights();
                            goto IL_C70;
                        }
                        goto IL_C70;
                    }

                    case 6:
                    case 7:
                    {
                        num2 = uint.Parse(text2.Split(new char[]
                            {
                                ' '
                            })[0]);
                        uint uint_ = uint.Parse(text2.Split(new char[]
                            {
                                ' '
                            })[1]);
                        int int_ = int.Parse(text2.Split(new char[]
                            {
                                ' '
                            })[2]);
                        string string_ = text2.Substring(num2.ToString().Length + uint_.ToString().Length + int_.ToString().Length + 3);
                        Essential.GetGame().GetCatalog().CreateGift(string_, num2, uint_, int_);

                        goto IL_C70;
                    }

                    case 8:
                        uint_2 = uint.Parse(text2);
                        class4 = Essential.GetGame().GetRoomManager().GetRoom(uint_2);
                        Essential.GetGame().GetRoomManager().method_16(class4);
                        goto IL_C70;

                    case 37:
                        num3 = uint.Parse(text2.Split(new char[]
                        {
                            ' '
                        })[0]);

                        class4 = Essential.GetGame().GetRoomManager().GetRoom(num3);
                        if (class4 != null)
                        {
                            Essential.GetGame().GetModerationTool().ClearRoomFromUsers(num3);
                            goto IL_C70;
                        }
                        goto IL_C70;

                    case 38:
                        num3 = uint.Parse(text2.Split(new char[]
                        {
                            ' '
                        })[0]);

                        class4 = Essential.GetGame().GetRoomManager().GetRoom(num3);
                        if (class4 != null)
                        {
                            Essential.GetGame().GetModerationTool().SetInApp(num3);
                            goto IL_C70;
                        }
                        goto IL_C70;

                    case 39:
                        num3 = uint.Parse(text2.Split(new char[]
                        {
                            ' '
                        })[0]);

                        class4 = Essential.GetGame().GetRoomManager().GetRoom(num3);
                        if (class4 != null)
                        {
                            Essential.GetGame().GetModerationTool().LockRoom(num3);
                            goto IL_C70;
                        }
                        goto IL_C70;

                    case 40:
                        using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().GetNavigator().Initialize(dbClient);
                            Essential.GetGame().GetRoomManager().method_8(dbClient);
                            Essential.GetGame().GetRoomManager().LoadMagicTiles(dbClient);
                            Essential.GetGame().GetRoomManager().LoadBillboards(dbClient);
                        }
                        goto IL_C70;

                    case 9:
                        num3 = uint.Parse(text2.Split(new char[]
                        {
                            ' '
                        })[0]);
                        class4 = Essential.GetGame().GetRoomManager().GetRoom(num3);
                        if (class4 != null)
                        {
                            string string_2 = text2.Substring(num3.ToString().Length + 1);
                            for (int i = 0; i < class4.RoomUsers.Length; i++)
                            {
                                RoomUser class5 = class4.RoomUsers[i];
                                if (class5 != null && !class5.IsBot && !class5.IsPet)
                                {
                                    class5.GetClient().SendNotification(string_2);
                                }
                            }
                            goto IL_C70;
                        }
                        goto IL_C70;

                    case 10:
                    {
                        int int_2 = int.Parse(text2.Split(new char[]
                            {
                                ' '
                            })[0]);
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            Groups.UpdateGroup(class2, int_2);
                            goto IL_C70;
                        }
                    }

                    case 11:
                        goto IL_5BF;

                    case 12:
                        goto IL_602;

                    case 13:
                    case 14:
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            ChatCommandHandler.InitWords(class2);
                            goto IL_C70;
                        }

                    case 15:
                        goto IL_633;

                    case 16:
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().LoadServerSettings(class2);
                            goto IL_C70;
                        }

                    case 17:
                        goto IL_6F7;

                    case 18:
                        client = Essential.GetGame().GetClientManager().GetClient(uint.Parse(text2));
                        if (client != null)
                        {
                            client.GetHabbo().UpdateVipPoints(true, false);
                            goto IL_C70;
                        }
                        goto IL_C70;

                    case 19:
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().GetBanManager().Initialise(class2);
                        }
                        Essential.GetGame().GetClientManager().UpdateBans();
                        goto IL_C70;

                    case 20:
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().GetBotManager().Initialize(class2);
                            goto IL_C70;
                        }

                    case 21:
                        goto IL_839;

                    case 22:
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            class2.ExecuteQuery(text2);
                            goto IL_C70;
                        }

                    case 23:
                        goto IL_880;

                    case 24:
                    {
                        ServerMessage Message = new ServerMessage(Outgoing.InstantChat);
                        Message.AppendUInt(0u);
                        Message.AppendString("Habbo: " + text2);
                        Message.AppendString(Essential.GetUnixTimestamp() + string.Empty);
                        Essential.GetGame().GetClientManager().SendToStaffs(Message, Message);
                        goto IL_C70;
                    }

                    case 25:
                    {
                        ServerMessage Message2 = new ServerMessage(Outgoing.BroadcastMessage);
                        Message2.AppendStringWithBreak(EssentialEnvironment.GetExternalText("mus_ha_title") + "\n\n" + text2);
                        Message2.AppendStringWithBreak("");

                        /*ServerMessage Message3 = new ServerMessage(161u);
                         * Message3.AppendStringWithBreak(text2);
                         */
                        Essential.GetGame().GetClientManager().SendToHotel(Message2, Message2);
                        goto IL_C70;
                    }

                    case 26:
                    {
                        string text4 = text2.Split(new char[]
                            {
                                ' '
                            })[0];
                        text5 = text2.Substring(text4.Length + 1);
                        ServerMessage Message4 = new ServerMessage(Outgoing.SendNotif); // Updated
                        Message4.AppendStringWithBreak(string.Concat(new string[]
                            {
                                EssentialEnvironment.GetExternalText("mus_hal_title"),
                                "\r\n",
                                text5,
                                "\r\n-",
                                EssentialEnvironment.GetExternalText("mus_hal_tail")
                            }));
                        Message4.AppendStringWithBreak(text4);
                        Essential.GetGame().GetClientManager().BroadcastMessage(Message4);
                        goto IL_C70;
                    }

                    case 29:
                    {
                        num3 = uint.Parse(text2.Split(new char[]
                            {
                                ' '
                            })[0]);
                        uint UserIidu3 = num3;
                        client = Essential.GetGame().GetClientManager().GetClient(UserIidu3);
                        if (client != null)
                        {
                            client.GetHabbo().GetBadgeComponent().AddBadge(text2.Split(new char[]
                                {
                                    ' '
                                })[1], 0, false);
                        }

                        ServerMessage Message = new ServerMessage(Outgoing.AddBadge);

                        Message.AppendInt32(1);
                        Message.AppendInt32(4);
                        Message.AppendInt32(1);

                        Message.AppendUInt(0);

                        client.SendMessage(Message);

                        client.SendMessage(client.GetHabbo().GetBadgeComponent().ComposeBadgeListMessage());


                        goto IL_C70;
                    }

                    case 30:
                    {
                        uint UserIidu = uint.Parse(text2);
                        client = Essential.GetGame().GetClientManager().GetClient(UserIidu);
                        if (client != null)
                        {
                            if (client.GetHabbo().InRoom)
                            {
                                if (client.GetHabbo().CurrentRoom.CCTs.Contains("park"))
                                {
                                    if (!client.GetHabbo().CurrentRoom.IsInfobusOpen)
                                    {
                                        client.GetHabbo().CurrentRoom.IsInfobusOpen = true;
                                    }
                                    else
                                    {
                                        client.GetHabbo().CurrentRoom.IsInfobusOpen = false;
                                    }

                                    for (int i = 0; i < client.GetHabbo().CurrentRoom.RoomUsers.Length; i++)
                                    {
                                        RoomUser RoomiUser = client.GetHabbo().CurrentRoom.RoomUsers[i];
                                        if (RoomiUser != null)
                                        {
                                            ServerMessage ParkBusDoorMessage = new ServerMessage(Outgoing.ParkBusDoor);
                                            ParkBusDoorMessage.AppendBoolean(client.GetHabbo().CurrentRoom.IsInfobusOpen);
                                            RoomiUser.GetClient().SendMessage(ParkBusDoorMessage);
                                        }
                                    }
                                }
                                else
                                {
                                    // client.SendNotification("Sinun täytyy olla puistossa avataksesi tietolinjurin oven!");
                                }
                            }
                        }
                        goto IL_C70;
                    }

                    case 355:
                    {
                        uint UserIidu2 = uint.Parse(text2.Split(';')[0]);
                        client = Essential.GetGame().GetClientManager().GetClient(UserIidu2);
                        if (client != null)
                        {
                            if (client.GetHabbo().InRoom)
                            {
                                Room      Room       = Essential.GetGame().GetRoomManager().GetRoom(client.GetHabbo().CurrentRoomId);
                                DataTable Data       = null;
                                int       QuestionId = int.Parse(text2.Split(';')[1]);
                                Room.CurrentPollId = QuestionId;
                                string Question;

                                using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                {
                                    Question = dbClient.ReadString("SELECT question FROM infobus_questions WHERE id = '" + QuestionId + "' LIMIT 1");
                                    Data     = dbClient.ReadDataTable("SELECT * FROM infobus_answers WHERE question_id = '" + QuestionId + "'");
                                }

                                ServerMessage InfobusQuestion = new ServerMessage(Outgoing.InfobusPoll3); // Updated
                                InfobusQuestion.AppendStringWithBreak(Question);
                                InfobusQuestion.AppendInt32(Data.Rows.Count);
                                if (Data != null)
                                {
                                    foreach (DataRow Row in Data.Rows)
                                    {
                                        InfobusQuestion.AppendInt32((int)Row["id"]);
                                        InfobusQuestion.AppendStringWithBreak((string)Row["answer_text"]);
                                    }
                                }
                                Room.SendMessage(InfobusQuestion, null);

                                Thread Infobus = new Thread(delegate() { Room.ShowResults(Room, QuestionId, client); });
                                Infobus.Start();
                            }
                        }
                        goto IL_C70;
                    }

                    case 27:
                    case 28:
                    {
                        uint_2 = uint.Parse(text2);
                        client = Essential.GetGame().GetClientManager().GetClient(uint_2);
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            dataRow = class2.ReadDataRow("SELECT look,gender,motto,mutant_penalty,block_newfriends FROM users WHERE id = '" + client.GetHabbo().Id + "' LIMIT 1");
                        }
                        client.GetHabbo().Figure          = (string)dataRow["look"];
                        client.GetHabbo().Gender          = dataRow["gender"].ToString().ToLower();
                        client.GetHabbo().Motto           = Essential.FilterString((string)dataRow["motto"]);
                        client.GetHabbo().BlockNewFriends = Essential.StringToBoolean(dataRow["block_newfriends"].ToString());

                        /*ServerMessage Message5 = new ServerMessage(Outgoing.UpdateUserInformation);
                         *                      Message5.AppendInt32(-1);
                         *                      Message5.AppendStringWithBreak(client.GetHabbo().Figure);
                         *                      Message5.AppendStringWithBreak(client.GetHabbo().Gender.ToLower());
                         *                      Message5.AppendStringWithBreak(client.GetHabbo().Motto);
                         *                      client.SendMessage(Message5);*/
                        if (client.GetHabbo().InRoom)
                        {
                            class4 = Essential.GetGame().GetRoomManager().GetRoom(client.GetHabbo().CurrentRoomId);
                            RoomUser      class6   = class4.GetRoomUserByHabbo(client.GetHabbo().Id);
                            ServerMessage Message6 = new ServerMessage(Outgoing.UpdateUserInformation);
                            Message6.AppendInt32(class6.VirtualId);
                            Message6.AppendStringWithBreak(client.GetHabbo().Figure);
                            Message6.AppendStringWithBreak(client.GetHabbo().Gender.ToLower());
                            Message6.AppendStringWithBreak(client.GetHabbo().Motto);
                            Message6.AppendInt32(client.GetHabbo().AchievementScore);
                            class4.SendMessage(Message6, null);
                        }
                        text3 = text.ToLower();
                        if (text3 == null)
                        {
                            goto IL_C70;
                        }
                        if (text3 == "updatemotto")
                        {
                            class4 = Essential.GetGame().GetRoomManager().GetRoom(client.GetHabbo().CurrentRoomId);
                            RoomUser      class6   = class4.GetRoomUserByHabbo(client.GetHabbo().Id);
                            ServerMessage Message6 = new ServerMessage(Outgoing.UpdateUserInformation);
                            Message6.AppendInt32(class6.VirtualId);
                            Message6.AppendStringWithBreak(client.GetHabbo().Figure);
                            Message6.AppendStringWithBreak(client.GetHabbo().Gender.ToLower());
                            Message6.AppendStringWithBreak(client.GetHabbo().Motto);
                            Message6.AppendInt32(client.GetHabbo().AchievementScore);
                            class4.SendMessage(Message6, null);
                            client.GetHabbo().MottoAchievementsCompleted();
                            goto IL_C70;
                        }
                        if (text3 == "updatelook")
                        {
                            ServerMessage serverMessage = new ServerMessage(Outgoing.UpdateUserInformation);
                            serverMessage.AppendInt32(-1);
                            serverMessage.AppendStringWithBreak(client.GetHabbo().Figure);
                            serverMessage.AppendStringWithBreak(client.GetHabbo().Gender.ToLower());
                            serverMessage.AppendStringWithBreak(client.GetHabbo().Motto);
                            serverMessage.AppendInt32(client.GetHabbo().AchievementScore);
                            // serverMessage.AppendStringWithBreak("");
                            client.SendMessage(serverMessage);
                            class4 = Essential.GetGame().GetRoomManager().GetRoom(client.GetHabbo().CurrentRoomId);
                            RoomUser      class6   = class4.GetRoomUserByHabbo(client.GetHabbo().Id);
                            ServerMessage Message6 = new ServerMessage(Outgoing.UpdateUserInformation);
                            Message6.AppendInt32(class6.VirtualId);
                            Message6.AppendStringWithBreak(client.GetHabbo().Figure);
                            Message6.AppendStringWithBreak(client.GetHabbo().Gender.ToLower());
                            Message6.AppendStringWithBreak(client.GetHabbo().Motto);
                            Message6.AppendInt32(client.GetHabbo().AchievementScore);
                            class4.SendMessage(Message6, null);
                            client.GetHabbo().AvatarLookAchievementsCompleted();
                            goto IL_C70;
                        }
                        goto IL_C70;
                    }

                    case 31:
                    {
                        int QuestionID = int.Parse(text2.Split(';')[1]);
                        using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                        {
                            DataRow   QuestionRow  = dbClient.ReadDataRow("SELECT * FROM infobus_questions WHERE id='" + QuestionID + "' LIMIT 1");
                            DataTable AnswersTable = dbClient.ReadDataTable("SELECT * FROM infobus_answers WHERE question_id='" + QuestionID + "'");
                            Room      PollRoom     = Essential.GetGame().GetClientManager().GetClientByHabbo(QuestionRow["owner"].ToString()).GetHabbo().CurrentRoom;
                            if (PollRoom.Owner == QuestionRow["owner"].ToString() || Essential.GetGame().GetClientManager().GetClientByHabbo(QuestionRow["owner"].ToString()).GetHabbo().Rank < 5)
                            {
                                PollRoom.GetPollManager().SetCurrentPoll(PollRoom.GetPollManager().CreateNewRoomPoll(QuestionRow, AnswersTable));
                                PollRoom.SendMessage(PollRoom.GetPollManager().GetCurrentPoll().PollToServerMessage(new ServerMessage(Outgoing.InfobusPoll3)), null);
                                Thread Poll = new Thread(delegate() { PollRoom.GetPollManager().GetCurrentPoll().ShowResults(); });
                                Poll.Start();
                            }
                        }

                        goto IL_C70;
                    }

                    case 32:
                    {
                        uint   UserId    = uint.Parse(text2.Split(new char[] { ' ' })[0]);
                        string BadgeCode = text2.Split(new char[] { ' ' })[1];

                        GameClient Session = Essential.GetGame().GetClientManager().GetClientByHabbo(Essential.GetGame().GetClientManager().GetNameById(UserId));
                        if (Session != null)
                        {
                            Session.GetHabbo().GetBadgeComponent().SendBadge(Session, BadgeCode, true);
                        }
                        else
                        {
                            using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                            {
                                DataRow dr = dbClient.ReadDataRow("SELECT username FROM users WHERE id=" + UserId + " LIMIT 1");
                                if (dr != null)
                                {
                                    dbClient.AddParamWithValue("badge", BadgeCode);
                                    DataRow dr2 = dbClient.ReadDataRow("SELECT * FROM user_badges WHERE user_id=" + UserId + " AND badge_id=@badge LIMIT 1");
                                    if (dr2 == null)
                                    {
                                        dbClient.AddParamWithValue("badge", BadgeCode);
                                        dbClient.ExecuteQuery(string.Concat(new object[]
                                            {
                                                "INSERT INTO user_badges (user_id,badge_id,badge_slot) VALUES ('",
                                                UserId,
                                                "',@badge,'0')"
                                            }));
                                    }
                                }
                            }
                        }
                    }
                        goto IL_C70;

                    case 33:
                        using (DatabaseClient class5 = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().GetRoleManager().Initialize(class5);
                        }
                        goto IL_C70;

                    case 35:
                    {
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            Essential.GetGame().GetCatalog().Initialize(class2);
                        }
                        Essential.GetGame().GetCatalog().InitializeCache();
                        goto IL_C70;
                    }

                    case 36:
                    {
                        uint sender   = uint.Parse(text2.Split(new char[] { ' ' })[0]);
                        uint reciever = uint.Parse(text2.Split(new char[] { ' ' })[1]);
                        if (!this.FriendshipExists(reciever, sender))
                        {
                            using (DatabaseClient @class = Essential.GetDatabase().GetClient())
                            {
                                @class.AddParamWithValue("toid", reciever);
                                @class.AddParamWithValue("userid", sender);
                                @class.ExecuteQuery("INSERT INTO messenger_friendships (user_one_id,user_two_id) VALUES (@userid,@toid)");
                                @class.ExecuteQuery("INSERT INTO messenger_friendships (user_one_id,user_two_id) VALUES (@toid,@userid)");
                            }
                            GameClient SenderClient   = Essential.GetGame().GetClientManager().GetClient(sender);
                            GameClient RecieverClient = Essential.GetGame().GetClientManager().GetClient(reciever);
                            if (RecieverClient != null)
                            {
                                RecieverClient.GetHabbo().GetMessenger().method_14(sender);
                            }
                            if (SenderClient != null)
                            {
                                SenderClient.GetHabbo().GetMessenger().method_14(reciever);
                            }
                        }
                        goto IL_C70;
                    }

                    case 50:
                    {
                        Essential.getWebSocketManager().Dispose();
                        Essential.InitWebsocketManager();
                        goto IL_C70;
                    }

                    case 51:
                    {
                        Room   room      = Essential.GetGame().GetRoomManager().GetRoom(uint.Parse(text2.Split(';')[0]));
                        string Eventname = text2.Split(';')[1];
                        if (Eventname.Length > 1)
                        {
                            Eventname = AntiAd.Utf8ToUtf16(Eventname);
                            string toSend = "5|" + Eventname + "|" + room.Owner + "|" + room.Id;
                            Essential.getWebSocketManager().SendMessageToEveryConnection(toSend);
                            using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                            {
                                dbClient.AddParamWithValue("param1", room.Id);
                                dbClient.AddParamWithValue("param2", Eventname);
                                dbClient.ExecuteQuery("INSERT INTO hp_aktivitaetenstream (`user_id`,`type`,`extra_data`,`extra_data2`,`timestamp`) VALUES ('" + room.OwnerId + "','makeevent',@param1,@param2,'" + Convert.ToInt32(Essential.GetUnixTimestamp()) + "');");
                            }
                        }
                        goto IL_C70;
                    }

                    default:
                        goto IL_C70;
                    }
                    using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                    {
                        Essential.GetGame().GetCatalog().Initialize(class2);
                    }
                    Essential.GetGame().GetCatalog().InitializeCache();
                    Essential.GetGame().GetClientManager().BroadcastMessage(new ServerMessage(Outgoing.UpdateShop)); // Updated
                    goto IL_C70;
IL_34E:
                    num2 = uint.Parse(text2.Split(new char[]
                    {
                        ' '
                    })[0]);
                    num3 = uint.Parse(text2.Split(new char[]
                    {
                        ' '
                    })[1]);
                    GameClient class7 = Essential.GetGame().GetClientManager().GetClient(num2);
                    class4 = Essential.GetGame().GetRoomManager().GetRoom(num3);
                    if (class7 != null)
                    {
                        ServerMessage Message = new ServerMessage(Outgoing.RoomForward);
                        Message.AppendBoolean(class4.IsPublic);
                        Message.AppendUInt(class4.Id);
                        class7.SendMessage(Message);
                        goto IL_C70;
                    }
                    goto IL_C70;
IL_5BF:
                    uint_2 = uint.Parse(text2);
                    using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                    {
                        Essential.GetGame().GetClientManager().GetClient(uint_2).GetHabbo().method_0(class2);
                        goto IL_C70;
                    }
IL_602:
                    Essential.Close();
                    goto IL_C70;
IL_633:
                    client = Essential.GetGame().GetClientManager().GetClient(uint.Parse(text2));
                    if (client != null)
                    {
                        int int_3 = 0;
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            int_3 = (int)class2.ReadDataRow("SELECT credits FROM users WHERE id = '" + client.GetHabbo().Id + "' LIMIT 1")[0];
                        }
                        client.GetHabbo().SetCredits(int_3, "MUS UPDATE", "");
                        client.GetHabbo().UpdateCredits(false);
                        goto IL_C70;
                    }
                    goto IL_C70;
IL_6F7:
                    client = Essential.GetGame().GetClientManager().GetClient(uint.Parse(text2));
                    if (client != null)
                    {
                        int int_4 = 0;
                        using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                        {
                            int_4 = (int)class2.ReadDataRow("SELECT activity_points FROM users WHERE id = '" + client.GetHabbo().Id + "' LIMIT 1")[0];
                        }
                        client.GetHabbo().ActivityPoints = int_4;
                        client.GetHabbo().UpdateActivityPoints(false);
                        goto IL_C70;
                    }
                    goto IL_C70;
IL_839:
                    Essential.GetGame().GetClientManager().GetClient(uint.Parse(text2)).Disconnect("MUS");
                    goto IL_C70;
IL_880:
                    string text6 = text2.Split(new char[]
                    {
                        ' '
                    })[0];
                    text5 = text2.Substring(text6.Length + 1);

                    Essential.GetGame().GetClientManager().GetClient(uint.Parse(text6)).SendNotification(text5);
                }
            }
IL_C70:
            try
            {
                ServerMessage Message9 = new ServerMessage(Outgoing.MusAnswer);
                Message9.AppendString("Essential 5");
                Message9.AppendString("MUS Handler");
                this.ClientSocket.Send(Message9.GetBytes());
            }
            catch {}
        }
Esempio n. 10
0
        public static ServerMessage PlaceFurni(GameClient Session, int id, int x, int y, int rot, DatabaseClient dbClient)
        {
            List <UserInventory> mInventoryItem = AleedaEnvironment.GetHabboHotel().GetRoomUser().GetUserInventory(Session.GetHabbo().ID, false, Session.GetHabbo().ItemUsingID);

            foreach (UserInventory mItem in mInventoryItem)
            {
                dbClient.AddParamWithValue("id", Session.GetHabbo().RoomId);
                dbClient.AddParamWithValue("x", x);
                dbClient.AddParamWithValue("y", y);
                dbClient.AddParamWithValue("rotation", rot);
                dbClient.AddParamWithValue("sID", mItem.SpriteID);
                dbClient.ExecuteQuery("INSERT INTO room_items (`id`, `mID`, `x_axis`, `y_axis`, `rotation`, `sprite_id`, `trigger`, `isWallItem`) VALUES ('" + id + "', @id, @x, @y, @rotation, @sID, 1, 0);");

                ServerMessage Message = new ServerMessage(93);
                Message.AppendInt32(id);
                Message.AppendInt32(mItem.SpriteID);
                Message.AppendInt32(x);
                Message.AppendInt32(y);
                Message.AppendInt32(rot);
                Message.AppendString("0.0");
                Message.AppendInt32(1);
                Message.AppendString("" + 1);
                Message.AppendInt32(-1);
                return(Message);
            }
            return(null);
        }
Esempio n. 11
0
        /// <summary>
        /// Runs a client that connects to the server and automatically feeds in random records to add to the database
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
            int       port      = 8021;
            int       delayms   = 100;

            //Parse Command Line arguments
            int argc = args.GetUpperBound(0);

            if (argc > 2)
            {
                for (int i = 0; i < argc; i++)
                {
                    try
                    {
                        //delay
                        if (args[i] == "-d" && (i + 1) < argc)
                        {
                            delayms = int.Parse(args[i + 1]);
                        }
                        //Port
                        else if (args[i] == "-p" && (i + 1) < argc)
                        {
                            port = int.Parse(args[i + 1]);
                        }
                        //ip address
                        else if (args[i] == "-i" && (i + 1) < argc)
                        {
                            ipAddress = IPAddress.Parse(args[i + 1]);
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Failed to accept arguments: {0} {1}:", args[i], args[i + 1]);
                        // Print usage statement...
                        Console.WriteLine("Usage: Client1 [-d delay][-p port][-i ipaddress]");
                    }
                }
            }

            Console.WriteLine("(DataClient): Starting...");
            try
            {
                Random         rand   = new Random();
                DatabaseClient client = new DatabaseClient();
                Console.WriteLine("(DataClient): Connecting");
                client.Connect(ipAddress.ToString(), port);

                for (int i = 1; i <= 40000; i++)
                {
                    int namemin = kRandomNames.GetLowerBound(0);
                    int namemax = kRandomNames.GetUpperBound(0);

                    string firstname = kRandomNames[rand.Next(namemin, namemax)];
                    string lastname  = kRandomNames[rand.Next(namemin, namemax)];

                    string   datestr = rand.Next(int.MaxValue / 4).ToString() + rand.Next(int.MaxValue / 4).ToString();
                    DateTime date    = DateTime.FromFileTime(long.Parse(datestr));

                    Console.WriteLine("(DataClient): Inserting Record {0}", i);
                    Console.WriteLine("(DataClient):\tFirstName: {0}\tLastName: {1}\tDate: {2}", firstname, lastname, date);

                    try
                    {
                        DataRecord record = new DataRecord(0, firstname, lastname, date);
                        client.Insert(record);
                    }
                    catch (ArgumentException)
                    {
                        Console.WriteLine("(DataClient): Error, bad response");
                    }
                    catch (OutOfMemoryException)
                    {
                        Console.WriteLine("(DataClient): Database is full");
                    }
                    catch (DatabaseException)
                    {
                        Console.WriteLine("(DataClient): Database Error");
                    }

                    Thread.Sleep(delayms);
                }

                Console.WriteLine("(DataClient): Disconnecting");
                client.Disconnect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("(DataClient): Shutting Down");
            Console.ReadKey();
        }
    /// <summary>
    /// Connect to google-spreadsheet with the specified account and password then query cells and
    /// call the given callback.
    /// </summary>
    private void DoCellQuery(OnEachCell onCell)
    {
        // first we need to connect to the google-spreadsheet to get all the first row of the cells
        // which are used for the properties of data class.
        var client = new DatabaseClient("", "");

        if (string.IsNullOrEmpty(machine.SpreadSheetName))
            return;
        if (string.IsNullOrEmpty(machine.WorkSheetName))
            return;

        var db = client.GetDatabase(machine.SpreadSheetName);
        if (db == null) {
            Debug.LogError("The given spreadsheet does not exist.");
            return;
        }

        // retrieves all cells
        var worksheet = ((Database)db).GetWorksheetEntry(machine.WorkSheetName);

        // Fetch the cell feed of the worksheet.
        CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
        var cellFeed = client.SpreadsheetService.Query(cellQuery);

        // Iterate through each cell, printing its value.
        foreach (CellEntry cell in cellFeed.Entries) {
            if (onCell != null)
                onCell(cell);
        }
    }
Esempio n. 13
0
        //Data used by the status tool for measuring lagg, etc.

        #endregion

        #region Constructor
        /// <summary>
        /// Creates a new Database session
        /// </summary>
        /// <param name="client">The client which holds the connection</param>
        internal QueryAdapter(DatabaseClient client)
        {
            this.client = client;
        }
Esempio n. 14
0
        public DatabaseClient GetClient()
        {
            lock (this)
            {
                if(mClients.Length > 2)
                for (uint i = 0; i < mClients.Length; i++)
                {
                    if (mClientAvailable[i] == true)
                    {
                        mClientAvailable[i] = false;
                        mClientStarvationCounter = 0;

                        if (mClients[i].State == ConnectionState.Closed)
                        {
                            try
                            {
                                ConnectionState StateConn = mClients[i].Connect();
                                if (StateConn == ConnectionState.Connecting)
                                {
                                    Log.WriteLine(LogLevel.Debug,"Opening connection for database client #" + mClients[i].mHandle);
                                }
                                else if (StateConn == ConnectionState.Open)
                                {
                                    mClients[i].Destroy();
                                    mClients[i] = new DatabaseClient(i, this);
                                    mClients[i].Connect();
                                }
                                else if (StateConn == ConnectionState.Closed)
                                {
                                   //TODO Caching
                                    Console.WriteLine("Caching client Message");
                                    return mClients[i];
                                }
                                else if(StateConn == ConnectionState.Broken)
                                {
                                    mClients[i].Destroy();
                                    mClients[i] = new DatabaseClient(i, this);
                                    mClients[i].Connect();
                                }
                            }
                            catch(Exception ex)
                            {

                                Log.WriteLine(LogLevel.Exception,"{0}", ex.Message);
                            }
                        }

                        if (mClients[i].State == ConnectionState.Open)
                        {
                            mClients[i].UpdateLastActivity();
                            if (!mClients[i].IsBussy)
                            {
                                mClients[i].IsBussy = true;
                                return mClients[i];
                            }
                        }
                    }
                }

                mClientStarvationCounter++;

                if (mClientStarvationCounter >= ((mClients.Length + 1) / 2))
                {
                    mClientStarvationCounter = 0;
                    SetClientAmount((uint)(mClients.Length + 1 * 1.3f));

                    return GetClient();
                }

                DatabaseClient pAnonymous = new DatabaseClient(0, this);
                ConnectionState StateConns = pAnonymous.Connect();
                if (StateConns == ConnectionState.Connecting)
                {
                    pAnonymous.IsBussy = true;
                    Log.WriteLine(LogLevel.Debug, "Opening connection for database clientanon");
                }
                else if (StateConns == ConnectionState.Open)
                {
                    pAnonymous.Destroy();
                    pAnonymous = new DatabaseClient(0, this);
                    pAnonymous.Connect();
                }
                else if (StateConns == ConnectionState.Closed)
                {
                    //TODO Caching
                    Console.WriteLine("Caching client Message");
                    return pAnonymous;
                }
                else if (StateConns == ConnectionState.Broken)
                {
                    pAnonymous.Destroy();
                    pAnonymous = new DatabaseClient(0, this);
                    pAnonymous.Connect();
                }
            //                pAnonymous.Connect();

                 Log.WriteLine(LogLevel.Debug,"Handed out anonymous client.");
                return pAnonymous;
            }
        }
Esempio n. 15
0
        public void Handle(GameClient Session, ClientMessage Event)
        {
            Room @class = Essential.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (@class != null && Session != null && Session.GetHabbo().PassedSafetyQuiz)
            {
                Session.GetHabbo().CheckForUnmute();
                if (Session.GetHabbo().IsMuted)
                {
                    Session.SendNotification(EssentialEnvironment.GetExternalText("error_muted"));
                }
                else
                {
                    if (Session.GetHabbo().HasFuse("ignore_roommute") || [email protected]_4)
                    {
                        string text = Essential.FilterString(Event.PopFixedString());
                        if (!String.IsNullOrEmpty(text) || !String.IsNullOrWhiteSpace(text))
                        {
                            string text2 = text.Split(new char[]
                            {
                                ' '
                            })[0];
                            string text3 = text.Substring(text2.Length + 1);
                            text3 = ChatCommandHandler.ApplyFilter(text3);
                            RoomUser class2 = @class.GetRoomUserByHabbo(Session.GetHabbo().Id);
                            RoomUser class3 = @class.method_56(text2);
                            if (Session.GetHabbo().method_4() > 0)
                            {
                                TimeSpan timeSpan = DateTime.Now - Session.GetHabbo().dateTime_0;
                                if (timeSpan.Seconds > 4)
                                {
                                    Session.GetHabbo().int_23 = 0;
                                }
                                if (timeSpan.Seconds < 4 && Session.GetHabbo().int_23 > 5 && !class2.IsBot)
                                {
                                    ServerMessage Message = new ServerMessage(Outgoing.FloodFilter);
                                    Message.AppendInt32(Session.GetHabbo().method_4());
                                    Session.SendMessage(Message);
                                    Session.GetHabbo().IsMuted = true;
                                    Session.GetHabbo().int_4   = Session.GetHabbo().method_4();
                                    return;
                                }
                                Session.GetHabbo().dateTime_0 = DateTime.Now;
                                Session.GetHabbo().int_23++;
                            }
                            ServerMessage Message2 = new ServerMessage(Outgoing.Whisp); // OLD 25 UPDATED
                            Message2.AppendInt32(class2.VirtualId);
                            Message2.AppendStringWithBreak(text3);
                            Message2.AppendInt32(0);
                            Message2.AppendInt32(Event.PopWiredInt32());
                            Message2.AppendInt32(0);
                            Message2.AppendInt32(-1);
                            if (class2 != null && !class2.IsBot && !Essential.GetAntiAd().ContainsIllegalWord(text3))
                            {
                                class2.GetClient().SendMessage(Message2);
                            }
                            class2.Unidle();
                            if (class3 != null && !class3.IsBot && (class3.GetClient().GetHabbo().list_2.Count <= 0 || !class3.GetClient().GetHabbo().list_2.Contains(Session.GetHabbo().Id)))
                            {
                                if (!Essential.GetAntiAd().ContainsIllegalWord(text3))
                                {
                                    class3.GetClient().SendMessage(Message2);
                                }
                                if (ServerConfiguration.EnableChatlog)
                                {
                                    using (DatabaseClient class4 = Essential.GetDatabase().GetClient())
                                    {
                                        class4.AddParamWithValue("message", "<Whisper to " + class3.GetClient().GetHabbo().Username + ">: " + text3);
                                        class4.ExecuteQuery(string.Concat(new object[]
                                        {
                                            "INSERT INTO chatlogs (user_id,room_id,hour,minute,timestamp,message,user_name,full_date) VALUES ('",
                                            Session.GetHabbo().Id,
                                            "','",
                                            @class.Id,
                                            "','",
                                            DateTime.Now.Hour,
                                            "','",
                                            DateTime.Now.Minute,
                                            "',UNIX_TIMESTAMP(),@message,'",
                                            Session.GetHabbo().Username,
                                            "','",
                                            DateTime.Now.ToLongDateString(),
                                            "')"
                                        }));
                                    }
                                }
                                if (Essential.GetAntiAd().ContainsIllegalWord(text3))
                                {
                                    ServerMessage Message3 = new ServerMessage(Outgoing.InstantChat);
                                    Message3.AppendUInt(0u);
                                    Message3.AppendString("[AWS] " + Session.GetHabbo().Username + ": " + text3);
                                    Message3.AppendString(Essential.GetUnixTimestamp() + string.Empty);
                                    Essential.GetGame().GetClientManager().SendToStaffs(Session, Message3);
                                    Session.SendNotification(Essential.GetGame().GetRoleManager().GetConfiguration().getData("antiad.alert"));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 16
0
        public void addAchievement(GameClient Session, uint uint_0, int int_0)
        {
            if (!AchievementManager.dictionary_0.ContainsKey(uint_0))
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("AchievementID: " + uint_0 + " does not exist in our database!");
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Achievement @class = AchievementManager.dictionary_0[uint_0];
                if (@class != null && !this.method_1(Session, @class.Id, int_0) && int_0 >= 1 && int_0 <= @class.Levels)
                {
                    int num  = AchievementManager.smethod_2(@class.Dynamic_badgelevel, @class.PixelMultiplier, int_0);
                    int num2 = AchievementManager.smethod_2(@class.ScoreBase, @class.PixelMultiplier, int_0);
                    using (TimedLock.Lock(Session.GetHabbo().method_22().List_0))
                    {
                        List <string> list = new List <string>();
                        foreach (Badge current in Session.GetHabbo().method_22().List_0)
                        {
                            if (current.Code.StartsWith(@class.BadgeCode))
                            {
                                list.Add(current.Code);
                            }
                        }
                        foreach (string current2 in list)
                        {
                            Session.GetHabbo().method_22().method_6(current2);
                        }
                    }
                    Session.GetHabbo().method_22().method_2(Session, AchievementManager.smethod_3(@class.BadgeCode, int_0, @class.DynamicBadgeLevel), true);
                    if (Session.GetHabbo().dictionary_0.ContainsKey(@class.Id))
                    {
                        Session.GetHabbo().dictionary_0[@class.Id] = int_0;
                        using (DatabaseClient class2 = GoldTree.GetDatabase().GetClient())
                        {
                            class2.ExecuteQuery(string.Concat(new object[]
                            {
                                "UPDATE user_achievements SET achievement_level = '",
                                int_0,
                                "' WHERE user_id = '",
                                Session.GetHabbo().Id,
                                "' AND achievement_id = '",
                                @class.Id,
                                "' LIMIT 1; UPDATE user_stats SET AchievementScore = AchievementScore + ",
                                num2,
                                " WHERE Id = '",
                                Session.GetHabbo().Id,
                                "' LIMIT 1; "
                            }));
                            goto IL_346;
                        }
                    }
                    Session.GetHabbo().dictionary_0.Add(@class.Id, int_0);
                    using (DatabaseClient class2 = GoldTree.GetDatabase().GetClient())
                    {
                        class2.ExecuteQuery(string.Concat(new object[]
                        {
                            "INSERT INTO user_achievements (user_id,achievement_id,achievement_level) VALUES ('",
                            Session.GetHabbo().Id,
                            "','",
                            @class.Id,
                            "','",
                            int_0,
                            "'); UPDATE user_stats SET AchievementScore = AchievementScore + ",
                            num2,
                            " WHERE Id = '",
                            Session.GetHabbo().Id,
                            "' LIMIT 1; "
                        }));
                    }
IL_346:
                    ServerMessage Message = new ServerMessage(437u);
                    Message.AppendUInt(@class.Id);
                    Message.AppendInt32(int_0);
                    Message.AppendInt32(1337);
                    Message.AppendStringWithBreak(AchievementManager.smethod_3(@class.BadgeCode, int_0, @class.DynamicBadgeLevel));
                    Message.AppendInt32(num2);
                    Message.AppendInt32(num);
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                    Message.AppendInt32(0);
                    if (int_0 > 1)
                    {
                        Message.AppendStringWithBreak(AchievementManager.smethod_3(@class.BadgeCode, int_0 - 1, @class.DynamicBadgeLevel));
                    }
                    else
                    {
                        Message.AppendStringWithBreak("");
                    }
                    Message.AppendStringWithBreak(@class.Type);
                    Session.SendMessage(Message);
                    Session.GetHabbo().AchievementScore += num2;
                    Session.GetHabbo().ActivityPoints   += num;
                    Session.GetHabbo().method_16(num);
                }
            }
        }
        public override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            RoomUser User = Item.method_8().GetRoomUserByHabbo((uint)Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (Request == 0 && Item.FireWorkCount > 0 && Item.ExtraData == "1")
            {
                Item.ExtraData = "2";
                Item.UpdateState(false, true);

                if (Item.FireWorkCount > 0)
                {
                    Task T = null;
                    T = new Task(delegate() { Action(Item, T, "1"); });
                    T.Start();
                }
                else
                {
                    Task T = null;
                    T = new Task(delegate() { Action(Item, T, "0"); });
                    T.Start();
                }
            }
            else if (Request == 1)
            {
                ServerMessage PixelMessage = new ServerMessage(629);
                PixelMessage.AppendUInt(Item.uint_0);
                PixelMessage.AppendInt32(Item.FireWorkCount);
                PixelMessage.AppendBoolean(false);
                PixelMessage.AppendInt32(Pixels);    // pixels :D
                PixelMessage.AppendBoolean(false);
                PixelMessage.AppendInt32(Fireworks); // 10 fireworks :D
                Session.SendMessage(PixelMessage);
            }
            else if (Request == 2 && Session.GetHabbo().ActivityPoints >= 20)
            {
                Item.FireWorkCount += Fireworks;

                Session.GetHabbo().FireworkPixelLoadedCount += Pixels;
                Session.GetHabbo().ActivityPoints           -= 20;
                Session.GetHabbo().UpdateActivityPoints(true);

                using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient())
                {
                    dbClient.AddParamWithValue("itemid", Item.uint_0);
                    dbClient.AddParamWithValue("sessionid", Session.GetHabbo().Id);
                    dbClient.ExecuteQuery("UPDATE items_firework SET fw_count = fw_count + '" + Fireworks + "' WHERE item_id = @itemid LIMIT 1");
                    dbClient.ExecuteQuery("UPDATE user_stats SET fireworks = fireworks + '" + Pixels + "' WHERE id = @sessionid LIMIT 1");
                }

                ServerMessage PixelMessage = new ServerMessage(629);
                PixelMessage.AppendUInt(Item.uint_0);
                PixelMessage.AppendInt32(Item.FireWorkCount);
                PixelMessage.AppendBoolean(false);
                PixelMessage.AppendInt32(Pixels);    // pixels :D
                PixelMessage.AppendBoolean(false);
                PixelMessage.AppendInt32(Fireworks); // 10 fireworks :D
                Session.SendMessage(PixelMessage);

                if (Item.ExtraData == "0")
                {
                    Item.ExtraData = "1";
                    Item.UpdateState(true, true);
                }

                Session.GetHabbo().CheckFireworkAchievements();
            }
        }
Esempio n. 18
0
 public ServerMessage SerializeUserChatlog(uint UserId)
 {
     using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
     {
         DataTable     dataTable = adapter.ReadDataTable("SELECT room_id,entry_timestamp,exit_timestamp FROM user_roomvisits WHERE user_id = '" + UserId + "' ORDER BY entry_timestamp DESC LIMIT 5");
         ServerMessage Message   = new ServerMessage(536u);
         Message.AppendUInt(UserId);
         Message.AppendStringWithBreak(PhoenixEnvironment.GetGame().GetClientManager().GetNameById(UserId));
         if (dataTable != null)
         {
             Message.AppendInt32(dataTable.Rows.Count);
             IEnumerator enumerator = dataTable.Rows.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     DataRow   dataRow = (DataRow)enumerator.Current;
                     DataTable dataTable2;
                     if ((double)dataRow["exit_timestamp"] <= 0.0)
                     {
                         dataTable2 = adapter.ReadDataTable(string.Concat(new object[]
                         {
                             "SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '",
                             (uint)dataRow["room_id"],
                             "' AND timestamp > ",
                             (double)dataRow["entry_timestamp"],
                             " AND timestamp < UNIX_TIMESTAMP() ORDER BY timestamp DESC LIMIT 100"
                         }));
                     }
                     else
                     {
                         dataTable2 = adapter.ReadDataTable(string.Concat(new object[]
                         {
                             "SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '",
                             (uint)dataRow["room_id"],
                             "' AND timestamp > ",
                             (double)dataRow["entry_timestamp"],
                             " AND timestamp < ",
                             (double)dataRow["exit_timestamp"],
                             " ORDER BY timestamp DESC LIMIT 100"
                         }));
                     }
                     RoomData class2 = PhoenixEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData((uint)dataRow["room_id"]);
                     Message.AppendBoolean(class2.IsPublicRoom);
                     Message.AppendUInt(class2.Id);
                     Message.AppendStringWithBreak(class2.Name);
                     if (dataTable2 != null)
                     {
                         Message.AppendInt32(dataTable2.Rows.Count);
                         IEnumerator enumerator2 = dataTable2.Rows.GetEnumerator();
                         try
                         {
                             while (enumerator2.MoveNext())
                             {
                                 DataRow dataRow2 = (DataRow)enumerator2.Current;
                                 Message.AppendInt32((int)dataRow2["hour"]);
                                 Message.AppendInt32((int)dataRow2["minute"]);
                                 Message.AppendUInt((uint)dataRow2["user_id"]);
                                 Message.AppendStringWithBreak((string)dataRow2["user_name"]);
                                 Message.AppendStringWithBreak((string)dataRow2["message"]);
                             }
                             continue;
                         }
                         finally
                         {
                             IDisposable disposable = enumerator2 as IDisposable;
                             if (disposable != null)
                             {
                                 disposable.Dispose();
                             }
                         }
                     }
                     Message.AppendInt32(0);
                 }
             }
             finally
             {
                 IDisposable disposable = enumerator as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
         }
         Message.AppendInt32(0);
         return(Message);
     }
 }
Esempio n. 19
0
 internal void method_19(DatabaseClient class6_0, bool bool_0)
 {
     try
     {
         if (this.list_1.Count > 0 || this.hashtable_1.Count > 0 || this.hashtable_0.Count > 0)
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (Pet @class in this.hashtable_0.Values)
             {
                 if (@class.DBState == DatabaseUpdateState.NeedsInsert)
                 {
                     class6_0.AddParamWithValue("petname" + @class.PetId, @class.Name);
                     class6_0.AddParamWithValue("petcolor" + @class.PetId, @class.Color);
                     class6_0.AddParamWithValue("petrace" + @class.PetId, @class.Race);
                     stringBuilder.Append(string.Concat(new object[]
                     {
                         "INSERT INTO `user_pets` VALUES ('",
                         @class.PetId,
                         "', '",
                         @class.OwnerId,
                         "', '",
                         @class.RoomId,
                         "', @petname",
                         @class.PetId,
                         ", @petrace",
                         @class.PetId,
                         ", @petcolor",
                         @class.PetId,
                         ", '",
                         @class.Type,
                         "', '",
                         @class.Expirience,
                         "', '",
                         @class.Energy,
                         "', '",
                         @class.Nutrition,
                         "', '",
                         @class.Respect,
                         "', '",
                         @class.CreationStamp,
                         "', '",
                         @class.X,
                         "', '",
                         @class.Y,
                         "', '",
                         @class.Z,
                         "');"
                     }));
                 }
                 else
                 {
                     if (@class.DBState == DatabaseUpdateState.NeedsUpdate)
                     {
                         stringBuilder.Append(string.Concat(new object[]
                         {
                             "UPDATE user_pets SET room_id = '",
                             @class.RoomId,
                             "', expirience = '",
                             @class.Expirience,
                             "', energy = '",
                             @class.Energy,
                             "', nutrition = '",
                             @class.Nutrition,
                             "', respect = '",
                             @class.Respect,
                             "', x = '",
                             @class.X,
                             "', y = '",
                             @class.Y,
                             "', z = '",
                             @class.Z,
                             "' WHERE Id = '",
                             @class.PetId,
                             "' LIMIT 1; "
                         }));
                     }
                 }
                 @class.DBState = DatabaseUpdateState.Updated;
             }
             if (stringBuilder.Length > 0)
             {
                 class6_0.ExecuteQuery(stringBuilder.ToString());
             }
         }
         if (bool_0)
         {
             Console.WriteLine("Inventory for user: "******" saved.");
         }
     }
     catch (Exception ex)
     {
         Logging.LogCacheError("FATAL ERROR DURING DB UPDATE: " + ex.ToString());
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Sets the amount of clients that will be available to requesting methods. If the new amount is lower than the current amount, the 'excluded' connections are destroyed. If the new connection amount is higher than the current amount, new clients are prepared. Already existing clients and their state will be maintained.
        /// </summary>
        /// <param name="Amount">The new amount of clients.</param>
        internal void SetClientAmount(uint Amount)
        {
            lock (this)
            {
                if (mClients.Length == Amount)
                    return;

                if (Amount < mClients.Length) // Client amount shrinks, dispose clients that will die
                {
                    for (uint i = Amount; i < mClients.Length; i++)
                    {
                        mClients[i].Destroy();
                        mClients[i] = null;
                    }
                }

                DatabaseClient[] pClients = new DatabaseClient[Amount];
                bool[] pClientAvailable = new bool[Amount];
                for (uint i = 0; i < Amount; i++)
                {
                    if (i < mClients.Length) // Keep the existing client and it's available state
                    {
                        pClients[i] = mClients[i];
                        pClientAvailable[i] = mClientAvailable[i];
                    }
                    else // We are in need of more clients, so make another one
                    {
                        pClients[i] = new DatabaseClient((i + 1), this);
                        pClientAvailable[i] = true; // Elegant?
                    }
                }

                // Update the instance fields
                mClients = pClients;
                mClientAvailable = pClientAvailable;
            }
        }
Esempio n. 21
0
 public Database(DatabaseClient database, bool debug)
 {
     _Debug    = debug;
     _Database = database;
 }
Esempio n. 22
0
 public UserController()
 {
     client = new DatabaseClient();
 }
Esempio n. 23
0
 public void BanUser(GameClient Client, string Moderator, double LengthSeconds, string Reason, bool IpBan)
 {
     if (!Client.GetHabbo().isAaron)
     {
         ModerationBanType uSERNAME = ModerationBanType.USERNAME;
         string            username = Client.GetHabbo().Username;
         string            val      = "user";
         double            Expire   = PhoenixEnvironment.GetUnixTimestamp() + LengthSeconds;
         if (IpBan)
         {
             uSERNAME = ModerationBanType.IP;
             if (!GlobalClass.UseIP_Last)
             {
                 username = Client.GetConnection().ipAddress;
             }
             else
             {
                 using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                 {
                     username = adapter.ReadString("SELECT ip_last FROM users WHERE Id = " + Client.GetHabbo().Id + " LIMIT 1;");
                 }
             }
             val = "ip";
         }
         this.Bans.Add(new ModerationBan(uSERNAME, username, Reason, Expire));
         using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
         {
             adapter.AddParamWithValue("rawvar", val);
             adapter.AddParamWithValue("var", username);
             adapter.AddParamWithValue("reason", Reason);
             adapter.AddParamWithValue("mod", Moderator);
             adapter.ExecuteQuery("INSERT INTO bans (bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES (@rawvar,@var,@reason,'" + Expire + "',@mod,'" + DateTime.Now.ToLongDateString() + "', '1')");
         }
         if (IpBan)
         {
             DataTable table = null;
             using (DatabaseClient client3 = PhoenixEnvironment.GetDatabase().GetClient())
             {
                 client3.AddParamWithValue("var", username);
                 table = client3.ReadDataTable("SELECT id FROM users WHERE ip_last = @var");
             }
             if (table != null)
             {
                 foreach (DataRow row in table.Rows)
                 {
                     using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                     {
                         adapter.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + ((uint)row["id"]) + "' LIMIT 1");
                     }
                 }
             }
         }
         else
         {
             using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
             {
                 adapter.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + Client.GetHabbo().Id + "' LIMIT 1");
             }
         }
         Client.SendBanMessage("You have been banned: " + Reason);
         Client.Disconnect();
     }
 }
        public void Handle(GameClient session, ClientMessage message)
        {
            ServerMessage response = new ServerMessage(950u);

            session.GetHabbo().GetUserDataFactory().UpdateFriendStream();

            int streamCount = session.GetHabbo().GetUserDataFactory().GetFriendStream().Rows.Count;

            response.AppendInt32(streamCount);

            DataTable dataTable_ = session.GetHabbo().GetUserDataFactory().GetFriendStream();

            foreach (DataRow row in dataTable_.Rows)
            {
                int type = (int)row["type"];

                if (type >= 0 && type <= 4)
                {
                    uint id = (uint)row["id"];

                    int  likes   = 0;
                    bool canlike = false;

                    using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
                    {
                        likes = @class.ReadInt32("SELECT COUNT(friend_stream_id) FROM friend_stream_likes WHERE friend_stream_id = '" + id + "' LIMIT 1");

                        DataRow datarow = @class.ReadDataRow("SELECT id FROM friend_stream_likes WHERE friend_stream_id = '" + id + "' AND userid = '" + session.GetHabbo().Id + "' LIMIT 1");

                        if (datarow == null)
                        {
                            canlike = true;
                        }
                        else
                        {
                            canlike = false;
                        }
                    }

                    uint   userid   = (uint)row["userid"];
                    string username = GoldTree.GetGame().GetClientManager().GetNameById(userid);

                    string gender = (string)row["gender"].ToString().ToLower();
                    string look   = (string)row["look"];

                    int time = (int)((GoldTree.GetUnixTimestamp() - (double)row["time"]) / 60);

                    string data = (string)row["data"];

                    response.AppendUInt(id);
                    response.AppendInt32(type);

                    response.AppendStringWithBreak(userid.ToString());
                    response.AppendStringWithBreak(username);

                    response.AppendStringWithBreak(gender);
                    response.AppendStringWithBreak("http://goldtreehotel.net/r63/c_images/friendstream/head.gif?figure=" + look);
                    //response.AppendStringWithBreak("http://goldtreehotel.net/r63/c_images/album1584/ADM.gif");

                    response.AppendInt32(time);

                    if (type == 0)
                    {
                        string data_extra = (string)row["data_extra"];

                        uint friend_id = uint.Parse(data, CustomCultureInfo.GetCustomCultureInfo());

                        if (session.GetHabbo().Id == friend_id || session.GetHabbo().GetMessenger().UserInFriends(friend_id))
                        {
                            response.AppendInt32(0);
                        }
                        else
                        {
                            response.AppendInt32(5);
                        }
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);
                        response.AppendStringWithBreak(data);
                        response.AppendStringWithBreak(data_extra);
                    }
                    else if (type == 1)
                    {
                        response.AppendInt32(2);
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);

                        uint roomId;

                        RoomData RoomData;

                        if (uint.TryParse(data, out roomId))
                        {
                            RoomData = GoldTree.GetGame().GetRoomManager().method_12(roomId);
                        }
                        else
                        {
                            RoomData = GoldTree.GetGame().GetRoomManager().method_12(0);
                        }

                        if (RoomData != null)
                        {
                            response.AppendStringWithBreak(RoomData.Id.ToString()); //data
                            response.AppendStringWithBreak(RoomData.Name);          //extra data
                        }
                        else
                        {
                            response.AppendStringWithBreak("");
                            response.AppendStringWithBreak("Room deleted");
                        }
                    }
                    else if (type == 2)
                    {
                        response.AppendInt32(3);
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);
                        response.AppendStringWithBreak(data);
                    }
                    else if (type == 3)
                    {
                        response.AppendInt32(4);
                        response.AppendInt32(likes);
                        response.AppendBoolean(canlike);
                        response.AppendStringWithBreak(data);
                    }
                }
            }

            session.SendMessage(response);
        }
        public void LoadMembersPetitions(int a, int gId, int b, string search, GameClient Session)
        {
            try
            {
                int           guildId = gId;
                int           num2    = a;
                int           num3    = b;
                string        str     = search;
                GroupsManager guild   = Groups.GetGroupById(guildId);
                if (guild != null)
                {
                    ServerMessage message;
                    int           memberCounter = 0;
                    int           results;
                    if (num3 == 0)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            results = 0;
                            foreach (int num4 in guild.Members)
                            {
                                if (Essential.GetGame().GetClientManager().GetNameById((uint)num4).ToLower().Contains(str.ToLower()))
                                {
                                    results++;
                                }
                            }
                        }
                        else
                        {
                            results = guild.Members.Count();
                        }
                        message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                        message.AppendInt32(guild.Id);
                        message.AppendString(guild.Name);
                        message.AppendInt32(guild.RoomId);
                        message.AppendString(guild.Badge);
                        message.AppendInt32(results);

                        if (num2 == 0)
                        {
                            message.AppendInt32(results);
                        }
                        else
                        {
                            message.AppendInt32(results - (num2 * 14));
                        }

                        foreach (int num4 in guild.Members)
                        {
                            if (!string.IsNullOrEmpty(str))
                            {
                                if (Essential.GetGame().GetClientManager().GetNameById((uint)num4).ToLower().Contains(str.ToLower()))
                                {
                                    if (memberCounter >= ((num2) * 14))
                                    {
                                        if (guild.OwnerId == num4)
                                        {
                                            message.AppendInt32(0);
                                        }
                                        else
                                        {
                                            message.AppendInt32(guild.getRank(num4));
                                        }
                                        message.AppendInt32(num4);
                                        message.AppendString(Essential.GetGame().GetClientManager().GetNameById((uint)num4));
                                        using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                            message.AppendString(dbClient.ReadString("SELECT look FROM users WHERE id=" + num4));
                                        message.AppendString("");
                                    }
                                    memberCounter++;
                                }
                            }

                            else
                            {
                                if (memberCounter >= (num2 * 14))
                                {
                                    if (guild.OwnerId == (uint)num4)
                                    {
                                        message.AppendInt32(0);
                                    }
                                    else
                                    {
                                        message.AppendInt32(guild.getRank(num4));
                                    }
                                    message.AppendInt32(num4);
                                    message.AppendString(Essential.GetGame().GetClientManager().GetNameById((uint)num4));
                                    using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                        message.AppendString(dbClient.ReadString("SELECT look FROM users WHERE id=" + num4));
                                    message.AppendString("");
                                }
                                memberCounter++;
                            }
                        }

                        if (Session.GetHabbo().InGuild(guild.Id))
                        {
                            if (guild.UserWithRanks.Contains((int)Session.GetHabbo().Id))
                            {
                                message.AppendBoolean(true);
                            }
                            else
                            {
                                message.AppendBoolean(false);
                            }
                        }
                        else
                        {
                            message.AppendBoolean(false);
                        }
                        message.AppendInt32(14);
                        message.AppendInt32(num2);
                        message.AppendInt32(0);
                        message.AppendString(str);
                        Session.SendMessage(message);
                    }
                    else if (num3 == 1)
                    {
                        int admins = 0;

                        foreach (int num4 in guild.Members)
                        {
                            if (guild.UserWithRanks.Contains(num4))
                            {
                                admins++;
                            }
                        }

                        if (!string.IsNullOrEmpty(str))
                        {
                            results = 0;
                            foreach (int num4 in guild.Members)
                            {
                                if ((Essential.GetGame().GetClientManager().GetNameById((uint)num4).ToLower().Contains(str.ToLower())) && ((guild.UserWithRanks.Contains(num4))))
                                {
                                    results++;
                                }
                            }
                        }
                        else
                        {
                            results = admins;
                        }

                        message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                        message.AppendInt32(guild.Id);
                        message.AppendString(guild.Name);
                        message.AppendInt32(guild.RoomId);
                        message.AppendString(guild.Badge);
                        message.AppendInt32(results);

                        if (num2 == 0)
                        {
                            message.AppendInt32(results);
                        }

                        else
                        {
                            message.AppendInt32(results - (num2 * 14));
                        }
                        memberCounter = 0;
                        foreach (int num4 in guild.Members)
                        {
                            if (!string.IsNullOrEmpty(str))
                            {
                                if (Essential.GetGame().GetClientManager().GetNameById((uint)num4).ToLower().Contains(str.ToLower()))
                                {
                                    if (guild.UserWithRanks.Contains(num4))
                                    {
                                        if (memberCounter >= ((num2) * 14))
                                        {
                                            if (guild.OwnerId == num4)
                                            {
                                                message.AppendInt32(0);
                                            }
                                            else
                                            {
                                                message.AppendInt32(guild.getRank(num4));
                                            }
                                            message.AppendInt32(num4);
                                            message.AppendString(Essential.GetGame().GetClientManager().GetNameById((uint)num4));
                                            using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                                message.AppendString(dbClient.ReadString("SELECT look FROM users WHERE id=" + num4));
                                            message.AppendString("");
                                        }
                                    }
                                    memberCounter++;
                                }
                            }

                            else
                            {
                                if (memberCounter >= (num2 * 14))
                                {
                                    if (guild.UserWithRanks.Contains(num4))
                                    {
                                        if (guild.OwnerId == num4)
                                        {
                                            message.AppendInt32(0);
                                        }
                                        else
                                        {
                                            message.AppendInt32(guild.getRank(num4));
                                        }
                                        message.AppendInt32(num4);
                                        message.AppendString(Essential.GetGame().GetClientManager().GetNameById((uint)num4));
                                        using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                            message.AppendString(dbClient.ReadString("SELECT look FROM users WHERE id=" + num4));
                                        message.AppendString("");
                                    }
                                }
                                memberCounter++;
                            }
                        }
                        if (Session.GetHabbo().InGuild(guild.Id))
                        {
                            if (guild.UserWithRanks.Contains((int)Session.GetHabbo().Id))
                            {
                                message.AppendBoolean(true);
                            }
                            else
                            {
                                message.AppendBoolean(false);
                            }
                        }
                        else
                        {
                            message.AppendBoolean(false);
                        }
                        message.AppendInt32(14);
                        message.AppendInt32(num2);
                        message.AppendInt32(1);
                        message.AppendString(str);
                        Session.SendMessage(message);
                    }

                    else if (num3 == 2)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            results = 0;
                            foreach (int num4 in guild.Petitions)
                            {
                                if (Essential.GetGame().GetClientManager().GetNameById((uint)num4).ToLower().Contains(str.ToLower()))
                                {
                                    results++;
                                }
                            }
                        }

                        else
                        {
                            results = guild.Petitions.Count();
                        }

                        message = new ServerMessage(Outgoing.SendMembersAndPetitions);
                        message.AppendInt32(guild.Id);
                        message.AppendString(guild.Name);
                        message.AppendInt32(guild.RoomId);
                        message.AppendString(guild.Badge);
                        message.AppendInt32(results);
                        if (num2 == 0)
                        {
                            message.AppendInt32(results);
                        }

                        else
                        {
                            message.AppendInt32(results - (num2 * 14));
                        }
                        memberCounter = 0;
                        foreach (int num4 in guild.Petitions)
                        {
                            if (!string.IsNullOrEmpty(str))
                            {
                                if (Essential.GetGame().GetClientManager().GetNameById((uint)num4).ToLower().Contains(str.ToLower()))
                                {
                                    if (memberCounter >= ((num2) * 14))
                                    {
                                        message.AppendInt32(3);
                                        message.AppendInt32(num4);
                                        message.AppendString(Essential.GetGame().GetClientManager().GetNameById((uint)num4));
                                        using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                            message.AppendString(dbClient.ReadString("SELECT look FROM users WHERE id=" + num4));
                                        message.AppendString("");
                                    }
                                    memberCounter++;
                                }
                            }

                            else
                            {
                                if (memberCounter >= (num2 * 14))
                                {
                                    message.AppendInt32(3);
                                    message.AppendInt32(num4);
                                    message.AppendString(Essential.GetGame().GetClientManager().GetNameById((uint)num4));
                                    using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                                        message.AppendString(dbClient.ReadString("SELECT look FROM users WHERE id=" + num4));
                                    message.AppendString("");
                                }
                                memberCounter++;
                            }
                        }
                        if (guild.UserWithRanks.Contains((int)Session.GetHabbo().Id))
                        {
                            message.AppendBoolean(true);
                        }
                        else
                        {
                            message.AppendBoolean(false);
                        }
                        message.AppendInt32(14);
                        message.AppendInt32(num2);
                        message.AppendInt32(2);
                        message.AppendString(str);
                        Session.SendMessage(message);
                    }
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 26
0
	void Start () {
		for (int i = 0; i < 10; i++) 
			leaderInfo[i] = new LeaderBoard();
        dataBase = GameObject.FindGameObjectWithTag("Database").GetComponent<DatabaseClient>();
		loadPage ();
	}
        public void Handle(GameClient Session, ClientMessage Event)
        {
            int           guildId = Event.PopWiredInt32();
            GroupsManager guild   = Groups.GetGroupById(guildId);
            int           UserId  = Event.PopWiredInt32();

            if (UserId != Session.GetHabbo().Id&& !guild.UserWithRanks.Contains((int)Session.GetHabbo().Id))
            {
                return;
            }
            if (guild != null)
            {
                using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                {
                    dbClient.ExecuteQuery("DELETE FROM `group_memberships` WHERE (`groupid`='" + guildId + "') AND (`userid`='" + UserId + "') LIMIT 1");
                    dbClient.ExecuteQuery("UPDATE user_stats SET groupid=0 WHERE (groupid=" + guildId + ") AND (id=" + UserId + ") LIMIT 1");
                }
                guild.Leave(UserId);
                if (guild.UserWithRanks.Contains((int)UserId))
                {
                    guild.UserWithRanks.Remove((int)UserId);
                }
                if ((uint)UserId != Session.GetHabbo().Id)
                {
                    LoadMembersPetitions(0, guildId, 0, "", Session);
                }
                GameClient habbo = Essential.GetGame().GetClientManager().GetClientById((uint)UserId);
                if (habbo != null)
                {
                    if (habbo.GetHabbo().FavouriteGroup == guild.Id)
                    {
                        habbo.GetHabbo().FavouriteGroup = 0;
                        if (habbo.GetHabbo().CurrentRoom != null)
                        {
                            List <RoomUser> list    = new List <RoomUser>(habbo.GetHabbo().CurrentRoom.RoomUsers);
                            ServerMessage   message = new ServerMessage(Outgoing.SendGroup);
                            message.AppendInt32(0);
                            Session.SendMessage(message);
                            ServerMessage message2 = new ServerMessage(Outgoing.SetRoomUser);
                            message2.AppendInt32(1);
                            foreach (RoomUser user in list)
                            {
                                if (user.UId == habbo.GetHabbo().Id)
                                {
                                    user.method_14(message2);
                                    user.RemoveStatus("flatctrl 1");
                                    user.AddStatus("flatctrl 0", "");
                                    user.UpdateNeeded = true;
                                }
                            }
                            habbo.GetHabbo().CurrentRoom.SendMessage(message2, null);
                        }

                        habbo.GetHabbo().RefreshGuilds();
                    }
                    if ((int)Session.GetHabbo().Id == UserId)
                    {
                        RoomData      data = Essential.GetGame().GetRoomManager().method_11((uint)guild.RoomId);
                        ServerMessage message;
                        message = new ServerMessage(Outgoing.SendAdvGroupInit);
                        message.AppendInt32(guild.Id);
                        message.AppendBoolean(true);
                        message.AppendInt32(guild.Type);
                        message.AppendString(guild.Name);
                        message.AppendString(guild.Description);
                        message.AppendString(guild.Badge);
                        message.AppendInt32(data.Id);
                        message.AppendString(data.Name);
                        if (guild.Petitions.Contains((int)Session.GetHabbo().Id))
                        {
                            message.AppendInt32(2);
                        }
                        else if (!Session.GetHabbo().InGuild(guild.Id))
                        {
                            message.AppendInt32(0);
                        }
                        else if (Session.GetHabbo().InGuild(guild.Id))
                        {
                            message.AppendInt32(1);
                        }
                        message.AppendInt32(guild.Members.Count);
                        message.AppendBoolean(false);
                        message.AppendString(guild.Created);
                        message.AppendBoolean(guild.UserWithRanks.Contains((int)Session.GetHabbo().Id));//(int)Session.GetHabbo().Id == guild.OwnerId);

                        if (Session.GetHabbo().InGuild(guild.Id))
                        {
                            if (guild.getRank((int)Session.GetHabbo().Id) < 2)
                            {
                                message.AppendBoolean(true);
                            }
                            else
                            {
                                message.AppendBoolean(false);
                            }
                        }
                        else
                        {
                            message.AppendBoolean(false);
                        }
                        message.AppendString(guild.OwnerName);
                        message.AppendBoolean(true);
                        message.AppendBoolean(true);
                        message.AppendInt32(guild.Members.Contains((int)Session.GetHabbo().Id) ? guild.Petitions.Count : 0);
                        Session.SendMessage(message);
                    }
                }
            }
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            while (String.IsNullOrEmpty(_Filename))
            {
                Console.Write("Filename: ");
                _Filename = Console.ReadLine();
            }

            _Database = new DatabaseClient(_Filename);

            Console.WriteLine("Type '?' for help.");

            while (_RunForever)
            {
                Console.Write("> ");
                string userInput = Console.ReadLine();
                if (String.IsNullOrEmpty(userInput))
                {
                    continue;
                }

                switch (userInput)
                {
                case "?":
                    Console.WriteLine("---");
                    Console.WriteLine("q        quit the application");
                    Console.WriteLine("cls      clear the screen");
                    Console.WriteLine("backup   backup database to another file");
                    Console.WriteLine("scalar   execute a scalar query");
                    Console.WriteLine("<query>  submit query to Sqlite");
                    Console.WriteLine("");
                    break;

                case "q":
                case "Q":
                    _RunForever = false;
                    break;

                case "cls":
                case "CLS":
                    Console.Clear();
                    break;

                case "backup":
                    Console.Write("Backup filename > ");
                    userInput = null;
                    while (String.IsNullOrEmpty(userInput))
                    {
                        userInput = Console.ReadLine();
                    }
                    _Database.Backup(userInput);
                    break;

                case "scalar":
                    Console.Write("scalar > ");
                    userInput = null;
                    while (String.IsNullOrEmpty(userInput))
                    {
                        userInput = Console.ReadLine();
                    }
                    object ret = null;
                    try
                    {
                        ret = _Database.QueryScalar(userInput);
                    }
                    catch (Exception e1)
                    {
                        Console.WriteLine("Exception: " + e1.Message);
                    }
                    if (ret != null)
                    {
                        Console.WriteLine(ret.ToString());
                    }
                    else
                    {
                        Console.WriteLine("(null)");
                    }
                    break;

                default:
                    DataTable result = null;
                    try
                    {
                        result = _Database.Query(userInput);
                    }
                    catch (Exception e2)
                    {
                        Console.WriteLine("Exception: " + e2.Message);
                    }
                    if (result != null)
                    {
                        Console.WriteLine(result.Rows.Count + " rows returned");
                    }
                    else
                    {
                        Console.WriteLine("(null)");
                    }
                    break;
                }
            }
        }
Esempio n. 29
0
        public void SendToAccounting(DateTime date, ILogging logger)
        {
            var databaseClient = new DatabaseClient <QuickBooksOnlineConnection>(new AmazonDynamoDBClient(), logger);
            var qboClient      = new QuickBooksOnlineClient(PrivateAccounting.Constants.LakelandMiPuebloRealmId, databaseClient, logger);

            var originalMonth = date.Month;

            var client = new CloverClient(
                Environment.GetEnvironmentVariable("CLOVER_MI_PUEBLO_CHICKEN_ACCESS_TOKEN"),
                Environment.GetEnvironmentVariable("CLOVER_MI_PUEBLO_CHICKEN_MERCHANT_ID"),
                logger
                );

            var restaurantCustomer = qboClient
                                     .QueryAll <Customer>($"select * from Customer where Id = '{PrivateAccounting.Constants.LakelandMiPuebloAccountRestaurant}'")
                                     .First();

            var cashTenderType = client.QueryAll <Tender>($"tenders")
                                 .Single(x => string.Equals(x.LabelKey, "com.clover.tender.cash", StringComparison.OrdinalIgnoreCase));

            do
            {
                var salesReceipts = qboClient.QueryAll <SalesReceipt>(
                    $"select * from SalesReceipt where CustomerRef = '{PrivateAccounting.Constants.LakelandMiPuebloAccountRestaurant}' and TxnDate = '{date:yyyy-MM-dd}'");

                if (salesReceipts.Any())
                {
                    logger.Log($"Skipping {date:yyyy-MM-dd}, because a sales receipt already exists.");
                }
                else
                {
                    var today    = new DateTimeOffset(date).ToUnixTimeMilliseconds();
                    var tomorrow = new DateTimeOffset(date.AddDays(1)).ToUnixTimeMilliseconds();
                    var result   =
                        client.QueryAll <Payment>($"payments?filter=createdTime>={today}&filter=createdTime<{tomorrow}");

                    var cashPayments = result.Where(x => x.Tender.Id == cashTenderType.Id).ToList();
                    var cardPayments = result.Where(x => x.Tender.Id != cashTenderType.Id).ToList();
                    var cashTotal    = GetTotal(cashPayments);
                    var cardTotal    = GetTotal(cardPayments);
                    if (cashTotal > 0)
                    {
                        CreateSalesReceipt(
                            qboClient,
                            restaurantCustomer.Id,
                            restaurantCustomer.DefaultTaxCodeRef.Value,
                            PrivateAccounting.Constants.LakelandMiPuebloProductRestaurant,
                            date,
                            GetTotal(cashPayments),
                            "Restaurant sales using cash in Clover Register");
                    }

                    if (cardTotal > 0)
                    {
                        CreateSalesReceipt(
                            qboClient,
                            restaurantCustomer.Id,
                            restaurantCustomer.DefaultTaxCodeRef.Value,
                            PrivateAccounting.Constants.LakelandMiPuebloProductRestaurant,
                            date,
                            cardTotal,
                            "Restaurant sales using credit card in Clover Register");
                    }
                }
                date = date.AddDays(1);
            } while (date.Month == originalMonth);
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            try
            {
                #region Setup-Database

                Console.Write("Filename: ");
                _Filename = Console.ReadLine();
                if (String.IsNullOrEmpty(_Filename))
                {
                    return;
                }
                _Database = new DatabaseClient(_Filename);

                _Database.Logger     = Logger;
                _Database.LogQueries = true;
                _Database.LogResults = true;

                #endregion

                #region Drop-Table

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Dropping table 'person'...");
                _Database.DropTable("person");
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                #endregion

                #region Create-Table

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Creating table 'person'...");
                List <Column> columns = new List <Column>();
                columns.Add(new Column("id", true, DataType.Int, 11, null, false));
                columns.Add(new Column("firstName", false, DataType.Nvarchar, 30, null, false));
                columns.Add(new Column("lastName", false, DataType.Nvarchar, 30, null, false));
                columns.Add(new Column("age", false, DataType.Int, 11, null, true));
                columns.Add(new Column("value", false, DataType.Long, 12, null, true));
                columns.Add(new Column("birthday", false, DataType.DateTime, null, null, true));
                columns.Add(new Column("hourly", false, DataType.Decimal, 18, 2, true));

                _Database.CreateTable("person", columns);
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                #endregion

                #region Check-Existence-and-Describe

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Table 'person' exists: " + _Database.TableExists("person"));
                Console.WriteLine("Table 'person' configuration:");
                columns = _Database.DescribeTable("person");
                foreach (Column col in columns)
                {
                    Console.WriteLine(col.ToString());
                }
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                #endregion

                #region Load-Update-Retrieve-Delete

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Loading rows...");
                LoadRows();
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Updating rows...");
                UpdateRows();
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Retrieving rows...");
                RetrieveRows();
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Retrieving rows by index...");
                RetrieveRowsByIndex();
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Retrieving rows by between...");
                RetrieveRowsByBetween();
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Deleting rows...");
                DeleteRows();
                Console.WriteLine("Press ENTER to continue");
                Console.ReadLine();

                #endregion

                #region Drop-Table

                for (int i = 0; i < 24; i++)
                {
                    Console.WriteLine("");
                }
                Console.WriteLine("Dropping table...");
                _Database.DropTable("person");
                Console.ReadLine();

                #endregion
            }
            catch (Exception e)
            {
                ExceptionConsole("Main", "Outer exception", e);
            }
        }
Esempio n. 31
0
        public List <Table> GetTables(string dbName, bool describe)
        {
            if (String.IsNullOrEmpty(dbName))
            {
                throw new ArgumentNullException(nameof(dbName));
            }

            DatabaseClient db = GetDatabaseClient(dbName);

            if (db == null)
            {
                _Logging.Log(LoggingModule.Severity.Warn, "GetTables unable to find client for database " + dbName);
                return(null);
            }

            List <string> tableNames = db.ListTables();

            if (tableNames == null || tableNames.Count < 1)
            {
                _Logging.Log(LoggingModule.Severity.Warn, "GetTables no tables returned from list tables for database " + dbName);
                return(null);
            }
            else
            {
                _Logging.Log(LoggingModule.Severity.Debug, "GetTables returning " + tableNames.Count + " tables for database " + dbName);
            }

            List <Table> ret = new List <Table>();

            foreach (string curr in tableNames)
            {
                Table currTable = new Table();
                currTable.Name = curr;

                if (describe)
                {
                    currTable.Columns = new List <Column>();
                    List <DatabaseWrapper.Column> columns = db.DescribeTable(curr);
                    if (columns == null || columns.Count < 1)
                    {
                        _Logging.Log(LoggingModule.Severity.Warn, "GetTables no columns found for table " + curr + " in database " + dbName);
                        ret.Add(currTable);
                        continue;
                    }

                    foreach (DatabaseWrapper.Column currColumn in columns)
                    {
                        Column tempColumn = new Column();
                        tempColumn.Name      = currColumn.Name;
                        tempColumn.Nullable  = currColumn.Nullable;
                        tempColumn.MaxLength = currColumn.MaxLength;
                        tempColumn.Type      = currColumn.DataType;
                        if (currColumn.IsPrimaryKey)
                        {
                            currTable.PrimaryKey = tempColumn.Name;
                        }

                        currTable.Columns.Add(tempColumn);
                        // _Logging.Log(LoggingModule.Severity.Debug, "GetTables adding column " + tempColumn.Name + " for table " + currTable.Name + " database " + dbName);
                    }
                }

                ret.Add(currTable);
            }

            return(ret);
        }
        public void Handle(GameClient Session, ClientMessage Event)
        {
            int num = Event.PopWiredInt32();

            if (num > 0 && (Session != null && Session.GetHabbo() != null))
            {
                Session.GetHabbo().int_0 = num;
                using (DatabaseClient @class = HabboIM.GetDatabase().GetClient())
                {
                    @class.ExecuteQuery(string.Concat(new object[]
                    {
                        "UPDATE user_stats SET groupid = ",
                        num,
                        " WHERE Id = ",
                        Session.GetHabbo().Id,
                        " LIMIT 1;"
                    }));
                }
                DataTable dataTable_ = Session.GetHabbo().dataTable_0;
                if (dataTable_ != null)
                {
                    ServerMessage Message = new ServerMessage(915u);
                    Message.AppendInt32(dataTable_.Rows.Count);
                    foreach (DataRow dataRow in dataTable_.Rows)
                    {
                        GroupsManager class2 = Groups.smethod_2((int)dataRow["groupid"]);
                        Message.AppendInt32(class2.int_0);
                        Message.AppendStringWithBreak(class2.string_0);
                        Message.AppendStringWithBreak(class2.string_2);
                        if (Session.GetHabbo().int_0 == class2.int_0)
                        {
                            Message.AppendBoolean(true);
                        }
                        else
                        {
                            Message.AppendBoolean(false);
                        }
                    }
                    Session.SendMessage(Message);
                    if (Session.GetHabbo().InRoom)
                    {
                        Room          class14_ = Session.GetHabbo().CurrentRoom;
                        RoomUser      class3   = class14_.GetRoomUserByHabbo(Session.GetHabbo().Id);
                        ServerMessage Message2 = new ServerMessage(28u);
                        Message2.AppendInt32(1);
                        class3.method_14(Message2);
                        class14_.SendMessage(Message2, null);
                        GroupsManager class4 = Groups.smethod_2(Session.GetHabbo().int_0);
                        if (!class14_.list_17.Contains(class4))
                        {
                            class14_.list_17.Add(class4);
                            ServerMessage Message3 = new ServerMessage(309u);
                            Message3.AppendInt32(class14_.list_17.Count);
                            foreach (GroupsManager class2 in class14_.list_17)
                            {
                                Message3.AppendInt32(class2.int_0);
                                Message3.AppendStringWithBreak(class2.string_2);
                            }
                            class14_.SendMessage(Message3, null);
                        }
                        else
                        {
                            foreach (GroupsManager current in class14_.list_17)
                            {
                                if (current == class4 && current.string_2 != class4.string_2)
                                {
                                    ServerMessage Message3 = new ServerMessage(309u);
                                    Message3.AppendInt32(class14_.list_17.Count);
                                    foreach (GroupsManager class2 in class14_.list_17)
                                    {
                                        Message3.AppendInt32(class2.int_0);
                                        Message3.AppendStringWithBreak(class2.string_2);
                                    }
                                    class14_.SendMessage(Message3, null);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 33
0
        public bool method_6(GameClient Session, int int_0, uint uint_1, string string_0, bool bool_0, string string_1, string string_2, bool bool_1)
        {
            CatalogPage @class = this.method_5(int_0);

            if (@class == null || [email protected]_1 || [email protected]_0 || @class.uint_0 > Session.GetHabbo().Rank)
            {
                return(false);
            }
            else
            {
                if (@class.bool_2 && (!Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club") || !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")))
                {
                    return(false);
                }
                else
                {
                    CatalogItem class2 = @class.method_1(uint_1);
                    if (class2 == null)
                    {
                        return(false);
                    }
                    else
                    {
                        uint num = 0u;
                        if (bool_0)
                        {
                            if (!class2.method_0().AllowGift)
                            {
                                return(false);
                            }
                            if (Session.GetHabbo().method_4() > 0)
                            {
                                TimeSpan timeSpan = DateTime.Now - Session.GetHabbo().dateTime_0;
                                if (timeSpan.Seconds > 4)
                                {
                                    Session.GetHabbo().int_23 = 0;
                                }
                                if (timeSpan.Seconds < 4 && Session.GetHabbo().int_23 > 3)
                                {
                                    Session.GetHabbo().bool_15 = true;
                                    return(false);
                                }
                                if (Session.GetHabbo().bool_15&& timeSpan.Seconds < Session.GetHabbo().method_4())
                                {
                                    return(false);
                                }
                                Session.GetHabbo().bool_15    = false;
                                Session.GetHabbo().dateTime_0 = DateTime.Now;
                                Session.GetHabbo().int_23++;
                            }
                            using (DatabaseClient class3 = GoldTree.GetDatabase().GetClient())
                            {
                                class3.AddParamWithValue("gift_user", string_1);
                                try
                                {
                                    num = (uint)class3.ReadDataRow("SELECT Id FROM users WHERE username = @gift_user LIMIT 1")[0];
                                }
                                catch (Exception)
                                {
                                }
                            }
                            if (num == 0u)
                            {
                                ServerMessage Message = new ServerMessage(76u);
                                Message.AppendBoolean(true);
                                Message.AppendStringWithBreak(string_1);
                                Session.SendMessage(Message);
                                return(false);
                            }
                        }
                        bool flag  = false;
                        bool flag2 = false;
                        int  int_  = class2.int_2;
                        if (Session.GetHabbo().Credits < class2.int_0)
                        {
                            flag = true;
                        }
                        if ((int_ == 0 && Session.GetHabbo().ActivityPoints < class2.int_1) || (int_ > 0 && Session.GetHabbo().VipPoints < class2.int_1))
                        {
                            flag2 = true;
                        }
                        if (flag || flag2)
                        {
                            ServerMessage Message2 = new ServerMessage(68u);
                            Message2.AppendBoolean(flag);
                            Message2.AppendBoolean(flag2);
                            Session.SendMessage(Message2);
                            return(false);
                        }
                        else
                        {
                            if (bool_0 && class2.method_0().Type == 'e')
                            {
                                Session.SendNotif("You can not send this item as a gift.");
                                return(false);
                            }
                            else
                            {
                                string text = class2.method_0().InteractionType.ToLower();
                                if (text != null)
                                {
                                    if (!(text == "pet"))
                                    {
                                        if (text == "roomeffect")
                                        {
                                            double num2 = 0.0;
                                            try
                                            {
                                                num2 = double.Parse(string_0);
                                            }
                                            catch (Exception)
                                            {
                                            }
                                            string_0 = num2.ToString().Replace(',', '.');
                                            goto IL_4FC;
                                        }
                                        if (text == "postit")
                                        {
                                            string_0 = "FFFF33";
                                            goto IL_4FC;
                                        }
                                        if (text == "dimmer")
                                        {
                                            string_0 = "1,1,1,#000000,255";
                                            goto IL_4FC;
                                        }
                                        if (text == "trophy")
                                        {
                                            string_0 = string.Concat(new object[]
                                            {
                                                Session.GetHabbo().Username,
                                                Convert.ToChar(9),
                                                DateTime.Now.Day,
                                                "-",
                                                DateTime.Now.Month,
                                                "-",
                                                DateTime.Now.Year,
                                                Convert.ToChar(9),
                                                ChatCommandHandler.smethod_4(GoldTree.DoFilter(string_0, true, true))
                                            });
                                            goto IL_4FC;
                                        }
                                        if (text == "musicdisc")
                                        {
                                            string_0 = class2.song_id.ToString();
                                            goto IL_4FC;
                                        }
                                    }
                                    else
                                    {
                                        try
                                        {
                                            string[] array = string_0.Split(new char[]
                                            {
                                                '\n'
                                            });
                                            string string_3 = array[0];
                                            string text2    = array[1];
                                            string text3    = array[2];
                                            int.Parse(text2);
                                            if (!this.method_8(string_3))
                                            {
                                                return(false);
                                            }
                                            if (text2.Length > 2)
                                            {
                                                return(false);
                                            }
                                            if (text3.Length != 6)
                                            {
                                                return(false);
                                            }
                                            goto IL_4FC;
                                        }
                                        catch (Exception)
                                        {
                                            return(false);
                                        }
                                    }
                                }
                                if (class2.string_0.StartsWith("disc_"))
                                {
                                    string_0 = class2.string_0.Split(new char[]
                                    {
                                        '_'
                                    })[1];
                                }
                                else
                                {
                                    string_0 = "";
                                }
IL_4FC:
                                if (class2.int_0 > 0)
                                {
                                    Session.GetHabbo().Credits -= class2.int_0;
                                    Session.GetHabbo().method_13(true);
                                }
                                if (class2.int_1 > 0 && int_ == 0)
                                {
                                    Session.GetHabbo().ActivityPoints -= class2.int_1;
                                    Session.GetHabbo().method_15(true);
                                }
                                else
                                {
                                    if (class2.int_1 > 0 && int_ > 0)
                                    {
                                        Session.GetHabbo().VipPoints -= class2.int_1;
                                        Session.GetHabbo().method_16(0);
                                        Session.GetHabbo().method_14(false, true);
                                    }
                                }
                                ServerMessage Message3 = new ServerMessage(67u);
                                Message3.AppendUInt(class2.method_0().UInt32_0);
                                Message3.AppendStringWithBreak(class2.method_0().Name);
                                Message3.AppendInt32(class2.int_0);
                                Message3.AppendInt32(class2.int_1);
                                Message3.AppendInt32(class2.int_2);
                                if (bool_1)
                                {
                                    Message3.AppendInt32(1);
                                }
                                else
                                {
                                    Message3.AppendInt32(0);
                                }
                                Message3.AppendStringWithBreak(class2.method_0().Type.ToString());
                                Message3.AppendInt32(class2.method_0().Sprite);
                                Message3.AppendStringWithBreak("");
                                Message3.AppendInt32(1);
                                Message3.AppendInt32(-1);
                                Message3.AppendStringWithBreak("");
                                Session.SendMessage(Message3);
                                if (bool_0)
                                {
                                    uint num3   = this.method_14();
                                    Item class4 = this.method_10();
                                    using (DatabaseClient class3 = GoldTree.GetDatabase().GetClient())
                                    {
                                        class3.AddParamWithValue("gift_message", "!" + ChatCommandHandler.smethod_4(GoldTree.DoFilter(string_2, true, true)) + " - " + Session.GetHabbo().Username);
                                        class3.AddParamWithValue("extra_data", string_0);
                                        class3.ExecuteQuery(string.Concat(new object[]
                                        {
                                            "INSERT INTO items (Id,user_id,base_item,extra_data,wall_pos) VALUES ('",
                                            num3,
                                            "','",
                                            num,
                                            "','",
                                            class4.UInt32_0,
                                            "',@gift_message,'')"
                                        }));
                                        class3.ExecuteQuery(string.Concat(new object[]
                                        {
                                            "INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES ('",
                                            num3,
                                            "','",
                                            class2.method_0().UInt32_0,
                                            "','",
                                            class2.int_3,
                                            "',@extra_data)"
                                        }));
                                    }
                                    GameClient class5 = GoldTree.GetGame().GetClientManager().method_2(num);
                                    if (class5 != null)
                                    {
                                        class5.SendNotif("You have received a gift! Check your inventory.");
                                        class5.GetHabbo().method_23().method_9(true);
                                        class5.GetHabbo().GiftsReceived++;
                                        class5.GetHabbo().CheckGiftReceivedAchievements();
                                    }
                                    Session.GetHabbo().GiftsGiven++;
                                    Session.GetHabbo().CheckGiftGivenAchievements();
                                    Session.SendNotif("Gift sent successfully!");
                                    return(true);
                                }
                                else
                                {
                                    this.method_9(Session, class2.method_0(), class2.int_3, string_0, true, 0u);
                                    if (class2.uint_2 > 0u)
                                    {
                                        GoldTree.GetGame().GetAchievementManager().addAchievement(Session, class2.uint_2, 1);
                                    }
                                    if (!string.IsNullOrEmpty(class2.BadgeID))
                                    {
                                        Session.GetHabbo().method_22().method_2(Session, class2.BadgeID, true);
                                    }
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 34
0
        static void Main(string[] args)
        {
            Console.WriteLine("Opening file");
            _Database = new DatabaseClient("test", true);

            Console.WriteLine("Creating table 'company' with fields 'id' (int) and 'val' (string)...");
            string createTableQuery =
                "CREATE TABLE IF NOT EXISTS company " +
                "( id  INTEGER PRIMARY KEY AUTOINCREMENT, " +
                "  val NVARCHAR(64))";
            DataTable createTableResult = _Database.Query(createTableQuery);

            while (_RunForever)
            {
                string userInput = InputString("Command [? for help]:", null, false);
                switch (userInput)
                {
                case "?":
                    Menu();
                    break;

                case "c":
                case "cls":
                    Console.Clear();
                    break;

                case "q":
                    _RunForever = false;
                    break;

                case "dispose":
                    _Database.Dispose();
                    break;

                case "delete":
                    File.Delete("test");
                    break;

                case "init":
                    _Database = new DatabaseClient("test", true);
                    break;

                default:
                    DataTable result = _Database.Query(userInput);
                    if (result != null)
                    {
                        if (result.Rows != null && result.Rows.Count > 0)
                        {
                            if (result.Rows.Count > 1)
                            {
                                Console.WriteLine(SerializeJson(DataTableToListDynamic(result), true));
                            }
                            else
                            {
                                Console.WriteLine(SerializeJson(DataTableToDynamic(result), true));
                            }
                        }
                        else
                        {
                            Console.WriteLine("No rows returned");
                        }
                    }
                    else
                    {
                        Console.WriteLine("No table returned");
                    }
                    break;
                }
            }
        }
Esempio n. 35
0
        public void method_0(DatabaseClient class6_0)
        {
            Logging.smethod_0("Loading Catalogue..");
            this.dictionary_0 = new Dictionary <int, CatalogPage>();
            this.list_0       = new List <EcotronReward>();
            DataTable dataTable  = class6_0.ReadDataTable("SELECT * FROM catalog_pages WHERE order_num >= '0' ORDER BY order_num ASC");
            DataTable dataTable2 = class6_0.ReadDataTable("SELECT * FROM ecotron_rewards ORDER BY item_id");
            DataTable dataTable4 = class6_0.ReadDataTable("SELECT * FROM catalog_pages WHERE order_num = '-1' ORDER BY caption ASC");

            try
            {
                this.uint_0 = (uint)class6_0.ReadDataRow("SELECT ID FROM items ORDER BY ID DESC LIMIT 1")[0];
            }
            catch
            {
                this.uint_0 = 0u;
            }
            this.uint_0 += 1u;
            Hashtable hashtable  = new Hashtable();
            DataTable dataTable3 = class6_0.ReadDataTable("SELECT * FROM catalog_items");

            if (dataTable3 != null)
            {
                foreach (DataRow dataRow in dataTable3.Rows)
                {
                    if (!(dataRow["item_ids"].ToString() == "") && (int)dataRow["amount"] > 0)
                    {
                        string BadgeID = dataRow["BadgeID"].ToString();
                        if (string.IsNullOrEmpty(BadgeID) || string.IsNullOrWhiteSpace(BadgeID))
                        {
                            BadgeID = string.Empty;
                        }
                        hashtable.Add((uint)dataRow["Id"], new CatalogItem((uint)dataRow["Id"], (string)dataRow["catalog_name"], (string)dataRow["item_ids"], (int)dataRow["cost_credits"], (int)dataRow["cost_pixels"], (int)dataRow["cost_snow"], (int)dataRow["amount"], (int)dataRow["page_id"], GoldTree.smethod_2(dataRow["vip"].ToString()), (uint)dataRow["achievement"], (int)dataRow["song_id"], BadgeID));
                    }
                }
            }
            if (dataTable != null)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    bool bool_  = false;
                    bool bool_2 = false;
                    if (dataRow["visible"].ToString() == "1")
                    {
                        bool_ = true;
                    }
                    if (dataRow["enabled"].ToString() == "1")
                    {
                        bool_2 = true;
                    }
                    this.dictionary_0.Add((int)dataRow["Id"], new CatalogPage((int)dataRow["Id"], (int)dataRow["parent_id"], (string)dataRow["caption"], bool_, bool_2, (uint)dataRow["min_rank"], GoldTree.smethod_3(dataRow["club_only"].ToString()), (int)dataRow["icon_color"], (int)dataRow["icon_image"], (string)dataRow["page_layout"], (string)dataRow["page_headline"], (string)dataRow["page_teaser"], (string)dataRow["page_special"], (string)dataRow["page_text1"], (string)dataRow["page_text2"], (string)dataRow["page_text_details"], (string)dataRow["page_text_teaser"], (string)dataRow["page_link_description"], (string)dataRow["page_link_pagename"], ref hashtable));
                }
            }
            if (dataTable4 != null)
            {
                foreach (DataRow dataRow in dataTable4.Rows)
                {
                    bool bool_  = false;
                    bool bool_2 = false;
                    if (dataRow["visible"].ToString() == "1")
                    {
                        bool_ = true;
                    }
                    if (dataRow["enabled"].ToString() == "1")
                    {
                        bool_2 = true;
                    }
                    this.dictionary_0.Add((int)dataRow["Id"], new CatalogPage((int)dataRow["Id"], (int)dataRow["parent_id"], (string)dataRow["caption"], bool_, bool_2, (uint)dataRow["min_rank"], GoldTree.smethod_3(dataRow["club_only"].ToString()), (int)dataRow["icon_color"], (int)dataRow["icon_image"], (string)dataRow["page_layout"], (string)dataRow["page_headline"], (string)dataRow["page_teaser"], (string)dataRow["page_special"], (string)dataRow["page_text1"], (string)dataRow["page_text2"], (string)dataRow["page_text_details"], (string)dataRow["page_text_teaser"], (string)dataRow["page_link_description"], (string)dataRow["page_link_pagename"], ref hashtable));
                }
            }
            if (dataTable2 != null)
            {
                foreach (DataRow dataRow in dataTable2.Rows)
                {
                    this.list_0.Add(new EcotronReward((uint)dataRow["Id"], (uint)dataRow["display_id"], (uint)dataRow["item_id"], (uint)dataRow["reward_level"]));
                }
            }
            Logging.WriteLine("completed!");
        }
Esempio n. 36
0
        public void parse(GameClient Session, ClientMessage Event)
        {
            Room room = PhoenixEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (room != null && Session != null)
            {
                if (Session.GetHabbo().Muted)
                {
                    Session.SendNotif(TextManager.GetText("error_muted"));
                }
                else
                {
                    if (Session.GetHabbo().HasRole("ignore_roommute") || !room.RoomMuted)
                    {
                        string str  = PhoenixEnvironment.FilterInjectionChars(Event.PopFixedString());
                        string name = str.Split(new char[]
                        {
                            ' '
                        })[0];
                        string s = str.Substring(name.Length + 1);
                        s = ChatCommandHandler.ApplyWordFilter(s);
                        RoomUser roomUserByHabbo = room.GetRoomUserByHabbo(Session.GetHabbo().Id);
                        RoomUser user2           = room.GetRoomUserByHabbo(name);
                        if (Session.GetHabbo().MaxFloodTime() > 0)
                        {
                            TimeSpan timeSpan = DateTime.Now - Session.GetHabbo().FloodTime;
                            if (timeSpan.Seconds > 4)
                            {
                                Session.GetHabbo().FloodCount = 0;
                            }
                            if (timeSpan.Seconds < 4 && Session.GetHabbo().FloodCount > 5 && !roomUserByHabbo.IsBot)
                            {
                                ServerMessage Message = new ServerMessage(27);
                                Message.AppendInt32(Session.GetHabbo().MaxFloodTime());
                                Session.SendMessage(Message);
                                Session.GetHabbo().Muted      = true;
                                Session.GetHabbo().MuteLength = Session.GetHabbo().MaxFloodTime();
                                return;
                            }
                            Session.GetHabbo().FloodTime = DateTime.Now;
                            Session.GetHabbo().FloodCount++;
                        }
                        ServerMessage Message2 = new ServerMessage(25);
                        Message2.AppendInt32(roomUserByHabbo.VirtualId);
                        Message2.AppendStringWithBreak(s);
                        Message2.AppendBoolean(false);
                        if (roomUserByHabbo != null && !roomUserByHabbo.IsBot)
                        {
                            roomUserByHabbo.GetClient().SendMessage(Message2);
                        }
                        roomUserByHabbo.Unidle();
                        if (user2 != null && !user2.IsBot && (user2.GetClient().GetHabbo().MutedUsers.Count <= 0 || !user2.GetClient().GetHabbo().MutedUsers.Contains(Session.GetHabbo().Id)))
                        {
                            user2.GetClient().SendMessage(Message2);
                            if (GlobalClass.RecordChatlogs && !Session.GetHabbo().isAaron)
                            {
                                using (DatabaseClient client = PhoenixEnvironment.GetDatabase().GetClient())
                                {
                                    client.AddParamWithValue("message", "<Whisper to " + user2.GetClient().GetHabbo().Username + ">: " + s);
                                    client.ExecuteQuery(string.Concat(new object[]
                                    {
                                        "INSERT INTO chatlogs (user_id,room_id,hour,minute,timestamp,message,user_name,full_date) VALUES ('",
                                        Session.GetHabbo().Id,
                                        "','",
                                        room.RoomId,
                                        "','",
                                        DateTime.Now.Hour,
                                        "','",
                                        DateTime.Now.Minute,
                                        "',UNIX_TIMESTAMP(),@message,'",
                                        Session.GetHabbo().Username,
                                        "','",
                                        DateTime.Now.ToLongDateString(),
                                        "')"
                                    }));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 37
0
        public void method_9(GameClient Session, Item Item, int int_0, string string_0, bool bool_0, uint uint_1)
        {
            string text = Item.Type.ToString();

            if (text != null)
            {
                if (text == "i" || text == "s")
                {
                    int i = 0;
                    while (i < int_0)
                    {
                        uint num;
                        if (!bool_0 && uint_1 > 0u)
                        {
                            num = uint_1;
                        }
                        else
                        {
                            num = this.method_14();
                        }
                        text = Item.InteractionType.ToLower();
                        if (text == null)
                        {
                            goto IL_4CF;
                        }
                        if (!(text == "pet"))
                        {
                            if (!(text == "teleport"))
                            {
                                if (!(text == "dimmer"))
                                {
                                    goto IL_4CF;
                                }
                                using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
                                {
                                    @class.ExecuteQuery("INSERT INTO room_items_moodlight (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES ('" + num + "','0','1','#000000,255,0','#000000,255,0','#000000,255,0')");
                                }
                                Session.GetHabbo().method_23().method_11(num, Item.UInt32_0, string_0, bool_0);
                            }
                            else
                            {
                                uint num2 = this.method_14();
                                using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
                                {
                                    @class.ExecuteQuery(string.Concat(new object[]
                                    {
                                        "INSERT INTO tele_links (tele_one_id,tele_two_id) VALUES ('",
                                        num,
                                        "','",
                                        num2,
                                        "')"
                                    }));
                                    @class.ExecuteQuery(string.Concat(new object[]
                                    {
                                        "INSERT INTO tele_links (tele_one_id,tele_two_id) VALUES ('",
                                        num2,
                                        "','",
                                        num,
                                        "')"
                                    }));
                                }
                                Session.GetHabbo().method_23().method_11(num2, Item.UInt32_0, "0", bool_0);
                                Session.GetHabbo().method_23().method_11(num, Item.UInt32_0, "0", bool_0);
                            }
                        }
                        else
                        {
                            string[] array = string_0.Split(new char[]
                            {
                                '\n'
                            });
                            Pet class15_ = this.method_11(Session.GetHabbo().Id, array[0], Convert.ToInt32(Item.Name.Split(new char[]
                            {
                                't'
                            })[1]), array[1], array[2]);
                            Session.GetHabbo().method_23().method_7(class15_);
                            Session.GetHabbo().method_23().method_11(num, 320u, "0", bool_0);
                        }
IL_4EA:
                        ServerMessage Message = new ServerMessage(832u);
                        Message.AppendInt32(1);
                        if (Item.InteractionType.ToLower() == "pet")
                        {
                            Message.AppendInt32(3);
                            Session.GetHabbo().NewPetsBuyed++;
                        }
                        else
                        {
                            if (Item.Type.ToString() == "i")
                            {
                                Message.AppendInt32(2);
                            }
                            else
                            {
                                Message.AppendInt32(1);
                            }
                        }
                        Message.AppendInt32(1);
                        Message.AppendUInt(num);
                        Session.SendMessage(Message);
                        i++;
                        Session.GetHabbo().CheckPetCountAchievements();
                        continue;
IL_4CF:
                        Session.GetHabbo().method_23().method_11(num, Item.UInt32_0, string_0, bool_0);
                        goto IL_4EA;
                    }
                    Session.GetHabbo().method_23().method_9(false);
                    return;
                }
                if (text == "e")
                {
                    for (int i = 0; i < int_0; i++)
                    {
                        Session.GetHabbo().method_24().method_0(Item.Sprite, 3600);
                    }
                    return;
                }
                if (text == "h")
                {
                    for (int i = 0; i < int_0; i++)
                    {
                        Session.GetHabbo().GetSubscriptionManager().method_3("habbo_club", 2678400);
                        Session.GetHabbo().CheckHCAchievements();
                    }
                    ServerMessage Message2 = new ServerMessage(7u);
                    Message2.AppendStringWithBreak("habbo_club");
                    if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                    {
                        double num3 = (double)Session.GetHabbo().GetSubscriptionManager().method_1("habbo_club").Int32_0;
                        double num4 = num3 - GoldTree.GetUnixTimestamp();
                        int    num5 = (int)Math.Ceiling(num4 / 86400.0);
                        int    num6 = num5 / 31;
                        if (num6 >= 1)
                        {
                            num6--;
                        }
                        Message2.AppendInt32(num5 - num6 * 31);
                        Message2.AppendBoolean(true);
                        Message2.AppendInt32(num6);
                    }
                    else
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Message2.AppendInt32(0);
                        }
                    }
                    Session.SendMessage(Message2);
                    ServerMessage Message3 = new ServerMessage(2u);
                    if (Session.GetHabbo().Vip || LicenseTools.Boolean_3)
                    {
                        Message3.AppendInt32(2);
                    }
                    else
                    {
                        if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                        {
                            Message3.AppendInt32(1);
                        }
                        else
                        {
                            Message3.AppendInt32(0);
                        }
                    }
                    if (Session.GetHabbo().HasFuse("acc_anyroomowner"))
                    {
                        Message3.AppendInt32(7);
                    }
                    else
                    {
                        if (Session.GetHabbo().HasFuse("acc_anyroomrights"))
                        {
                            Message3.AppendInt32(5);
                        }
                        else
                        {
                            if (Session.GetHabbo().HasFuse("acc_supporttool"))
                            {
                                Message3.AppendInt32(4);
                            }
                            else
                            {
                                if (Session.GetHabbo().Vip || LicenseTools.Boolean_3 || Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                                {
                                    Message3.AppendInt32(2);
                                }
                                else
                                {
                                    Message3.AppendInt32(0);
                                }
                            }
                        }
                    }
                    Session.SendMessage(Message3);
                    return;
                }
            }
            Session.SendNotif("Something went wrong! The item type could not be processed. Please do not try to buy this item anymore, instead inform support as soon as possible.");
        }
Esempio n. 38
0
        public void Handle(GameClient session, ClientMessage message)
        {
            int request = message.PopWiredInt32();

            DataTable friendStream = null;

            using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
            {
                friendStream = dbClient.ReadDataTable("SELECT * FROM user_friend_stream ORDER BY timestamp DESC LIMIT 15"); //check if the user is my friend xo xo
            }

            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);

            message_.Init(r63aOutgoing.FriendStream);
            message_.AppendInt32(friendStream.Rows.Count); //count

            foreach (DataRow dataRow in friendStream.Rows)
            {
                int      type      = (int)dataRow["type"];
                uint     userId    = (uint)dataRow["user_id"];
                string[] extraData = ((string)dataRow["extra_data"]).Split((char)9);

                message_.AppendInt32((int)dataRow["id"]);
                message_.AppendInt32(type);
                message_.AppendString(userId.ToString());
                if (type != 2) //0 = friend made, 1 = room liked, 3 = motto changed, 4 = room decorated
                {
                    string username = "******";
                    string gender   = "m";
                    string look     = "";

                    GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientById(userId);
                    if (target != null)
                    {
                        username = target.GetHabbo().Username;
                        gender   = target.GetHabbo().Gender;
                        look     = target.GetHabbo().Look;
                    }
                    else
                    {
                        DataRow userData = null;
                        using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                        {
                            dbClient.AddParamWithValue("userId", userId);
                            userData = dbClient.ReadDataRow("SELECT username, gender, look FROM users WHERE id = @userId LIMIT 1");
                        }

                        if (userData != null)
                        {
                            username = (string)userData["username"];
                            gender   = (string)userData["gender"];
                            look     = (string)userData["look"];
                        }
                    }

                    message_.AppendString(username);                                                      //user name
                    message_.AppendString(gender.ToLower());                                              //gender
                    message_.AppendString("http://localhost:7977/habbo-imaging/head.gif?figure=" + look); //user head
                }
                else //2 = achievement earned
                {
                    message_.AppendString(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));        //user name
                    message_.AppendString("");                                                                       //gender
                    message_.AppendString("http://25.76.128.47/habway/c_images/album1584/" + extraData[0] + ".gif"); //image
                }

                message_.AppendInt32((int)Math.Ceiling((TimeUtilies.GetUnixTimestamp() - (double)dataRow["timestamp"]) / 60.0)); //time as minutes
                if (type != 0)                                                                                                   //1 = room liked, 2 = achievement earned, 3 = motto changed, 4 = room decorated
                {
                    if (type == 4)
                    {
                        message_.AppendInt32(2); //link action
                    }
                    else
                    {
                        message_.AppendInt32(1 + type); //link action
                    }
                }
                else //0 = friend made
                {
                    if (session.GetHabbo().GetMessenger().IsFriendWith(uint.Parse(extraData[0])))
                    {
                        message_.AppendInt32(1); //link action
                    }
                    else
                    {
                        message_.AppendInt32(5); //link action
                    }
                }
                message_.AppendInt32(0);                                                                                        //likes
                message_.AppendBoolean(false);                                                                                  //can like?

                if (type == 0)                                                                                                  //friend made
                {
                    message_.AppendString(extraData[0]);                                                                        //friend id
                    message_.AppendString(Skylight.GetGame().GetGameClientManager().GetUsernameByID(uint.Parse(extraData[0]))); //friend name
                }
                else if (type == 1)                                                                                             //room liked
                {
                    RoomData roomData = Skylight.GetGame().GetRoomManager().TryGetRoomData(uint.Parse(extraData[0]));
                    if (roomData != null)
                    {
                        message_.AppendString(roomData.ID.ToString()); //room id
                        message_.AppendString(roomData.Name);          //room name
                    }
                    else
                    {
                        message_.AppendString(extraData[0]);     //room id
                        message_.AppendString("Room not found"); //room name
                    }
                }
                else if (type == 2)                      //achievement earned
                {
                    message_.AppendString(extraData[0]); //badge code
                }
                else if (type == 3)                      //motto changed
                {
                    message_.AppendString(extraData[0]); //new motto
                }
                else if (type == 4)                      //room decorated
                {
                    RoomData roomData = Skylight.GetGame().GetRoomManager().TryGetRoomData(uint.Parse(extraData[0]));
                    if (roomData != null)
                    {
                        message_.AppendString(roomData.ID.ToString()); //room id
                        message_.AppendString(roomData.Name);          //room name
                    }
                    else
                    {
                        message_.AppendString(extraData[0]);     //room id
                        message_.AppendString("Room not found"); //room name
                    }
                }
            }

            session.SendMessage(message_);
        }
Esempio n. 39
0
        /// <summary>
        /// Initializes the navigtor
        /// </summary>
        public static void Init()
        {
            type                  = new Dictionary <int, int>();
            parent                = new Dictionary <int, int>();
            name                  = new Dictionary <int, string>();
            roomAccesName         = new Dictionary <string, string>();
            roomAccesParent       = new Dictionary <string, DataColumn>();
            roomsInsideCatagories = new Dictionary <string, string>();
            guestRooms            = new Dictionary <string, DataTable>();
            DataTable dTable;

            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
            {
                dTable = dbClient.getTable("SELECT id , type FROM room_categories");
            }
            foreach (DataRow dRow in dTable.Rows)
            {
                type.Add(Convert.ToInt32(dRow[0]), Convert.ToInt32(dRow[1]));
            }
            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
            {
                dTable = dbClient.getTable("SELECT id, parent FROM room_categories");
            }
            foreach (DataRow dRow in dTable.Rows)
            {
                parent.Add(Convert.ToInt32(dRow[0]), Convert.ToInt32(dRow[1]));
            }
            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
            {
                dTable = dbClient.getTable("SELECT id, name FROM room_categories");
            }

            foreach (DataRow dRow in dTable.Rows)
            {
                name.Add(Convert.ToInt32(dRow[0]), Convert.ToString(dRow[1]));
            }

            ThreadStart roomAccesThread = new ThreadStart(roomAcces);

            roomAccesSort          = new Thread(roomAccesThread);
            roomAccesSort.Priority = ThreadPriority.BelowNormal;
            roomAccesSort.Start();

            ThreadStart guestRoomRefresh = new ThreadStart(reNewRoomsThread);

            reNewRooms          = new Thread(guestRoomRefresh);
            reNewRooms.Priority = ThreadPriority.BelowNormal;
            reNewRooms.Name     = "Updates guestrooms catagories";
            reNewRooms.Start();

            ThreadStart randoms = new ThreadStart(randomRooms);

            randomizerThread          = new Thread(randoms);
            randomizerThread.Priority = ThreadPriority.Lowest;
            randomizerThread.Name     = "Update Random Rooms";
            randomizerThread.Start();

            ThreadStart guestRoomsInroom = new ThreadStart(refreshGuestrooms);

            updateInRooms          = new Thread(guestRoomsInroom);
            updateInRooms.Priority = ThreadPriority.Lowest;
            updateInRooms.Name     = "Update In Rooms";
            updateInRooms.Start();

            Out.WriteLine("Navigator names cached: " + name.Count);
            Out.WriteLine("Navigator \"Parent id's\" cached: " + parent.Count);
            Out.WriteLine("Navigator type's cached: " + type.Count);
        }
Esempio n. 40
0
 /// <summary>
 /// Creates a new Database session
 /// </summary>
 /// <param name="client">The client which holds the connection</param>
 internal NormalQueryReactor(DatabaseClient client) : base (client)
 {
     this.command = client.getNewCommand();
 }
Esempio n. 41
0
 /// <summary>
 /// Creates a new Database session
 /// </summary>
 /// <param name="client">The client which holds the connection</param>
 internal TransactionQueryReactor(DatabaseClient client) : base (client)
 {
     this.initTransaction();
 }