Exemple #1
0
		public void AddPageButton( int x, int y, int buttonID, string text, AdminGumpPage page, params AdminGumpPage[] subPages )
		{
			bool isSelection = ( m_PageType == page );

			for ( int i = 0; !isSelection && i < subPages.Length; ++i )
				isSelection = ( m_PageType == subPages[i] );

			AddSelectedButton( x, y, buttonID, text, isSelection );
		}
Exemple #2
0
		public AdminGump( Mobile from, AdminGumpPage pageType, int listPage, ArrayList list, string notice, object state ) : base( 50, 40 )
		{
			from.CloseGump( typeof( AdminGump ) );

			m_From = from;
			m_PageType = pageType;
			m_ListPage = listPage;
			m_State = state;
			m_List = list;

			AddPage( 0 );

			AddBackground( 0, 0, 420, 440, 5054 );

			AddBlackAlpha( 10, 10, 170, 100 );
			AddBlackAlpha( 190, 10, 220, 100 );
			AddBlackAlpha( 10, 120, 400, 260 );
			AddBlackAlpha( 10, 390, 400, 40 );

			AddPageButton( 10, 10, GetButtonID( 0, 0 ), "INFORMATION", AdminGumpPage.Information_General, AdminGumpPage.Information_Perf );
			AddPageButton( 10, 30, GetButtonID( 0, 1 ), "ADMINISTER", AdminGumpPage.Administer, AdminGumpPage.Administer_Access, AdminGumpPage.Administer_Commands, AdminGumpPage.Administer_Server, AdminGumpPage.Administer_WorldBuilding, AdminGumpPage.Administer_Access_Lockdown );
			AddPageButton( 10, 50, GetButtonID( 0, 2 ), "CLIENT LIST", AdminGumpPage.Clients, AdminGumpPage.ClientInfo );
			AddPageButton( 10, 70, GetButtonID( 0, 3 ), "ACCOUNT LIST", AdminGumpPage.Accounts, AdminGumpPage.Accounts_Shared, AdminGumpPage.AccountDetails, AdminGumpPage.AccountDetails_Information, AdminGumpPage.AccountDetails_Characters, AdminGumpPage.AccountDetails_Access, AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions, AdminGumpPage.AccountDetails_Comments, AdminGumpPage.AccountDetails_Tags, AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword );
			AddPageButton( 10, 90, GetButtonID( 0, 4 ), "FIREWALL", AdminGumpPage.Firewall, AdminGumpPage.FirewallInfo );

			if ( notice != null )
				AddHtml( 12, 392, 396, 36, Color( notice, LabelColor32 ), false, false );

			switch ( pageType )
			{
				case AdminGumpPage.Information_General:
				{
					int banned = 0;
					int active = 0;

					foreach ( Account acct in Accounts.GetAccounts() )
					{
						if ( acct.Banned )
							++banned;
						else
							++active;
					}

					AddLabel( 20, 130, LabelHue, "Active Accounts:" );
					AddLabel( 150, 130, LabelHue, active.ToString() );

					AddLabel( 20, 150, LabelHue, "Banned Accounts:" );
					AddLabel( 150, 150, LabelHue, banned.ToString() );

					AddLabel( 20, 170, LabelHue, "Firewalled:" );
					AddLabel( 150, 170, LabelHue, Firewall.List.Count.ToString() );

					AddLabel( 20, 190, LabelHue, "Clients:" );
					AddLabel( 150, 190, LabelHue, NetState.Instances.Count.ToString() );

					AddLabel( 20, 210, LabelHue, "Mobiles:" );
					AddLabel( 150, 210, LabelHue, World.Mobiles.Count.ToString() );

					AddLabel( 20, 230, LabelHue, "Mobile Scripts:" );
					AddLabel( 150, 230, LabelHue, Core.ScriptMobiles.ToString() );

					AddLabel( 20, 250, LabelHue, "Items:" );
					AddLabel( 150, 250, LabelHue, World.Items.Count.ToString() );

					AddLabel( 20, 270, LabelHue, "Item Scripts:" );
					AddLabel( 150, 270, LabelHue, Core.ScriptItems.ToString() );

					AddLabel( 20, 290, LabelHue, "Uptime:" );
					AddLabel( 150, 290, LabelHue, FormatTimeSpan( DateTime.UtcNow - Clock.ServerStart ) );

					AddLabel( 20, 310, LabelHue, "Memory:" );
					AddLabel( 150, 310, LabelHue, FormatByteAmount( GC.GetTotalMemory( false ) ) );

					AddLabel( 20, 330, LabelHue, "Framework:" );
					AddLabel( 150, 330, LabelHue, Environment.Version.ToString() );

					AddLabel( 20, 350, LabelHue, "Operating System: " );
					string os = Environment.OSVersion.ToString();

					os = os.Replace( "Microsoft", "MSFT" );
					os = os.Replace( "Service Pack", "SP" );

					AddLabel( 150, 350, LabelHue, os );

					/*string str;

					try{ str = FormatTimeSpan( Core.Process.TotalProcessorTime ); }
					catch{ str = "(unable to retrieve)"; }

					AddLabel( 20, 330, LabelHue, "Process Time:" );
					AddLabel( 250, 330, LabelHue, str );*/

					/*try{ str = Core.Process.PriorityClass.ToString(); }
					catch{ str = "(unable to retrieve)"; }

					AddLabel( 20, 350, LabelHue, "Process Priority:" );
					AddLabel( 250, 350, LabelHue, str );*/

					AddPageButton( 200, 20, GetButtonID( 0, 0 ), "General", AdminGumpPage.Information_General );
					AddPageButton( 200, 40, GetButtonID( 0, 5 ), "Performance", AdminGumpPage.Information_Perf );

					break;
				}
				case AdminGumpPage.Information_Perf:
				{
					AddLabel( 20, 130, LabelHue, "Cycles Per Second:" );
					AddLabel( 40, 150, LabelHue, "Current: " + Core.CyclesPerSecond.ToString( "N2" ) );
					AddLabel( 40, 170, LabelHue, "Average: " + Core.AverageCPS.ToString( "N2" ) );

					StringBuilder sb = new StringBuilder();

					int curUser, maxUser;
					int curIOCP, maxIOCP;

					System.Threading.ThreadPool.GetAvailableThreads( out curUser, out curIOCP );
					System.Threading.ThreadPool.GetMaxThreads( out maxUser, out maxIOCP );

					sb.Append( "Worker Threads:<br>Capacity: " );
					sb.Append( maxUser );
					sb.Append( "<br>Available: " );
					sb.Append( curUser );
					sb.Append( "<br>Usage: " );
					sb.Append( ((maxUser - curUser) * 100) / maxUser );
					sb.Append( "%<br><br>IOCP Threads:<br>Capacity: " );
					sb.Append( maxIOCP );
					sb.Append( "<br>Available: " );
					sb.Append( curIOCP );
					sb.Append( "<br>Usage: " );
					sb.Append( ((maxIOCP - curIOCP) * 100) / maxIOCP );
					sb.Append( "%" );

					List<BufferPool> pools = BufferPool.Pools;

					lock ( pools )
					{
						for ( int i = 0; i < pools.Count; ++i )
						{
							BufferPool pool = pools[i];
							string name;
							int freeCount;
							int initialCapacity;
							int currentCapacity;
							int bufferSize;
							int misses;

							pool.GetInfo( out name, out freeCount, out initialCapacity, out currentCapacity, out bufferSize, out misses );

							if ( sb.Length > 0 )
								sb.Append( "<br><br>" );

							sb.Append( name );
							sb.Append( "<br>Size: " );
							sb.Append( FormatByteAmount( bufferSize ) );
							sb.Append( "<br>Capacity: " );
							sb.Append( currentCapacity );
							sb.Append( " (" );
							sb.Append( misses );
							sb.Append( " misses)<br>Available: " );
							sb.Append( freeCount );
							sb.Append( "<br>Usage: " );
							sb.Append( ((currentCapacity - freeCount) * 100) / currentCapacity );
							sb.Append( "% : " );
							sb.Append( FormatByteAmount( (currentCapacity - freeCount) * bufferSize ) );
							sb.Append( " of " );
							sb.Append( FormatByteAmount( currentCapacity * bufferSize ) );
						}
					}

					
					AddLabel( 20, 200, LabelHue, "Pooling:" );
					AddHtml( 20, 220, 380, 150, sb.ToString(), true, true );

					AddPageButton( 200, 20, GetButtonID( 0, 0 ), "General", AdminGumpPage.Information_General );
					AddPageButton( 200, 40, GetButtonID( 0, 5 ), "Performance", AdminGumpPage.Information_Perf );

					break;
				}
				case AdminGumpPage.Administer_WorldBuilding:
				{
					AddHtml( 10, 125, 400, 20, Color( Center( "Generating" ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 150, GetButtonID( 3, 100 ), "Documentation" );
					AddButtonLabeled( 220, 150, GetButtonID( 3, 107 ), "Rebuild Categorization" );

					AddButtonLabeled( 20, 175, GetButtonID( 3, 101 ), "Teleporters" );
					AddButtonLabeled( 220, 175, GetButtonID( 3, 102 ), "Moongates" );

					AddButtonLabeled( 20, 200, GetButtonID( 3, 103 ), "Vendors" );
					AddButtonLabeled( 220, 200, GetButtonID( 3, 106 ), "Decoration" );

					AddButtonLabeled( 20, 225, GetButtonID( 3, 104 ), "Doors" );
					AddButtonLabeled( 220, 225, GetButtonID( 3, 105 ), "Signs" );

					AddHtml( 20, 275, 400, 30, Color( Center( "Statics" ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 300, GetButtonID( 3, 110 ), "Freeze (Target)" );
					AddButtonLabeled( 20, 325, GetButtonID( 3, 111 ), "Freeze (World)" );
					AddButtonLabeled( 20, 350, GetButtonID( 3, 112 ), "Freeze (Map)" );

					AddButtonLabeled( 220, 300, GetButtonID( 3, 120 ), "Unfreeze (Target)" );
					AddButtonLabeled( 220, 325, GetButtonID( 3, 121 ), "Unfreeze (World)" );
					AddButtonLabeled( 220, 350, GetButtonID( 3, 122 ), "Unfreeze (Map)" );

					goto case AdminGumpPage.Administer;
				}
				case AdminGumpPage.Administer_Server:
				{
					AddHtml( 10, 125, 400, 20, Color( Center( "Server" ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 150, GetButtonID( 3, 200 ), "Save" );

					/*if ( !Core.Service )
					{*/
						AddButtonLabeled( 20, 180, GetButtonID( 3, 201 ), "Shutdown (With Save)" );
						AddButtonLabeled( 20, 200, GetButtonID( 3, 202 ), "Shutdown (Without Save)" );

						AddButtonLabeled( 20, 230, GetButtonID( 3, 203 ), "Shutdown & Restart (With Save)" );
						AddButtonLabeled( 20, 250, GetButtonID( 3, 204 ), "Shutdown & Restart (Without Save)" );
					/*}
					else
					{
						AddLabel( 20, 215, LabelHue, "Shutdown/Restart not available." );
					}*/

					AddHtml( 10, 295, 400, 20, Color( Center( "Broadcast" ), LabelColor32 ), false, false );

					AddTextField( 20, 320, 380, 20, 0 );
					AddButtonLabeled( 20, 350, GetButtonID( 3, 210 ), "To Everyone" );
					AddButtonLabeled( 220, 350, GetButtonID( 3, 211 ), "To Staff" );

					goto case AdminGumpPage.Administer;
				}
				case AdminGumpPage.Administer_Access_Lockdown:
				{
					AddHtml( 10, 125, 400, 20, Color( Center( "Server Lockdown" ), LabelColor32 ), false, false );

					AddHtml( 20, 150, 380, 80, Color( "When enabled, only clients with an access level equal to or greater than the specified lockdown level may access the server. After setting a lockdown level, use the <em>Purge Invalid Clients</em> button to disconnect those clients without access.", LabelColor32 ), false, false );

					AccessLevel level = Misc.AccountHandler.LockdownLevel;
					bool isLockedDown = ( level > AccessLevel.Player );

					AddSelectedButton( 20, 230, GetButtonID( 3, 500 ), "Not Locked Down", !isLockedDown );
					AddSelectedButton( 20, 260, GetButtonID( 3, 504 ), "Administrators", ( isLockedDown && level <= AccessLevel.Administrator ) );
					AddSelectedButton( 20, 280, GetButtonID( 3, 503 ), "Seers", ( isLockedDown && level <= AccessLevel.Seer ) );
					AddSelectedButton( 20, 300, GetButtonID( 3, 502 ), "Game Masters", ( isLockedDown && level <= AccessLevel.GameMaster ) );
					AddSelectedButton( 20, 320, GetButtonID( 3, 501 ), "Counselors", ( isLockedDown && level <= AccessLevel.Counselor ) );

					AddButtonLabeled( 20, 350, GetButtonID( 3, 510 ), "Purge Invalid Clients" );

					goto case AdminGumpPage.Administer;
				}
				case AdminGumpPage.Administer_Access:
				{
					AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );

					AddHtml( 10, 155, 400, 20, Color( Center( "Connectivity" ), LabelColor32 ), false, false );

					AddButtonLabeled(  20, 180, GetButtonID( 3, 300 ), "Kick" );
					AddButtonLabeled( 220, 180, GetButtonID( 3, 301 ), "Ban" );

					AddButtonLabeled(  20, 210, GetButtonID( 3, 302 ), "Firewall" );
					AddButtonLabeled( 220, 210, GetButtonID( 3, 303 ), "Lockdown" );

					AddHtml( 10, 245, 400, 20, Color( Center( "Staff" ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 270, GetButtonID( 3, 310 ), "Make Player" );
					AddButtonLabeled( 20, 290, GetButtonID( 3, 311 ), "Make Counselor" );
					AddButtonLabeled( 20, 310, GetButtonID( 3, 312 ), "Make Game Master" );
					AddButtonLabeled( 20, 330, GetButtonID( 3, 313 ), "Make Seer" );

					if ( from.AccessLevel > AccessLevel.Administrator )
					{
						AddButtonLabeled( 220, 270, GetButtonID( 3, 314 ), "Make Administrator" );

						if ( from.AccessLevel > AccessLevel.Developer )
						{
							AddButtonLabeled( 220, 290, GetButtonID( 3, 315 ), "Make Developer" );

							if ( from.AccessLevel >= AccessLevel.Owner )
								AddButtonLabeled( 220, 310, GetButtonID( 3, 316 ), "Make Owner" );
						}
					}

					goto case AdminGumpPage.Administer;
				}
				case AdminGumpPage.Administer_Commands:
				{
					AddHtml( 10, 125, 400, 20, Color( Center( "Commands" ), LabelColor32 ), false, false );

					AddButtonLabeled(  20, 150, GetButtonID( 3, 400 ), "Add" );
					AddButtonLabeled( 220, 150, GetButtonID( 3, 401 ), "Remove" );

					AddButtonLabeled(  20, 170, GetButtonID( 3, 402 ), "Dupe" );
					AddButtonLabeled( 220, 170, GetButtonID( 3, 403 ), "Dupe in bag" );

					AddButtonLabeled(  20, 200, GetButtonID( 3, 404 ), "Properties" );
					AddButtonLabeled( 220, 200, GetButtonID( 3, 405 ), "Skills" );

					AddButtonLabeled(  20, 230, GetButtonID( 3, 406 ), "Mortal" );
					AddButtonLabeled( 220, 230, GetButtonID( 3, 407 ), "Immortal" );

					AddButtonLabeled(  20, 250, GetButtonID( 3, 408 ), "Squelch" );
					AddButtonLabeled( 220, 250, GetButtonID( 3, 409 ), "Unsquelch" );

					AddButtonLabeled(  20, 270, GetButtonID( 3, 410 ), "Freeze" );
					AddButtonLabeled( 220, 270, GetButtonID( 3, 411 ), "Unfreeze" );

					AddButtonLabeled(  20, 290, GetButtonID( 3, 412 ), "Hide" );
					AddButtonLabeled( 220, 290, GetButtonID( 3, 413 ), "Unhide" );

					AddButtonLabeled(  20, 310, GetButtonID( 3, 414 ), "Kill" );
					AddButtonLabeled( 220, 310, GetButtonID( 3, 415 ), "Resurrect" );

					AddButtonLabeled(  20, 330, GetButtonID( 3, 416 ), "Move" );
					AddButtonLabeled( 220, 330, GetButtonID( 3, 417 ), "Wipe" );

					AddButtonLabeled(  20, 350, GetButtonID( 3, 418 ), "Teleport" );
					AddButtonLabeled( 220, 350, GetButtonID( 3, 419 ), "Teleport (Multiple)" );

					goto case AdminGumpPage.Administer;
				}
				case AdminGumpPage.Administer:
				{
					AddPageButton( 200, 20, GetButtonID( 3, 0 ), "World Building", AdminGumpPage.Administer_WorldBuilding );
					AddPageButton( 200, 40, GetButtonID( 3, 1 ), "Server", AdminGumpPage.Administer_Server );
					AddPageButton( 200, 60, GetButtonID( 3, 2 ), "Access", AdminGumpPage.Administer_Access, AdminGumpPage.Administer_Access_Lockdown );
					AddPageButton( 200, 80, GetButtonID( 3, 3 ), "Commands", AdminGumpPage.Administer_Commands );

					break;
				}
				case AdminGumpPage.Clients:
				{
					if ( m_List == null )
					{
						m_List = new ArrayList( NetState.Instances );
						m_List.Sort( NetStateComparer.Instance );
					}

					AddClientHeader();

					AddLabelCropped(  12, 120, 81, 20, LabelHue, "Name" );
					AddLabelCropped(  95, 120, 81, 20, LabelHue, "Account" );
					AddLabelCropped( 178, 120, 81, 20, LabelHue, "Access Level" );
					AddLabelCropped( 273, 120,109, 20, LabelHue, "IP Address" );

					if ( listPage > 0 )
						AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 375, 122, 0x25EA );

					if ( (listPage + 1) * 12 < m_List.Count )
						AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 392, 122, 0x25E6 );

					if ( m_List.Count == 0 )
						AddLabel( 12, 140, LabelHue, "There are no clients to display." );

					for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						NetState ns = m_List[index] as NetState;

						if ( ns == null )
							continue;

						Mobile m = ns.Mobile;
						Account a = ns.Account as Account;
						int offset = 140 + (i * 20);

						if ( m == null )
						{
							if ( RemoteAdmin.AdminNetwork.IsAuth( ns ) )
								AddLabelCropped( 12, offset, 81, 20, LabelHue, "(remote admin)" );
							else
								AddLabelCropped( 12, offset, 81, 20, LabelHue, "(logging in)" );
						}
						else
						{
							AddLabelCropped(  12, offset, 81, 20, GetHueFor( m ), m.Name );
						}
						AddLabelCropped(  95, offset, 81, 20, LabelHue, a == null ? "(no account)" : a.Username );
						AddLabelCropped( 178, offset, 81, 20, LabelHue, m == null ? (a != null ? FormatAccessLevel( a.AccessLevel ) : "") : FormatAccessLevel( m.AccessLevel ) );
						AddLabelCropped( 273, offset,109, 20, LabelHue, ns.ToString() );

						if ( a != null || m != null )
							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 4, index + 2 ), GumpButtonType.Reply, 0 );
					}

					break;
				}
				case AdminGumpPage.ClientInfo:
				{
					Mobile m = state as Mobile;

					if ( m == null )
						break;

					AddClientHeader();

					AddHtml( 10, 125, 400, 20, Color( Center( "Information" ), LabelColor32 ), false, false );

					int y = 146;

					AddLabel(  20, y, LabelHue, "Name:" );
					AddLabel( 200, y, GetHueFor( m ), m.Name );
					y += 20;

					Account a = m.Account as Account;

					AddLabel(  20, y, LabelHue, "Account:" );
					AddLabel( 200, y, (a != null && a.Banned) ? RedHue : LabelHue, a == null ? "(no account)" : a.Username );
					AddButton( 380, y, 0xFA5, 0xFA7, GetButtonID( 7, 14 ), GumpButtonType.Reply, 0 );
					y += 20;

					NetState ns = m.NetState;

					if ( ns == null )
					{
						AddLabel(  20, y, LabelHue, "Address:" );
						AddLabel( 200, y, RedHue, "Offline" );
						y += 20;

						AddLabel( 20, y, LabelHue, "Location:" );
						AddLabel( 200, y, LabelHue, String.Format( "{0} [{1}]", m.Location, m.Map ) );
						y += 44;
					}
					else
					{
						AddLabel(  20, y, LabelHue, "Address:" );
						AddLabel( 200, y, GreenHue, ns.ToString() );
						y += 20;

						ClientVersion v = ns.Version;

						AddLabel(  20, y, LabelHue, "Version:" );
						AddLabel( 200, y, LabelHue, v == null ? "(null)" : v.ToString() );
						y += 20;

						AddLabel( 20, y, LabelHue, "Location:" );
						AddLabel( 200, y, LabelHue, String.Format( "{0} [{1}]", m.Location, m.Map ) );
						y += 24;
					}

					AddButtonLabeled(  20, y, GetButtonID( 7, 0 ), "Go to" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 1 ), "Get" );
					y += 20;

					AddButtonLabeled(  20, y, GetButtonID( 7, 2 ), "Kick" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 3 ), "Ban" );
					y += 20;

					AddButtonLabeled(  20, y, GetButtonID( 7, 4 ), "Properties" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 5 ), "Skills" );
					y += 20;

					AddButtonLabeled(  20, y, GetButtonID( 7, 6 ), "Mortal" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 7 ), "Immortal" );
					y += 20;

					AddButtonLabeled(  20, y, GetButtonID( 7, 8 ), "Squelch" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 9 ), "Unsquelch" );
					y += 20;

					/*AddButtonLabeled(  20, y, GetButtonID( 7, 10 ), "Hide" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 11 ), "Unhide" );
					y += 20;*/

					AddButtonLabeled(  20, y, GetButtonID( 7, 12 ), "Kill" );
					AddButtonLabeled( 200, y, GetButtonID( 7, 13 ), "Resurrect" );
					y += 20;

					break;
				}
				case AdminGumpPage.Accounts_Shared:
				{
					if ( m_List == null )
						m_List = GetAllSharedAccounts();

					AddLabelCropped( 12, 120, 60, 20, LabelHue, "Count" );
					AddLabelCropped( 72, 120, 120, 20, LabelHue, "Address" );
					AddLabelCropped( 192, 120, 180, 20, LabelHue, "Accounts" );

					if ( listPage > 0 )
						AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 375, 122, 0x25EA );

					if ( (listPage + 1) * 12 < m_List.Count )
						AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 392, 122, 0x25E6 );

					if ( m_List.Count == 0 )
						AddLabel( 12, 140, LabelHue, "There are no accounts to display." );

					StringBuilder sb = new StringBuilder();

					for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						DictionaryEntry de = (DictionaryEntry)m_List[index];

						IPAddress ipAddr = (IPAddress)de.Key;
						ArrayList accts = (ArrayList)de.Value;

						int offset = 140 + (i * 20);

						AddLabelCropped( 12, offset,  60, 20, LabelHue, accts.Count.ToString() );
						AddLabelCropped( 72, offset, 120, 20, LabelHue, ipAddr.ToString() );

						if ( sb.Length > 0 )
							sb.Length = 0;

						for ( int j = 0; j < accts.Count; ++j )
						{
							if ( j > 0 )
								sb.Append( ", " );

							if ( j < 4 )
							{
								Account acct = (Account)accts[j];

								sb.Append( acct.Username );
							}
							else
							{
								sb.Append( "..." );
								break;
							}
						}

						AddLabelCropped( 192, offset, 180, 20, LabelHue, sb.ToString() );

						AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 56 ), GumpButtonType.Reply, 0 );
					}

					break;
				}
				case AdminGumpPage.Accounts:
				{
					if ( m_List == null )
					{
						m_List = new ArrayList(); // new ArrayList( (ICollection)Accounts.GetAccounts() );
						// m_List.Sort( AccountComparer.Instance );
					}

					ArrayList rads = ( state as ArrayList );

					AddAccountHeader();

					if ( rads == null )
						AddLabelCropped( 12, 120, 120, 20, LabelHue, "Name" );
					else
						AddLabelCropped( 32, 120, 100, 20, LabelHue, "Name" );

					AddLabelCropped( 132, 120, 120, 20, LabelHue, "Access Level" );
					AddLabelCropped( 252, 120, 120, 20, LabelHue, "Status" );

					if ( listPage > 0 )
						AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 375, 122, 0x25EA );

					if ( (listPage + 1) * 12 < m_List.Count )
						AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 392, 122, 0x25E6 );

					if ( m_List.Count == 0 )
						AddLabel( 12, 140, LabelHue, "There are no accounts to display." );

					if ( rads != null && notice == null )
					{
						AddButtonLabeled( 10, 390, GetButtonID( 5, 27 ), "Ban marked" );
						AddButtonLabeled( 10, 410, GetButtonID( 5, 28 ), "Delete marked" );

						AddButtonLabeled( 210, 390, GetButtonID( 5, 29 ), "Mark all" );
						AddButtonLabeled( 210, 410, GetButtonID( 5, 35 ), "Unmark house owners" );
					}

					for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						Account a = m_List[index] as Account;

						if ( a == null )
							continue;

						int offset = 140 + (i * 20);

						AccessLevel accessLevel;
						bool online;

						GetAccountInfo( a, out accessLevel, out online );

						if ( rads == null )
						{
							AddLabelCropped( 12, offset, 120, 20, LabelHue, a.Username );
						}
						else
						{
							AddCheck( 10, offset, 0xD2, 0xD3, rads.Contains( a ), index );
							AddLabelCropped( 32, offset, 100, 20, LabelHue, a.Username );
						}

						AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );

						if ( online )
							AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
						else if ( a.Banned )
							AddLabelCropped( 252, offset, 120, 20, RedHue, "Banned" );
						else
							AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );

						AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 56 ), GumpButtonType.Reply, 0 );
					}

					break;
				}
				case AdminGumpPage.AccountDetails:
				{
					AddPageButton( 190, 10, GetButtonID( 5, 0 ), "Information", AdminGumpPage.AccountDetails_Information, AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword );
					AddPageButton( 190, 30, GetButtonID( 5, 1 ), "Characters", AdminGumpPage.AccountDetails_Characters );
					AddPageButton( 190, 50, GetButtonID( 5, 13 ), "Access", AdminGumpPage.AccountDetails_Access, AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions );
					AddPageButton( 190, 70, GetButtonID( 5, 2 ), "Comments", AdminGumpPage.AccountDetails_Comments );
					AddPageButton( 190, 90, GetButtonID( 5, 3 ), "Tags", AdminGumpPage.AccountDetails_Tags );
					break;
				}
				case AdminGumpPage.AccountDetails_ChangePassword:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( "Change Password" ), LabelColor32 ), false, false );

					AddLabel(  20, 150, LabelHue, "Username:"******"Password:"******"Confirm:" );
					AddTextField( 200, 210, 160, 20, 1 );

					AddButtonLabeled( 20, 240, GetButtonID( 5, 12 ), "Submit Change" );

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.AccountDetails_ChangeAccess:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( "Change Access Level" ), LabelColor32 ), false, false );

					AddLabel(  20, 150, LabelHue, "Username:"******"Current Level:" );
					AddLabel( 200, 170, LabelHue, FormatAccessLevel( a.AccessLevel ) );

					AddButtonLabeled( 20, 200, GetButtonID( 5, 20 ), "Player" );
					AddButtonLabeled( 20, 220, GetButtonID( 5, 21 ), "Counselor" );
					AddButtonLabeled( 20, 240, GetButtonID( 5, 22 ), "Game Master" );
					AddButtonLabeled( 20, 260, GetButtonID( 5, 23 ), "Seer" );

					if ( from.AccessLevel > AccessLevel.Administrator )
					{
						AddButtonLabeled( 20, 280, GetButtonID( 5, 24 ), "Administrator" );

						if ( from.AccessLevel > AccessLevel.Developer )
						{
							AddButtonLabeled( 20, 300, GetButtonID( 5, 33 ), "Developer" );

							if ( from.AccessLevel >= AccessLevel.Owner )
								AddButtonLabeled( 20, 320, GetButtonID( 5, 34 ), "Owner" );
						}
					}

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.AccountDetails_Information:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					int charCount = 0;

					for ( int i = 0; i < a.Length; ++i )
					{
						if ( a[i] != null )
							++charCount;
					}

					AddHtml( 10, 125, 400, 20, Color( Center( "Information" ), LabelColor32 ), false, false );

					AddLabel(  20, 150, LabelHue, "Username:"******"Access Level:" );
					AddLabel( 200, 170, LabelHue, FormatAccessLevel( a.AccessLevel ) );

					AddLabel(  20, 190, LabelHue, "Status:" );
					AddLabel( 200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active" );

					DateTime banTime;
					TimeSpan banDuration;

					if ( a.Banned && a.GetBanTags( out banTime, out banDuration ) )
					{
						if ( banDuration == TimeSpan.MaxValue )
						{
							AddLabel( 250, 190, LabelHue, "(Infinite)" );
						}
						else if ( banDuration == TimeSpan.Zero )
						{
							AddLabel( 250, 190, LabelHue, "(Zero)" );
						}
						else
						{
							TimeSpan remaining = (DateTime.UtcNow - banTime);

							if ( remaining < TimeSpan.Zero )
								remaining = TimeSpan.Zero;
							else if ( remaining > banDuration )
								remaining = banDuration;

							double remMinutes = remaining.TotalMinutes;
							double totMinutes = banDuration.TotalMinutes;

							double perc = remMinutes / totMinutes;

							AddLabel( 250, 190, LabelHue, String.Format( "{0} [{1:F0}%]", FormatTimeSpan( banDuration ), perc*100 ) );
						}
					}
					else if ( a.Banned )
					{
						AddLabel( 250, 190, LabelHue, "(Unspecified)" );
					}

					AddLabel(  20, 210, LabelHue, "Created:" );
					AddLabel( 200, 210, LabelHue, a.Created.ToString() );

					AddLabel(  20, 230, LabelHue, "Last Login:"******"Character Count:" );
					AddLabel( 200, 250, LabelHue, charCount.ToString() );

					AddLabel(  20, 270, LabelHue, "Comment Count:" );
					AddLabel( 200, 270, LabelHue, a.Comments.Count.ToString() );

					AddLabel(  20, 290, LabelHue, "Tag Count:" );
					AddLabel( 200, 290, LabelHue, a.Tags.Count.ToString() );

					AddButtonLabeled( 20, 320, GetButtonID( 5, 8 ), "Change Password" );
					AddButtonLabeled( 200, 320, GetButtonID( 5, 9 ), "Change Access Level" );

					if ( !a.Banned )
						AddButtonLabeled( 20, 350, GetButtonID( 5, 10 ), "Ban Account" );
					else
						AddButtonLabeled( 20, 350, GetButtonID( 5, 11 ), "Unban Account" );

					AddButtonLabeled( 200, 350, GetButtonID( 5, 25 ), "Delete Account" );

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.AccountDetails_Access:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );

					AddPageButton( 20, 150, GetButtonID( 5, 14 ), "View client addresses", AdminGumpPage.AccountDetails_Access_ClientIPs );
					AddPageButton( 20, 170, GetButtonID( 5, 15 ), "Manage restrictions", AdminGumpPage.AccountDetails_Access_Restrictions );

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.AccountDetails_Access_ClientIPs:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					if ( m_List == null )
						m_List = new ArrayList( a.LoginIPs );

					AddHtml( 10, 195, 400, 20, Color( Center( "Client Addresses" ), LabelColor32 ), false, false );

					AddButtonLabeled( 227, 225, GetButtonID( 5, 16 ), "View all shared accounts" );
					AddButtonLabeled( 227, 245, GetButtonID( 5, 17 ), "Ban all shared accounts" );
					AddButtonLabeled( 227, 265, GetButtonID( 5, 18 ), "Firewall all addresses" );
					AddButtonLabeled( 227, 285, GetButtonID( 5, 36 ), "Clear all addresses" );

					AddHtml( 225, 315, 180, 80, Color( "List of IP addresses which have accessed this account.", LabelColor32 ), false, false );

					AddImageTiled( 15, 219, 206, 156, 0xBBC );
					AddBlackAlpha( 16, 220, 204, 154 );

					AddHtml( 18, 221, 114, 20, Color( "IP Address", LabelColor32 ), false, false );

					if ( listPage > 0 )
						AddButton( 184, 223, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 184, 223, 0x25EA );

					if ( (listPage + 1) * 6 < m_List.Count )
						AddButton( 201, 223, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 201, 223, 0x25E6 );

					if ( m_List.Count == 0 )
						AddHtml( 18, 243, 200, 60, Color( "This account has not yet been accessed.", LabelColor32 ), false, false );

					for ( int i = 0, index = (listPage * 6); i < 6 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						AddHtml( 18, 243 + (i * 22), 114, 20, Color( m_List[index].ToString(), LabelColor32 ), false, false );
						AddButton( 130, 242 + (i * 22), 0xFA2, 0xFA4, GetButtonID( 8, index ), GumpButtonType.Reply, 0 );
						AddButton( 160, 242 + (i * 22), 0xFA8, 0xFAA, GetButtonID( 9, index ), GumpButtonType.Reply, 0 );
						AddButton( 190, 242 + (i * 22), 0xFB1, 0xFB3, GetButtonID( 10, index ), GumpButtonType.Reply, 0 );
					}

					goto case AdminGumpPage.AccountDetails_Access;
				}
				case AdminGumpPage.AccountDetails_Access_Restrictions:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					if ( m_List == null )
						m_List = new ArrayList( a.IPRestrictions );

					AddHtml( 10, 195, 400, 20, Color( Center( "Address Restrictions" ), LabelColor32 ), false, false );

					AddTextField( 227, 225, 120, 20, 0 );

					AddButtonLabeled( 352, 225, GetButtonID( 5, 19 ), "Add" );

					AddHtml( 225, 255, 180, 120, Color( "Any clients connecting from an address not in this list will be rejected. Or, if the list is empty, any client may connect.", LabelColor32 ), false, false );

					AddImageTiled( 15, 219, 206, 156, 0xBBC );
					AddBlackAlpha( 16, 220, 204, 154 );

					AddHtml( 18, 221, 114, 20, Color( "IP Address", LabelColor32 ), false, false );

					if ( listPage > 0 )
						AddButton( 184, 223, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 184, 223, 0x25EA );

					if ( (listPage + 1) * 6 < m_List.Count )
						AddButton( 201, 223, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 201, 223, 0x25E6 );

					if ( m_List.Count == 0 )
						AddHtml( 18, 243, 200, 60, Color( "There are no addresses in this list.", LabelColor32 ), false, false );

					for ( int i = 0, index = (listPage * 6); i < 6 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						AddHtml( 18, 243 + (i * 22), 114, 20, Color( m_List[index].ToString(), LabelColor32 ), false, false );
						AddButton( 190, 242 + (i * 22), 0xFB1, 0xFB3, GetButtonID( 8, index ), GumpButtonType.Reply, 0 );
					}

					goto case AdminGumpPage.AccountDetails_Access;
				}
				case AdminGumpPage.AccountDetails_Characters:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( "Characters" ), LabelColor32 ), false, false );

					AddLabelCropped(  12, 150, 120, 20, LabelHue, "Name" );
					AddLabelCropped( 132, 150, 120, 20, LabelHue, "Access Level" );
					AddLabelCropped( 252, 150, 120, 20, LabelHue, "Status" );

					int index = 0;

					for ( int i = 0; i < a.Length; ++i )
					{
						Mobile m = a[i];

						if ( m == null )
							continue;

						int offset = 170 + (index * 20);

						AddLabelCropped(  12, offset, 120, 20, GetHueFor( m ), m.Name );
						AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( m.AccessLevel ) );

						if ( m.NetState != null )
							AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
						else
							AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );

						AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, i + 50 ), GumpButtonType.Reply, 0 );

						++index;
					}

					if ( index == 0 )
						AddLabel( 12, 170, LabelHue, "The character list is empty." );

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.AccountDetails_Comments:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( "Comments" ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 150, GetButtonID( 5, 4 ), "Add Comment" );

					StringBuilder sb = new StringBuilder();

					if ( a.Comments.Count == 0 )
						sb.Append( "There are no comments for this account." );

					for ( int i = 0; i < a.Comments.Count; ++i )
					{
						if ( i > 0 )
							sb.Append( "<BR><BR>" );

						AccountComment c = a.Comments[i];

						sb.AppendFormat( "[{0} on {1}]<BR>{2}", c.AddedBy, c.LastModified, c.Content );
					}

					AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.AccountDetails_Tags:
				{
					Account a = state as Account;

					if ( a == null )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( "Tags" ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 150, GetButtonID( 5, 5 ), "Add Tag" );

					StringBuilder sb = new StringBuilder();

					if ( a.Tags.Count == 0 )
						sb.Append( "There are no tags for this account." );

					for ( int i = 0; i < a.Tags.Count; ++i )
					{
						if ( i > 0 )
							sb.Append( "<BR>" );

						AccountTag tag = a.Tags[i];

						sb.AppendFormat( "{0} = {1}", tag.Name, tag.Value );
					}

					AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );

					goto case AdminGumpPage.AccountDetails;
				}
				case AdminGumpPage.Firewall:
				{
					AddFirewallHeader();

					if ( m_List == null )
						m_List = new ArrayList( Firewall.List );

					AddLabelCropped(  12, 120, 358, 20, LabelHue, "IP Address" );

					if ( listPage > 0 )
						AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 375, 122, 0x25EA );

					if ( (listPage + 1) * 12 < m_List.Count )
						AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 392, 122, 0x25E6 );

					if ( m_List.Count == 0 )
						AddLabel( 12, 140, LabelHue, "The firewall list is empty." );

					for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						object obj = m_List[index];

						if ( !(obj is Firewall.IFirewallEntry ) )
							break;

						int offset = 140 + (i * 20);

						AddLabelCropped( 12, offset, 358, 20, LabelHue, obj.ToString() );
						AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 6, index + 4 ), GumpButtonType.Reply, 0 );
					}

					break;
				}
				case AdminGumpPage.FirewallInfo:
				{
					AddFirewallHeader();

					if ( !(state is Firewall.IFirewallEntry) )
						break;

					AddHtml( 10, 125, 400, 20, Color( Center( state.ToString() ), LabelColor32 ), false, false );

					AddButtonLabeled( 20, 150, GetButtonID( 6, 3 ), "Remove" );

					AddHtml( 10, 175, 400, 20, Color( Center( "Potentially Affected Accounts" ), LabelColor32 ), false, false );

					if ( m_List == null )
					{
						m_List = new ArrayList();

						foreach ( Account acct in Accounts.GetAccounts() )
						{
							IPAddress[] loginList = acct.LoginIPs;

							bool contains = false;

							for( int i = 0; !contains && i < loginList.Length; ++i )
							{
								if( ((Firewall.IFirewallEntry)state).IsBlocked( loginList[i] ) )
								{
									m_List.Add( acct );
									break;
								}
							}
						}

						m_List.Sort( AccountComparer.Instance );
					}

					if ( listPage > 0 )
						AddButton( 375, 177, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 375, 177, 0x25EA );

					if ( (listPage + 1) * 12 < m_List.Count )
						AddButton( 392, 177, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
					else
						AddImage( 392, 177, 0x25E6 );

					if ( m_List.Count == 0 )
						AddLabelCropped( 12, 200, 398, 20, LabelHue, "No accounts found." );

					for ( int i = 0, index = (listPage * 9); i < 9 && index >= 0 && index < m_List.Count; ++i, ++index )
					{
						Account a = m_List[index] as Account;

						if ( a == null )
							continue;

						int offset = 200 + (i * 20);

						AccessLevel accessLevel;
						bool online;

						GetAccountInfo( a, out accessLevel, out online );

						AddLabelCropped(  12, offset, 120, 20, LabelHue, a.Username );
						AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );

						if ( online )
							AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
						else if( a.Banned )
							AddLabelCropped( 252, offset, 120, 20, RedHue, "Banned" );
						else
							AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );

						AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 56 ), GumpButtonType.Reply, 0 );
					}

					break;
				}
			}
		}
Exemple #3
0
		public AdminGump( Mobile from, AdminGumpPage pageType, int listPage, ArrayList list, string notice, object state ) : base( 50, 40 )
		{
			// 3/14/06 - safeguard put in against unknown crash
			// See comments for fix: 7/8/08, Adam
			try
			{
				from.CloseGump( typeof( AdminGump ) );
				
				m_From = from;
				m_PageType = pageType;
				m_ListPage = listPage;
				m_State = state;
				m_List = list;

				AddPage( 0 );

				AddBackground( 0, 0, 420, 440, 5054 );

				AddBlackAlpha( 10, 10, 170, 100 );
				AddBlackAlpha( 190, 10, 220, 100 );
				AddBlackAlpha( 10, 120, 400, 260 );
				AddBlackAlpha( 10, 390, 400, 40 );

				AddPageButton( 10, 10, GetButtonID( 0, 0 ), "INFORMATION", AdminGumpPage.Information );
				AddPageButton( 10, 30, GetButtonID( 0, 1 ), "ADMINISTER", AdminGumpPage.Administer, AdminGumpPage.Administer_Access, AdminGumpPage.Administer_Commands, AdminGumpPage.Administer_Server, AdminGumpPage.Administer_WorldBuilding, AdminGumpPage.Administer_Access_Lockdown );
				AddPageButton( 10, 50, GetButtonID( 0, 2 ), "CLIENT LIST", AdminGumpPage.Clients, AdminGumpPage.ClientInfo );
				AddPageButton( 10, 70, GetButtonID( 0, 3 ), "ACCOUNT LIST", AdminGumpPage.Accounts, AdminGumpPage.Accounts_Shared, AdminGumpPage.AccountDetails, AdminGumpPage.AccountDetails_Information, AdminGumpPage.AccountDetails_Characters, AdminGumpPage.AccountDetails_Access, AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions, AdminGumpPage.AccountDetails_Comments, AdminGumpPage.AccountDetails_Tags, AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword );
				AddPageButton( 10, 90, GetButtonID( 0, 4 ), "FIREWALL", AdminGumpPage.Firewall, AdminGumpPage.FirewallInfo );
				//AddPageButton( 110, 90, GetButtonID( 0, 5 ), "IPEXC", AdminGumpPage.IPException );
				
				if ( notice != null )
					AddHtml( 12, 392, 396, 36, Color( notice, LabelColor32 ), false, false );
				
				switch ( pageType )
				{
					case AdminGumpPage.Information:
					{
						int banned = 0;
						int active = 0;
						
						foreach ( Account acct in Accounts.Table.Values )
						{
							if ( acct.Banned )
								++banned;
							else
								++active;
						}
						
						AddLabel( 20, 130, LabelHue, "Active Accounts:" );
						AddLabel( 150, 130, LabelHue, active.ToString() );

						AddLabel( 20, 150, LabelHue, "Banned Accounts:" );
						AddLabel( 150, 150, LabelHue, banned.ToString() );

						AddLabel( 20, 170, LabelHue, "Firewalled:" );
						AddLabel( 150, 170, LabelHue, Firewall.List.Count.ToString() );

						AddLabel( 20, 190, LabelHue, "Clients:" );
						AddLabel( 150, 190, LabelHue, NetState.Instances.Count.ToString() );

						AddLabel( 20, 210, LabelHue, "Mobiles:" );
						AddLabel( 150, 210, LabelHue, World.Mobiles.Count.ToString() );

						AddLabel( 20, 230, LabelHue, "Mobile Scripts:" );
						AddLabel( 150, 230, LabelHue, Core.ScriptMobiles.ToString() );

						AddLabel( 20, 250, LabelHue, "Items:" );
						AddLabel( 150, 250, LabelHue, World.Items.Count.ToString() );

						AddLabel( 20, 270, LabelHue, "Item Scripts:" );
						AddLabel( 150, 270, LabelHue, Core.ScriptItems.ToString() );

						AddLabel( 20, 290, LabelHue, "Uptime:" );
						AddLabel( 150, 290, LabelHue, FormatTimeSpan( DateTime.Now - Clock.ServerStart ) );

						AddLabel( 20, 310, LabelHue, "Memory:" );
						AddLabel( 150, 310, LabelHue, FormatByteAmount( GC.GetTotalMemory( false ) ) );

						AddLabel( 20, 330, LabelHue, "Framework:" );
						AddLabel( 150, 330, LabelHue, Environment.Version.ToString() );

						AddLabel( 20, 350, LabelHue, "Operating System: " );
						AddLabel( 150, 350, LabelHue, Environment.OSVersion.ToString() );
						
						/*string str;

						try{ str = FormatTimeSpan( Core.Process.TotalProcessorTime ); }
						catch{ str = "(unable to retrieve)"; }

						AddLabel( 20, 330, LabelHue, "Process Time:" );
						AddLabel( 250, 330, LabelHue, str );*/

						/*try{ str = Core.Process.PriorityClass.ToString(); }
						catch{ str = "(unable to retrieve)"; }

						AddLabel( 20, 350, LabelHue, "Process Priority:" );
						AddLabel( 250, 350, LabelHue, str );*/

						break;
					}
					case AdminGumpPage.Administer_WorldBuilding:
						{
							
						AddHtml( 10, 125, 400, 20, Color( Center( "Generating" ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 150, GetButtonID( 3, 100 ), "Documentation" );
						AddButtonLabeled( 220, 150, GetButtonID( 3, 107 ), "Rebuild Categorization" );

						AddButtonLabeled( 20, 175, GetButtonID( 3, 101 ), "Teleporters" );
						AddButtonLabeled( 220, 175, GetButtonID( 3, 102 ), "Moongates" );

						AddButtonLabeled( 20, 200, GetButtonID( 3, 103 ), "Vendors" );
						AddButtonLabeled( 220, 200, GetButtonID( 3, 106 ), "Decoration" );

						AddButtonLabeled( 20, 225, GetButtonID( 3, 104 ), "Doors" );
						AddButtonLabeled( 220, 225, GetButtonID( 3, 105 ), "Signs" );

						AddHtml( 20, 275, 400, 30, Color( Center( "Statics" ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 300, GetButtonID( 3, 110 ), "Freeze (Target)" );
						AddButtonLabeled( 20, 325, GetButtonID( 3, 111 ), "Freeze (World)" );
						AddButtonLabeled( 20, 350, GetButtonID( 3, 112 ), "Freeze (Map)" );

						AddButtonLabeled( 220, 300, GetButtonID( 3, 120 ), "Unfreeze (Target)" );
						AddButtonLabeled( 220, 325, GetButtonID( 3, 121 ), "Unfreeze (World)" );
						AddButtonLabeled( 220, 350, GetButtonID( 3, 122 ), "Unfreeze (Map)" );
						
						goto case AdminGumpPage.Administer;
					}
					case AdminGumpPage.Administer_Server:
						{
							
						AddHtml( 10, 125, 400, 20, Color( Center( "Server" ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 150, GetButtonID( 3, 200 ), "Save" );
						
						if ( !Core.Service )
						{
							AddButtonLabeled( 20, 180, GetButtonID( 3, 201 ), "Shutdown (With Save)" );
							AddButtonLabeled( 20, 200, GetButtonID( 3, 202 ), "Shutdown (Without Save)" );

							AddButtonLabeled( 20, 230, GetButtonID( 3, 203 ), "Shutdown & Restart (With Save)" );
							AddButtonLabeled( 20, 250, GetButtonID( 3, 204 ), "Shutdown & Restart (Without Save)" );
						}
						else
						{
							AddLabel( 20, 215, LabelHue, "Shutdown/Restart not available." );
						}
						
						AddHtml( 10, 295, 400, 20, Color( Center( "Broadcast" ), LabelColor32 ), false, false );

						AddTextField( 20, 320, 380, 20, 0 );
						AddButtonLabeled( 20, 350, GetButtonID( 3, 210 ), "To Everyone" );
						AddButtonLabeled( 220, 350, GetButtonID( 3, 211 ), "To Staff" );
						
						goto case AdminGumpPage.Administer;
					}
					case AdminGumpPage.Administer_Access_Lockdown:
						{
							
						AddHtml( 10, 125, 400, 20, Color( Center( "Server Lockdown" ), LabelColor32 ), false, false );

						AddHtml( 20, 150, 380, 80, Color( "When enabled, only clients with an access level equal to or greater than the specified lockdown level may access the server. After setting a lockdown level, use the <em>Purge Invalid Clients</em> button to disconnect those clients without access.", LabelColor32 ), false, false );

						AccessLevel level = Misc.AccountHandler.LockdownLevel;
						bool isLockedDown = ( level > AccessLevel.Player );
						
						AddSelectedButton( 20, 230, GetButtonID( 3, 500 ), "Not Locked Down", !isLockedDown );
						AddSelectedButton( 20, 260, GetButtonID( 3, 507 ), "Owners", (isLockedDown && level <= AccessLevel.Owner ) );
						AddSelectedButton( 20, 280, GetButtonID( 3, 506 ), "Administrators", ( isLockedDown && level <= AccessLevel.Administrator ) );
						AddSelectedButton( 20, 300, GetButtonID( 3, 505 ), "Seers", ( isLockedDown && level <= AccessLevel.Seer ) );
						AddSelectedButton( 20, 320, GetButtonID( 3, 504 ), "Game Masters", ( isLockedDown && level <= AccessLevel.GameMaster ) );
						AddSelectedButton( 220, 260, GetButtonID( 3, 503 ), "Counselors", ( isLockedDown && level <= AccessLevel.Counselor ) );
						AddSelectedButton( 220, 280, GetButtonID( 3, 502 ), "Fight Brokers", ( isLockedDown && level <= AccessLevel.FightBroker ) );
						AddSelectedButton( 220, 300, GetButtonID( 3, 501 ), "Reporters", ( isLockedDown && level <= AccessLevel.Reporter ) );

						AddButtonLabeled( 20, 350, GetButtonID( 3, 510 ), "Purge Invalid Clients" );
						
						goto case AdminGumpPage.Administer;
					}
					case AdminGumpPage.Administer_Access:
						{
							
						AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );

						AddHtml( 10, 155, 400, 20, Color( Center( "Connectivity" ), LabelColor32 ), false, false );

						AddButtonLabeled(  20, 180, GetButtonID( 3, 300 ), "Kick" );
						AddButtonLabeled( 220, 180, GetButtonID( 3, 301 ), "Ban" );

						AddButtonLabeled(  20, 210, GetButtonID( 3, 302 ), "Firewall" );
						AddButtonLabeled( 220, 210, GetButtonID( 3, 303 ), "Lockdown" );

						AddHtml( 10, 245, 400, 20, Color( Center( "Staff" ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 270, GetButtonID( 3, 310 ), "Make Player" );
						AddButtonLabeled( 20, 290, GetButtonID( 3, 311 ), "Make Reporter" );
						AddButtonLabeled( 20, 310, GetButtonID( 3, 312 ), "Make FightBroker" );
						AddButtonLabeled( 20, 330, GetButtonID( 3, 313 ), "Make Counselor" );
						AddButtonLabeled( 220, 270, GetButtonID( 3, 314 ), "Make Game Master" );
						AddButtonLabeled( 220, 290, GetButtonID( 3, 315 ), "Make Seer" );
						AddButtonLabeled( 220, 310, GetButtonID( 3, 316 ), "Make Administrator" );
						
						goto case AdminGumpPage.Administer;
					}
					case AdminGumpPage.Administer_Commands:
						{
							
						AddHtml( 10, 125, 400, 20, Color( Center( "Commands" ), LabelColor32 ), false, false );

						AddButtonLabeled(  20, 150, GetButtonID( 3, 400 ), "Add" );
						AddButtonLabeled( 220, 150, GetButtonID( 3, 401 ), "Remove" );

						AddButtonLabeled(  20, 170, GetButtonID( 3, 402 ), "Dupe" );
						AddButtonLabeled( 220, 170, GetButtonID( 3, 403 ), "Dupe in bag" );

						AddButtonLabeled(  20, 200, GetButtonID( 3, 404 ), "Properties" );
						AddButtonLabeled( 220, 200, GetButtonID( 3, 405 ), "Skills" );

						AddButtonLabeled(  20, 230, GetButtonID( 3, 406 ), "Mortal" );
						AddButtonLabeled( 220, 230, GetButtonID( 3, 407 ), "Immortal" );

						AddButtonLabeled(  20, 250, GetButtonID( 3, 408 ), "Squelch" );
						AddButtonLabeled( 220, 250, GetButtonID( 3, 409 ), "Unsquelch" );

						AddButtonLabeled(  20, 270, GetButtonID( 3, 410 ), "Freeze" );
						AddButtonLabeled( 220, 270, GetButtonID( 3, 411 ), "Unfreeze" );

						AddButtonLabeled(  20, 290, GetButtonID( 3, 412 ), "Hide" );
						AddButtonLabeled( 220, 290, GetButtonID( 3, 413 ), "Unhide" );

						AddButtonLabeled(  20, 310, GetButtonID( 3, 414 ), "Kill" );
						AddButtonLabeled( 220, 310, GetButtonID( 3, 415 ), "Resurrect" );

						AddButtonLabeled(  20, 330, GetButtonID( 3, 416 ), "Move" );
						AddButtonLabeled( 220, 330, GetButtonID( 3, 417 ), "Wipe" );

						AddButtonLabeled(  20, 350, GetButtonID( 3, 418 ), "Teleport" );
						AddButtonLabeled( 220, 350, GetButtonID( 3, 419 ), "Teleport (Multiple)" );
						
						goto case AdminGumpPage.Administer;
					}
					case AdminGumpPage.Administer:
						{
							
						AddPageButton( 200, 20, GetButtonID( 3, 0 ), "World Building", AdminGumpPage.Administer_WorldBuilding );
						AddPageButton( 200, 40, GetButtonID( 3, 1 ), "Server", AdminGumpPage.Administer_Server );
						AddPageButton( 200, 60, GetButtonID( 3, 2 ), "Access", AdminGumpPage.Administer_Access, AdminGumpPage.Administer_Access_Lockdown );
						AddPageButton( 200, 80, GetButtonID( 3, 3 ), "Commands", AdminGumpPage.Administer_Commands );
						
						break;
					}
					case AdminGumpPage.Clients:
						{
							
						if ( m_List == null )
						{
							m_List = new ArrayList( NetState.Instances );
							m_List.Sort( NetStateComparer.Instance );
						}
						
						AddClientHeader();
						
						AddLabelCropped(  12, 120, 81, 20, LabelHue, "Name" );
						AddLabelCropped(  95, 120, 81, 20, LabelHue, "Account" );
						AddLabelCropped( 178, 120, 81, 20, LabelHue, "Access Level" );
						AddLabelCropped( 273, 120,109, 20, LabelHue, "IP Address" );
						
						if ( listPage > 0 )
							AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 375, 122, 0x25EA );
						
						if ( (listPage + 1) * 12 < m_List.Count )
							AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 392, 122, 0x25E6 );
						
						if ( m_List.Count == 0 )
							AddLabel( 12, 140, LabelHue, "There are no clients to display." );
						
						for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							NetState ns = m_List[index] as NetState;

							if ( ns == null )
								continue;
							
							Mobile m = ns.Mobile;
							Account a = ns.Account as Account;
							int offset = 140 + (i * 20);
							
							if ( m == null )
							{
								if ( Admin.AdminNetwork.IsAuth( ns ) )
									AddLabelCropped( 12, offset, 81, 20, LabelHue, "(remote admin)" );
								else
									AddLabelCropped( 12, offset, 81, 20, LabelHue, "(logging in)" );
							}
							else
							{
								
								AddLabelCropped(12, offset, 81, 20, m.GetHueForNameInList(), m.Name); 
							}
							AddLabelCropped(  95, offset, 81, 20, LabelHue, a == null ? "(no account)" : a.Username );
							AddLabelCropped( 178, offset, 81, 20, LabelHue, m == null ? (a != null ? FormatAccessLevel( a.AccessLevel ) : "") : FormatAccessLevel( m.AccessLevel ) );
							AddLabelCropped( 273, offset,109, 20, LabelHue, ns.ToString() );
							
							if ( a != null || m != null )
								AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2), GumpButtonType.Reply, 0); 
						}

						break;
					}
					case AdminGumpPage.ClientInfo:
						{
							
						Mobile m = state as Mobile;

						if ( m == null )
							break;
						
						AddClientHeader();
						
						AddHtml( 10, 125, 400, 20, Color( Center( "Information" ), LabelColor32 ), false, false );
						
						int y = 146;
						
						AddLabel(  20, y, LabelHue, "Name:" );
						AddLabel( 200, y, m.GetHueForNameInList(), m.Name );
						y += 20;
						
						Account a = m.Account as Account;
						
						AddLabel(  20, y, LabelHue, "Account:" );
						AddLabel( 200, y, (a != null && a.Banned) ? RedHue : LabelHue, a == null ? "(no account)" : a.Username );
						AddButton( 380, y, 0xFA5, 0xFA7, GetButtonID( 7, 15 ), GumpButtonType.Reply, 0 );
						y += 20;
						
						NetState ns = m.NetState;
						
						if ( ns == null )
						{
							AddLabel(  20, y, LabelHue, "Address:" );
							AddLabel( 200, y, RedHue, "Offline" );
							y += 20;
							
							AddLabel( 20, y, LabelHue, "Location:" );
							AddLabel( 200, y, LabelHue, String.Format( "{0} [{1}]", m.Location, m.Map ) );
							y += 44; 
						}
						else
						{
							
							AddLabel(  20, y, LabelHue, "Address:" );
							AddLabel( 200, y, GreenHue, ns.ToString() );
							y += 20;
							
							ClientVersion v = ns.Version;
							
							AddLabel(  20, y, LabelHue, "Version:" );
							AddLabel( 200, y, LabelHue, v == null ? "(null)" : v.ToString() );
							y += 20;
							
							AddLabel( 20, y, LabelHue, "Location:" );
							AddLabel( 200, y, LabelHue, String.Format( "{0} [{1}]", m.Location, m.Map ) );
							y += 24; 
						}
						
						AddButtonLabeled(  20, y, GetButtonID( 7, 0 ), "Go to" );
						AddButtonLabeled( 150, y, GetButtonID( 7, 1 ), "Get" );
						AddButtonLabeled( 280, y, GetButtonID( 7, 14 ), "View Houses" );
						y += 20;
						
						AddButtonLabeled(  20, y, GetButtonID( 7, 2 ), "Kick" );
						AddButtonLabeled( 150, y, GetButtonID( 7, 3 ), "Ban" );
						y += 20;
						
						AddButtonLabeled(  20, y, GetButtonID( 7, 4 ), "Properties" );
						AddButtonLabeled( 150, y, GetButtonID( 7, 5 ), "Skills" );
						y += 20;
						
						AddButtonLabeled(  20, y, GetButtonID( 7, 6 ), "Mortal" );
						AddButtonLabeled( 150, y, GetButtonID( 7, 7 ), "Immortal" );
						y += 20;
						
						AddButtonLabeled(  20, y, GetButtonID( 7, 8 ), "Squelch" );
						AddButtonLabeled( 150, y, GetButtonID( 7, 9 ), "Unsquelch" );
						y += 20;
						
						/*AddButtonLabeled(  20, y, GetButtonID( 7, 10 ), "Hide" );
						AddButtonLabeled( 200, y, GetButtonID( 7, 11 ), "Unhide" );
						y += 20;*/

						AddButtonLabeled(  20, y, GetButtonID( 7, 12 ), "Kill" );
						AddButtonLabeled( 150, y, GetButtonID( 7, 13 ), "Resurrect" );
						y += 20;
						
						break;
					}
					case AdminGumpPage.Accounts_Shared:
						{
							
						if ( m_List == null )
							m_List = GetAllSharedAccounts();
						
						AddLabelCropped( 12, 120, 60, 20, LabelHue, "Count" );
						AddLabelCropped( 72, 120, 120, 20, LabelHue, "Address" );
						AddLabelCropped( 192, 120, 180, 20, LabelHue, "Accounts" );
						
						if ( listPage > 0 )
							AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 375, 122, 0x25EA );
						
						if ( (listPage + 1) * 12 < m_List.Count )
							AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 392, 122, 0x25E6 );
						
						if ( m_List.Count == 0 )
							AddLabel( 12, 140, LabelHue, "There are no accounts to display." );
						
						StringBuilder sb = new StringBuilder();
						
						for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							
							DictionaryEntry de = (DictionaryEntry)m_List[index];
							
							IPAddress ipAddr = (IPAddress)de.Key;
							ArrayList accts = (ArrayList)de.Value;

							int offset = 140 + (i * 20);

							AddLabelCropped( 12, offset,  60, 20, LabelHue, accts.Count.ToString() );
							AddLabelCropped( 72, offset, 120, 20, LabelHue, ipAddr.ToString() );

							if ( sb.Length > 0 )
								sb.Length = 0;

							for ( int j = 0; j < accts.Count; ++j )
							{
								if ( j > 0 )
									sb.Append( ", " );

								if ( j < 4 )
								{
									Account acct = (Account)accts[j];

									sb.Append( acct.Username );
								}
								else
								{
									sb.Append( "..." );
									break;
								}
							}

							AddLabelCropped( 192, offset, 180, 20, LabelHue, sb.ToString() );

							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 55 ), GumpButtonType.Reply, 0 );
						}

						break;
					}
					case AdminGumpPage.Accounts:
						{
							
						if ( m_List == null )
						{
							m_List = new ArrayList( Accounts.Table.Values );
							m_List.Sort( AccountComparer.Instance );
						}
						
						ArrayList rads = ( state as ArrayList );
						
						AddAccountHeader();
						
						if ( rads == null )
							AddLabelCropped( 12, 120, 120, 20, LabelHue, "Name" );
						else
							AddLabelCropped( 32, 120, 100, 20, LabelHue, "Name" );

						AddLabelCropped( 132, 120, 120, 20, LabelHue, "Access Level" );
						AddLabelCropped( 252, 120, 120, 20, LabelHue, "Status" );

						if ( listPage > 0 )
							AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 375, 122, 0x25EA );

						if ( (listPage + 1) * 12 < m_List.Count )
							AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 392, 122, 0x25E6 );

						if ( m_List.Count == 0 )
							AddLabel( 12, 140, LabelHue, "There are no accounts to display." );

						if ( rads != null && notice == null )
						{
							AddButtonLabeled( 10, 390, GetButtonID( 5, 29 ), "Ban marked" );
							AddButtonLabeled( 10, 410, GetButtonID( 5, 30 ), "Delete marked" );

							AddButtonLabeled( 210, 400, GetButtonID( 5, 31 ), "Mark all" );
						}
						
						for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							
							Account a = m_List[index] as Account;

							if ( a == null )
								continue;
							
							int offset = 140 + (i * 20);

							AccessLevel accessLevel;
							bool online;
							
							a.GetAccountInfo(out accessLevel, out online );

							if ( rads == null )
							{
								AddLabelCropped( 12, offset, 120, 20, LabelHue, "\"" + a.Username + "\"" );
							}
							else
							{
								AddCheck( 10, offset, 0xD2, 0xD3, rads.Contains( a ), index );
								AddLabelCropped( 32, offset, 100, 20, LabelHue, "\"" + a.Username + "\"" );
							}
							
							AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );

							if ( online )
								AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
							else if ( a.Banned )
								AddLabelCropped( 252, offset, 120, 20, RedHue, "Banned" );
							else
								AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );

							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 55 ), GumpButtonType.Reply, 0 );
						}

						break;
					}
					case AdminGumpPage.AccountDetails:
						{
							
						AddPageButton( 190, 10, GetButtonID( 5, 0 ), "Information", AdminGumpPage.AccountDetails_Information, AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword );
						AddPageButton( 190, 30, GetButtonID( 5, 1 ), "Characters", AdminGumpPage.AccountDetails_Characters );
						AddPageButton( 190, 50, GetButtonID( 5, 13 ), "Access", AdminGumpPage.AccountDetails_Access, AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions );
						AddPageButton( 190, 70, GetButtonID( 5, 2 ), "Comments", AdminGumpPage.AccountDetails_Comments );
						AddPageButton( 190, 90, GetButtonID( 5, 3 ), "Tags", AdminGumpPage.AccountDetails_Tags );
						AddPageButton( 290, 10, GetButtonID( 5, 36 ), "Activation", AdminGumpPage.AccountDetails_Activation );
						AddPageButton( 290, 30, GetButtonID( 5, 37 ), "Email History", AdminGumpPage.AccountDetails_EmailHistory );
						break;
					}
					case AdminGumpPage.AccountDetails_Activation:
					{
						
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Account Activation" ), LabelColor32 ), false, false );

						AddLabel(  20, 150, LabelHue, "Username:"******"\"" + a.Username + "\"" );

						AddLabel( 20, 170, LabelHue, "Email:" );
						AddLabel( 200, 170, LabelHue, a.EmailAddress );

						AddLabel( 20, 190, LabelHue, "Activated:" );
						AddLabel( 200, 190, LabelHue, a.AccountActivated ? "YES" : "NO" );

						AddLabel( 20, 210, LabelHue, "Activation Key:" );
						AddLabel( 200, 210, LabelHue, a.ActivationKey );

						AddLabel( 20, 230, LabelHue, "Notification Emails:" );
						AddLabel( 200, 230, LabelHue, a.DoNotSendEmail ? "OFF" : "ON" );

						//Adam: 7/8/08 - add null checks .. this was crashing
						if (a.EmailAddress != null && a.EmailAddress.Length > 5 &&
							a.ActivationKey != null && a.ActivationKey.Length > 6 &&
							a.AccountActivated == false )
						{
							AddButtonLabeled( 20, 280, GetButtonID( 5, 38 ), "Reset Activation" );
							AddButtonLabeled( 20, 320, GetButtonID( 5, 39 ), "Resend Activation" );
						}
						
						if( a.DoNotSendEmail ) //Toggle Notification Emails
						{
							AddButtonLabeled( 20, 340, GetButtonID( 5, 41 ), "Turn Notification Emails ON" );
						}
						else
						{
							AddButtonLabeled( 20, 340, GetButtonID( 5, 41 ), "Turn Notification Emails OFF" );
						}

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_EmailHistory:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Email History" ), LabelColor32 ), false, false );

						AddLabel(  20, 150, LabelHue, "Username:"******"There is no email history for this account." );

						for ( int i = 0; i < a.EmailHistory.Length; ++i )
						{
							if ( i > 0 )
								sb.Append( "<BR><BR>" );

							String email = a.EmailHistory[i];

							sb.AppendFormat( "[{0}]", email );
						}

						AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_ChangePassword:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Change Password" ), LabelColor32 ), false, false );

						AddLabel(  20, 150, LabelHue, "Username:"******"Password:"******"Confirm:" );
						AddTextField( 200, 210, 160, 20, 1 );

						AddButtonLabeled( 20, 240, GetButtonID( 5, 12 ), "Submit Change" );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_ChangeAccess:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Change Access Level" ), LabelColor32 ), false, false );

						AddLabel(  20, 150, LabelHue, "Username:"******"Current Level:" );
						AddLabel( 200, 170, LabelHue, FormatAccessLevel( a.AccessLevel ) );

						AddButtonLabeled( 20, 200, GetButtonID( 5, 20 ), "Player" );
						AddButtonLabeled( 20, 220, GetButtonID( 5, 21 ), "Reporter" );
						AddButtonLabeled( 20, 240, GetButtonID( 5, 22 ), "Fight Broker" );
						AddButtonLabeled( 20, 260, GetButtonID( 5, 23 ), "Counselor" );
						AddButtonLabeled( 20, 280, GetButtonID( 5, 24 ), "Game Master" );
						AddButtonLabeled( 20, 300, GetButtonID( 5, 25 ), "Seer" );
						AddButtonLabeled( 20, 320, GetButtonID( 5, 26 ), "Administrator" );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_Information:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						int charCount = 0;

						for ( int i = 0; i < 5; ++i )
						{
							if ( a[i] != null )
								++charCount;
						}

						AddHtml( 10, 125, 400, 20, Color( Center( "Information" ), LabelColor32 ), false, false );

						AddLabel(  20, 150, LabelHue, "Username:"******"Access Level:" );
						AddLabel( 200, 170, LabelHue, FormatAccessLevel( a.AccessLevel ) );

						AddLabel(  20, 190, LabelHue, "Status:" );
						AddLabel( 200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active" );

						DateTime banTime;
						TimeSpan banDuration;

						if ( a.Banned && a.GetBanTags( out banTime, out banDuration ) )
						{
							if ( banDuration == TimeSpan.MaxValue )
							{
								AddLabel( 250, 190, LabelHue, "(Infinite)" );
							}
							else if ( banDuration == TimeSpan.Zero )
							{
								AddLabel( 250, 190, LabelHue, "(Zero)" );
							}
							else
							{
								TimeSpan remaining = (DateTime.Now - banTime);

								if ( remaining < TimeSpan.Zero )
									remaining = TimeSpan.Zero;
								else if ( remaining > banDuration )
									remaining = banDuration;

								double remMinutes = remaining.TotalMinutes;
								double totMinutes = banDuration.TotalMinutes;

								double perc = remMinutes / totMinutes;

								AddLabel( 250, 190, LabelHue, String.Format( "{0} [{1:F0}%]", FormatTimeSpan( banDuration ), perc*100 ) );
							}
						}
						else if ( a.Banned )
						{
							AddLabel( 250, 190, LabelHue, "(Unspecified)" );
						}

						AddLabel(  20, 210, LabelHue, "Created:" );
						AddLabel( 200, 210, LabelHue, a.Created.ToString() );

						AddLabel(  20, 230, LabelHue, "Last Login:"******"Character Count:" );
						AddLabel( 200, 250, LabelHue, charCount.ToString() );

						AddLabel(  20, 270, LabelHue, "Comment Count:" );
						AddLabel( 200, 270, LabelHue, a.Comments.Count.ToString() );

						AddLabel(  20, 290, LabelHue, "Tag Count:" );
						AddLabel( 200, 290, LabelHue, a.Tags.Count.ToString() );

						AddButtonLabeled( 20, 320, GetButtonID( 5, 8 ), "Change Password" );
						AddButtonLabeled( 200, 320, GetButtonID( 5, 9 ), "Change Access Level" );

						if ( !a.Banned )
							AddButtonLabeled( 20, 350, GetButtonID( 5, 10 ), "Ban Account" );
						else
							AddButtonLabeled( 20, 350, GetButtonID( 5, 11 ), "Unban Account" );

						AddButtonLabeled( 200, 350, GetButtonID( 5, 27 ), "Delete Account" );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_Access:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );

						AddPageButton( 20, 150, GetButtonID( 5, 14 ), "View client addresses", AdminGumpPage.AccountDetails_Access_ClientIPs );
						AddPageButton( 20, 170, GetButtonID( 5, 15 ), "Manage restrictions", AdminGumpPage.AccountDetails_Access_Restrictions );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_Access_ClientIPs:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						if ( m_List == null )
							m_List = new ArrayList( a.LoginIPs );

						AddHtml( 10, 195, 400, 20, Color( Center( "Client Addresses" ), LabelColor32 ), false, false );

						AddButtonLabeled( 200, 225, GetButtonID( 5, 16 ), "View all shared accounts" );
						AddButtonLabeled( 200, 245, GetButtonID( 5, 17 ), "Ban all shared accounts" );
						AddButtonLabeled( 200, 265, GetButtonID( 5, 18 ), "Firewall all addresses" );

						AddHtml( 195, 295, 210, 80, Color( "List of IP addresses which have accessed this account.", LabelColor32 ), false, false );

						AddImageTiled( 15, 219, 176, 156, 0xBBC );
						AddBlackAlpha( 16, 220, 174, 154 );

						AddHtml( 18, 221, 114, 20, Color( "IP Address", LabelColor32 ), false, false );

						if ( listPage > 0 )
							AddButton( 154, 223, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 154, 223, 0x25EA );

						if ( (listPage + 1) * 6 < m_List.Count )
							AddButton( 171, 223, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 171, 223, 0x25E6 );

						if ( m_List.Count == 0 )
							AddHtml( 18, 243, 170, 60, Color( "This account has not yet been accessed.", LabelColor32 ), false, false );

						for ( int i = 0, index = (listPage * 6); i < 6 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							AddHtml( 18, 243 + (i * 22), 114, 20, Color( m_List[index].ToString(), LabelColor32 ), false, false );
							AddButton( 130, 242 + (i * 22), 0xFA2, 0xFA4, GetButtonID( 8, index ), GumpButtonType.Reply, 0 );
							AddButton( 160, 242 + (i * 22), 0xFA8, 0xFAA, GetButtonID( 9, index ), GumpButtonType.Reply, 0 );
						}

						goto case AdminGumpPage.AccountDetails_Access;
					}
					case AdminGumpPage.AccountDetails_Access_Restrictions:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						if ( m_List == null )
							m_List = new ArrayList( a.IPRestrictions );

						AddHtml( 10, 195, 400, 20, Color( Center( "Address Restrictions" ), LabelColor32 ), false, false );

						AddTextField( 200, 225, 120, 20, 0 );

						AddButtonLabeled( 330, 225, GetButtonID( 5, 19 ), "Add" );

						AddHtml( 195, 255, 210, 120, Color( "Any clients connecting from an address not in this list will be rejected. Or, if the list is empty, any client may connect.", LabelColor32 ), false, false );

						AddImageTiled( 15, 219, 176, 156, 0xBBC );
						AddBlackAlpha( 16, 220, 174, 154 );

						AddHtml( 18, 221, 114, 20, Color( "IP Address", LabelColor32 ), false, false );

						if ( listPage > 0 )
							AddButton( 154, 223, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 154, 223, 0x25EA );

						if ( (listPage + 1) * 6 < m_List.Count )
							AddButton( 171, 223, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 171, 223, 0x25E6 );

						if ( m_List.Count == 0 )
							AddHtml( 18, 243, 170, 60, Color( "There are no addresses in this list.", LabelColor32 ), false, false );

						for ( int i = 0, index = (listPage * 6); i < 6 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							AddHtml( 18, 243 + (i * 22), 114, 20, Color( m_List[index].ToString(), LabelColor32 ), false, false );
							AddButton( 160, 242 + (i * 22), 0xFB1, 0xFB3, GetButtonID( 8, index ), GumpButtonType.Reply, 0 );
						}

						goto case AdminGumpPage.AccountDetails_Access;
					}
					case AdminGumpPage.AccountDetails_Characters:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Characters" ), LabelColor32 ), false, false );

						AddLabelCropped(  12, 150, 120, 20, LabelHue, "Name" );
						AddLabelCropped( 132, 150, 120, 20, LabelHue, "Access Level" );
						AddLabelCropped( 252, 150, 120, 20, LabelHue, "Status" );

						int index = 0;

						for ( int i = 0; i < 5; ++i )
						{
							Mobile m = a[i];

							if ( m == null )
								continue;

							int offset = 170 + (index * 20);

							AddLabelCropped(  12, offset, 120, 20, m.GetHueForNameInList(), m.Name );
							AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( m.AccessLevel ) );

							if ( m.NetState != null )
								AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
							else
								AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );

							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, i + 50 ), GumpButtonType.Reply, 0 );

							++index;
						}

						if ( index == 0 )
							AddLabel( 12, 170, LabelHue, "The character list is empty." );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_Comments:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Comments" ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 150, GetButtonID( 5, 4 ), "Add Comment" );

						StringBuilder sb = new StringBuilder();

						if ( a.Comments.Count == 0 )
							sb.Append( "There are no comments for this account." );

						for ( int i = 0; i < a.Comments.Count; ++i )
						{
							if ( i > 0 )
								sb.Append( "<BR><BR>" );

							AccountComment c = (AccountComment)a.Comments[i];

							sb.AppendFormat( "[{0}]<BR>{1}", c.AddedBy, c.Content );
						}

						AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.AccountDetails_Tags:
					{
						Account a = state as Account;

						if ( a == null )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( "Tags" ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 150, GetButtonID( 5, 5 ), "Add Tag" );
						AddButtonLabeled( 150, 150, GetButtonID( 5, 35 ), "Remove Tag" );

						StringBuilder sb = new StringBuilder();

						if ( a.Tags.Count == 0 )
							sb.Append( "There are no tags for this account." );

						for ( int i = 0; i < a.Tags.Count; ++i )
						{
							if ( i > 0 )
								sb.Append( "<BR>" );

							AccountTag tag = (AccountTag)a.Tags[i];

							sb.AppendFormat( "{0} = {1}", tag.Name, tag.Value );
						}

						AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );

						goto case AdminGumpPage.AccountDetails;
					}
					case AdminGumpPage.Firewall:
					{
						AddFirewallHeader();

						if ( m_List == null )
							m_List = new ArrayList( Firewall.List );

						AddLabelCropped(  12, 120, 358, 20, LabelHue, "IP Address" );

						if ( listPage > 0 )
							AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 375, 122, 0x25EA );

						if ( (listPage + 1) * 12 < m_List.Count )
							AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 392, 122, 0x25E6 );

						if ( m_List.Count == 0 )
							AddLabel( 12, 140, LabelHue, "The firewall list is empty." );

						for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							object obj = m_List[index];

							if ( !(obj is IPAddress) && !(obj is String) )
								break;

							int offset = 140 + (i * 20);

							AddLabelCropped( 12, offset, 358, 20, LabelHue, obj.ToString() );
							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 6, index + 4 ), GumpButtonType.Reply, 0 );
						}

						break;
					}
					case AdminGumpPage.FirewallInfo:
					{
						AddFirewallHeader();

						if ( !(state is IPAddress) && !(state is String) )
							break;

						AddHtml( 10, 125, 400, 20, Color( Center( state.ToString() ), LabelColor32 ), false, false );

						AddButtonLabeled( 20, 150, GetButtonID( 6, 3 ), "Remove" );

						AddHtml( 10, 175, 400, 20, Color( Center( "Potentially Effected Accounts" ), LabelColor32 ), false, false );

						if ( m_List == null )
						{
							m_List = new ArrayList();

							string pattern = state as String;
							IPAddress addr = ( state is IPAddress ? (IPAddress)state : IPAddress.Any );

							foreach ( Account acct in Accounts.Table.Values )
							{
								IPAddress[] loginList = acct.LoginIPs;

								bool contains = false;

								for ( int i = 0; !contains && i < loginList.Length; ++i )
									contains = ( pattern == null ? loginList[i].Equals( addr ) : Utility.IPMatch( pattern, loginList[i] ) );

								if ( contains )
									m_List.Add( acct );
							}

							m_List.Sort( AccountComparer.Instance );
						}

						if ( listPage > 0 )
							AddButton( 375, 177, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 375, 177, 0x25EA );

						if ( (listPage + 1) * 12 < m_List.Count )
							AddButton( 392, 177, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 392, 177, 0x25E6 );

						if ( m_List.Count == 0 )
							AddLabelCropped( 12, 200, 398, 20, LabelHue, "No accounts found." );

						for ( int i = 0, index = (listPage * 9); i < 9 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							Account a = m_List[index] as Account;

							if ( a == null )
								continue;

							int offset = 200 + (i * 20);

							AccessLevel accessLevel;
							bool online;

							a.GetAccountInfo(out accessLevel, out online );

							AddLabelCropped(  12, offset, 120, 20, LabelHue, a.Username );
							AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );

							if ( online )
								AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
							else
								AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );

							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 55 ), GumpButtonType.Reply, 0 );
						}

						break;
					}
					/*case AdminGumpPage.IPException:
					{
						if ( m_List == null )
						{
							m_List = new ArrayList(IPException.Table.Keys);
							m_List.Sort();
						}

						AddIPExceptionHeader();

						AddLabelCropped(  12, 120, 181, 40, LabelHue, "IP Address" );
						AddLabelCropped(  235, 120, 81, 40, LabelHue, "Allowed" );
						if ( listPage > 0 )
							AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 375, 122, 0x25EA );

						if ( (listPage + 1) * 12 < m_List.Count )
							AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
						else
							AddImage( 392, 122, 0x25E6 );

						if ( m_List.Count == 0 )
							AddLabel( 12, 140, LabelHue, "There are no ip exceptions to display." );

						for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
						{
							string ipaddress = m_List[index] as String;

							if ( ipaddress == null )
								continue;

							int count = 1;
							try
							{
								count = (int)IPException.Table[ipaddress];
							}
							catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

							int offset = 140 + (i * 20);

							AddLabelCropped(  12, offset, 181, 40, LabelHue, ipaddress );
							AddLabelCropped(  235, offset, 81, 40, LabelHue, count.ToString() );

							AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 2, index + 3 ), GumpButtonType.Reply, 0 );
						}


						break;
					}*/
					/*case AdminGumpPage.IPException_IPDetails:
					{
						string ipAddress = state as String;

						AddIPExceptionHeader();

						if ( ipAddress == null )
						{
							break;
						}

						AddLabelCropped( 12, 120, 181, 40, LabelHue, "Account" );
						AddLabelCropped( 185, 120, 81, 40, LabelHue, "AccessLevel" );
						AddLabelCropped( 285, 120, 50, 40, LabelHue, "Status" );

						int count = Server.Accounting.Accounts.Table.Values.Count;
						int matchingLoginIPs = 0;
						int i = 0;
						m_List = new ArrayList();
						foreach ( Account acct in Accounts.Table.Values )
						{
							int offset = 150 + (i * 20);
							if( acct != null )
							{
								for( int j=0; j < acct.LoginIPs.Length; j++ )
								{
									if( acct.LoginIPs[j].ToString() == ipAddress )
									{
										m_List.Add(acct);
										AddLabelCropped(  12, offset, 181, 40, LabelHue, acct.Username );
										AddLabelCropped(  185, offset, 81, 40, LabelHue, acct.AccessLevel.ToString() );
										AddLabelCropped(  285, offset, 50, 40, acct.Banned ? RedHue : GreenHue, acct.Banned ? "Banned" : "Active" );

										AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 2, i+3 ), GumpButtonType.Reply, 0 );

										i++;
										matchingLoginIPs++;

										break;
									}
								}
							}
						}


						break;
					}*/
				}
			}
			// we are still seeing thie crash once in a while .. start collecting info;
			catch (Exception ex) 
			{
				EventSink.InvokeLogException(new LogExceptionEventArgs(new ApplicationException(String.Format("pageType:{0},", pageType), ex))); 
			}
		}