PageRenderTime 34ms CodeModel.GetById 17ms RepoModel.GetById 0ms 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
  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_WorldBuilding; break;
  1197. case 1: page = AdminGumpPage.Administer_Server; break;
  1198. case 2: page = AdminGumpPage.Administer_Access; break;
  1199. case 3: page = AdminGumpPage.Administer_Commands; break;
  1200. case 100: InvokeCommand( "DocGen" ); notice = "Documentation has been generated."; break;
  1201. case 101: InvokeCommand( "TelGen" ); notice = "Teleporters have been generated."; break;
  1202. case 102: InvokeCommand( "MoonGen" ); notice = "Moongates have been generated."; break;
  1203. case 103: InvokeCommand( "UOAMVendors" ); notice = "Vendor spawners have been generated."; break;
  1204. case 104: InvokeCommand( "DoorGen" ); notice = "Doors have been generated."; break;
  1205. case 105: InvokeCommand( "SignGen" ); notice = "Signs have been generated."; break;
  1206. case 106: InvokeCommand( "Decorate" ); notice = "Decoration has been generated."; break;
  1207. case 107: InvokeCommand( "RebuildCategorization" ); notice = "Categorization menu has been regenerated. The server should be restarted."; break;
  1208. case 110: InvokeCommand( "Freeze" ); notice = "Target bounding points."; break;
  1209. case 120: InvokeCommand( "Unfreeze" ); notice = "Target bounding points."; break;
  1210. case 200: InvokeCommand( "Save" ); notice = "The world has been saved."; break;
  1211. case 201: Shutdown( false, true ); break;
  1212. case 202: Shutdown( false, false ); break;
  1213. case 203: Shutdown( true, true ); break;
  1214. case 204: Shutdown( true, false ); break;
  1215. case 210:
  1216. case 211:
  1217. {
  1218. TextRelay relay = info.GetTextEntry( 0 );
  1219. string text = ( relay == null ? null : relay.Text.Trim() );
  1220. if ( text == null || text.Length == 0 )
  1221. {
  1222. notice = "You must enter text to broadcast it.";
  1223. }
  1224. else
  1225. {
  1226. notice = "Your message has been broadcasted.";
  1227. InvokeCommand( String.Format( "{0} {1}", index == 210 ? "BC" : "SM", text ) );
  1228. }
  1229. break;
  1230. }
  1231. case 300: InvokeCommand( "Kick" ); notice = "Target the player to kick."; break;
  1232. case 301: InvokeCommand( "Ban" ); notice = "Target the player to ban."; break;
  1233. case 302: InvokeCommand( "Firewall" ); notice = "Target the player to firewall."; break;
  1234. case 303: page = AdminGumpPage.Administer_Access_Lockdown; break;
  1235. case 310: InvokeCommand( "Set AccessLevel Player" ); notice = "Target the player to change their access level. (Player)"; break;
  1236. case 311: InvokeCommand( "Set AccessLevel Counselor" ); notice = "Target the player to change their access level. (Counselor)"; break;
  1237. case 312: InvokeCommand( "Set AccessLevel GameMaster" ); notice = "Target the player to change their access level. (Game Master)"; break;
  1238. case 313: InvokeCommand( "Set AccessLevel Seer" ); notice = "Target the player to change their access level. (Seer)"; break;
  1239. case 314: InvokeCommand( "Set AccessLevel Administrator" ); notice = "Target the player to change their access level. (Administrator)"; break;
  1240. case 400: notice = "Enter search terms to add objects."; break;
  1241. case 401: InvokeCommand( "Remove" ); notice = "Target the item or mobile to remove."; break;
  1242. case 402: InvokeCommand( "Dupe" ); notice = "Target the item to dupe."; break;
  1243. case 403: InvokeCommand( "DupeInBag" ); notice = "Target the item to dupe. The item will be duped at it's current location."; break;
  1244. case 404: InvokeCommand( "Props" ); notice = "Target the item or mobile to inspect."; break;
  1245. case 405: InvokeCommand( "Skills" ); notice = "Target a mobile to view their skills."; break;
  1246. case 406: InvokeCommand( "Set Blessed False" ); notice = "Target the mobile to make mortal."; break;
  1247. case 407: InvokeCommand( "Set Blessed True" ); notice = "Target the mobile to make immortal."; break;
  1248. case 408: InvokeCommand( "Set Squelched True" ); notice = "Target the mobile to squelch."; break;
  1249. case 409: InvokeCommand( "Set Squelched False" ); notice = "Target the mobile to unsquelch."; break;
  1250. case 410: InvokeCommand( "Set Frozen True" ); notice = "Target the mobile to freeze."; break;
  1251. case 411: InvokeCommand( "Set Frozen False" ); notice = "Target the mobile to unfreeze."; break;
  1252. case 412: InvokeCommand( "Set Hidden True" ); notice = "Target the mobile to hide."; break;
  1253. case 413: InvokeCommand( "Set Hidden False" ); notice = "Target the mobile to unhide."; break;
  1254. case 414: InvokeCommand( "Kill" ); notice = "Target the mobile to kill."; break;
  1255. case 415: InvokeCommand( "Resurrect" ); notice = "Target the mobile to resurrect."; break;
  1256. case 416: InvokeCommand( "Move" ); notice = "Target the item or mobile to move."; break;
  1257. case 417: InvokeCommand( "Wipe" ); notice = "Target bounding points."; break;
  1258. case 418: InvokeCommand( "Tele" ); notice = "Choose your destination."; break;
  1259. case 419: InvokeCommand( "Multi Tele" ); notice = "Choose your destination."; break;
  1260. case 500:
  1261. case 501:
  1262. case 502:
  1263. case 503:
  1264. case 504:
  1265. {
  1266. Misc.AccountHandler.LockdownLevel = (AccessLevel)(index - 500);
  1267. if ( Misc.AccountHandler.LockdownLevel > AccessLevel.Player )
  1268. notice = "The lockdown level has been changed.";
  1269. else
  1270. notice = "The server is now accessible to everyone.";
  1271. break;
  1272. }
  1273. case 510:
  1274. {
  1275. AccessLevel level = Misc.AccountHandler.LockdownLevel;
  1276. if ( level > AccessLevel.Player )
  1277. {
  1278. int count = 0;
  1279. foreach (NetState ns in NetState.Instances)
  1280. {
  1281. Account a = ns.Account as Account;
  1282. if ( a == null )
  1283. continue;
  1284. bool hasAccess = false;
  1285. if ( a.AccessLevel >= level )
  1286. {
  1287. hasAccess = true;
  1288. }
  1289. else
  1290. {
  1291. for ( int j = 0; !hasAccess && j < 5; ++j )
  1292. {
  1293. Mobile m = (Mobile)a[j];
  1294. if ( m != null && m.AccessLevel >= level )
  1295. hasAccess = true;
  1296. }
  1297. }
  1298. if ( !hasAccess )
  1299. {
  1300. ns.Dispose();
  1301. ++count;
  1302. }
  1303. }
  1304. if ( count == 0 )
  1305. notice = "Nobody without access was found to disconnect.";
  1306. else
  1307. notice = String.Format( "Number of players disconnected: {0}", count );
  1308. }
  1309. else
  1310. {
  1311. notice = "The server is not currently locked down.";
  1312. }
  1313. break;
  1314. }
  1315. }
  1316. from.SendGump( new AdminGump( from, page, 0, null, notice, null ) );
  1317. switch ( index )
  1318. {
  1319. case 400: InvokeCommand( "Add" ); break;
  1320. case 111: InvokeCommand( "FreezeWorld" ); break;
  1321. case 112: InvokeCommand( "FreezeMap" ); break;
  1322. case 121: InvokeCommand( "UnfreezeWorld" ); break;
  1323. case 122: InvokeCommand( "UnfreezeMap" ); break;
  1324. }
  1325. break;
  1326. }
  1327. case 4:
  1328. {
  1329. switch ( index )
  1330. {
  1331. case 0:
  1332. case 1:
  1333. {
  1334. bool forName = ( index == 0 );
  1335. ArrayList results = new ArrayList();
  1336. TextRelay matchEntry = info.GetTextEntry( 0 );
  1337. string match = ( matchEntry == null ? null : matchEntry.Text.Trim().ToLower() );
  1338. string notice = null;
  1339. if ( match == null || match.Length == 0 )
  1340. {
  1341. notice = String.Format( "You must enter {0} to search.", forName ? "a name" : "an ip address" );
  1342. }
  1343. else
  1344. {
  1345. foreach (NetState ns in NetState.Instances)
  1346. {
  1347. bool isMatch;
  1348. if ( forName )
  1349. {
  1350. Mobile m = ns.Mobile;
  1351. Account a = ns.Account as Account;
  1352. RacePlayerMobile pm = (RacePlayerMobile)m;
  1353. isMatch = ( m != null && pm.PlayerName.ToLower().IndexOf( match ) >= 0 )
  1354. || ( a != null && a.Username.ToLower().IndexOf( match ) >= 0 );
  1355. }
  1356. else
  1357. {
  1358. isMatch = ( ns.ToString().IndexOf( match ) >= 0 );
  1359. }
  1360. if ( isMatch )
  1361. results.Add( ns );
  1362. }
  1363. results.Sort( NetStateComparer.Instance );
  1364. }
  1365. if ( results.Count == 1 )
  1366. {
  1367. NetState ns = (NetState)results[0];
  1368. object state = ns.Mobile;
  1369. if ( state == null )
  1370. state = ns.Account;
  1371. if ( state is Mobile )
  1372. from.SendGump( new AdminGump( from, AdminGumpPage.ClientInfo, 0, null, "One match found.", state ) );
  1373. else if ( state is Account )
  1374. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "One match found.", state ) );
  1375. else
  1376. from.SendGump( new AdminGump( from, AdminGumpPage.Clients, 0, results, "One match found.", null ) );
  1377. }
  1378. else
  1379. {
  1380. from.SendGump( new AdminGump( from, AdminGumpPage.Clients, 0, results, notice == null ? (results.Count == 0 ? "Nothing matched your search terms." : null) : notice, null ) );
  1381. }
  1382. break;
  1383. }
  1384. default:
  1385. {
  1386. index -= 2;
  1387. if ( m_List != null && index >= 0 && index < m_List.Count )
  1388. {
  1389. NetState ns = m_List[index] as NetState;
  1390. if ( ns == null )
  1391. break;
  1392. Mobile m = ns.Mobile;
  1393. Account a = ns.Account as Account;
  1394. if ( m != null )
  1395. from.SendGump( new AdminGump( from, AdminGumpPage.ClientInfo, 0, null, null, m ) );
  1396. else if ( a != null )
  1397. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, null, a ) );
  1398. }
  1399. break;
  1400. }
  1401. }
  1402. break;
  1403. }
  1404. case 5:
  1405. {
  1406. switch ( index )
  1407. {
  1408. case 0: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, null, m_State ) ); break;
  1409. case 1: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Characters, 0, null, null, m_State ) ); break;
  1410. case 2: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Comments, 0, null, null, m_State ) ); break;
  1411. case 3: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Tags, 0, null, null, m_State ) ); break;
  1412. case 13: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access, 0, null, null, m_State ) ); break;
  1413. case 14: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, null, m_State ) ); break;
  1414. case 15: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, null, m_State ) ); break;
  1415. case 4: from.Prompt = new AddCommentPrompt( m_State as Account ); from.SendMessage( "Enter the new account comment." ); break;
  1416. case 5: from.Prompt = new AddTagNamePrompt( m_State as Account ); from.SendMessage( "Enter the new tag name." ); break;
  1417. case 6:
  1418. {
  1419. TextRelay unEntry = info.GetTextEntry( 0 );
  1420. TextRelay pwEntry = info.GetTextEntry( 1 );
  1421. string un = ( unEntry == null ? null : unEntry.Text.Trim() );
  1422. string pw = ( pwEntry == null ? null : pwEntry.Text.Trim() );
  1423. Account dispAccount = null;
  1424. string notice;
  1425. if ( un == null || un.Length == 0 )
  1426. {
  1427. notice = "You must enter a username to add an account.";
  1428. }
  1429. else if ( pw == null || pw.Length == 0 )
  1430. {
  1431. notice = "You must enter a password to add an account.";
  1432. }
  1433. else
  1434. {
  1435. Account account = Accounts.GetAccount( un );
  1436. if ( account != null )
  1437. {
  1438. notice = "There is already an account with that username.";
  1439. }
  1440. else
  1441. {
  1442. dispAccount = Accounts.AddAccount( un, pw );
  1443. notice = String.Format( "{0} : Account added.", un );
  1444. CommandLogging.WriteLine( from, "{0} {1} adding new account: {2}", from.AccessLevel, CommandLogging.Format( from ), un );
  1445. }
  1446. }
  1447. from.SendGump( new AdminGump( from, dispAccount != null ? AdminGumpPage.AccountDetails_Information : m_PageType, m_ListPage, m_List, notice, dispAccount != null ? dispAccount : m_State ) );
  1448. break;
  1449. }
  1450. case 7:
  1451. {
  1452. ArrayList results = new ArrayList();
  1453. TextRelay matchEntry = info.GetTextEntry( 0 );
  1454. string match = ( matchEntry == null ? null : matchEntry.Text.Trim().ToLower() );
  1455. string notice = null;
  1456. if ( match == null || match.Length == 0 )
  1457. {
  1458. notice = "You must enter a username to search.";
  1459. }
  1460. else
  1461. {
  1462. foreach ( Account check in Accounts.Table.Values )
  1463. {
  1464. if ( check.Username.ToLower().IndexOf( match ) >= 0 )
  1465. results.Add( check );
  1466. }
  1467. results.Sort( AccountComparer.Instance );
  1468. }
  1469. if ( results.Count == 1 )
  1470. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "One match found.", results[0] ) );
  1471. else
  1472. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, results, notice == null ? (results.Count == 0 ? "Nothing matched your search terms." : null) : notice, new ArrayList() ) );
  1473. break;
  1474. }
  1475. case 8: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_ChangePassword, 0, null, null, m_State ) ); break;
  1476. case 9: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_ChangeAccess, 0, null, null, m_State ) ); break;
  1477. case 10: case 11:
  1478. {
  1479. Account a = m_State as Account;
  1480. if ( a == null )
  1481. break;
  1482. a.SetUnspecifiedBan( from );
  1483. a.Banned = ( index == 10 );
  1484. CommandLogging.WriteLine( from, "{0} {1} {3} account {2}", from.AccessLevel, CommandLogging.Format( from ), a.Username, a.Banned ? "banning" : "unbanning" );
  1485. from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, String.Format( "The account has been {0}.", a.Banned ? "banned" : "unbanned" ), m_State ) );
  1486. if ( index == 10 )
  1487. from.SendGump( new BanDurationGump( a ) );
  1488. break;
  1489. }
  1490. case 12:
  1491. {
  1492. Account a = m_State as Account;
  1493. if ( a == null )
  1494. break;
  1495. TextRelay passwordEntry = info.GetTextEntry( 0 );
  1496. TextRelay confirmEntry = info.GetTextEntry( 1 );
  1497. string password = ( passwordEntry == null ? null : passwordEntry.Text.Trim() );
  1498. string confirm = ( confirmEntry == null ? null : confirmEntry.Text.Trim() );
  1499. string notice;
  1500. AdminGumpPage page = AdminGumpPage.AccountDetails_ChangePassword;
  1501. if ( password == null || password.Length == 0 )
  1502. {
  1503. notice = "You must enter the password.";
  1504. }
  1505. else if ( confirm != password )
  1506. {
  1507. notice = "You must confirm the password. That field must precisely match the password field.";
  1508. }
  1509. else
  1510. {
  1511. notice = "The password has been changed.";
  1512. a.SetPassword( password );
  1513. page = AdminGumpPage.AccountDetails_Information;
  1514. CommandLogging.WriteLine( from, "{0} {1} changing password of account {2}", from.AccessLevel, CommandLogging.Format( from ), a.Username );
  1515. }
  1516. from.SendGump( new AdminGump( from, page, 0, null, notice, m_State ) );
  1517. break;
  1518. }
  1519. case 16: // view shared
  1520. {
  1521. Account a = m_State as Account;
  1522. if ( a == null )
  1523. break;
  1524. ArrayList list = GetSharedAccounts( a.LoginIPs );
  1525. if ( list.Count > 1 || (list.Count == 1 && !list.Contains( a )) )
  1526. {
  1527. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, list, null, new ArrayList() ) );
  1528. }
  1529. else if ( a.LoginIPs.Length > 0 )
  1530. {
  1531. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "There are no other accounts which share an address with this one.", m_State ) );
  1532. }
  1533. else
  1534. {
  1535. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "This account has not yet been accessed.", m_State ) );
  1536. }
  1537. break;
  1538. }
  1539. case 17: // ban shared
  1540. {
  1541. Account a = m_State as Account;
  1542. if ( a == null )
  1543. break;
  1544. ArrayList list = GetSharedAccounts( a.LoginIPs );
  1545. if ( list.Count > 0 )
  1546. {
  1547. StringBuilder sb = new StringBuilder();
  1548. sb.AppendFormat( "You are about to ban {0} account{1}. Do you wish to continue?", list.Count, list.Count != 1 ? "s" : "" );
  1549. for ( int i = 0; i < list.Count; ++i )
  1550. sb.AppendFormat( "<br>- {0}", ((Account)list[i]).Username );
  1551. from.SendGump( new WarningGump( 1060635, 30720, sb.ToString(), 0xFFC000, 420, 400, new WarningGumpCallback( BanShared_Callback ), a ) );
  1552. }
  1553. else if ( a.LoginIPs.Length > 0 )
  1554. {
  1555. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "There are no accounts which share an address with this one.", m_State ) );
  1556. }
  1557. else
  1558. {
  1559. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "This account has not yet been accessed.", m_State ) );
  1560. }
  1561. break;
  1562. }
  1563. case 18: // firewall all
  1564. {
  1565. Account a = m_State as Account;
  1566. if ( a == null )
  1567. break;
  1568. if ( a.LoginIPs.Length > 0 )
  1569. {
  1570. from.SendGump( new WarningGump( 1060635, 30720, String.Format( "You are about to firewall {0} address{1}. Do you wish to continue?", a.LoginIPs.Length, a.LoginIPs.Length != 1 ? "s" : "" ), 0xFFC000, 420, 400, new WarningGumpCallback( FirewallShared_Callback ), a ) );
  1571. }
  1572. else
  1573. {
  1574. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "This account has not yet been accessed.", m_State ) );
  1575. }
  1576. break;
  1577. }
  1578. case 19: // add
  1579. {
  1580. Account a = m_State as Account;
  1581. if ( a == null )
  1582. break;
  1583. TextRelay entry = info.GetTextEntry( 0 );
  1584. string ip = ( entry == null ? null : entry.Text.Trim() );
  1585. string notice;
  1586. if ( ip == null || ip.Length == 0 )
  1587. {
  1588. notice = "You must enter an address to add.";
  1589. }
  1590. else
  1591. {
  1592. string[] list = a.IPRestrictions;
  1593. bool contains = false;
  1594. for ( int i = 0; !contains && i < list.Length; ++i )
  1595. contains = ( list[i] == ip );
  1596. if ( contains )
  1597. {
  1598. notice = "That address is already contained in the list.";
  1599. }
  1600. else
  1601. {
  1602. string[] newList = new string[list.Length + 1];
  1603. for ( int i = 0; i < list.Length; ++i )
  1604. newList[i] = list[i];
  1605. newList[list.Length] = ip;
  1606. a.IPRestrictions = newList;
  1607. notice = String.Format( "{0} : Added to restriction list.", ip );
  1608. }
  1609. }
  1610. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, notice, m_State ) );
  1611. break;
  1612. }
  1613. case 20:
  1614. case 21:
  1615. case 22:
  1616. case 23:
  1617. case 24:
  1618. {
  1619. Account a = m_State as Account;
  1620. if ( a == null )
  1621. break;
  1622. AccessLevel newLevel;
  1623. switch ( index )
  1624. {
  1625. default:
  1626. case 20: newLevel = AccessLevel.Player; break;
  1627. case 21: newLevel = AccessLevel.Counselor; break;
  1628. case 22: newLevel = AccessLevel.GameMaster; break;
  1629. case 23: newLevel = AccessLevel.Seer; break;
  1630. case 24: newLevel = AccessLevel.Administrator; break;
  1631. }
  1632. a.AccessLevel = newLevel;
  1633. CommandLogging.WriteLine( from, "{0} {1} changing access level of account {2} to {3}", from.AccessLevel, CommandLogging.Format( from ), a.Username, a.AccessLevel );
  1634. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "The access level has been changed.", m_State ) );
  1635. break;
  1636. }
  1637. case 25:
  1638. {
  1639. Account a = m_State as Account;
  1640. if ( a == null )
  1641. break;
  1642. from.SendGump( new WarningGump( 1060635, 30720, String.Format( "<center>Account of {0}</center><br>You are about to <em><basefont color=red>permanently delete</basefont></em> the account. Likewise, all characters on the account will be deleted, including equiped, inventory, and banked items. Any houses tied to the account will be demolished.<br><br>Do you wish to continue?", a.Username ), 0xFFC000, 420, 280, new WarningGumpCallback( AccountDelete_Callback ), m_State ) );
  1643. break;
  1644. }
  1645. case 26: // View all shared accounts
  1646. {
  1647. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts_Shared, 0, null, null, null ) );
  1648. break;
  1649. }
  1650. case 27: // Ban marked
  1651. {
  1652. ArrayList list = m_List;
  1653. ArrayList rads = m_State as ArrayList;
  1654. if ( list == null || rads == null )
  1655. break;
  1656. if ( rads.Count > 0 )
  1657. from.SendGump( new WarningGump( 1060635, 30720, String.Format( "You are about to ban {0} marked account{1}. Be cautioned, the only way to reverse this is by hand--manually unbanning each account.<br><br>Do you wish to continue?", rads.Count, rads.Count == 1 ? "" : "s" ), 0xFFC000, 420, 280, new WarningGumpCallback( Marked_Callback ), new object[]{ true, list, rads, m_ListPage } ) );
  1658. else
  1659. from.SendGump( new NoticeGump( 1060637, 30720, "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", 0xFFC000, 420, 280, new NoticeGumpCallback( ResendGump_Callback ), new object[]{ list, rads, m_ListPage } ) );
  1660. break;
  1661. }
  1662. case 28: // Delete marked
  1663. {
  1664. ArrayList list = m_List;
  1665. ArrayList rads = m_State as ArrayList;
  1666. if ( list == null || rads == null )
  1667. break;
  1668. if ( rads.Count > 0 )
  1669. from.SendGump( new WarningGump( 1060635, 30720, String.Format( "You are about to <em><basefont color=red>permanently delete</basefont></em> {0} marked account{1}. Likewise, all characters on the account{1} will be deleted, including equiped, inventory, and banked items. Any houses tied to the account{1} will be demolished.<br><br>Do you wish to continue?", rads.Count, rads.Count == 1 ? "" : "s" ), 0xFFC000, 420, 280, new WarningGumpCallback( Marked_Callback ), new object[]{ false, list, rads, m_ListPage } ) );
  1670. else
  1671. from.SendGump( new NoticeGump( 1060637, 30720, "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", 0xFFC000, 420, 280, new NoticeGumpCallback( ResendGump_Callback ), new object[]{ list, rads, m_ListPage } ) );
  1672. break;
  1673. }
  1674. case 29: // Mark all
  1675. {
  1676. ArrayList list = m_List;
  1677. ArrayList rads = m_State as ArrayList;
  1678. if ( list == null || rads == null )
  1679. break;
  1680. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, m_ListPage, m_List, null, new ArrayList( list ) ) );
  1681. break;
  1682. }
  1683. case 30: // View all empty accounts
  1684. {
  1685. ArrayList results = new ArrayList();
  1686. foreach ( Account acct in Accounts.Table.Values )
  1687. {
  1688. bool empty = true;
  1689. for ( int i = 0; empty && i < 5; ++i )
  1690. empty = ( acct[i] == null );
  1691. if ( empty )
  1692. results.Add( acct );
  1693. }
  1694. if ( results.Count == 1 )
  1695. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "One match found.", results[0] ) );
  1696. else
  1697. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, results, (results.Count == 0 ? "Nothing matched your search terms." : null), new ArrayList() ) );
  1698. break;
  1699. }
  1700. case 31: // View all inactive accounts
  1701. {
  1702. ArrayList results = new ArrayList();
  1703. DateTime minTime = DateTime.Now - TimeSpan.FromDays( 30.0 );
  1704. foreach ( Account acct in Accounts.Table.Values )
  1705. {
  1706. if ( acct.LastLogin <= minTime )
  1707. results.Add( acct );
  1708. }
  1709. if ( results.Count == 1 )
  1710. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "One match found.", results[0] ) );
  1711. else
  1712. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, results, (results.Count == 0 ? "Nothing matched your search terms." : null), new ArrayList() ) );
  1713. break;
  1714. }
  1715. case 32: // View all banned accounts
  1716. {
  1717. ArrayList results = new ArrayList();
  1718. foreach ( Account acct in Accounts.Table.Values )
  1719. {
  1720. if ( acct.Banned )
  1721. results.Add( acct );
  1722. }
  1723. if ( results.Count == 1 )
  1724. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, "One match found.", results[0] ) );
  1725. else
  1726. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, results, (results.Count == 0 ? "Nothing matched your search terms." : null), new ArrayList() ) );
  1727. break;
  1728. }
  1729. default:
  1730. {
  1731. index -= 50;
  1732. if ( index >= 0 && index < 5 )
  1733. {
  1734. Account a = m_State as Account;
  1735. if ( a == null )
  1736. break;
  1737. Mobile m = a[index];
  1738. if ( m != null )
  1739. from.SendGump( new AdminGump( from, AdminGumpPage.ClientInfo, 0, null, null, m ) );
  1740. }
  1741. else
  1742. {
  1743. index -= 5;
  1744. if ( m_List != null && index >= 0 && index < m_List.Count )
  1745. {
  1746. if ( m_List[index] is Account )
  1747. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, null, m_List[index] ) );
  1748. else if ( m_List[index] is DictionaryEntry )
  1749. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, (ArrayList)(((DictionaryEntry)m_List[index]).Value), null, new ArrayList() ) );
  1750. }
  1751. }
  1752. break;
  1753. }
  1754. }
  1755. break;
  1756. }
  1757. case 6:
  1758. {
  1759. switch ( index )
  1760. {
  1761. case 0:
  1762. {
  1763. TextRelay matchEntry = info.GetTextEntry( 0 );
  1764. string match = ( matchEntry == null ? null : matchEntry.Text.Trim() );
  1765. string notice = null;
  1766. ArrayList results = new ArrayList();
  1767. if ( match == null || match.Length == 0 )
  1768. {
  1769. notice = "You must enter a username to search.";
  1770. }
  1771. else
  1772. {
  1773. for ( int i = 0; i < Firewall.List.Count; ++i )
  1774. {
  1775. string check = Firewall.List[i].ToString();
  1776. if ( check.IndexOf( match ) >= 0 )
  1777. results.Add( Firewall.List[i] );
  1778. }
  1779. }
  1780. if ( results.Count == 1 )
  1781. from.SendGump( new AdminGump( from, AdminGumpPage.FirewallInfo, 0, null, "One match found.", results[0] ) );
  1782. else if ( results.Count > 1 )
  1783. from.SendGump( new AdminGump( from, AdminGumpPage.Firewall, 0, results, String.Format( "Search results for : {0}", match ), m_State ) );
  1784. else
  1785. from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, notice == null ? "Nothing matched your search terms." : notice, m_State ) );
  1786. break;
  1787. }
  1788. case 1:
  1789. {
  1790. TextRelay relay = info.GetTextEntry( 0 );
  1791. string text = ( relay == null ? null : relay.Text.Trim() );
  1792. if ( text == null || text.Length == 0 )
  1793. {
  1794. from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, "You must enter an address or pattern to add.", m_State ) );
  1795. }
  1796. else if ( !Utility.IsValidIP( text ) )
  1797. {
  1798. from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, "That is not a valid address or pattern.", m_State ) );
  1799. }
  1800. else
  1801. {
  1802. object toAdd;
  1803. try{ toAdd = IPAddress.Parse( text ); }
  1804. catch{ toAdd = text; }
  1805. CommandLogging.WriteLine( from, "{0} {1} firewalling {2}", from.AccessLevel, CommandLogging.Format( from ), toAdd );
  1806. Firewall.Add( toAdd );
  1807. from.SendGump( new AdminGump( from, AdminGumpPage.FirewallInfo, 0, null, String.Format( "{0} : Added to firewall.", toAdd ), toAdd ) );
  1808. }
  1809. break;
  1810. }
  1811. case 2:
  1812. {
  1813. InvokeCommand( "Firewall" );
  1814. from.SendGump( new AdminGump( from, m_PageType, m_ListPage, m_List, "Target the player to firewall.", m_State ) );
  1815. break;
  1816. }
  1817. case 3:
  1818. {
  1819. if ( m_State is IPAddress || m_State is String )
  1820. {
  1821. CommandLogging.WriteLine( from, "{0} {1} removing {2} from firewall list", from.AccessLevel, CommandLogging.Format( from ), m_State );
  1822. Firewall.List.Remove( m_State );
  1823. Firewall.Save();
  1824. from.SendGump( new AdminGump( from, AdminGumpPage.Firewall, 0, null, String.Format( "{0} : Removed from firewall.", m_State ), null ) );
  1825. }
  1826. break;
  1827. }
  1828. default:
  1829. {
  1830. index -= 4;
  1831. if ( m_List != null && index >= 0 && index < m_List.Count )
  1832. from.SendGump( new AdminGump( from, AdminGumpPage.FirewallInfo, 0, null, null, m_List[index] ) );
  1833. break;
  1834. }
  1835. }
  1836. break;
  1837. }
  1838. case 7:
  1839. {
  1840. Mobile m = m_State as Mobile;
  1841. if ( m == null )
  1842. break;
  1843. string notice = null;
  1844. bool sendGump = true;
  1845. switch ( index )
  1846. {
  1847. case 0:
  1848. {
  1849. Map map = m.Map;
  1850. Point3D loc = m.Location;
  1851. if ( map == null || map == Map.Internal )
  1852. {
  1853. map = m.LogoutMap;
  1854. loc = m.LogoutLocation;
  1855. }
  1856. if ( map != null && map != Map.Internal )
  1857. {
  1858. from.MoveToWorld( loc, map );
  1859. notice = "You have been teleported to their location.";
  1860. }
  1861. break;
  1862. }
  1863. case 1:
  1864. {
  1865. m.MoveToWorld( from.Location, from.Map );
  1866. notice = "They have been teleported to your location.";
  1867. break;
  1868. }
  1869. case 2:
  1870. {
  1871. NetState ns = m.NetState;
  1872. if ( ns != null )
  1873. {
  1874. CommandLogging.WriteLine( from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format( from ), "kicking", CommandLogging.Format( m ) );
  1875. ns.Dispose();
  1876. notice = "They have been kicked.";
  1877. }
  1878. else
  1879. {
  1880. notice = "They are already disconnected.";
  1881. }
  1882. break;
  1883. }
  1884. case 3:
  1885. {
  1886. Account a = m.Account as Account;
  1887. if ( a != null )
  1888. {
  1889. CommandLogging.WriteLine( from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format( from ), "banning", CommandLogging.Format( m ) );
  1890. a.Banned = true;
  1891. NetState ns = m.NetState;
  1892. if ( ns != null )
  1893. ns.Dispose();
  1894. notice = "They have been banned.";
  1895. }
  1896. break;
  1897. }
  1898. case 6:
  1899. {
  1900. Properties.SetValue( from, m, "Blessed", "False" );
  1901. notice = "They are now mortal.";
  1902. break;
  1903. }
  1904. case 7:
  1905. {
  1906. Properties.SetValue( from, m, "Blessed", "True" );
  1907. notice = "They are now immortal.";
  1908. break;
  1909. }
  1910. case 8:
  1911. {
  1912. Properties.SetValue( from, m, "Squelched", "True" );
  1913. notice = "They are now squelched.";
  1914. break;
  1915. }
  1916. case 9:
  1917. {
  1918. Properties.SetValue( from, m, "Squelched", "False" );
  1919. notice = "They are now unsquelched.";
  1920. break;
  1921. }
  1922. case 10:
  1923. {
  1924. Properties.SetValue( from, m, "Hidden", "True" );
  1925. notice = "They are now hidden.";
  1926. break;
  1927. }
  1928. case 11:
  1929. {
  1930. Properties.SetValue( from, m, "Hidden", "False" );
  1931. notice = "They are now unhidden.";
  1932. break;
  1933. }
  1934. case 12:
  1935. {
  1936. CommandLogging.WriteLine( from, "{0} {1} killing {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( m ) );
  1937. m.Kill();
  1938. notice = "They have been killed.";
  1939. break;
  1940. }
  1941. case 13:
  1942. {
  1943. CommandLogging.WriteLine( from, "{0} {1} resurrecting {2}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( m ) );
  1944. m.Resurrect();
  1945. notice = "They have been resurrected.";
  1946. break;
  1947. }
  1948. case 14:
  1949. {
  1950. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Information, 0, null, null, m.Account ) );
  1951. sendGump = false;
  1952. break;
  1953. }
  1954. }
  1955. if ( sendGump )
  1956. from.SendGump( new AdminGump( from, AdminGumpPage.ClientInfo, 0, null, notice, m_State ) );
  1957. switch ( index )
  1958. {
  1959. case 3:
  1960. {
  1961. Account a = m.Account as Account;
  1962. if ( a != null )
  1963. from.SendGump( new BanDurationGump( a ) );
  1964. break;
  1965. }
  1966. case 4:
  1967. {
  1968. from.SendGump( new APropertiesGump( from, m ) );
  1969. break;
  1970. }
  1971. case 5:
  1972. {
  1973. from.SendGump( new Server.Scripts.Gumps.SkillsGump( from, m ) );
  1974. break;
  1975. }
  1976. }
  1977. break;
  1978. }
  1979. case 8:
  1980. {
  1981. if ( m_List != null && index >= 0 && index < m_List.Count )
  1982. {
  1983. Account a = m_State as Account;
  1984. if ( a == null )
  1985. break;
  1986. if ( m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs )
  1987. {
  1988. from.SendGump( new WarningGump( 1060635, 30720, String.Format( "You are about to firewall {0}. All connection attempts from a matching IP will be refused. Are you sure?", m_List[index] ), 0xFFC000, 420, 280, new WarningGumpCallback( Firewall_Callback ), new object[]{ a, m_List[index] } ) );
  1989. }
  1990. else if ( m_PageType == AdminGumpPage.AccountDetails_Access_Restrictions )
  1991. {
  1992. ArrayList list = new ArrayList( a.IPRestrictions );
  1993. list.Remove( m_List[index] );
  1994. a.IPRestrictions = (string[])list.ToArray( typeof( string ) );
  1995. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, String.Format( "{0} : Removed from list.", m_List[index] ), a ) );
  1996. }
  1997. }
  1998. break;
  1999. }
  2000. case 9:
  2001. {
  2002. if ( m_List != null && index >= 0 && index < m_List.Count )
  2003. {
  2004. if ( m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs )
  2005. {
  2006. object obj = m_List[index];
  2007. if ( !(obj is IPAddress) )
  2008. break;
  2009. Account a = m_State as Account;
  2010. if ( a == null )
  2011. break;
  2012. ArrayList list = GetSharedAccounts( (IPAddress)obj );
  2013. if ( list.Count > 1 || (list.Count == 1 && !list.Contains( a )) )
  2014. from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, 0, list, null, new ArrayList() ) );
  2015. else
  2016. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, "There are no other accounts which share that address.", m_State ) );
  2017. }
  2018. }
  2019. break;
  2020. }
  2021. }
  2022. }
  2023. private void Shutdown( bool restart, bool save )
  2024. {
  2025. CommandLogging.WriteLine( m_From, "{0} {1} shuting down server (Restart: {2}) (Save: {3})", m_From.AccessLevel, CommandLogging.Format( m_From ), restart, save );
  2026. if ( save )
  2027. InvokeCommand( "Save" );
  2028. if ( restart )
  2029. Process.Start( Core.ExePath );
  2030. Core.Process.Kill();
  2031. }
  2032. private void InvokeCommand( string ip )
  2033. {
  2034. Commands.Handle( m_From, String.Format( "{0}{1}", Server.Commands.CommandPrefix, ip ) );
  2035. }
  2036. public static void GetAccountInfo( Account a, out AccessLevel accessLevel, out bool online )
  2037. {
  2038. accessLevel = a.AccessLevel;
  2039. online = false;
  2040. for ( int j = 0; j < 5; ++j )
  2041. {
  2042. Mobile check = a[j];
  2043. if ( check == null )
  2044. continue;
  2045. if ( check.AccessLevel > accessLevel )
  2046. accessLevel = check.AccessLevel;
  2047. if ( check.NetState != null )
  2048. online = true;
  2049. }
  2050. }
  2051. private class AddCommentPrompt : Prompt
  2052. {
  2053. private Account m_Account;
  2054. public AddCommentPrompt( Account acct )
  2055. {
  2056. m_Account = acct;
  2057. }
  2058. public override void OnCancel( Mobile from )
  2059. {
  2060. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Comments, 0, null, "Request to add comment was canceled.", m_Account ) );
  2061. }
  2062. public override void OnResponse( Mobile from, string text )
  2063. {
  2064. RacePlayerMobile pm = (RacePlayerMobile)from;
  2065. if ( m_Account != null )
  2066. {
  2067. m_Account.Comments.Add( new AccountComment( pm.PlayerName, text ) );
  2068. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Comments, 0, null, "Comment added.", m_Account ) );
  2069. }
  2070. }
  2071. }
  2072. private class AddTagNamePrompt : Prompt
  2073. {
  2074. private Account m_Account;
  2075. public AddTagNamePrompt( Account acct )
  2076. {
  2077. m_Account = acct;
  2078. }
  2079. public override void OnCancel( Mobile from )
  2080. {
  2081. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Tags, 0, null, "Request to add tag was canceled.", m_Account ) );
  2082. }
  2083. public override void OnResponse( Mobile from, string text )
  2084. {
  2085. from.Prompt = new AddTagValuePrompt( m_Account, text );
  2086. from.SendMessage( "Enter the new tag value." );
  2087. }
  2088. }
  2089. private class AddTagValuePrompt : Prompt
  2090. {
  2091. private Account m_Account;
  2092. private string m_Name;
  2093. public AddTagValuePrompt( Account acct, string name )
  2094. {
  2095. m_Account = acct;
  2096. m_Name = name;
  2097. }
  2098. public override void OnCancel( Mobile from )
  2099. {
  2100. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Tags, 0, null, "Request to add tag was canceled.", m_Account ) );
  2101. }
  2102. public override void OnResponse( Mobile from, string text )
  2103. {
  2104. if ( m_Account != null )
  2105. {
  2106. m_Account.AddTag( m_Name, text );
  2107. from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_Tags, 0, null, "Tag added.", m_Account ) );
  2108. }
  2109. }
  2110. }
  2111. private class NetStateComparer : IComparer
  2112. {
  2113. public static readonly IComparer Instance = new NetStateComparer();
  2114. public NetStateComparer()
  2115. {
  2116. }
  2117. public int Compare( object x, object y )
  2118. {
  2119. if ( x == null && y == null )
  2120. return 0;
  2121. else if ( x == null )
  2122. return -1;
  2123. else if ( y == null )
  2124. return 1;
  2125. NetState a = x as NetState;
  2126. NetState b = y as NetState;
  2127. if ( a == null || b == null )
  2128. throw new ArgumentException();
  2129. Mobile aMob = a.Mobile;
  2130. Mobile bMob = b.Mobile;
  2131. RacePlayerMobile pm = (RacePlayerMobile)aMob;
  2132. RacePlayerMobile lpm = (RacePlayerMobile)bMob;
  2133. if ( pm == null && lpm == null )
  2134. return 0;
  2135. else if ( pm == null )
  2136. return 1;
  2137. else if ( lpm == null )
  2138. return -1;
  2139. if ( pm.AccessLevel > lpm.AccessLevel )
  2140. return -1;
  2141. else if ( pm.AccessLevel < lpm.AccessLevel )
  2142. return 1;
  2143. else
  2144. return Insensitive.Compare( pm.PlayerName, lpm.PlayerName );
  2145. }
  2146. }
  2147. private class AccountComparer : IComparer
  2148. {
  2149. public static readonly IComparer Instance = new AccountComparer();
  2150. public AccountComparer()
  2151. {
  2152. }
  2153. public int Compare( object x, object y )
  2154. {
  2155. if ( x == null && y == null )
  2156. return 0;
  2157. else if ( x == null )
  2158. return -1;
  2159. else if ( y == null )
  2160. return 1;
  2161. Account a = x as Account;
  2162. Account b = y as Account;
  2163. if ( a == null || b == null )
  2164. throw new ArgumentException();
  2165. AccessLevel aLevel, bLevel;
  2166. bool aOnline, bOnline;
  2167. GetAccountInfo( a, out aLevel, out aOnline );
  2168. GetAccountInfo( b, out bLevel, out bOnline );
  2169. if ( aOnline && !bOnline )
  2170. return -1;
  2171. else if ( bOnline && !aOnline )
  2172. return 1;
  2173. else if ( aLevel > bLevel )
  2174. return -1;
  2175. else if ( aLevel < bLevel )
  2176. return 1;
  2177. else
  2178. return Insensitive.Compare( a.Username, b.Username );
  2179. }
  2180. }
  2181. }
  2182. }