Esempio n. 1
0
 internal void BroadcastMessage(ServerMessage Message)
 {
     byte[] bytes = Message.GetBytes();
     for (int i = 0; i < this.Session.Length; i++)
     {
         GameClient Session = this.Session[i];
         if (Session != null)
         {
             try
             {
                 Session.GetConnection().SendData(bytes);
             }
             catch { }
         }
     }
 }
Esempio n. 2
0
 internal void BroadcastMessage(ServerMessage Message, ServerMessage HotelView)
 {
     byte[] bytes = Message.GetBytes();
     byte[] data = HotelView.GetBytes();
     for (int i = 0; i < this.Session.Length; i++)
     {
         GameClient Session = this.Session[i];
         if (Session != null)
         {
             try
             {
                 if (Session.GetHabbo().InRoom)
                 {
                     Session.GetConnection().SendData(bytes);
                 }
                 else
                 {
                     Session.GetConnection().SendData(data);
                 }
             }
             catch { }
         }
     }
 }
Esempio n. 3
0
		public void processCommand(string data)
		{
			string str = data.Split(new char[] { Convert.ToChar(1)	})[0];
			string s = data.Split(new char[] { Convert.ToChar(1) })[1];

            GameClient clientByUserID = null;
            DataRow Row = null;
            Habbo habbo;
            Room room;
            GameClient clientByUsername;
            string text3 = str.ToLower();
            uint uint_2;
            uint num2;
            uint num3;
            string text5;

            switch (str.ToLower())
            {
                case "update_items":
                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        PhoenixEnvironment.GetGame().GetItemManager().LoadItems(adapter);
                    }
                    break;

                case "updateusersrooms":
                    habbo = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(Convert.ToUInt32(s)).GetHabbo();
                    if (habbo != null)
                    {
                        using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                        {
                            habbo.UpdateRooms(adapter);
                        }
                    }
                    break;

                case "senduser":
                    num2 = uint.Parse(s.Split(new char[] { ' ' })[0]);
					num3 = uint.Parse(s.Split(new char[] { ' ' })[1]);

					clientByUsername = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(num2);
					room = PhoenixEnvironment.GetGame().GetRoomManager().GetRoom(num3);
					if (clientByUsername != null)
					{
						ServerMessage message1 = new ServerMessage(286);
						message1.AppendBoolean(room.IsPublic);
						message1.AppendUInt(num3);
						clientByUsername.SendMessage(message1);
					}
                    break;

                case "updatevip":
                    habbo = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(Convert.ToUInt32(s)).GetHabbo();
                    if (habbo != null)
                    {
                        habbo.UpdateVIP();
                    }
                    break;

                case "giftitem":
                case "giveitem":	
                    num2 = uint.Parse(s.Split(new char[] { ' ' })[0]);
					uint uint_ = uint.Parse(s.Split(new char[] { ' ' })[1]);
					int int_ = int.Parse(s.Split(new char[] { ' ' })[2]);
					string string_ = s.Substring(num2.ToString().Length + uint_.ToString().Length + int_.ToString().Length + 3);

					PhoenixEnvironment.GetGame().GetCatalog().GiveGift(string_, num2, uint_, int_);
                    break;

                case "unloadroom":
                    uint_2 = uint.Parse(s);
					room = PhoenixEnvironment.GetGame().GetRoomManager().GetRoom(uint_2);
					PhoenixEnvironment.GetGame().GetRoomManager().UnloadRoom(room);
                    break;

                case "roomalert":
                    num3 = uint.Parse(s.Split(new char[] { ' ' })[0]);

                    room = PhoenixEnvironment.GetGame().GetRoomManager().GetRoom(num3);
                    if (room != null)
                    {
                        string msg = s.Substring(num3.ToString().Length + 1);
                        for (int i = 0; i < room.UserList.Length; i++)
                        {
                            RoomUser user = room.UserList[i];
                            if (user != null)
                            {
                                user.GetClient().SendNotif(msg);
                            }
                        }
                    }
                    break;

                case "updategroup":
                    int int_2 = int.Parse(s.Split(new char[] { ' ' })[0]);

                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        GroupManager.UpdateGroup(adapter, int_2);
                    }
                    break;

                case "updateusersgroups":
					uint_2 = uint.Parse(s);
					using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
					{
						PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint_2).GetHabbo().UpdateGroups(adapter);
					}
                    break;

                case "shutdown":
					PhoenixEnvironment.BeginShutDown();
                    break;

                case "update_filter":
                case "refresh_filter":
                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        ChatCommandHandler.UpdateFilters(adapter);
                    }
                    break;

                case "updatecredits":
					clientByUserID = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint.Parse(s));
					if (clientByUserID != null)
					{
						int int_3 = 0;
						using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
						{
							int_3 = (int)adapter.ReadDataRow("SELECT credits FROM users WHERE UserId = '" + clientByUserID.GetHabbo().Id + "' LIMIT 1")[0];
						}
						clientByUserID.GetHabbo().Credits = int_3;
						clientByUserID.GetHabbo().UpdateCreditsBalance(false);
					}
                    break;

                case "updatesettings":
                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        PhoenixEnvironment.GetGame().LoadSettings(adapter);
                    }
                    break;

                case "updatepixels":
					clientByUserID = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint.Parse(s));
					if (clientByUserID != null)
					{
						int int_4 = 0;
						using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
						{
                            int_4 = (int)adapter.ReadDataRow("SELECT activity_points FROM users WHERE UserId = '" + clientByUserID.GetHabbo().Id + "' LIMIT 1")[0];
						}
						clientByUserID.GetHabbo().ActivityPoints = int_4;
						clientByUserID.GetHabbo().UpdateActivityPointsBalance(false);
					}
                    break;

                case "updatepoints":					
                    clientByUserID = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint.Parse(s));
					if (clientByUserID != null)
					{
						clientByUserID.GetHabbo().UpdateShellsBalance(true, false);
					}
                    break;

                case "reloadbans":					
                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
					{
						PhoenixEnvironment.GetGame().GetBanManager().LoadBans(adapter);
					}
					PhoenixEnvironment.GetGame().GetClientManager().CheckForAllBanConflicts();                     
                    break;

                case "update_bots":
                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        PhoenixEnvironment.GetGame().GetBotManager().LoadBots(adapter);
                    }
                    break;

                case "signout":
                    PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint.Parse(s)).Disconnect();
                    break;

                case "exe":
                    using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
                    {
                        adapter.ExecuteQuery(s);
                    }
                    break;

                case "alert":
                    string text6 = s.Split(new char[] { ' ' })[0];
					text5 = s.Substring(text6.Length + 1);
					ServerMessage Message8 = new ServerMessage(808);
					Message8.AppendStringWithBreak(TextManager.GetText("mus_alert_title"));
					Message8.AppendStringWithBreak(text5);
					PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint.Parse(text6)).SendMessage(Message8);
                    break;

                case "sa":						
                    ServerMessage Message = new ServerMessage(134);
					Message.AppendUInt(0);
					Message.AppendString("PHX: " + s);
					PhoenixEnvironment.GetGame().GetClientManager().BroadcastMessageToStaff(Message, Message);                        
                    break;

                case "ha":		
                    ServerMessage Message2 = new ServerMessage(808);
					Message2.AppendStringWithBreak(TextManager.GetText("mus_ha_title"));
					Message2.AppendStringWithBreak(s);
					ServerMessage hotelView = new ServerMessage(161);
					hotelView.AppendStringWithBreak(s);
					PhoenixEnvironment.GetGame().GetClientManager().BroadcastMessage(Message2, hotelView);
                    break;

                case "hal":						
                    string text4 = s.Split(new char[] { ' ' })[0];
				    text5 = s.Substring(text4.Length + 1);
					ServerMessage Message4 = new ServerMessage(161u);
					Message4.AppendStringWithBreak(string.Concat(new string[]
					{
						TextManager.GetText("mus_hal_title"),
						"\r\n",
						text5,
						"\r\n-",
						TextManager.GetText("mus_hal_tail")
					}));
					Message4.AppendStringWithBreak(text4);
					PhoenixEnvironment.GetGame().GetClientManager().BroadcastMessage(Message4);
                    break;

                case "updatemotto":
                case "updatelook":			
                uint_2 = uint.Parse(s);
				clientByUserID = PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(uint_2);
				using (DatabaseClient class2 = PhoenixEnvironment.GetDatabase().GetClient())
				{
					Row = class2.ReadDataRow("SELECT look,gender,motto,mutant_penalty,block_newfriends FROM users WHERE UserId = '" + clientByUserID.GetHabbo().Id + "' LIMIT 1");
				}
                clientByUserID.GetHabbo().Look = (string)Row["look"];
                clientByUserID.GetHabbo().Gender = Row["gender"].ToString().ToLower();
                clientByUserID.GetHabbo().Motto = PhoenixEnvironment.FilterInjectionChars((string)Row["motto"]);
                clientByUserID.GetHabbo().BlockNewFriends = PhoenixEnvironment.EnumToBool(Row["block_newfriends"].ToString());
				ServerMessage Message5 = new ServerMessage(266);
				Message5.AppendInt32(-1);
				Message5.AppendStringWithBreak(clientByUserID.GetHabbo().Look);
				Message5.AppendStringWithBreak(clientByUserID.GetHabbo().Gender.ToLower());
				Message5.AppendStringWithBreak(clientByUserID.GetHabbo().Motto);
				clientByUserID.SendMessage(Message5);
				if (clientByUserID.GetHabbo().InRoom)
				{
					room = PhoenixEnvironment.GetGame().GetRoomManager().GetRoom(clientByUserID.GetHabbo().CurrentRoomId);
					RoomUser class6 = room.GetRoomUserByHabbo(clientByUserID.GetHabbo().Id);
					ServerMessage Message6 = new ServerMessage(266u);
					Message6.AppendInt32(class6.VirtualId);
					Message6.AppendStringWithBreak(clientByUserID.GetHabbo().Look);
					Message6.AppendStringWithBreak(clientByUserID.GetHabbo().Gender.ToLower());
					Message6.AppendStringWithBreak(clientByUserID.GetHabbo().Motto);
					Message6.AppendInt32(clientByUserID.GetHabbo().AchievementScore);
					Message6.AppendStringWithBreak("");
					room.SendMessage(Message6, null);
				}
				text3 = str.ToLower();
                //if (text3 == null)
                //{
                //    ServerMessage message = new ServerMessage(1);
                //    message.AppendString("Hello Housekeeping, Love from Phoenix Emu");
                //    socket.Send(message.GetBytes());
                //}
				if (text3 == "updatemotto")
				{
					PhoenixEnvironment.GetGame().GetAchievementManager().UnlockAchievement(clientByUserID, 5u, 1);
				}
				if (text3 == "updatelook")
				{
					PhoenixEnvironment.GetGame().GetAchievementManager().UnlockAchievement(clientByUserID, 1u, 1);
				}
                break;

                default:                    
                    ServerMessage message11 = new ServerMessage(1);
                    message11.AppendString("Hello Housekeeping, Love from Phoenix Emu");
                    socket.Send(message11.GetBytes());
                break;
            }
		}
Esempio n. 4
0
 private void TestClientConnections()
 {
     int millisecondsTimeout = int.Parse(PhoenixEnvironment.GetConfig().data["client.ping.interval"]);
     if (millisecondsTimeout <= 100)
     {
         throw new ArgumentException("Invalid configuration value for ping interval! Must be above 100 miliseconds.");
     }
     while (true)
     {
         try
         {
             ServerMessage Message = new ServerMessage(50);
             List<GameClient> SuccessTest = new List<GameClient>();
             List<GameClient> FailTest = new List<GameClient>();
             for (int i = 0; i < this.Session.Length; i++)
             {
                 GameClient Session = this.Session[i];
                 if (Session != null)
                 {
                     if (Session.PongOK)
                     {
                         Session.PongOK = false;
                         FailTest.Add(Session);
                     }
                     else
                     {
                         SuccessTest.Add(Session);
                     }
                 }
             }
             foreach (GameClient Session in SuccessTest)
             {
                 try
                 {
                     Session.Disconnect();
                 }
                 catch { }
             }
             byte[] bytes = Message.GetBytes();
             foreach (GameClient Session in FailTest)
             {
                 try
                 {
                     Session.GetConnection().SendData(bytes);
                 }
                 catch { }
             }
         }
         catch (Exception ex)
         {
             Logging.LogThreadException(ex.ToString(), "Connection checker task");
         }
         Thread.Sleep(millisecondsTimeout);
     }
 }
Esempio n. 5
0
 internal void SendStaffChat(GameClient Session, ServerMessage Message)
 {
     byte[] bytes = Message.GetBytes();
     for (int i = 0; i < this.Session.Length; i++)
     {
         GameClient session = this.Session[i];
         if (session != null && session != Session)
         {
             try
             {
                 if (session.GetHabbo().HasRole("receive_sa"))
                 {
                     session.GetConnection().SendData(bytes);
                 }
             }
             catch { }
         }
     }
 }
Esempio n. 6
0
 public void method_61(ServerMessage Message5_0)
 {
     try
     {
         byte[] array = Message5_0.GetBytes();
         for (int i = 0; i < this.UserList.Length; i++)
         {
             RoomUser @class = this.UserList[i];
             if (@class != null && [email protected])
             {
                 GameClient class2 = @class.GetClient();
                 if (class2 != null && this.CheckRights(class2))
                 {
                     try
                     {
                         class2.GetConnection().SendData(array);
                     }
                     catch
                     {
                     }
                 }
             }
         }
     }
     catch (InvalidOperationException)
     {
     }
 }
Esempio n. 7
0
 internal void method_60(ServerMessage Message5_0, int int_17)
 {
     try
     {
         byte[] array = Message5_0.GetBytes();
         for (int i = 0; i < this.UserList.Length; i++)
         {
             RoomUser @class = this.UserList[i];
             if (@class != null && [email protected])
             {
                 GameClient class2 = @class.GetClient();
                 if (class2 != null && class2.GetHabbo() != null && (ulong)class2.GetHabbo().Rank >= (ulong)((long)int_17))
                 {
                     try
                     {
                         class2.GetConnection().SendData(array);
                     }
                     catch
                     {
                     }
                 }
             }
         }
     }
     catch (InvalidOperationException)
     {
     }
 }
Esempio n. 8
0
 internal void SendMessage(ServerMessage Message5_0, List<uint> list_18)
 {
     try
     {
         if (this.UserList != null)
         {
             byte[] array = Message5_0.GetBytes();
             for (int i = 0; i < this.UserList.Length; i++)
             {
                 RoomUser @class = this.UserList[i];
                 if (@class != null && [email protected])
                 {
                     GameClient class2 = @class.GetClient();
                     if (class2 != null && (list_18 == null || !list_18.Contains(class2.GetHabbo().Id)))
                     {
                         try
                         {
                             class2.GetConnection().SendData(array);
                         }
                         catch
                         {
                         }
                     }
                 }
             }
         }
     }
     catch (InvalidOperationException)
     {
     }
 }
Esempio n. 9
0
 public void SendMessage(ServerMessage Message)
 {
     if (Message != null)
     {
         this.SendData(Message.GetBytes());
     }
 }