Beispiel #1
0
        public void AddOrExtendSubscription(string SubscriptionId, int DurationSeconds)
        {
            SubscriptionId = SubscriptionId.ToLower();
            if (Subscriptions.ContainsKey(SubscriptionId))
            {
                Subscription Sub = Subscriptions[SubscriptionId];
                Sub.ExtendSubscription(DurationSeconds);
                if (Sub.ExpireTime <= 0 || Sub.ExpireTime >= 2147483647)
                {
                    return;
                }
                using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                {
                    adapter.AddParamWithValue("subcrbr", SubscriptionId);
                    adapter.ExecuteQuery("UPDATE user_subscriptions SET timestamp_expire = '" + Sub.ExpireTime + "' WHERE user_id = '" + UserId + "' AND subscription_id = @subcrbr LIMIT 1");
                    return;
                }
            }
            if (!Subscriptions.ContainsKey("habbo_vip"))
            {
                int TimeCreated = (int)PhoenixEnvironment.GetUnixTimestamp();
                int TimeExpire  = (int)PhoenixEnvironment.GetUnixTimestamp() + DurationSeconds;

                Subscription NewSub = new Subscription(SubscriptionId, TimeCreated, TimeExpire);

                using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                {
                    adapter.AddParamWithValue("subcrbr", SubscriptionId);
                    adapter.ExecuteQuery("INSERT INTO user_subscriptions (user_id,subscription_id,timestamp_activated,timestamp_expire) VALUES ('" + UserId + "',@subcrbr,'" + TimeCreated + "','" + TimeExpire + "')");
                }
                Subscriptions.Add(NewSub.SubscriptionId.ToLower(), NewSub);
            }
        }
Beispiel #2
0
 public HabboData(string pSSOTicket, string pIPAddress, bool LoadFull)
 {
     using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
     {
         adapter.AddParamWithValue("auth_ticket", pSSOTicket);
         string str = "";
         if (GlobalClass.SecureSessions)
         {
             str = "AND ip_last = '" + pIPAddress + "' ";
         }
         try
         {
             if (int.Parse(PhoenixEnvironment.GetConfig().data["debug"]) == 1)
             {
                 str = "";
             }
         }
         catch
         {
         }
         this.mUserInformation = adapter.ReadDataRow("SELECT * FROM users WHERE auth_ticket = @auth_ticket " + str + " LIMIT 1;");
         if (this.mUserInformation != null)
         {
             this.mUserFound = true;
             uint Id = (uint)this.mUserInformation["Id"];
             if (LoadFull)
             {
                 this.mAchievementData    = adapter.ReadDataTable("SELECT achievement_id,achievement_level FROM user_achievements WHERE user_id = '" + Id + "'");
                 this.mUserFavouriteRooms = adapter.ReadDataTable("SELECT room_id FROM user_favorites WHERE user_id = '" + Id + "'");
                 this.mUserIgnores        = adapter.ReadDataTable("SELECT ignore_id FROM user_ignores WHERE user_id = '" + Id + "'");
                 this.mUsertags           = adapter.ReadDataTable("SELECT tag FROM user_tags WHERE user_id = '" + Id + "'");
                 this.mSubscriptionData   = adapter.ReadDataTable("SELECT subscription_id, timestamp_activated, timestamp_expire FROM user_subscriptions WHERE user_id = '" + Id + "'");
                 this.mUserBadges         = adapter.ReadDataTable("SELECT user_badges.badge_id,user_badges.badge_slot FROM user_badges WHERE user_id = " + Id + " ORDER BY badge_slot ASC");
                 this.mUserInventory      = adapter.ReadDataTable("SELECT Id,base_item,extra_data FROM items WHERE room_id = 0 AND user_id = " + Id);
                 this.mUserEffects        = adapter.ReadDataTable("SELECT user_effects.effect_id,user_effects.total_duration,user_effects.is_activated,user_effects.activated_stamp FROM user_effects WHERE user_id =  " + Id);
                 this.mUserFriends        = adapter.ReadDataTable("SELECT users.Id,users.username,users.motto,users.look,users.last_online FROM users JOIN messenger_friendships ON users.Id = messenger_friendships.user_two_id WHERE messenger_friendships.user_one_id = '" + Id + "'");
                 this.mUserRequests       = adapter.ReadDataTable("SELECT messenger_requests.Id,messenger_requests.from_id,users.username FROM users JOIN messenger_requests ON users.Id = messenger_requests.from_id WHERE messenger_requests.to_id = '" + Id + "'");
                 adapter.AddParamWithValue("name", this.mUserInformation["username"]);
                 this.mUsersRooms   = adapter.ReadDataTable("SELECT * FROM rooms WHERE owner = @name ORDER BY Id ASC LIMIT " + GlobalClass.MaxRoomsPerUser);
                 this.mUserPets     = adapter.ReadDataTable("SELECT Id, user_id, room_id, name, type, race, color, expirience, energy, nutrition, respect, createstamp, x, y, z FROM user_pets WHERE user_id = " + Id + " AND room_id = 0");
                 this.mFriendStream = adapter.ReadDataTable("SELECT friend_stream.id, friend_stream.type, friend_stream.userid, friend_stream.gender, friend_stream.look, friend_stream.time, friend_stream.data, friend_stream.data_extra FROM friend_stream JOIN messenger_friendships ON friend_stream.userid = messenger_friendships.user_two_id WHERE messenger_friendships.user_one_id = '" + Id + "' ORDER BY friend_stream.time DESC LIMIT 15"); //FriendStream fix
                 adapter.ExecuteQuery(string.Concat(new object[]
                 {
                     "UPDATE users SET online = '1'" + /*auth_ticket = ''*/ "WHERE Id = '",
                     Id,
                     "' LIMIT 1; UPDATE user_info SET login_timestamp = '",
                     PhoenixEnvironment.GetUnixTimestamp(),
                     "' WHERE user_id = '",
                     Id,
                     "' LIMIT 1;"
                 }));
             }
         }
         else
         {
             this.mUserFound = false;
         }
     }
 }
Beispiel #3
0
 public Boolean IsValid()
 {
     if (TimeExpire <= PhoenixEnvironment.GetUnixTimestamp())
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
        public void SellItem(GameClient Session, uint ItemId, int SellingPrice)
        {
            UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null || SellingPrice > GlobalClass.MaxMarketPlacePrice || !this.CanSellItem(Item))
            {
                ServerMessage Message = new ServerMessage(610u);
                Message.AppendBoolean(false);
                Session.SendMessage(Message);
            }
            else
            {
                int num  = this.CalculateComissionPrice((float)SellingPrice);
                int num2 = SellingPrice + num;
                int num3 = 1;
                if (Item.GetBaseItem().Type == 'i')
                {
                    num3++;
                }
                using (DatabaseClient class2 = PhoenixEnvironment.GetDatabase().GetClient())
                {
                    class2.AddParamWithValue("public_name", Item.GetBaseItem().PublicName);
                    class2.AddParamWithValue("extra_data", Item.ExtraData);
                    class2.ExecuteQuery(string.Concat(new object[]
                    {
                        "INSERT INTO catalog_marketplace_offers (furni_id, item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES ('",
                        ItemId,
                        "','",
                        Item.BaseItem,
                        "','",
                        Session.GetHabbo().Id,
                        "','",
                        SellingPrice,
                        "','",
                        num2,
                        "',@public_name,'",
                        Item.GetBaseItem().SpriteId,
                        "','",
                        num3,
                        "','",
                        PhoenixEnvironment.GetUnixTimestamp(),
                        "',@extra_data)"
                    }));
                }
                Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, 0u, true);
                ServerMessage Message2 = new ServerMessage(610u);
                Message2.AppendBoolean(true);
                Session.SendMessage(Message2);
            }
        }
Beispiel #5
0
 public ServerMessage SerializeUserInfo(uint UserId)
 {
     using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
     {
         DataRow User = adapter.ReadDataRow("SELECT Id, username, online FROM users WHERE Id = '" + UserId + "' LIMIT 1");
         DataRow Info = adapter.ReadDataRow("SELECT reg_timestamp, login_timestamp, cfhs, cfhs_abusive, cautions, bans FROM user_info WHERE user_id = '" + UserId + "' LIMIT 1");
         if (User == null)
         {
             throw new ArgumentException();
         }
         ServerMessage Message = new ServerMessage(533);
         Message.AppendUInt((uint)User["Id"]);
         Message.AppendStringWithBreak((string)User["username"]);
         if (Info != null)
         {
             Message.AppendInt32((int)Math.Ceiling((PhoenixEnvironment.GetUnixTimestamp() - (double)Info["reg_timestamp"]) / 60.0));
             Message.AppendInt32((int)Math.Ceiling((PhoenixEnvironment.GetUnixTimestamp() - (double)Info["login_timestamp"]) / 60.0));
         }
         else
         {
             Message.AppendInt32(0);
             Message.AppendInt32(0);
         }
         if (User["online"].ToString() == "1")
         {
             Message.AppendBoolean(true);
         }
         else
         {
             Message.AppendBoolean(false);
         }
         if (Info != null)
         {
             Message.AppendInt32((int)Info["cfhs"]);
             Message.AppendInt32((int)Info["cfhs_abusive"]);
             Message.AppendInt32((int)Info["cautions"]);
             Message.AppendInt32((int)Info["bans"]);
         }
         else
         {
             Message.AppendInt32(0);
             Message.AppendInt32(0);
             Message.AppendInt32(0);
             Message.AppendInt32(0);
         }
         return(Message);
     }
 }
Beispiel #6
0
 public void PlaySong()
 {
     if (this.mSongQueuePosition >= this.mPlaylist.Count)
     {
         this.mSongQueuePosition = 0;
     }
     if (this.mPlaylist.Count == 0)
     {
         this.Stop();
     }
     else
     {
         if (!this.mPlaylist.ContainsKey(this.mSongQueuePosition))
         {
             this.mSongQueuePosition = 0;
         }
         this.mSong       = this.mPlaylist[this.mSongQueuePosition];
         this.mSongLength = this.mSong.SongData.Length / 1000;
         this.mStartedPlayingTimestamp = PhoenixEnvironment.GetUnixTimestamp();
         mBroadcastNeeded = true;
     }
 }
Beispiel #7
0
 public void GivePixels(GameClient Session)
 {
     try
     {
         if (Session.GetHabbo().InRoom)
         {
             RoomUser @class = Session.GetHabbo().CurrentRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
             if (@class.IdleTime <= GlobalClass.IdleSleep)
             {
                 double double_ = PhoenixEnvironment.GetUnixTimestamp();
                 Session.GetHabbo().LastActivityPointsUpdate = double_;
                 if (GlobalClass.Pixels > 0 && (Session.GetHabbo().ActivityPoints < GlobalClass.pixels_max || GlobalClass.pixels_max == 0))
                 {
                     Session.GetHabbo().ActivityPoints += GlobalClass.Pixels;
                     Session.GetHabbo().UpdateActivityPointsBalance(GlobalClass.Pixels);
                 }
                 if (GlobalClass.Credits > 0 && (Session.GetHabbo().Credits < GlobalClass.credits_max || GlobalClass.credits_max == 0))
                 {
                     Session.GetHabbo().Credits += GlobalClass.Credits;
                     if (Session.GetHabbo().Vip)
                     {
                         Session.GetHabbo().Credits += GlobalClass.Credits;
                     }
                     Session.GetHabbo().UpdateCreditsBalance(true);
                 }
                 if (GlobalClass.Points > 0 && (Session.GetHabbo().shells < GlobalClass.points_max || GlobalClass.points_max == 0))
                 {
                     Session.GetHabbo().shells += GlobalClass.Points;
                     Session.GetHabbo().UpdateShellsBalance(false, true);
                 }
             }
         }
     }
     catch
     {
     }
 }
Beispiel #8
0
        public void EnableEffect(int EffectId)
        {
            AvatarEffect Effect = this.GetEffect(EffectId, false);

            if (Effect != null && !Effect.HasExpired && !Effect.Activated && (this.GetClient() != null && this.GetClient().GetHabbo() != null))
            {
                Room class2 = this.GetUserRoom();
                if (class2 != null)
                {
                    RoomUser User = class2.GetRoomUserByHabbo(this.GetClient().GetHabbo().Id);
                    if (User.byte_1 <= 0 && User.Riding == null)
                    {
                        using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                        {
                            adapter.ExecuteQuery("UPDATE user_effects SET is_activated = '1', activated_stamp = '" + PhoenixEnvironment.GetUnixTimestamp() + "' WHERE user_id = '" + UserId + "' AND effect_id = '" + EffectId + "' LIMIT 1");
                        }
                        Effect.Activate();
                        ServerMessage Message = new ServerMessage(462);
                        Message.AppendInt32(Effect.EffectId);
                        Message.AppendInt32(Effect.TotalDuration);
                        this.GetClient().SendMessage(Message);
                    }
                }
            }
        }
Beispiel #9
0
        public bool NeedsUpdate(GameClient Client)
        {
            double num = (PhoenixEnvironment.GetUnixTimestamp() - Client.GetHabbo().LastActivityPointsUpdate) / 60.0;

            return(num >= GlobalClass.Timer);
        }
Beispiel #10
0
        public Habbo(uint Id, string Username, string RealName, string SSO, uint Rank, string Motto, string Look, string Gender, int Credits, int Pixels, double Activity_Points_LastUpdate, bool Muted, uint HomeRoom, int NewbieStatus, bool BlockNewFriends, bool HideInRoom, bool HideOnline, bool Vip, int Volume, int Points, bool AcceptTrading, string LastIp, GameClient Session, HabboData HabboData, bool FriendStream)
        {
            if (Session != null)
            {
                PhoenixEnvironment.GetGame().GetClientManager().RegisterClientShit(Id, Username, Session);
            }
            this.Id                       = Id;
            this.Username                 = Username;
            this.RealName                 = RealName;
            this.isAaron                  = false;
            this.Visible                  = true;
            this.SSO                      = SSO;
            this.Rank                     = Rank;
            this.Motto                    = Motto;
            this.Look                     = PhoenixEnvironment.FilterInjectionChars(Look.ToLower());
            this.Gender                   = Gender.ToLower();
            this.Credits                  = Credits;
            this.shells                   = Points;
            this.ActivityPoints           = Pixels;
            this.LastActivityPointsUpdate = Activity_Points_LastUpdate;
            this.AcceptTrading            = AcceptTrading;
            this.Muted                    = Muted;
            this.LoadingRoom              = 0;
            this.LoadingChecksPassed      = false;
            this.Waitingfordoorbell       = false;
            this.CurrentRoomId            = 0;
            this.HomeRoom                 = HomeRoom;
            this.FavoriteRooms            = new List <uint>();
            this.MutedUsers               = new List <uint>();
            this.Tags                     = new List <string>();
            this.Achievements             = new Dictionary <uint, int>();
            this.RatedRooms               = new List <uint>();
            this.NewbieStatus             = NewbieStatus;
            this.CalledGuideBot           = false;
            this.BlockNewFriends          = BlockNewFriends;
            this.HideInRom                = HideInRoom;
            this.HideOnline               = HideOnline;
            this.Vip                      = Vip;
            this.Volume                   = Volume;
            this.Rigger                   = 0;
            this.BuyCount                 = 1;
            this.LastIp                   = LastIp;
            this.IsTeleporting            = false;
            this.TeleporterId             = 0;
            this.Session                  = Session;
            this.HabboData                = HabboData;
            this.UsersRooms               = new List <RoomData>();
            this.GroupReqs                = new List <int>();
            this.FriendStreamEnabled      = FriendStream;
            DataRow dataRow = null;

            using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
            {
                adapter.AddParamWithValue("user_id", Id);
                dataRow = adapter.ReadDataRow("SELECT * FROM user_stats WHERE Id = @user_id LIMIT 1");
                if (dataRow == null)
                {
                    adapter.ExecuteQuery("INSERT INTO user_stats (Id) VALUES ('" + Id + "')");
                    dataRow = adapter.ReadDataRow("SELECT * FROM user_stats WHERE Id = @user_id LIMIT 1");
                }
                this.GroupMemberships = adapter.ReadDataTable("SELECT * FROM group_memberships WHERE userid = @user_id");
                IEnumerator enumerator;
                if (this.GroupMemberships != null)
                {
                    enumerator = this.GroupMemberships.Rows.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow2 = (DataRow)enumerator.Current;
                            Group   class2   = GroupManager.GetGroup((int)dataRow2["groupid"]);
                            if (class2 == null)
                            {
                                DataTable   dataTable   = adapter.ReadDataTable("SELECT * FROM groups WHERE Id = " + (int)dataRow2["groupid"] + " LIMIT 1;");
                                IEnumerator enumerator2 = dataTable.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow3 = (DataRow)enumerator2.Current;
                                        if (!GroupManager.GroupList.ContainsKey((int)dataRow3["Id"]))
                                        {
                                            GroupManager.GroupList.Add((int)dataRow3["Id"], new Group((int)dataRow3["Id"], dataRow3, adapter));
                                        }
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;
                                    if (disposable != null)
                                    {
                                        disposable.Dispose();
                                    }
                                }
                            }
                            if (!class2.List.Contains((int)Id))
                            {
                                class2.AddMember((int)Id);
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    int   num    = (int)dataRow["groupid"];
                    Group class3 = GroupManager.GetGroup(num);
                    if (class3 != null)
                    {
                        this.GroupID = num;
                    }
                    else
                    {
                        this.GroupID = 0;
                    }
                }
                else
                {
                    this.GroupID = 0;
                }
                DataTable dataTable2 = adapter.ReadDataTable("SELECT groupid FROM group_requests WHERE userid = '" + Id + "';");
                enumerator = dataTable2.Rows.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        DataRow dataRow2 = (DataRow)enumerator.Current;
                        this.GroupReqs.Add((int)dataRow2["groupid"]);
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            this.RoomVisits            = (int)dataRow["RoomVisits"];
            this.Stat_LoginTime        = (int)PhoenixEnvironment.GetUnixTimestamp();
            this.Stat_OnlineTime       = (int)dataRow["OnlineTime"];
            this.Respect               = (int)dataRow["Respect"];
            this.RespectGiven          = (int)dataRow["RespectGiven"];
            this.GiftsGiven            = (int)dataRow["GiftsGiven"];
            this.GiftsReceived         = (int)dataRow["GiftsReceived"];
            this.DailyRespectPoints    = (int)dataRow["DailyRespectPoints"];
            this.DailyPetRespectPoints = (int)dataRow["DailyPetRespectPoints"];
            this.AchievementScore      = (int)dataRow["AchievementScore"];
            this.CompletedQuests       = new List <uint>();
            this.LastQuestId           = 0u;
            this.CurrentQuestId        = (uint)dataRow["quest_id"];
            this.CurrentQuestProgress  = (int)dataRow["quest_progress"];
            this.LevelBuilder          = (int)dataRow["lev_builder"];
            this.LevelIdentity         = (int)dataRow["lev_identity"];
            this.LevelSocial           = (int)dataRow["lev_social"];
            this.LevelExplorer         = (int)dataRow["lev_explore"];
            if (Session != null)
            {
                this.SubscriptionManager             = new SubscriptionManager(Id, HabboData);
                this.BadgeComponent                  = new BadgeComponent(Id, HabboData);
                this.InventoryComponent              = new InventoryComponent(Id, Session, HabboData);
                this.AvatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, Session, HabboData);
                this.SpectatorMode = false;
                this.Disconnected  = false;
                foreach (DataRow dataRow3 in HabboData.GetUsersRooms.Rows)
                {
                    this.UsersRooms.Add(PhoenixEnvironment.GetGame().GetRoomManager().FetchRoomData((uint)dataRow3["Id"], dataRow3));
                }
            }
        }
Beispiel #11
0
        public void parse(GameClient Session, ClientMessage Event)
        {
            string        text    = Event.PopFixedString();
            ServerMessage Message = new ServerMessage(7u);

            Message.AppendStringWithBreak(text.ToLower());
            if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
            {
                double num  = (double)Session.GetHabbo().GetSubscriptionManager().GetSubscription("habbo_vip").ExpireTime;
                double num2 = num - PhoenixEnvironment.GetUnixTimestamp();
                int    num3 = (int)Math.Ceiling(num2 / 86400.0);
                int    num4 = num3 / 31;
                if (num4 >= 1)
                {
                    num4--;
                }
                Message.AppendInt32(num3 - num4 * 31);
                Message.AppendBoolean(true);
                Message.AppendInt32(num4);
                Message.AppendBoolean(true);
                Message.AppendBoolean(true);
                Message.AppendBoolean(Session.GetHabbo().Vip);
                Message.AppendInt32(0);
                Message.AppendInt32(0);
            }
            else
            {
                if (Session.GetHabbo().GetSubscriptionManager().HasSubscription(text))
                {
                    double num  = (double)Session.GetHabbo().GetSubscriptionManager().GetSubscription(text).ExpireTime;
                    double num2 = num - PhoenixEnvironment.GetUnixTimestamp();
                    int    num3 = (int)Math.Ceiling(num2 / 86400.0);
                    int    num4 = num3 / 31;
                    if (num4 >= 1)
                    {
                        num4--;
                    }
                    Message.AppendInt32(num3 - num4 * 31);
                    Message.AppendBoolean(true);
                    Message.AppendInt32(num4);
                    if (Session.GetHabbo().Rank >= 2u)
                    {
                        Message.AppendInt32(1);
                        Message.AppendInt32(1);
                        Message.AppendInt32(2);
                    }
                    else
                    {
                        Message.AppendInt32(1);
                    }
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Message.AppendInt32(0);
                    }
                }
            }
            Session.SendMessage(Message);
        }
Beispiel #12
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);
        }
Beispiel #13
0
 public void SendNewTicket(GameClient Session, int Type, uint ReportedUser, string Message)
 {
     if (Session.GetHabbo().CurrentRoomId > 0)
     {
         RoomData Data     = PhoenixEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData(Session.GetHabbo().CurrentRoomId);
         uint     TicketId = 0;
         using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
         {
             adapter.AddParamWithValue("message", Message);
             adapter.AddParamWithValue("name", Data.Name);
             adapter.ExecuteQuery("INSERT INTO moderation_tickets (score,type,status,sender_id,reported_id,moderator_id,message,room_id,room_name,timestamp) VALUES (1,'" + Type + "','open','" + Session.GetHabbo().Id + "','" + ReportedUser + "','0',@message,'" + Data.Id + "',@name,UNIX_TIMESTAMP())");
             adapter.ExecuteQuery("UPDATE user_info SET cfhs = cfhs + 1 WHERE user_id = '" + Session.GetHabbo().Id + "' LIMIT 1");
             TicketId = (uint)adapter.ReadDataRow("SELECT Id FROM moderation_tickets WHERE sender_id = '" + Session.GetHabbo().Id + "' ORDER BY Id DESC LIMIT 1")[0];
         }
         SupportTicket Ticket = new SupportTicket(TicketId, 1, Type, Session.GetHabbo().Id, ReportedUser, Message, Data.Id, Data.Name, PhoenixEnvironment.GetUnixTimestamp(), 0u);
         this.Tickets.Add(Ticket);
         this.SendTicketToModerators(Ticket);
     }
 }
Beispiel #14
0
        public void LoadBans(DatabaseClient dbClient)
        {
            Logging.Write("Loading bans..");
            this.Bans.Clear();
            DataTable dataTable = dbClient.ReadDataTable("SELECT bantype,value,reason,expire FROM bans WHERE expire > '" + PhoenixEnvironment.GetUnixTimestamp() + "'");

            if (dataTable != null)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ModerationBanType iP = ModerationBanType.IP;
                    if ((string)dataRow["bantype"] == "user")
                    {
                        iP = ModerationBanType.USERNAME;
                    }
                    this.Bans.Add(new ModerationBan(iP, (string)dataRow["value"], (string)dataRow["reason"], (double)dataRow["expire"]));
                }
                Logging.WriteLine("completed!");
            }
        }
Beispiel #15
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();
     }
 }
Beispiel #16
0
 public void Activate()
 {
     this.Activated      = true;
     this.StampActivated = PhoenixEnvironment.GetUnixTimestamp();
 }
Beispiel #17
0
 public void parse(GameClient Session, ClientMessage Event)
 {
     if (Session != null)
     {
         uint    ItemId = Event.PopWiredUInt();
         DataRow Row    = null;
         using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
         {
             Row = adapter.ReadDataRow("SELECT furni_id, item_id, user_id, extra_data, offer_id, state, timestamp FROM catalog_marketplace_offers WHERE offer_id = '" + ItemId + "' LIMIT 1");
         }
         if (Row != null)
         {
             int num2 = (int)Math.Floor(((double)Row["timestamp"] + 172800.0 - PhoenixEnvironment.GetUnixTimestamp()) / 60.0);
             int num3 = int.Parse(Row["state"].ToString());
             if (num2 <= 0)
             {
                 num3 = 3;
             }
             if ((uint)Row["user_id"] == Session.GetHabbo().Id&& num3 != 2)
             {
                 Item class2 = PhoenixEnvironment.GetGame().GetItemManager().GetItem((uint)Row["item_id"]);
                 if (class2 != null)
                 {
                     PhoenixEnvironment.GetGame().GetCatalog().DeliverItems(Session, class2, 1, (string)Row["extra_data"], false, (uint)Row["furni_id"]);
                     using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                     {
                         adapter.ExecuteQuery("DELETE FROM catalog_marketplace_offers WHERE offer_id = '" + ItemId + "' LIMIT 1");
                     }
                     ServerMessage Message = new ServerMessage(614);
                     Message.AppendUInt((uint)Row["offer_id"]);
                     Message.AppendBoolean(true);
                     Session.SendMessage(Message);
                 }
             }
         }
     }
 }
Beispiel #18
0
 internal double FormatTimestamp()
 {
     return(PhoenixEnvironment.GetUnixTimestamp() - 172800.0);
 }
Beispiel #19
0
 public void OnDisconnect()
 {
     if (!this.Disconnected)
     {
         this.Disconnected = true;
         PhoenixEnvironment.GetGame().GetClientManager().NullClientShit(this.Id, this.Username);
         if (!this.HabboInfoSaved)
         {
             this.HabboInfoSaved = true;
             using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
             {
                 adapter.ExecuteQuery(string.Concat(new object[]
                 {
                     "UPDATE users SET last_online = UNIX_TIMESTAMP(), users.online = '0', activity_points = '",
                     this.ActivityPoints,
                     "', activity_points_lastupdate = '",
                     this.LastActivityPointsUpdate,
                     "', credits = '",
                     this.Credits,
                     "' WHERE Id = '",
                     this.Id,
                     "' LIMIT 1;"
                 }));
                 int num = (int)PhoenixEnvironment.GetUnixTimestamp() - this.Stat_LoginTime;
                 adapter.ExecuteQuery(string.Concat(new object[]
                 {
                     "UPDATE user_stats SET RoomVisits = '",
                     this.RoomVisits,
                     "', OnlineTime = OnlineTime + ",
                     num,
                     ", Respect = '",
                     this.Respect,
                     "', RespectGiven = '",
                     this.RespectGiven,
                     "', GiftsGiven = '",
                     this.GiftsGiven,
                     "', GiftsReceived = '",
                     this.GiftsReceived,
                     "' WHERE Id = '",
                     this.Id,
                     "' LIMIT 1; "
                 }));
             }
         }
         if (this.InRoom && this.CurrentRoom != null)
         {
             this.CurrentRoom.RemoveUserFromRoom(this.Session, false, false);
         }
         if (this.Messenger != null)
         {
             this.Messenger.AppearOffline = true;
             this.Messenger.OnStatusChanged(true);
             this.Messenger = null;
         }
         if (this.SubscriptionManager != null)
         {
             this.SubscriptionManager.Clear();
             this.SubscriptionManager = null;
         }
         this.InventoryComponent.RunDBUpdate();
     }
 }
Beispiel #20
0
        public ServerMessage SerializeOwnOffers(uint HabboId)
        {
            int i = 0;

            using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
            {
                DataTable Table = adapter.ReadDataTable("SELECT timestamp, state, offer_id, item_type, sprite_id, total_price FROM catalog_marketplace_offers WHERE user_id = '" + HabboId + "'");
                string    s     = adapter.ReadDataRow("SELECT SUM(asking_price) FROM catalog_marketplace_offers WHERE state = '2' AND user_id = '" + HabboId + "'")[0].ToString();
                if (s.Length > 0)
                {
                    i = int.Parse(s);
                }
                ServerMessage Message = new ServerMessage(616);
                Message.AppendInt32(i);
                if (Table != null)
                {
                    Message.AppendInt32(Table.Rows.Count);
                    IEnumerator enumerator = Table.Rows.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow = (DataRow)enumerator.Current;
                            int     num     = (int)Math.Floor(((double)dataRow["timestamp"] + 172800.0 - PhoenixEnvironment.GetUnixTimestamp()) / 60.0);
                            int     num2    = int.Parse(dataRow["state"].ToString());
                            if (num <= 0 && num2 != 2)
                            {
                                num2 = 3;
                                num  = 0;
                            }
                            Message.AppendUInt((uint)dataRow["offer_id"]);
                            Message.AppendInt32(num2);
                            Message.AppendInt32(int.Parse(dataRow["item_type"].ToString()));
                            Message.AppendInt32((int)dataRow["sprite_id"]);
                            Message.AppendStringWithBreak("");
                            Message.AppendInt32((int)dataRow["total_price"]);
                            Message.AppendInt32(num);
                            Message.AppendInt32((int)dataRow["sprite_id"]);
                        }
                        goto IL_1DE;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                Message.AppendInt32(0);
IL_1DE:
                return(Message);
            }
        }