rendered paste bodyusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
using System.Security.Permissions;
using System.Globalization;
using System.Xml;
using System.Web;
namespace HookTest
{
public partial class Form1 : Form
{
public string cstrike = "";
public string condump = "condump000.txt";
public int hmm = 0;
public Form1() {
InitializeComponent();
//Check();
//if (File.Exists( cstrike + condump ))
// File.Delete( cstrike + condump );
//if ( File.Exists( cstrike + "id.rc" ) )
// File.Delete( cstrike + "id.rc" );
}
private static bool FileUploadCompleted( string filename ) {
try {
using ( FileStream inputStream = File.Open( filename, FileMode.Open,
FileAccess.Read,
FileShare.None ) ) {
return true;
}
}
catch ( IOException ) {
return false;
}
}
[PermissionSet( SecurityAction.Demand, Name = "FullTrust" )]
public void Check() {
FileSystemWatcher fsw = new FileSystemWatcher();
try {
fsw.Path = textBox1.Text;
}
catch ( ArgumentException ) {
MessageBox.Show( "Invalid location!" );
return;
}
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
fsw.Filter = condump;
fsw.EnableRaisingEvents = true;
fsw.Created += new FileSystemEventHandler( ConCreated );
}
public void DeleteDump() {
try {
if ( File.Exists( cstrike + condump ) )
File.Delete( cstrike + condump );
}
catch ( IOException ) {
System.Threading.Thread.Sleep( 100 );
}
}
public void ConCreated( object source, FileSystemEventArgs e ) {
DateTime fileReceived = DateTime.Now;
while ( true ) {
if ( FileUploadCompleted( e.FullPath ) ) {
this.Process( e.FullPath );
break;
}
TimeSpan timeElapsed = DateTime.Now - fileReceived;
if ( timeElapsed.TotalMinutes > 1 ) {
//WriteToEventLog( string.Format( CultureInfo.CurrentCulture, "The file \"{0}\" could not be processed.", e.FullPath ) );
MessageBox.Show( string.Format( CultureInfo.CurrentCulture, "The file \"{0}\" could not be processed.", e.FullPath ) );
break;
}
System.Threading.Thread.Sleep( 200 );
}
}
public void Process( string s ) {
TextReader t;
//MessageBox.Show( s, "worked", MessageBoxButtons.OKCancel );
try {
t = new StreamReader( cstrike + condump );
}
catch ( IOException ) {
MessageBox.Show( "IO'd" );
return;
}
XmlDocument doc = new XmlDocument();
//string status = t.ReadToEnd();
string status = HttpUtility.UrlEncode( t.ReadToEnd() ).Replace( "(", "%28" ).Replace( ")", "%29" ).Replace( "]", "%5D" ).Replace( "\r\n", "%0D%0A" ).ToUpper();
t.Close();
doc.Load( "http://steamid.esportsea.com/index.php?action=search&type=mass&query=" + status + "&format=status&output=xml" );
XmlNodeList steamidxml = doc.GetElementsByTagName( "result" );
StringBuilder sb = new StringBuilder();
if ( steamidxml.Count == 0 ) {
sb.Append( "echo \" returned zero results." );
//MessageBox.Show( "status returned 0 results!" );
// return;
}
else {
foreach ( XmlNode node in steamidxml ) {
XmlElement sid = ( XmlElement ) node;
sb.Append( "echo \"" + sid.GetElementsByTagName( "player_steam_id" )[0].InnerText + ": " );
sb.Append( sid.GetElementsByTagName( "player_name_first" )[0].InnerText + " ''" );
sb.Append( sid.GetElementsByTagName( "player_alias" )[0].InnerText + "'' " );
sb.Append( sid.GetElementsByTagName( "player_name_last" )[0].InnerText + " " );
sb.Append( sid.GetElementsByTagName( "team_league" )[0].InnerText.ToUpper() );
sb.Append( sid.GetElementsByTagName( "team_division" )[0].InnerText + " " );
sb.Append( sid.GetElementsByTagName( "team_location" )[0].InnerText + " " );
sb.Append( sid.GetElementsByTagName( "team_name" )[0].InnerText + " (" );
sb.Append( sid.GetElementsByTagName( "wins" )[0].InnerText + "-" );
sb.Append( sid.GetElementsByTagName( "losses" )[0].InnerText + "-" );
sb.Append( sid.GetElementsByTagName( "ties" )[0].InnerText + ")\"\n" );
//sb.Append( sid.GetElementsByTagName( "team_irc" )[0].InnerText + "\r\n" );
}
}
File.WriteAllText( cstrike + "id.rc", sb.ToString() );
File.Delete( cstrike + condump );
}
private void textBox1_TextChanged( object sender, EventArgs e ) {
}
private void button1_Click( object sender, EventArgs e ) {
cstrike = textBox1.Text;
//if ( hmm != 1 ) {
Check();
// hmm = 1;
//}
}
private void Form1_Load( object sender, EventArgs e ) {
if ( File.Exists( cstrike + condump ) )
File.Delete( cstrike + condump );
if ( File.Exists( cstrike + "id.rc" ) )
File.Delete( cstrike + "id.rc" );
}
}
}