PageRenderTime 53ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/Gumps/AdminGump.cs

https://bitbucket.org/Kel/crepuscule
C# | 2767 lines | 2170 code | 582 blank | 15 comment | 557 complexity | 8e6f7815a9bd9f1b2ac5cde79a4101a7 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Net;
  3. using System.Text;
  4. using System.Collections;
  5. using System.Diagnostics;
  6. using Server;
  7. using Server.Items;
  8. using Server.Prompts;
  9. using Server.Network;
  10. using Server.Accounting;
  11. using Server.Mobiles;
  12. using Server.Scripts.Commands;
  13. namespace Server.Gumps
  14. {
  15. public enum AdminGumpPage
  16. {
  17. Information,
  18. Administer,
  19. Clients,
  20. Accounts,
  21. Accounts_Shared,
  22. Firewall,
  23. Administer_WorldBuilding,
  24. Administer_Server,
  25. Administer_Access,
  26. Administer_Access_Lockdown,
  27. Administer_Commands,
  28. ClientInfo,
  29. AccountDetails,
  30. AccountDetails_Information,
  31. AccountDetails_Characters,
  32. AccountDetails_Access,
  33. AccountDetails_Access_ClientIPs,
  34. AccountDetails_Access_Restrictions,
  35. AccountDetails_Comments,
  36. AccountDetails_Tags,
  37. AccountDetails_ChangePassword,
  38. AccountDetails_ChangeAccess,
  39. FirewallInfo
  40. }
  41. public class AdminGump : Gump
  42. {
  43. private Mobile m_From;
  44. private AdminGumpPage m_PageType;
  45. private ArrayList m_List;
  46. private int m_ListPage;
  47. private object m_State;
  48. private const int LabelColor = 0x7FFF;
  49. private const int SelectedColor = 0x421F;
  50. private const int DisabledColor = 0x4210;
  51. private const int LabelColor32 = 0xFFFFFF;
  52. private const int SelectedColor32 = 0x8080FF;
  53. private const int DisabledColor32 = 0x808080;
  54. private const int LabelHue = 0x480;
  55. private const int GreenHue = 0x40;
  56. private const int RedHue = 0x20;
  57. public void AddPageButton( int x, int y, int buttonID, string text, AdminGumpPage page, params AdminGumpPage[] subPages )
  58. {
  59. bool isSelection = ( m_PageType == page );
  60. for ( int i = 0; !isSelection && i < subPages.Length; ++i )
  61. isSelection = ( m_PageType == subPages[i] );
  62. AddSelectedButton( x, y, buttonID, text, isSelection );
  63. }
  64. public void AddSelectedButton( int x, int y, int buttonID, string text, bool isSelection )
  65. {
  66. AddButton( x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
  67. AddHtml( x + 35, y, 200, 20, Color( text, isSelection ? SelectedColor32 : LabelColor32 ), false, false );
  68. }
  69. public void AddButtonLabeled( int x, int y, int buttonID, string text )
  70. {
  71. AddButton( x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
  72. AddHtml( x + 35, y, 240, 20, Color( text, LabelColor32 ), false, false );
  73. }
  74. public string Center( string text )
  75. {
  76. return String.Format( "<CENTER>{0}</CENTER>", text );
  77. }
  78. public string Color( string text, int color )
  79. {
  80. return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
  81. }
  82. public void AddBlackAlpha( int x, int y, int width, int height )
  83. {
  84. AddImageTiled( x, y, width, height, 2624 );
  85. AddAlphaRegion( x, y, width, height );
  86. }
  87. public int GetButtonID( int type, int index )
  88. {
  89. return 1 + (index * 10) + type;
  90. }
  91. public static string FormatTimeSpan( TimeSpan ts )
  92. {
  93. return String.Format( "{0:D2}:{1:D2}:{2:D2}:{3:D2}", ts.Days, ts.Hours % 24, ts.Minutes % 60, ts.Seconds % 60 );
  94. }
  95. public static string FormatByteAmount( long totalBytes )
  96. {
  97. if ( totalBytes > 1000000000 )
  98. return String.Format( "{0:F1} GB", (double)totalBytes / 1073741824 );
  99. if ( totalBytes > 1000000 )
  100. return String.Format( "{0:F1} MB", (double)totalBytes / 1048576 );
  101. if ( totalBytes > 1000 )
  102. return String.Format( "{0:F1} KB", (double)totalBytes / 1024 );
  103. return String.Format( "{0} Bytes", totalBytes );
  104. }
  105. public static void Initialize()
  106. {
  107. Commands.Register( "Admin", AccessLevel.Administrator, new CommandEventHandler( Admin_OnCommand ) );
  108. }
  109. [Usage( "Admin" )]
  110. [Description( "Opens an interface providing server information and administration features including client, account, and firewall management." )]
  111. public static void Admin_OnCommand( CommandEventArgs e )
  112. {
  113. e.Mobile.SendGump( new AdminGump( e.Mobile, AdminGumpPage.Clients, 0, null, null, null ) );
  114. }
  115. public static void ShowAdminGump(Mobile mobile)
  116. {
  117. mobile.SendGump(new AdminGump(mobile, AdminGumpPage.Clients, 0, null, null, null));
  118. }
  119. public static int GetHueFor( Mobile m )
  120. {
  121. if ( m == null )
  122. return LabelHue;
  123. switch ( m.AccessLevel )
  124. {
  125. case AccessLevel.Administrator: return 0x516;
  126. case AccessLevel.Seer: return 0x144;
  127. case AccessLevel.GameMaster: return 0x21;
  128. case AccessLevel.Counselor: return 0x2;
  129. case AccessLevel.Player: default:
  130. {
  131. if ( m.Kills >= 5 )
  132. return 0x21;
  133. else if ( m.Criminal )
  134. return 0x3B1;
  135. return 0x58;
  136. }
  137. }
  138. }
  139. private static string[] m_AccessLevelStrings = new string[]
  140. {
  141. "Player",
  142. "Counselor",
  143. "Game Master",
  144. "Seer",
  145. "Administrator"
  146. };
  147. public static string FormatAccessLevel( AccessLevel level )
  148. {
  149. int v = (int)level;
  150. if ( v >= 0 && v < m_AccessLevelStrings.Length )
  151. return m_AccessLevelStrings[v];
  152. return "Unknown";
  153. }
  154. public AdminGump( Mobile from, AdminGumpPage pageType, int listPage, ArrayList list, string notice, object state ) : base( 50, 40 )
  155. {
  156. from.CloseGump( typeof( AdminGump ) );
  157. m_From = from;
  158. m_PageType = pageType;
  159. m_ListPage = listPage;
  160. m_State = state;
  161. m_List = list;
  162. AddPage( 0 );
  163. AddBackground( 0, 0, 420, 440, 5054 );
  164. AddBlackAlpha( 10, 10, 170, 100 );
  165. AddBlackAlpha( 190, 10, 220, 100 );
  166. AddBlackAlpha( 10, 120, 400, 260 );
  167. AddBlackAlpha( 10, 390, 400, 40 );
  168. AddPageButton( 10, 10, GetButtonID( 0, 0 ), "INFORMATION", AdminGumpPage.Information );
  169. 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 );
  170. AddPageButton( 10, 50, GetButtonID( 0, 2 ), "CLIENT LIST", AdminGumpPage.Clients, AdminGumpPage.ClientInfo );
  171. 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 );
  172. AddPageButton( 10, 90, GetButtonID( 0, 4 ), "FIREWALL", AdminGumpPage.Firewall, AdminGumpPage.FirewallInfo );
  173. if ( notice != null )
  174. AddHtml( 12, 392, 396, 36, Color( notice, LabelColor32 ), false, false );
  175. switch ( pageType )
  176. {
  177. case AdminGumpPage.Information:
  178. {
  179. int banned = 0;
  180. int active = 0;
  181. foreach ( Account acct in Accounts.Table.Values )
  182. {
  183. if ( acct.Banned )
  184. ++banned;
  185. else
  186. ++active;
  187. }
  188. AddLabel( 20, 130, LabelHue, "Active Accounts:" );
  189. AddLabel( 150, 130, LabelHue, active.ToString() );
  190. AddLabel( 20, 150, LabelHue, "Banned Accounts:" );
  191. AddLabel( 150, 150, LabelHue, banned.ToString() );
  192. AddLabel( 20, 170, LabelHue, "Firewalled:" );
  193. AddLabel( 150, 170, LabelHue, Firewall.List.Count.ToString() );
  194. AddLabel( 20, 190, LabelHue, "Clients:" );
  195. AddLabel( 150, 190, LabelHue, NetState.Instances.Count.ToString() );
  196. AddLabel( 20, 210, LabelHue, "Mobiles:" );
  197. AddLabel( 150, 210, LabelHue, World.Mobiles.Count.ToString() );
  198. AddLabel( 20, 230, LabelHue, "Mobile Scripts:" );
  199. AddLabel( 150, 230, LabelHue, Core.ScriptMobiles.ToString() );
  200. AddLabel( 20, 250, LabelHue, "Items:" );
  201. AddLabel( 150, 250, LabelHue, World.Items.Count.ToString() );
  202. AddLabel( 20, 270, LabelHue, "Item Scripts:" );
  203. AddLabel( 150, 270, LabelHue, Core.ScriptItems.ToString() );
  204. AddLabel( 20, 290, LabelHue, "Uptime:" );
  205. AddLabel( 150, 290, LabelHue, FormatTimeSpan( DateTime.Now - Clock.ServerStart ) );
  206. AddLabel( 20, 310, LabelHue, "Memory:" );
  207. AddLabel( 150, 310, LabelHue, FormatByteAmount( GC.GetTotalMemory( false ) ) );
  208. AddLabel( 20, 330, LabelHue, "Framework:" );
  209. AddLabel( 150, 330, LabelHue, Environment.Version.ToString() );
  210. AddLabel( 20, 350, LabelHue, "Operating System: " );
  211. AddLabel( 150, 350, LabelHue, Environment.OSVersion.ToString() );
  212. /*string str;
  213. try{ str = FormatTimeSpan( Core.Process.TotalProcessorTime ); }
  214. catch{ str = "(unable to retrieve)"; }
  215. AddLabel( 20, 330, LabelHue, "Process Time:" );
  216. AddLabel( 250, 330, LabelHue, str );*/
  217. /*try{ str = Core.Process.PriorityClass.ToString(); }
  218. catch{ str = "(unable to retrieve)"; }
  219. AddLabel( 20, 350, LabelHue, "Process Priority:" );
  220. AddLabel( 250, 350, LabelHue, str );*/
  221. break;
  222. }
  223. case AdminGumpPage.Administer_WorldBuilding:
  224. {
  225. AddHtml( 10, 125, 400, 20, Color( Center( "Generating" ), LabelColor32 ), false, false );
  226. AddButtonLabeled( 20, 150, GetButtonID( 3, 100 ), "Documentation" );
  227. AddButtonLabeled( 220, 150, GetButtonID( 3, 107 ), "Rebuild Categorization" );
  228. AddButtonLabeled( 20, 175, GetButtonID( 3, 101 ), "Teleporters" );
  229. AddButtonLabeled( 220, 175, GetButtonID( 3, 102 ), "Moongates" );
  230. AddButtonLabeled( 20, 200, GetButtonID( 3, 103 ), "Vendors" );
  231. AddButtonLabeled( 220, 200, GetButtonID( 3, 106 ), "Decoration" );
  232. AddButtonLabeled( 20, 225, GetButtonID( 3, 104 ), "Doors" );
  233. AddButtonLabeled( 220, 225, GetButtonID( 3, 105 ), "Signs" );
  234. AddHtml( 20, 275, 400, 30, Color( Center( "Statics" ), LabelColor32 ), false, false );
  235. AddButtonLabeled( 20, 300, GetButtonID( 3, 110 ), "Freeze (Target)" );
  236. AddButtonLabeled( 20, 325, GetButtonID( 3, 111 ), "Freeze (World)" );
  237. AddButtonLabeled( 20, 350, GetButtonID( 3, 112 ), "Freeze (Map)" );
  238. AddButtonLabeled( 220, 300, GetButtonID( 3, 120 ), "Unfreeze (Target)" );
  239. AddButtonLabeled( 220, 325, GetButtonID( 3, 121 ), "Unfreeze (World)" );
  240. AddButtonLabeled( 220, 350, GetButtonID( 3, 122 ), "Unfreeze (Map)" );
  241. goto case AdminGumpPage.Administer;
  242. }
  243. case AdminGumpPage.Administer_Server:
  244. {
  245. AddHtml( 10, 125, 400, 20, Color( Center( "Server" ), LabelColor32 ), false, false );
  246. AddButtonLabeled( 20, 150, GetButtonID( 3, 200 ), "Save" );
  247. if ( !Core.Service )
  248. {
  249. AddButtonLabeled( 20, 180, GetButtonID( 3, 201 ), "Shutdown (With Save)" );
  250. AddButtonLabeled( 20, 200, GetButtonID( 3, 202 ), "Shutdown (Without Save)" );
  251. AddButtonLabeled( 20, 230, GetButtonID( 3, 203 ), "Shutdown & Restart (With Save)" );
  252. AddButtonLabeled( 20, 250, GetButtonID( 3, 204 ), "Shutdown & Restart (Without Save)" );
  253. }
  254. else
  255. {
  256. AddLabel( 20, 215, LabelHue, "Shutdown/Restart not available." );
  257. }
  258. AddHtml( 10, 295, 400, 20, Color( Center( "Broadcast" ), LabelColor32 ), false, false );
  259. AddTextField( 20, 320, 380, 20, 0 );
  260. AddButtonLabeled( 20, 350, GetButtonID( 3, 210 ), "To Everyone" );
  261. AddButtonLabeled( 220, 350, GetButtonID( 3, 211 ), "To Staff" );
  262. goto case AdminGumpPage.Administer;
  263. }
  264. case AdminGumpPage.Administer_Access_Lockdown:
  265. {
  266. AddHtml( 10, 125, 400, 20, Color( Center( "Server Lockdown" ), LabelColor32 ), false, false );
  267. 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 );
  268. AccessLevel level = Misc.AccountHandler.LockdownLevel;
  269. bool isLockedDown = ( level > AccessLevel.Player );
  270. AddSelectedButton( 20, 230, GetButtonID( 3, 500 ), "Not Locked Down", !isLockedDown );
  271. AddSelectedButton( 20, 260, GetButtonID( 3, 504 ), "Administrators", ( isLockedDown && level <= AccessLevel.Administrator ) );
  272. AddSelectedButton( 20, 280, GetButtonID( 3, 503 ), "Seers", ( isLockedDown && level <= AccessLevel.Seer ) );
  273. AddSelectedButton( 20, 300, GetButtonID( 3, 502 ), "Game Masters", ( isLockedDown && level <= AccessLevel.GameMaster ) );
  274. AddSelectedButton( 20, 320, GetButtonID( 3, 501 ), "Counselors", ( isLockedDown && level <= AccessLevel.Counselor ) );
  275. AddButtonLabeled( 20, 350, GetButtonID( 3, 510 ), "Purge Invalid Clients" );
  276. goto case AdminGumpPage.Administer;
  277. }
  278. case AdminGumpPage.Administer_Access:
  279. {
  280. AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );
  281. AddHtml( 10, 155, 400, 20, Color( Center( "Connectivity" ), LabelColor32 ), false, false );
  282. AddButtonLabeled( 20, 180, GetButtonID( 3, 300 ), "Kick" );
  283. AddButtonLabeled( 220, 180, GetButtonID( 3, 301 ), "Ban" );
  284. AddButtonLabeled( 20, 210, GetButtonID( 3, 302 ), "Firewall" );
  285. AddButtonLabeled( 220, 210, GetButtonID( 3, 303 ), "Lockdown" );
  286. AddHtml( 10, 245, 400, 20, Color( Center( "Staff" ), LabelColor32 ), false, false );
  287. AddButtonLabeled( 20, 270, GetButtonID( 3, 310 ), "Make Player" );
  288. AddButtonLabeled( 20, 290, GetButtonID( 3, 311 ), "Make Counselor" );
  289. AddButtonLabeled( 20, 310, GetButtonID( 3, 312 ), "Make Game Master" );
  290. AddButtonLabeled( 20, 330, GetButtonID( 3, 313 ), "Make Seer" );
  291. AddButtonLabeled( 20, 350, GetButtonID( 3, 314 ), "Make Administrator" );
  292. goto case AdminGumpPage.Administer;
  293. }
  294. case AdminGumpPage.Administer_Commands:
  295. {
  296. AddHtml( 10, 125, 400, 20, Color( Center( "Commands" ), LabelColor32 ), false, false );
  297. AddButtonLabeled( 20, 150, GetButtonID( 3, 400 ), "Add" );
  298. AddButtonLabeled( 220, 150, GetButtonID( 3, 401 ), "Remove" );
  299. AddButtonLabeled( 20, 170, GetButtonID( 3, 402 ), "Dupe" );
  300. AddButtonLabeled( 220, 170, GetButtonID( 3, 403 ), "Dupe in bag" );
  301. AddButtonLabeled( 20, 200, GetButtonID( 3, 404 ), "Properties" );
  302. AddButtonLabeled( 220, 200, GetButtonID( 3, 405 ), "Skills" );
  303. AddButtonLabeled( 20, 230, GetButtonID( 3, 406 ), "Mortal" );
  304. AddButtonLabeled( 220, 230, GetButtonID( 3, 407 ), "Immortal" );
  305. AddButtonLabeled( 20, 250, GetButtonID( 3, 408 ), "Squelch" );
  306. AddButtonLabeled( 220, 250, GetButtonID( 3, 409 ), "Unsquelch" );
  307. AddButtonLabeled( 20, 270, GetButtonID( 3, 410 ), "Freeze" );
  308. AddButtonLabeled( 220, 270, GetButtonID( 3, 411 ), "Unfreeze" );
  309. AddButtonLabeled( 20, 290, GetButtonID( 3, 412 ), "Hide" );
  310. AddButtonLabeled( 220, 290, GetButtonID( 3, 413 ), "Unhide" );
  311. AddButtonLabeled( 20, 310, GetButtonID( 3, 414 ), "Kill" );
  312. AddButtonLabeled( 220, 310, GetButtonID( 3, 415 ), "Resurrect" );
  313. AddButtonLabeled( 20, 330, GetButtonID( 3, 416 ), "Move" );
  314. AddButtonLabeled( 220, 330, GetButtonID( 3, 417 ), "Wipe" );
  315. AddButtonLabeled( 20, 350, GetButtonID( 3, 418 ), "Teleport" );
  316. AddButtonLabeled( 220, 350, GetButtonID( 3, 419 ), "Teleport (Multiple)" );
  317. goto case AdminGumpPage.Administer;
  318. }
  319. case AdminGumpPage.Administer:
  320. {
  321. AddPageButton( 200, 20, GetButtonID( 3, 0 ), "World Building", AdminGumpPage.Administer_WorldBuilding );
  322. AddPageButton( 200, 40, GetButtonID( 3, 1 ), "Server", AdminGumpPage.Administer_Server );
  323. AddPageButton( 200, 60, GetButtonID( 3, 2 ), "Access", AdminGumpPage.Administer_Access, AdminGumpPage.Administer_Access_Lockdown );
  324. AddPageButton( 200, 80, GetButtonID( 3, 3 ), "Commands", AdminGumpPage.Administer_Commands );
  325. break;
  326. }
  327. case AdminGumpPage.Clients:
  328. {
  329. if ( m_List == null )
  330. {
  331. m_List = new ArrayList( NetState.Instances );
  332. m_List.Sort( NetStateComparer.Instance );
  333. }
  334. AddClientHeader();
  335. AddLabelCropped( 12, 120, 81, 20, LabelHue, "Name" );
  336. AddLabelCropped( 95, 120, 81, 20, LabelHue, "Account" );
  337. AddLabelCropped( 178, 120, 81, 20, LabelHue, "Access Level" );
  338. AddLabelCropped( 273, 120,109, 20, LabelHue, "IP Address" );
  339. if ( listPage > 0 )
  340. AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  341. else
  342. AddImage( 375, 122, 0x25EA );
  343. if ( (listPage + 1) * 12 < m_List.Count )
  344. AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  345. else
  346. AddImage( 392, 122, 0x25E6 );
  347. if ( m_List.Count == 0 )
  348. AddLabel( 12, 140, LabelHue, "There are no clients to display." );
  349. for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
  350. {
  351. NetState ns = m_List[index] as NetState;
  352. if ( ns == null )
  353. continue;
  354. Mobile m = ns.Mobile;
  355. Account a = ns.Account as Account;
  356. RacePlayerMobile pm = (RacePlayerMobile)m;
  357. int offset = 140 + (i * 20);
  358. if ( m == null )
  359. {
  360. AddLabelCropped( 12, offset, 81, 20, LabelHue, "(logging in)" );
  361. }
  362. else
  363. {
  364. AddLabelCropped( 12, offset, 81, 20, GetHueFor( m ), pm.PlayerName );
  365. }
  366. AddLabelCropped( 95, offset, 81, 20, LabelHue, a == null ? "(no account)" : a.Username );
  367. AddLabelCropped( 178, offset, 81, 20, LabelHue, m == null ? (a != null ? FormatAccessLevel( a.AccessLevel ) : "") : FormatAccessLevel( m.AccessLevel ) );
  368. AddLabelCropped( 273, offset,109, 20, LabelHue, ns.ToString() );
  369. if ( a != null || m != null )
  370. AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 4, index + 2 ), GumpButtonType.Reply, 0 );
  371. }
  372. break;
  373. }
  374. case AdminGumpPage.ClientInfo:
  375. {
  376. Mobile m = state as Mobile;
  377. RacePlayerMobile pm = (RacePlayerMobile)m;
  378. if ( m == null )
  379. break;
  380. AddClientHeader();
  381. AddHtml( 10, 125, 400, 20, Color( Center( "Information" ), LabelColor32 ), false, false );
  382. int y = 146;
  383. AddLabel( 20, y, LabelHue, "Name:" );
  384. AddLabel( 200, y, GetHueFor( m ), pm.PlayerName );
  385. y += 20;
  386. Account a = m.Account as Account;
  387. AddLabel( 20, y, LabelHue, "Account:" );
  388. AddLabel( 200, y, (a != null && a.Banned) ? RedHue : LabelHue, a == null ? "(no account)" : a.Username );
  389. AddButton( 380, y, 0xFA5, 0xFA7, GetButtonID( 7, 14 ), GumpButtonType.Reply, 0 );
  390. y += 20;
  391. NetState ns = m.NetState;
  392. if ( ns == null )
  393. {
  394. AddLabel( 20, y, LabelHue, "Address:" );
  395. AddLabel( 200, y, RedHue, "Offline" );
  396. y += 20;
  397. AddLabel( 20, y, LabelHue, "Location:" );
  398. AddLabel( 200, y, LabelHue, String.Format( "{0} [{1}]", m.Location, m.Map ) );
  399. y += 44;
  400. }
  401. else
  402. {
  403. AddLabel( 20, y, LabelHue, "Address:" );
  404. AddLabel( 200, y, GreenHue, ns.ToString() );
  405. y += 20;
  406. ClientVersion v = ns.Version;
  407. AddLabel( 20, y, LabelHue, "Version:" );
  408. AddLabel( 200, y, LabelHue, v == null ? "(null)" : v.ToString() );
  409. y += 20;
  410. AddLabel( 20, y, LabelHue, "Location:" );
  411. AddLabel( 200, y, LabelHue, String.Format( "{0} [{1}]", m.Location, m.Map ) );
  412. y += 24;
  413. }
  414. AddButtonLabeled( 20, y, GetButtonID( 7, 0 ), "Go to" );
  415. AddButtonLabeled( 200, y, GetButtonID( 7, 1 ), "Get" );
  416. y += 20;
  417. AddButtonLabeled( 20, y, GetButtonID( 7, 2 ), "Kick" );
  418. AddButtonLabeled( 200, y, GetButtonID( 7, 3 ), "Ban" );
  419. y += 20;
  420. AddButtonLabeled( 20, y, GetButtonID( 7, 4 ), "Properties" );
  421. AddButtonLabeled( 200, y, GetButtonID( 7, 5 ), "Skills" );
  422. y += 20;
  423. AddButtonLabeled( 20, y, GetButtonID( 7, 6 ), "Mortal" );
  424. AddButtonLabeled( 200, y, GetButtonID( 7, 7 ), "Immortal" );
  425. y += 20;
  426. AddButtonLabeled( 20, y, GetButtonID( 7, 8 ), "Squelch" );
  427. AddButtonLabeled( 200, y, GetButtonID( 7, 9 ), "Unsquelch" );
  428. y += 20;
  429. /*AddButtonLabeled( 20, y, GetButtonID( 7, 10 ), "Hide" );
  430. AddButtonLabeled( 200, y, GetButtonID( 7, 11 ), "Unhide" );
  431. y += 20;*/
  432. AddButtonLabeled( 20, y, GetButtonID( 7, 12 ), "Kill" );
  433. AddButtonLabeled( 200, y, GetButtonID( 7, 13 ), "Resurrect" );
  434. y += 20;
  435. break;
  436. }
  437. case AdminGumpPage.Accounts_Shared:
  438. {
  439. if ( m_List == null )
  440. m_List = GetAllSharedAccounts();
  441. AddLabelCropped( 12, 120, 60, 20, LabelHue, "Count" );
  442. AddLabelCropped( 72, 120, 120, 20, LabelHue, "Address" );
  443. AddLabelCropped( 192, 120, 180, 20, LabelHue, "Accounts" );
  444. if ( listPage > 0 )
  445. AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  446. else
  447. AddImage( 375, 122, 0x25EA );
  448. if ( (listPage + 1) * 12 < m_List.Count )
  449. AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  450. else
  451. AddImage( 392, 122, 0x25E6 );
  452. if ( m_List.Count == 0 )
  453. AddLabel( 12, 140, LabelHue, "There are no accounts to display." );
  454. StringBuilder sb = new StringBuilder();
  455. for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
  456. {
  457. DictionaryEntry de = (DictionaryEntry)m_List[index];
  458. IPAddress ipAddr = (IPAddress)de.Key;
  459. ArrayList accts = (ArrayList)de.Value;
  460. int offset = 140 + (i * 20);
  461. AddLabelCropped( 12, offset, 60, 20, LabelHue, accts.Count.ToString() );
  462. AddLabelCropped( 72, offset, 120, 20, LabelHue, ipAddr.ToString() );
  463. if ( sb.Length > 0 )
  464. sb.Length = 0;
  465. for ( int j = 0; j < accts.Count; ++j )
  466. {
  467. if ( j > 0 )
  468. sb.Append( ", " );
  469. if ( j < 4 )
  470. {
  471. Account acct = (Account)accts[j];
  472. sb.Append( acct.Username );
  473. }
  474. else
  475. {
  476. sb.Append( "..." );
  477. break;
  478. }
  479. }
  480. AddLabelCropped( 192, offset, 180, 20, LabelHue, sb.ToString() );
  481. AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 55 ), GumpButtonType.Reply, 0 );
  482. }
  483. break;
  484. }
  485. case AdminGumpPage.Accounts:
  486. {
  487. if ( m_List == null )
  488. {
  489. m_List = new ArrayList( Accounts.Table.Values );
  490. m_List.Sort( AccountComparer.Instance );
  491. }
  492. ArrayList rads = ( state as ArrayList );
  493. AddAccountHeader();
  494. if ( rads == null )
  495. AddLabelCropped( 12, 120, 120, 20, LabelHue, "Name" );
  496. else
  497. AddLabelCropped( 32, 120, 100, 20, LabelHue, "Name" );
  498. AddLabelCropped( 132, 120, 120, 20, LabelHue, "Access Level" );
  499. AddLabelCropped( 252, 120, 120, 20, LabelHue, "Status" );
  500. if ( listPage > 0 )
  501. AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  502. else
  503. AddImage( 375, 122, 0x25EA );
  504. if ( (listPage + 1) * 12 < m_List.Count )
  505. AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  506. else
  507. AddImage( 392, 122, 0x25E6 );
  508. if ( m_List.Count == 0 )
  509. AddLabel( 12, 140, LabelHue, "There are no accounts to display." );
  510. if ( rads != null && notice == null )
  511. {
  512. AddButtonLabeled( 10, 390, GetButtonID( 5, 27 ), "Ban marked" );
  513. AddButtonLabeled( 10, 410, GetButtonID( 5, 28 ), "Delete marked" );
  514. AddButtonLabeled( 210, 400, GetButtonID( 5, 29 ), "Mark all" );
  515. }
  516. for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
  517. {
  518. Account a = m_List[index] as Account;
  519. if ( a == null )
  520. continue;
  521. int offset = 140 + (i * 20);
  522. AccessLevel accessLevel;
  523. bool online;
  524. GetAccountInfo( a, out accessLevel, out online );
  525. if ( rads == null )
  526. {
  527. AddLabelCropped( 12, offset, 120, 20, LabelHue, a.Username );
  528. }
  529. else
  530. {
  531. AddCheck( 10, offset, 0xD2, 0xD3, rads.Contains( a ), index );
  532. AddLabelCropped( 32, offset, 100, 20, LabelHue, a.Username );
  533. }
  534. AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );
  535. if ( online )
  536. AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
  537. else if ( a.Banned )
  538. AddLabelCropped( 252, offset, 120, 20, RedHue, "Banned" );
  539. else
  540. AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );
  541. AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 55 ), GumpButtonType.Reply, 0 );
  542. }
  543. break;
  544. }
  545. case AdminGumpPage.AccountDetails:
  546. {
  547. AddPageButton( 190, 10, GetButtonID( 5, 0 ), "Information", AdminGumpPage.AccountDetails_Information, AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword );
  548. AddPageButton( 190, 30, GetButtonID( 5, 1 ), "Characters", AdminGumpPage.AccountDetails_Characters );
  549. AddPageButton( 190, 50, GetButtonID( 5, 13 ), "Access", AdminGumpPage.AccountDetails_Access, AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions );
  550. AddPageButton( 190, 70, GetButtonID( 5, 2 ), "Comments", AdminGumpPage.AccountDetails_Comments );
  551. AddPageButton( 190, 90, GetButtonID( 5, 3 ), "Tags", AdminGumpPage.AccountDetails_Tags );
  552. break;
  553. }
  554. case AdminGumpPage.AccountDetails_ChangePassword:
  555. {
  556. Account a = state as Account;
  557. if ( a == null )
  558. break;
  559. AddHtml( 10, 125, 400, 20, Color( Center( "Change Password" ), LabelColor32 ), false, false );
  560. AddLabel( 20, 150, LabelHue, "Username:" );
  561. AddLabel( 200, 150, LabelHue, a.Username );
  562. AddLabel( 20, 180, LabelHue, "Password:" );
  563. AddTextField( 200, 180, 160, 20, 0 );
  564. AddLabel( 20, 210, LabelHue, "Confirm:" );
  565. AddTextField( 200, 210, 160, 20, 1 );
  566. AddButtonLabeled( 20, 240, GetButtonID( 5, 12 ), "Submit Change" );
  567. goto case AdminGumpPage.AccountDetails;
  568. }
  569. case AdminGumpPage.AccountDetails_ChangeAccess:
  570. {
  571. Account a = state as Account;
  572. if ( a == null )
  573. break;
  574. AddHtml( 10, 125, 400, 20, Color( Center( "Change Access Level" ), LabelColor32 ), false, false );
  575. AddLabel( 20, 150, LabelHue, "Username:" );
  576. AddLabel( 200, 150, LabelHue, a.Username );
  577. AddLabel( 20, 170, LabelHue, "Current Level:" );
  578. AddLabel( 200, 170, LabelHue, FormatAccessLevel( a.AccessLevel ) );
  579. AddButtonLabeled( 20, 200, GetButtonID( 5, 20 ), "Player" );
  580. AddButtonLabeled( 20, 220, GetButtonID( 5, 21 ), "Counselor" );
  581. AddButtonLabeled( 20, 240, GetButtonID( 5, 22 ), "Game Master" );
  582. AddButtonLabeled( 20, 260, GetButtonID( 5, 23 ), "Seer" );
  583. AddButtonLabeled( 20, 280, GetButtonID( 5, 24 ), "Administrator" );
  584. goto case AdminGumpPage.AccountDetails;
  585. }
  586. case AdminGumpPage.AccountDetails_Information:
  587. {
  588. Account a = state as Account;
  589. if ( a == null )
  590. break;
  591. int charCount = 0;
  592. for ( int i = 0; i < 5; ++i )
  593. {
  594. if ( a[i] != null )
  595. ++charCount;
  596. }
  597. AddHtml( 10, 125, 400, 20, Color( Center( "Information" ), LabelColor32 ), false, false );
  598. AddLabel( 20, 150, LabelHue, "Username:" );
  599. AddLabel( 200, 150, LabelHue, a.Username );
  600. AddLabel( 20, 170, LabelHue, "Access Level:" );
  601. AddLabel( 200, 170, LabelHue, FormatAccessLevel( a.AccessLevel ) );
  602. AddLabel( 20, 190, LabelHue, "Status:" );
  603. AddLabel( 200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active" );
  604. DateTime banTime;
  605. TimeSpan banDuration;
  606. if ( a.Banned && a.GetBanTags( out banTime, out banDuration ) )
  607. {
  608. if ( banDuration == TimeSpan.MaxValue )
  609. {
  610. AddLabel( 250, 190, LabelHue, "(Infinite)" );
  611. }
  612. else if ( banDuration == TimeSpan.Zero )
  613. {
  614. AddLabel( 250, 190, LabelHue, "(Zero)" );
  615. }
  616. else
  617. {
  618. TimeSpan remaining = (DateTime.Now - banTime);
  619. if ( remaining < TimeSpan.Zero )
  620. remaining = TimeSpan.Zero;
  621. else if ( remaining > banDuration )
  622. remaining = banDuration;
  623. double remMinutes = remaining.TotalMinutes;
  624. double totMinutes = banDuration.TotalMinutes;
  625. double perc = remMinutes / totMinutes;
  626. AddLabel( 250, 190, LabelHue, String.Format( "{0} [{1:F0}%]", FormatTimeSpan( banDuration ), perc*100 ) );
  627. }
  628. }
  629. else if ( a.Banned )
  630. {
  631. AddLabel( 250, 190, LabelHue, "(Unspecified)" );
  632. }
  633. AddLabel( 20, 210, LabelHue, "Created:" );
  634. AddLabel( 200, 210, LabelHue, a.Created.ToString() );
  635. AddLabel( 20, 230, LabelHue, "Last Login:" );
  636. AddLabel( 200, 230, LabelHue, a.LastLogin.ToString() );
  637. AddLabel( 20, 250, LabelHue, "Character Count:" );
  638. AddLabel( 200, 250, LabelHue, charCount.ToString() );
  639. AddLabel( 20, 270, LabelHue, "Comment Count:" );
  640. AddLabel( 200, 270, LabelHue, a.Comments.Count.ToString() );
  641. AddLabel( 20, 290, LabelHue, "Tag Count:" );
  642. AddLabel( 200, 290, LabelHue, a.Tags.Count.ToString() );
  643. AddButtonLabeled( 20, 320, GetButtonID( 5, 8 ), "Change Password" );
  644. AddButtonLabeled( 200, 320, GetButtonID( 5, 9 ), "Change Access Level" );
  645. if ( !a.Banned )
  646. AddButtonLabeled( 20, 350, GetButtonID( 5, 10 ), "Ban Account" );
  647. else
  648. AddButtonLabeled( 20, 350, GetButtonID( 5, 11 ), "Unban Account" );
  649. AddButtonLabeled( 200, 350, GetButtonID( 5, 25 ), "Delete Account" );
  650. goto case AdminGumpPage.AccountDetails;
  651. }
  652. case AdminGumpPage.AccountDetails_Access:
  653. {
  654. Account a = state as Account;
  655. if ( a == null )
  656. break;
  657. AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );
  658. AddPageButton( 20, 150, GetButtonID( 5, 14 ), "View client addresses", AdminGumpPage.AccountDetails_Access_ClientIPs );
  659. AddPageButton( 20, 170, GetButtonID( 5, 15 ), "Manage restrictions", AdminGumpPage.AccountDetails_Access_Restrictions );
  660. goto case AdminGumpPage.AccountDetails;
  661. }
  662. case AdminGumpPage.AccountDetails_Access_ClientIPs:
  663. {
  664. Account a = state as Account;
  665. if ( a == null )
  666. break;
  667. if ( m_List == null )
  668. m_List = new ArrayList( a.LoginIPs );
  669. AddHtml( 10, 195, 400, 20, Color( Center( "Client Addresses" ), LabelColor32 ), false, false );
  670. AddButtonLabeled( 200, 225, GetButtonID( 5, 16 ), "View all shared accounts" );
  671. AddButtonLabeled( 200, 245, GetButtonID( 5, 17 ), "Ban all shared accounts" );
  672. AddButtonLabeled( 200, 265, GetButtonID( 5, 18 ), "Firewall all addresses" );
  673. AddHtml( 195, 295, 210, 80, Color( "List of IP addresses which have accessed this account.", LabelColor32 ), false, false );
  674. AddImageTiled( 15, 219, 176, 156, 0xBBC );
  675. AddBlackAlpha( 16, 220, 174, 154 );
  676. AddHtml( 18, 221, 114, 20, Color( "IP Address", LabelColor32 ), false, false );
  677. if ( listPage > 0 )
  678. AddButton( 154, 223, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  679. else
  680. AddImage( 154, 223, 0x25EA );
  681. if ( (listPage + 1) * 6 < m_List.Count )
  682. AddButton( 171, 223, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  683. else
  684. AddImage( 171, 223, 0x25E6 );
  685. if ( m_List.Count == 0 )
  686. AddHtml( 18, 243, 170, 60, Color( "This account has not yet been accessed.", LabelColor32 ), false, false );
  687. for ( int i = 0, index = (listPage * 6); i < 6 && index >= 0 && index < m_List.Count; ++i, ++index )
  688. {
  689. AddHtml( 18, 243 + (i * 22), 114, 20, Color( m_List[index].ToString(), LabelColor32 ), false, false );
  690. AddButton( 130, 242 + (i * 22), 0xFA2, 0xFA4, GetButtonID( 8, index ), GumpButtonType.Reply, 0 );
  691. AddButton( 160, 242 + (i * 22), 0xFA8, 0xFAA, GetButtonID( 9, index ), GumpButtonType.Reply, 0 );
  692. }
  693. goto case AdminGumpPage.AccountDetails_Access;
  694. }
  695. case AdminGumpPage.AccountDetails_Access_Restrictions:
  696. {
  697. Account a = state as Account;
  698. if ( a == null )
  699. break;
  700. if ( m_List == null )
  701. m_List = new ArrayList( a.IPRestrictions );
  702. AddHtml( 10, 195, 400, 20, Color( Center( "Address Restrictions" ), LabelColor32 ), false, false );
  703. AddTextField( 200, 225, 120, 20, 0 );
  704. AddButtonLabeled( 330, 225, GetButtonID( 5, 19 ), "Add" );
  705. 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 );
  706. AddImageTiled( 15, 219, 176, 156, 0xBBC );
  707. AddBlackAlpha( 16, 220, 174, 154 );
  708. AddHtml( 18, 221, 114, 20, Color( "IP Address", LabelColor32 ), false, false );
  709. if ( listPage > 0 )
  710. AddButton( 154, 223, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  711. else
  712. AddImage( 154, 223, 0x25EA );
  713. if ( (listPage + 1) * 6 < m_List.Count )
  714. AddButton( 171, 223, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  715. else
  716. AddImage( 171, 223, 0x25E6 );
  717. if ( m_List.Count == 0 )
  718. AddHtml( 18, 243, 170, 60, Color( "There are no addresses in this list.", LabelColor32 ), false, false );
  719. for ( int i = 0, index = (listPage * 6); i < 6 && index >= 0 && index < m_List.Count; ++i, ++index )
  720. {
  721. AddHtml( 18, 243 + (i * 22), 114, 20, Color( m_List[index].ToString(), LabelColor32 ), false, false );
  722. AddButton( 160, 242 + (i * 22), 0xFB1, 0xFB3, GetButtonID( 8, index ), GumpButtonType.Reply, 0 );
  723. }
  724. goto case AdminGumpPage.AccountDetails_Access;
  725. }
  726. case AdminGumpPage.AccountDetails_Characters:
  727. {
  728. Account a = state as Account;
  729. if ( a == null )
  730. break;
  731. AddHtml( 10, 125, 400, 20, Color( Center( "Characters" ), LabelColor32 ), false, false );
  732. AddLabelCropped( 12, 150, 120, 20, LabelHue, "Name" );
  733. AddLabelCropped( 132, 150, 120, 20, LabelHue, "Access Level" );
  734. AddLabelCropped( 252, 150, 120, 20, LabelHue, "Status" );
  735. int index = 0;
  736. for ( int i = 0; i < 5; ++i )
  737. {
  738. Mobile m = a[i];
  739. RacePlayerMobile pm = (RacePlayerMobile)m;
  740. if ( m == null )
  741. continue;
  742. int offset = 170 + (index * 20);
  743. AddLabelCropped( 12, offset, 120, 20, GetHueFor( m ), pm.PlayerName );
  744. AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( m.AccessLevel ) );
  745. if ( m.NetState != null )
  746. AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
  747. else
  748. AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );
  749. AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, i + 50 ), GumpButtonType.Reply, 0 );
  750. ++index;
  751. }
  752. if ( index == 0 )
  753. AddLabel( 12, 170, LabelHue, "The character list is empty." );
  754. goto case AdminGumpPage.AccountDetails;
  755. }
  756. case AdminGumpPage.AccountDetails_Comments:
  757. {
  758. Account a = state as Account;
  759. if ( a == null )
  760. break;
  761. AddHtml( 10, 125, 400, 20, Color( Center( "Comments" ), LabelColor32 ), false, false );
  762. AddButtonLabeled( 20, 150, GetButtonID( 5, 4 ), "Add Comment" );
  763. StringBuilder sb = new StringBuilder();
  764. if ( a.Comments.Count == 0 )
  765. sb.Append( "There are no comments for this account." );
  766. for ( int i = 0; i < a.Comments.Count; ++i )
  767. {
  768. if ( i > 0 )
  769. sb.Append( "<BR><BR>" );
  770. AccountComment c = (AccountComment)a.Comments[i];
  771. sb.AppendFormat( "[{0}]<BR>{1}", c.AddedBy, c.Content );
  772. }
  773. AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );
  774. goto case AdminGumpPage.AccountDetails;
  775. }
  776. case AdminGumpPage.AccountDetails_Tags:
  777. {
  778. Account a = state as Account;
  779. if ( a == null )
  780. break;
  781. AddHtml( 10, 125, 400, 20, Color( Center( "Tags" ), LabelColor32 ), false, false );
  782. AddButtonLabeled( 20, 150, GetButtonID( 5, 5 ), "Add Tag" );
  783. StringBuilder sb = new StringBuilder();
  784. if ( a.Tags.Count == 0 )
  785. sb.Append( "There are no tags for this account." );
  786. for ( int i = 0; i < a.Tags.Count; ++i )
  787. {
  788. if ( i > 0 )
  789. sb.Append( "<BR>" );
  790. AccountTag tag = (AccountTag)a.Tags[i];
  791. sb.AppendFormat( "{0} = {1}", tag.Name, tag.Value );
  792. }
  793. AddHtml( 20, 180, 380, 190, sb.ToString(), true, true );
  794. goto case AdminGumpPage.AccountDetails;
  795. }
  796. case AdminGumpPage.Firewall:
  797. {
  798. AddFirewallHeader();
  799. if ( m_List == null )
  800. m_List = new ArrayList( Firewall.List );
  801. AddLabelCropped( 12, 120, 358, 20, LabelHue, "IP Address" );
  802. if ( listPage > 0 )
  803. AddButton( 375, 122, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  804. else
  805. AddImage( 375, 122, 0x25EA );
  806. if ( (listPage + 1) * 12 < m_List.Count )
  807. AddButton( 392, 122, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  808. else
  809. AddImage( 392, 122, 0x25E6 );
  810. if ( m_List.Count == 0 )
  811. AddLabel( 12, 140, LabelHue, "The firewall list is empty." );
  812. for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
  813. {
  814. object obj = m_List[index];
  815. if ( !(obj is IPAddress) && !(obj is String) )
  816. break;
  817. int offset = 140 + (i * 20);
  818. AddLabelCropped( 12, offset, 358, 20, LabelHue, obj.ToString() );
  819. AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 6, index + 4 ), GumpButtonType.Reply, 0 );
  820. }
  821. break;
  822. }
  823. case AdminGumpPage.FirewallInfo:
  824. {
  825. AddFirewallHeader();
  826. if ( !(state is IPAddress) && !(state is String) )
  827. break;
  828. AddHtml( 10, 125, 400, 20, Color( Center( state.ToString() ), LabelColor32 ), false, false );
  829. AddButtonLabeled( 20, 150, GetButtonID( 6, 3 ), "Remove" );
  830. AddHtml( 10, 175, 400, 20, Color( Center( "Potentially Effected Accounts" ), LabelColor32 ), false, false );
  831. if ( m_List == null )
  832. {
  833. m_List = new ArrayList();
  834. string pattern = state as String;
  835. IPAddress addr = ( state is IPAddress ? (IPAddress)state : IPAddress.Any );
  836. foreach ( Account acct in Accounts.Table.Values )
  837. {
  838. IPAddress[] loginList = acct.LoginIPs;
  839. bool contains = false;
  840. for ( int i = 0; !contains && i < loginList.Length; ++i )
  841. contains = ( pattern == null ? loginList[i].Equals( addr ) : Utility.IPMatch( pattern, loginList[i] ) );
  842. if ( contains )
  843. m_List.Add( acct );
  844. }
  845. m_List.Sort( AccountComparer.Instance );
  846. }
  847. if ( listPage > 0 )
  848. AddButton( 375, 177, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
  849. else
  850. AddImage( 375, 177, 0x25EA );
  851. if ( (listPage + 1) * 12 < m_List.Count )
  852. AddButton( 392, 177, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
  853. else
  854. AddImage( 392, 177, 0x25E6 );
  855. if ( m_List.Count == 0 )
  856. AddLabelCropped( 12, 200, 398, 20, LabelHue, "No accounts found." );
  857. for ( int i = 0, index = (listPage * 9); i < 9 && index >= 0 && index < m_List.Count; ++i, ++index )
  858. {
  859. Account a = m_List[index] as Account;
  860. if ( a == null )
  861. continue;
  862. int offset = 200 + (i * 20);
  863. AccessLevel accessLevel;
  864. bool online;
  865. GetAccountInfo( a, out accessLevel, out online );
  866. AddLabelCropped( 12, offset, 120, 20, LabelHue, a.Username );
  867. AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );
  868. if ( online )
  869. AddLabelCropped( 252, offset, 120, 20, GreenHue, "Online" );
  870. else
  871. AddLabelCropped( 252, offset, 120, 20, RedHue, "Offline" );
  872. AddButton( 380, offset - 1, 0xFA5, 0xFA7, GetButtonID( 5, index + 55 ), GumpButtonType.Reply, 0 );
  873. }
  874. break;
  875. }
  876. }
  877. }
  878. public void AddTextField( int x, int y, int width, int height, int index )
  879. {
  880. AddBackground( x - 2, y - 2, width + 4, height + 4, 0x2486 );
  881. AddTextEntry( x + 2, y + 2, width - 4, height - 4, 0, index, "" );
  882. }
  883. public void AddClientHeader()
  884. {
  885. AddTextField( 200, 20, 200, 20, 0 );
  886. AddButtonLabeled( 200, 50, GetButtonID( 4, 0 ), "Search For Name" );
  887. AddButtonLabeled( 200, 80, GetButtonID( 4, 1 ), "Search For IP Address" );
  888. }
  889. public void AddAccountHeader()
  890. {
  891. AddPage( 1 );
  892. AddLabel( 200, 20, LabelHue, "Name:" );
  893. AddTextField( 250, 20, 150, 20, 0 );
  894. AddLabel( 200, 50, LabelHue, "Pass:" );
  895. AddTextField( 250, 50, 150, 20, 1 );
  896. AddButtonLabeled( 200, 80, GetButtonID( 5, 6 ), "Add" );
  897. AddButtonLabeled( 290, 80, GetButtonID( 5, 7 ), "Search" );
  898. AddButton( 384, 84, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 2 );
  899. AddPage( 2 );
  900. AddButtonLabeled( 200, 20, GetButtonID( 5, 31 ), "View All: Inactive" );
  901. AddButtonLabeled( 200, 40, GetButtonID( 5, 32 ), "View All: Banned" );
  902. AddButtonLabeled( 200, 60, GetButtonID( 5, 26 ), "View All: Shared" );
  903. AddButtonLabeled( 200, 80, GetButtonID( 5, 30 ), "View All: Empty" );
  904. AddButton( 384, 84, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 1 );
  905. AddPage( 0 );
  906. }
  907. public void AddFirewallHeader()
  908. {
  909. AddTextField( 200, 20, 200, 20, 0 );
  910. AddButtonLabeled( 320, 50, GetButtonID( 6, 0 ), "Search" );
  911. AddButtonLabeled( 200, 50, GetButtonID( 6, 1 ), "Add (Input)" );
  912. AddButtonLabeled( 200, 80, GetButtonID( 6, 2 ), "Add (Target)" );
  913. }
  914. private static ArrayList GetAllSharedAccounts()
  915. {
  916. Hashtable table = new Hashtable();
  917. ArrayList list;
  918. foreach ( Account acct in Accounts.Table.Values )
  919. {
  920. IPAddress[] theirAddresses = acct.LoginIPs;
  921. for ( int i = 0; i < theirAddresses.Length; ++i )
  922. {
  923. list = (ArrayList)table[theirAddresses[i]];
  924. if ( list == null )
  925. table[theirAddresses[i]] = list = new ArrayList();
  926. list.Add( acct );
  927. }
  928. }
  929. list = new ArrayList( table );
  930. for ( int i = 0; i < list.Count; ++i )
  931. {
  932. DictionaryEntry de = (DictionaryEntry)list[i];
  933. ArrayList accts = (ArrayList)de.Value;
  934. if ( accts.Count == 1 )
  935. list.RemoveAt( i-- );
  936. else
  937. accts.Sort( AccountComparer.Instance );
  938. }
  939. list.Sort( SharedAccountComparer.Instance );
  940. return list;
  941. }
  942. private class SharedAccountComparer : IComparer
  943. {
  944. public static readonly IComparer Instance = new SharedAccountComparer();
  945. public SharedAccountComparer()
  946. {
  947. }
  948. public int Compare( object x, object y )
  949. {
  950. DictionaryEntry a = (DictionaryEntry)x;
  951. DictionaryEntry b = (DictionaryEntry)y;
  952. ArrayList aList = (ArrayList)a.Value;
  953. ArrayList bList = (ArrayList)b.Value;
  954. return bList.Count - aList.Count;
  955. }
  956. }
  957. private static ArrayList GetSharedAccounts( IPAddress ipAddress )
  958. {
  959. ArrayList list = new ArrayList();
  960. foreach ( Account acct in Accounts.Table.Values )
  961. {
  962. IPAddress[] theirAddresses = acct.LoginIPs;
  963. bool contains = false;
  964. for ( int i = 0; !contains && i < theirAddresses.Length; ++i )
  965. contains = ipAddress.Equals( theirAddresses[i] );
  966. if ( contains )
  967. list.Add( acct );
  968. }
  969. list.Sort( AccountComparer.Instance );
  970. return list;
  971. }
  972. private static ArrayList GetSharedAccounts( IPAddress[] ipAddresses )
  973. {
  974. ArrayList list = new ArrayList();
  975. foreach ( Account acct in Accounts.Table.Values )
  976. {
  977. IPAddress[] theirAddresses = acct.LoginIPs;
  978. bool contains = false;
  979. for ( int i = 0; !contains && i < theirAddresses.Length; ++i )
  980. {
  981. IPAddress check = theirAddresses[i];
  982. for ( int j = 0; !contains && j < ipAddresses.Length; ++j )
  983. contains = check.Equals( ipAddresses[j] );
  984. }
  985. if ( contains )
  986. list.Add( acct );
  987. }
  988. list.Sort( AccountComparer.Instance );
  989. return list;
  990. }
  991. public static void BanShared_Callback( Mobile from, bool okay, object state )
  992. {
  993. if ( from.AccessLevel < AccessLevel.Administrator )
  994. return;
  995. string notice;
  996. ArrayList list = null;
  997. if ( okay )
  998. {
  999. Account a = (Account)state;
  1000. list = GetSharedAccounts( a.LoginIPs );
  1001. for ( int i = 0; i < list.Count; ++i )
  1002. {
  1003. ((Account)list[i]).SetUnspecifiedBan( from );
  1004. ((Account)list[i]).Banned = true;
  1005. }
  1006. notice = "All addresses in the list have been banned.";
  1007. }
  1008. else
  1009. {
  1010. notice = "You have chosen not to ban all shared accounts.";
  1011. }
  1012. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, notice, state ) );
  1013. if ( okay )
  1014. from.SendGump( new BanDurationGump( list ) );
  1015. }
  1016. public static void AccountDelete_Callback( Mobile from, bool okay, object state )
  1017. {
  1018. if ( from.AccessLevel < AccessLevel.Administrator )
  1019. return;
  1020. if ( okay )
  1021. {
  1022. Account a = (Account)state;
  1023. a.Delete();
  1024. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, null, String.Format( "{0} : The account has been deleted.", a.Username ), null ) );
  1025. }
  1026. else
  1027. {
  1028. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "You have chosen not to delete the account.", state ) );
  1029. }
  1030. }
  1031. public static void ResendGump_Callback( Mobile from, object state )
  1032. {
  1033. if ( from.AccessLevel < AccessLevel.Administrator )
  1034. return;
  1035. object[] states = (object[])state;
  1036. ArrayList list = (ArrayList)states[0];
  1037. ArrayList rads = (ArrayList)states[1];
  1038. int page = (int)states[2];
  1039. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, page, list, null, rads ) );
  1040. }
  1041. public static void Marked_Callback( Mobile from, bool okay, object state )
  1042. {
  1043. if ( from.AccessLevel < AccessLevel.Administrator )
  1044. return;
  1045. object[] states = (object[])state;
  1046. bool ban = (bool)states[0];
  1047. ArrayList list = (ArrayList)states[1];
  1048. ArrayList rads = (ArrayList)states[2];
  1049. int page = (int)states[3];
  1050. if ( okay )
  1051. {
  1052. for ( int i = 0; i < rads.Count; ++i )
  1053. {
  1054. Account acct = (Account)rads[i];
  1055. if ( ban )
  1056. {
  1057. acct.SetUnspecifiedBan( from );
  1058. acct.Banned = true;
  1059. }
  1060. else
  1061. {
  1062. acct.Delete();
  1063. rads.RemoveAt( i-- );
  1064. list.Remove( acct );
  1065. }
  1066. }
  1067. from.SendGump( new NoticeGump( 1060637, 30720, String.Format( "You have {0} the account{1}.", ban ? "banned" : "deleted", rads.Count == 1 ? "" : "s" ), 0xFFC000, 420, 280, new NoticeGumpCallback( ResendGump_Callback ), new object[]{ list, rads, ban ? page : 0 } ) );
  1068. if ( ban )
  1069. from.SendGump( new BanDurationGump( list ) );
  1070. }
  1071. else
  1072. {
  1073. from.SendGump( new NoticeGump( 1060637, 30720, String.Format( "You have chosen not to {0} the account{1}.", ban ? "ban" : "delete", rads.Count == 1 ? "" : "s" ), 0xFFC000, 420, 280, new NoticeGumpCallback( ResendGump_Callback ), new object[]{ list, rads, page } ) );
  1074. }
  1075. }
  1076. public static void FirewallShared_Callback( Mobile from, bool okay, object state )
  1077. {
  1078. if ( from.AccessLevel < AccessLevel.Administrator )
  1079. return;
  1080. string notice;
  1081. if ( okay )
  1082. {
  1083. Account a = (Account)state;
  1084. for ( int i = 0; i < a.LoginIPs.Length; ++i )
  1085. Firewall.Add( a.LoginIPs[i] );
  1086. notice = "All addresses in the list have been firewalled.";
  1087. }
  1088. else
  1089. {
  1090. notice = "You have chosen not to firewall all addresses.";
  1091. }
  1092. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, notice, state ) );
  1093. }
  1094. public static void Firewall_Callback( Mobile from, bool okay, object state )
  1095. {
  1096. if ( from.AccessLevel < AccessLevel.Administrator )
  1097. return;
  1098. object[] states = (object[])state;
  1099. Account a = (Account)states[0];
  1100. object toFirewall = states[1];
  1101. string notice;
  1102. if ( okay )
  1103. {
  1104. Firewall.Add( toFirewall );
  1105. notice = String.Format( "{0} : Added to firewall.", toFirewall );
  1106. }
  1107. else
  1108. {
  1109. notice = "You have chosen not to firewall the address.";
  1110. }
  1111. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, notice, a ) );
  1112. }
  1113. public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
  1114. {
  1115. int val = info.ButtonID - 1;
  1116. if ( val < 0 )
  1117. return;
  1118. Mobile from = m_From;
  1119. if ( from.AccessLevel < AccessLevel.Administrator )
  1120. return;
  1121. if ( m_PageType == AdminGumpPage.Accounts )
  1122. {
  1123. ArrayList list = m_List;
  1124. ArrayList rads = m_State as ArrayList;
  1125. if ( list != null && rads != null )
  1126. {
  1127. for ( int i = 0, v = m_ListPage*12; i < 12 && v < list.Count; ++i, ++v )
  1128. {
  1129. object obj = list[v];
  1130. if ( info.IsSwitched( v ) )
  1131. {
  1132. if ( !rads.Contains( obj ) )
  1133. rads.Add( obj );
  1134. }
  1135. else if ( rads.Contains( obj ) )
  1136. {
  1137. rads.Remove( obj );
  1138. }
  1139. }
  1140. }
  1141. }
  1142. int type = val % 10;
  1143. int index = val / 10;
  1144. switch ( type )
  1145. {
  1146. case 0:
  1147. {
  1148. AdminGumpPage page;
  1149. switch ( index )
  1150. {
  1151. case 0: page = AdminGumpPage.Information; break;
  1152. case 1: page = AdminGumpPage.Administer; break;
  1153. case 2: page = AdminGumpPage.Clients; break;
  1154. case 3: page = AdminGumpPage.Accounts; break;
  1155. case 4: page = AdminGumpPage.Firewall; break;
  1156. default: return;
  1157. }
  1158. from.SendGump( new AdminGump( from, page, 0, null, null, null ) );
  1159. break;
  1160. }
  1161. case 1:
  1162. {
  1163. switch ( index )
  1164. {
  1165. case 0:
  1166. {
  1167. if ( m_List != null && m_ListPage > 0 )
  1168. from.SendGump( new AdminGump( from, m_PageType, m_ListPage - 1, m_List, null, m_State ) );
  1169. break;
  1170. }
  1171. case 1:
  1172. {
  1173. if ( m_List != null /*&& (m_ListPage + 1) * 12 < m_List.Count*/ )
  1174. from.SendGump( new AdminGump( from, m_PageType, m_ListPage + 1, m_List, null, m_State ) );
  1175. break;
  1176. }
  1177. }
  1178. break;
  1179. }
  1180. case 3:
  1181. {
  1182. string notice = null;
  1183. AdminGumpPage page = AdminGumpPage.Administer;
  1184. if ( index >= 500 )
  1185. page = AdminGumpPage.Administer_Access_Lockdown;
  1186. else if ( index >= 400 )
  1187. page = AdminGumpPage.Administer_Commands;
  1188. else if ( index >= 300 )
  1189. page = AdminGumpPage.Administer_Access;
  1190. else if ( index >= 200 )
  1191. page = AdminGumpPage.Administer_Server;
  1192. else if ( index >= 100 )
  1193. page = AdminGumpPage.Administer_WorldBuilding;
  1194. switch ( index )
  1195. {
  1196. case 0: page = AdminGumpPage.Administer_WorldBu

Large files files are truncated, but you can click here to view the full file