コード例 #1
0
        private static void AccountSearch(NetState state, PacketReader pvSrc)
        {
            AcctSearchType type = (AcctSearchType)pvSrc.ReadByte();
            string         term = pvSrc.ReadString();

            if (type == AcctSearchType.IP && !Utility.IsValidIP(term))
            {
                state.Send(new MessageBoxMessage("Invalid search term.\nThe IP sent was not valid.", "Invalid IP"));
                return;
            }
            else
            {
                term = term.ToUpper();
            }

            ArrayList list = new ArrayList();

            foreach (Account a in Accounts.Table.Values)
            {
                switch (type)
                {
                case AcctSearchType.Username:
                {
                    if (a.Username.ToUpper().IndexOf(term) != -1)
                    {
                        list.Add(a);
                    }
                    break;
                }

                case AcctSearchType.IP:
                {
                    for (int i = 0; i < a.LoginIPs.Length; i++)
                    {
                        if (Utility.IPMatch(term, a.LoginIPs[i]))
                        {
                            list.Add(a);
                            break;
                        }
                    }
                    break;
                }
                }
            }

            if (list.Count > 0)
            {
                if (list.Count <= 25)
                {
                    state.Send(AdminNetwork.Compress(new AccountSearchResults(list)));
                }
                else
                {
                    state.Send(new MessageBoxMessage("There were more than 25 matches to your search.\nNarrow the search parameters and try again.", "Too Many Results"));
                }
            }
            else
            {
                state.Send(new MessageBoxMessage("There were no results to your search.\nPlease try again.", "No Matches"));
            }
        }
コード例 #2
0
 private static void ServerInfoRequest(NetState state, PacketReader pvSrc)
 {
     state.Send(AdminNetwork.Compress(new ServerInfo()));
 }