| CODE |
using System; using System.IO; using System.Text; using System.Collections; using Server; using Server.Network; using Server.Guilds; namespace Server.Misc { public class StatusPage : Timer { public static void Initialize() { 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( "<html>" ); op.WriteLine( " <head>" ); op.WriteLine( " <title>The Ancient Quest - Server Status</title>"); op.WriteLine( " </head>" ); op.WriteLine( " <body bgcolor=\"black\">< font color=\"white\">" ); op.WriteLine( " <img src=\"http://www.theancientquest.com/taqwebstatus.jpg\"" ); op.WriteLine( " Online clients:<br>" ); op.WriteLine( " <table width=\"100%\">" ); op.WriteLine( " <tr>" ); op.WriteLine( " <td bgcolor=\"black\"><font color=\"red\">Name of Character Online and Guild</font></td>" ); op.WriteLine( " <font color=\"white\"></tr>" ); foreach ( NetState state in NetState.Instances ) { Mobile m = state.Mobile; if ( m != null ) { Guild g = m.Guild; op.Write( " <tr><td><font color=\"gold\">" ); 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.WriteLine( " <tr>" ); op.WriteLine( " </table>" ); op.WriteLine( " </body>" ); op.WriteLine( "</html>" ); } } } } |
| CODE |
using System; using System.IO; using System.Text; using System.Collections; using Server; using Server.Items; using Server.Network; using Server.Guilds; using Server.Accounting; // WK: replaced "BASEFONT" with "font" at every occurence. This fixes problems // WK: with all browsers != IE. IE is so broken that it mends what's wrong in // WK: the sources even. :-) namespace Server.Misc { public class StatusPage : Timer { public static void Initialize() { new StatusPage().Start(); } public StatusPage() : base( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromSeconds( 70.0 ) ) { Priority = TimerPriority.FiveSeconds; } private static string Encode( string input ) { StringBuilder sb = new StringBuilder( input ); sb.Replace( "&", "&" ); sb.Replace( "<", "<" ); sb.Replace( ">", ">" ); sb.Replace( "\"", """ ); return sb.ToString(); } public static int GetHueFor( Mobile m ) { switch ( m.AccessLevel ) { case AccessLevel.Administrator: return 0x8080FF; case AccessLevel.Seer: return 0x00FF00; case AccessLevel.GameMaster: return 0x8080FF; case AccessLevel.Counselor: return 0x00FF00; case AccessLevel.Player: default: { if ( m.Kills >= 5 ) return 0xFF0000; // WK: was: 800000, changed for readability else if ( m.Criminal ) return 0xFF0000; // WK: was: 800000, changed for readability return 0x99cc33; } } } protected override void OnTick() { if ( !Directory.Exists( "web" ) ) Directory.CreateDirectory( "web" ); using ( StreamWriter op = new StreamWriter( "web/status.html" ) ) { op.WriteLine( "<html>" ); op.WriteLine( " <head>" ); op.WriteLine( " <title>Server Status</title>"); op.WriteLine( " </head>" ); op.WriteLine( " <body bgcolor=\"#000000\" topmargin=\"0\" leftmargin=\"5\">" ); op.WriteLine( " <p align=\"center\"><font size=\"7\" face=\"Black Chancery\" color=\"#99cc33\"><strong>Krynn's Demise RunUO Server</strong></font><br>" ); op.WriteLine( " <font align=\"center\" color=\"#99cc33\" size=\"3\" face=\"Arial\">This information is updated in real time from the server every 1 minute</font><br>" ); op.WriteLine( " <font align=\"center\" size=\"2\" face=\"Arial\" color=\"#FFFFFF\"> Last Updated: {0:F} <br>",System.DateTime.Now); op.WriteLine( " <p align=\"left\"><font size=\"4\" color=\"#FFFFFF\" face=\"Arial\"><strong>Administrator:</font><font size=\"4\" color=\"#99cc33\" face=\"Arial\"> Wol'verana</font></strong><br><font size=\"3\" color=\"#FFFFFF\" face=\"Arial\"><strong>Email: </strong></font><a href=\"mailto:krynnsdemise@yahoo.com\"> krynnsdemise@yahoo.com<br></a></font><font size=\"3\" color=\"#FFFFFF\" face=\"Arial\"><strong>Server Version: </strong></font><font size=\"4\" color=\"#99cc33\" face=\"Arial\">RunUO Beta 32<br></font></p>" ); op.WriteLine( " <div align=\"left\">" ); op.WriteLine( " <table border=\"0\" cellpadding=\"2\" width=\"100%\"><tr>" ); op.WriteLine( " <td nowrap colspan=\"2\" bgcolor=\"#99cc33\"><strong><font face=\"Arial\" size=\"2\" color=\"#000000\">Statistics</font></strong></td></tr>" ); op.WriteLine( " <tr><td nowrap width=\"5%\" bgcolor=\"#000000\"><font face=\"Arial\" size=\"2\" color=\"#99cc33\">Mobiles</font></td><td width=\"95%\" bgcolor=\"#000000\"><font face=\"Arial\" size=\"2\" color=\"#99cc33\">{0}</font></td></tr>",World.Mobiles.Count.ToString() ); op.WriteLine( " <tr><td nowrap bgcolor=\"#FFFFFF\" width=\"5%\"><font face=\"Arial\" size=\"2\" color=\"#000000\">Items</font></td><td bgcolor=\"#E8E8E8\" width=\"95%\"><font face=\"Arial\" size=\"2\">{0}</font></td></tr>",World.Items.Count.ToString() ); int cuentas = 0; foreach ( Account acct in Accounts.Table.Values ) { ++cuentas; } op.WriteLine( " <tr><td nowrap width=\"5%\" bgcolor=\"#99cc33\"><font face=\"Arial\" size=\"2\" color=\"#000000\">Accounts</font></td><td width=\"95%\" bgcolor=\"#99cc33\"><font face=\"Arial\" size=\"2\" color=\"#000000\">{0}</font></td></tr>",cuentas.ToString() ); op.WriteLine( " <tr><td nowrap bgcolor=\"#000000\" width=\"5%\"><font face=\"Arial\" size=\"2\" color=\"#99cc33\">Clients</font></td><td bgcolor=\"#000000\" width=\"95%\"><font face=\"Arial\" size=\"2\" color=\"#99cc33\">{0}</font></td></tr>",NetState.Instances.Count.ToString() ); //op.WriteLine( " <tr><td nowrap width=\"5%\" bgcolor=\"#FFFFFF\"><font face=\"Arial\" size=\"2\" color=\"#000000\">Guilds</font></td><td width=\"95%\" bgcolor=\"#FFFFFF\"><font face=\"Arial\" size=\"2\" color=\"#000000\">{0}</font></td></tr>",clanes.ToString() ); op.WriteLine( " <tr><td width=\"5%\"></td><td width=\"95%\"></td></tr>" ); op.WriteLine( " </table><br>" ); op.WriteLine( " <table border=\"0\" cellpadding=\"2\" width=\"100%\">" ); op.WriteLine( " <tr>" ); op.WriteLine( " <td bgcolor=\"#99cc33\"><font face=\"Arial\" size=\"2\" color=\"#000000\"><strong>Online Clients</strong></font></td><td bgcolor=\"#99cc33\"><font face=\"Arial\" size=\"2\" color=\"#000000\"><strong>Location</strong></font></td><td bgcolor=\"#99cc33\"><font face=\"Arial\" size=\"2\" color=\"#000000\"><strong>Kills</strong></font></td><td bgcolor=\"#99cc33\"><font face=\"Arial\" size=\"2\" color=\"#000000\"><strong>Karma / Fame</strong></font></td>" ); op.WriteLine( " </tr>" ); foreach ( NetState state in NetState.Instances ) { Mobile m = state.Mobile; if ( m != null ) { // WK: added brackets in the next line: "&&" binds stronger than "||" but it's more obvious like this if ( m.AccessLevel == AccessLevel.Player || ((m.AccessLevel >= AccessLevel.Counselor && !m.Hidden)) )//added this line { Guild g = m.Guild; op.Write( " <tr><td>" ); if ( g != null ) { op.Write( "<font color=#{0:X6}>{1}</font>", GetHueFor(m), 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( "<font color=#{0:X6}>{1}</font>", GetHueFor(m), Encode( m.Name ) ); } op.Write( "</td><td>" ); //copy to set region instead of XYZ op.Write( "</b>" ); string region = m.Region.ToString(); if (region != "") { region=" in " + region; } else { region=" in Britannia"; } op.Write( "<font color=#{0:X6}>{1}", GetHueFor(m), Encode( region )); //End Copy // WK: The colors had to be set seperately for every column. // WK: Don't use "BASEFONT". Use "font" instead since it's known to all browsers. op.Write( " (" ); op.Write( m.Map ); op.Write( ")</td><td>" ); op.Write( "<font color=#{0:X6}>{1}", GetHueFor(m), m.Kills ); op.Write( "</td><td>" ); op.Write( "<font color=#{0:X6}>{1}", GetHueFor(m), m.Karma ); op.Write( " / " ); op.Write( "<font color=#{0:X6}>{1}", GetHueFor(m), m.Fame ); op.WriteLine( "</td></tr></font>" ); } } } op.WriteLine( " <tr>" ); op.WriteLine( " </table>" ); op.WriteLine( " <br><hr color=\"#99cc33\"><br>" ); op.WriteLine( " </body>" ); op.WriteLine( "</html>" ); } } } } |