using System; using System.IO; using System.Text; using Server; using Server.Network; using Server.Guilds; namespace Server.Misc { public class StatusPage : Timer { public static bool Enabled = false; public static void Initialize() { if ( Enabled ) new StatusPage().Start(); } public StatusPage() : base( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromSeconds( 60.0 ) ) { Priority = TimerPriority.FiveSeconds; } private static string Encode( string input ) { StringBuilder sb = new StringBuilder( input ); sb.Replace( "&", "&" ); sb.Replace( "<", "<" ); sb.Replace( ">", ">" ); sb.Replace( "\"", """ ); sb.Replace( "'", "'" ); return sb.ToString(); } protected override void OnTick() { if ( !Directory.Exists( "web" ) ) Directory.CreateDirectory( "web" ); using ( StreamWriter op = new StreamWriter( "web/status.html" ) ) { op.WriteLine( "" ); op.WriteLine( "
" ); op.WriteLine( "| Name | Location | Kills | Karma / Fame | " ); op.WriteLine( "
| " ); if ( g != null ) { op.Write( Encode( m.Name ) ); op.Write( " [" ); string title = m.GuildTitle; if ( title != null ) title = title.Trim(); else title = ""; if ( title.Length > 0 ) { op.Write( Encode( title ) ); op.Write( ", " ); } op.Write( Encode( g.Abbreviation ) ); op.Write( ']' ); } else { op.Write( Encode( m.Name ) ); } op.Write( " | " ); op.Write( m.X ); op.Write( ", " ); op.Write( m.Y ); op.Write( ", " ); op.Write( m.Z ); op.Write( " (" ); op.Write( m.Map ); op.Write( ") | " ); op.Write( m.Kills ); op.Write( " | " ); op.Write( m.Karma ); op.Write( " / " ); op.Write( m.Fame ); op.WriteLine( " |