T
TheGuxi
Guest
I have this source code, and i managed to fix some errors so far, but some i really cant understand. So please help me to fix those.
It really means a lot to me, Thanks in advance!
Source Code:
using System;
using System.Net;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Management;
using Microsoft.Win32;
using System.Diagnostics;
using MySql.Data.MySqlClient;
using System.Threading;
// TODO
// end program if active over 2.5 hours
namespace CaptureScreen
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.PictureBox picScreen;
private IContainer components;
private Button finalizebutton; // Finalize, Submit, and Close button
string steaminstallpath; // the steam install directory ie: c:/programfiles/steam/
List<string> steamaccounts = new List<string>(); // get all installed steamaccounts
List<string> startProc = new List<string>();
List<string> prochistory = new List<string>(); // logs open and closed programs
string[] originalArray; // the original running processes
// track how long the match takes place
DateTime startTime;
// timer when to take screenshots
System.Windows.Forms.Timer Clock;
// screenshot count used to make filename unique
int count = 0;
int errorcount = 0;
// info to be sent to dbase
string hardwareID;
string computerName;
string steamFolders;
string processesList;
string processActivity;
string OS;
//string[] league;
//string[] leaguename;
//string[] division;
//string[] season;
//string[] week;
//string[] map;
string matchlegth;
//string[] teamname;
//string[] opponent;
//string[] matchid;
//string[] uploadservers;
string selectedleague;
string selectedmatch;
private Button loginbutton;
private ProgressBar progressBar;
private TextBox password;
private TextBox userid;
private Label login_label;
private Label password_label;
private ComboBox league_combobox;
private ComboBox match_combobox;
string[] matchid = new string[20];
string[] teamid = new string[20];
string[] league = new string[20];
string[] division = new string[20];
string[] season = new string[20];
string[] week = new string[20];
string[] map = new string[20];
string[] teamname = new string[20];
string[] opponent = new string[20];
string[] leaguename = new string[20];
private Button startbutton;
private Label leaguelabel;
private Label matchlabel;
private Label finalizelabel;
string[,] uploadservers = new string[20, 20]; // 20 is the max number of alternative servers to check
bool sendinfo = false;
private PictureBox pictureBox1;
bool firstss = true;
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Closing += new CancelEventHandler(MainForm_Closing);
System.Diagnostics.Process.GetCurrentProcess().PriorityClass =
System.Diagnostics.ProcessPriorityClass.Normal;
// Get OS, Used for the Vista Config Workaround
OS = OS + System.Environment.OSVersion.ToString();
// Get Computer Name
computerName = computerName + System.Environment.MachineName;
// Get processors Hardward ID
string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == "")
{
//Get only the first CPUs ID
cpuInfo = mo.Properties["processorID"].Value.ToString();
break;
}
}
hardwareID = hardwareID + cpuInfo;
// Get Steam Install Path
try
{
Object steampath;
String RegID = "SOFTWARE\\Valve\\Steam\\";
RegistryKey key = Registry.CurrentUser;
key = key.OpenSubKey(RegID);
steampath = key.GetValue("SteamPath");
steampath = steampath + "\\steamapps\\";
steaminstallpath = steampath.ToString();
if (steampath != null)
{
DirectoryInfo di = new DirectoryInfo(steampath.ToString());
DirectoryInfo[] rgFolders = di.GetDirectories();
foreach (DirectoryInfo fi in rgFolders)
{
if (fi.Name != "common" && fi.Name != "SourceMods")
{
steamFolders = steamFolders + Environment.NewLine + fi.Name;
steamaccounts.Add(fi.Name);
writeConfigs(steampath.ToString() + fi.Name);
}
}
}
}
catch { }
// All process running at startup
startProc.Clear();
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
startProc.Add(theprocess.ProcessName + "_" + theprocess.Id);
processesList = processesList + theprocess.Id + ";" + theprocess.ProcessName + ";";
}
//
process_Timer();
}
private void process_Timer()
{
Clock = new System.Windows.Forms.Timer();
Clock.Interval = 1000;
Clock.Start();
Clock.Tick += new EventHandler(getProcesses);
}
private void getProcesses(object sender, EventArgs eArgs)
{
// Setup list that holds the latest processes running
List<string> curProc = new List<string>();
//curProc.Clear();
// get processes into list
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
curProc.Add(theprocess.ProcessName + "_" + theprocess.Id);
//String runningprocesses = String.Format("ID: {1} Process: {0}", theprocess.ProcessName, theprocess.Id);
//processes.Text = processes.Text + runningprocesses + Environment.NewLine
}
// Convert list into array to be compared
string[] latestArray = curProc.ToArray();
originalArray = startProc.ToArray();
//string[] originalArray = { "Red", "firefox", "Yellow", "rundll32", "Purple", "rundll32", "hack" };
// Find Closed Processes
int counter = 0;
foreach (string nextRole in originalArray)
{
if (Array.IndexOf(latestArray, nextRole) == -1)
{
processActivity = processActivity + "Closed " + nextRole + Environment.NewLine;
startProc.Remove(nextRole);
}
counter++;
}
// Find Opened Processes
counter = 0;
foreach (string nextRole in latestArray)
{
if (Array.IndexOf(originalArray, nextRole) == -1)
{
processActivity = processActivity + "Opened " + nextRole + Environment.NewLine;
startProc.Add(nextRole);
}
counter++;
}
}
private void init_Timer()
{
if (firstss == true)
{
Clock = new System.Windows.Forms.Timer();
Clock.Interval = 1000;
Clock.Start();
Clock.Tick += new EventHandler(Timer_Tick);
// Start the Match Length Clock
startTime = DateTime.Now;
}
else
{
Random RandomClass = new Random();
int RandomNumber = RandomClass.Next(5, 25);
int randomtime = RandomNumber * 1000;
Clock = new System.Windows.Forms.Timer();
Clock.Interval = randomtime;
Clock.Start();
Clock.Tick += new EventHandler(Timer_Tick);
}
}
public void Timer_Tick(object sender, EventArgs eArgs)
{
Clock.Stop();
if (sender == Clock)
{
string exePath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
exePath = exePath + @"\eco_ac32.dll";
System.Console.WriteLine(exePath);
System.Console.WriteLine(steaminstallpath);
//picScreen.Image.Save(exePath);
Bitmap bmp1 = CaptureScreen.GetDesktopImage();
//if (Clock.Interval <= (12 * 1000))
//{
//bmp1 = ResizeBitmap(bmp1, 416, 312);
//}
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
EncoderParameters myEncoderParameters = new EncoderParameters(1);
if (Clock.Interval >= (22 * 1000) || firstss == true)
{
int scale_x = (int)Math.Round((bmp1.Width / 1.5));
int scale_y = (int)Math.Round(bmp1.Height / 1.5);
if (scale_x >= 801 && scale_y >= 601)
{
bmp1 = ResizeBitmap(bmp1, scale_x, scale_y);
}
else
{
bmp1 = ResizeBitmap(bmp1, 800, 600);
}
Console.WriteLine("scale_x: " + scale_x + " scale_y: " + scale_y);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 80L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(exePath, jgpEncoder, myEncoderParameters);
sendImage(exePath, "large");
firstss = false;
}
else
{
bmp1 = ResizeBitmap(bmp1, 416, 312);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 30L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(exePath, jgpEncoder, myEncoderParameters);
sendImage(exePath, "thumb");
}
count++;
//Clock.Stop; // stop timer untill file uploads
}
}
public Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
{
Bitmap result = new Bitmap(nWidth, nHeight);
using (Graphics g = Graphics.FromImage((Image)result))
g.DrawImage(b, 0, 0, nWidth, nHeight);
return result;
}
private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
private void writeConfigs (string steamfolder)
{
steamfolder = steamfolder + "\\counter-strike source\\cstrike\\cfg\\";
if (File.Exists(steamfolder + "config.cfg"))
{
String line;
bool execExists = false;
try
{
//Pass the file path and file name to the StreamReader constructor
StreamReader sr = new StreamReader(steamfolder + "autoexec.cfg");
//Read the first line of text
line = sr.ReadLine();
//Continue to read until you reach end of file
while (line != null)
{
Console.WriteLine(line);
//write the lie to console window
//Console.WriteLine(line);
//Read the next line
if (line == "exec eco-config.cfg")
{
execExists = true;
}
line = sr.ReadLine();
}
//close the file
sr.Close();
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
// Write to the config folder
try
{
//Open the File
StreamWriter sw2 = new StreamWriter(steamfolder + "autoexec.cfg", true, Encoding.UTF8);
//Writeout the numbers 1 to 10 on the same line.
if (execExists == false)
{
sw2.WriteLine("exec eco-config.cfg");
}
//close the file
sw2.Close();
try
{
//Open the File
StreamWriter sw = new StreamWriter(steamfolder + "eco-config.cfg");
//Writeout the numbers 1 to 10 on the same line.
sw.WriteLine("mat_aaquality 0");
sw.WriteLine("mat_antialias 0");
sw.WriteLine("cl_updaterate 101");
sw.WriteLine("cl_cmdrate 101");
sw.WriteLine("rate 30000");
//close the file
sw.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.picScreen = new System.Windows.Forms.PictureBox();
this.finalizebutton = new System.Windows.Forms.Button();
this.loginbutton = new System.Windows.Forms.Button();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.password = new System.Windows.Forms.TextBox();
this.userid = new System.Windows.Forms.TextBox();
this.login_label = new System.Windows.Forms.Label();
this.password_label = new System.Windows.Forms.Label();
this.league_combobox = new System.Windows.Forms.ComboBox();
this.match_combobox = new System.Windows.Forms.ComboBox();
this.startbutton = new System.Windows.Forms.Button();
this.leaguelabel = new System.Windows.Forms.Label();
this.matchlabel = new System.Windows.Forms.Label();
this.finalizelabel = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.picScreen)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// picScreen
//
this.picScreen.Dock = System.Windows.Forms.DockStyle.Fill;
this.picScreen.Image = ((System.Drawing.Image)(resources.GetObject("picScreen.Image")));
this.picScreen.InitialImage = null;
this.picScreen.Location = new System.Drawing.Point(0, 0);
this.picScreen.Margin = new System.Windows.Forms.Padding(0);
this.picScreen.Name = "picScreen";
this.picScreen.Size = new System.Drawing.Size(500, 300);
this.picScreen.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.picScreen.TabIndex = 5;
this.picScreen.TabStop = false;
this.picScreen.Click += new System.EventHandler(this.picScreen_Click);
//
// finalizebutton
//
this.finalizebutton.Location = new System.Drawing.Point(280, 248);
this.finalizebutton.Name = "finalizebutton";
this.finalizebutton.Size = new System.Drawing.Size(103, 32);
this.finalizebutton.TabIndex = 14;
this.finalizebutton.Text = "Finalize";
this.finalizebutton.UseVisualStyleBackColor = true;
this.finalizebutton.Visible = false;
this.finalizebutton.Click += new System.EventHandler(this.button1_Click);
//
// loginbutton
//
this.loginbutton.Location = new System.Drawing.Point(280, 248);
this.loginbutton.Name = "loginbutton";
this.loginbutton.Size = new System.Drawing.Size(103, 32);
this.loginbutton.TabIndex = 15;
this.loginbutton.Text = "Login";
this.loginbutton.UseVisualStyleBackColor = true;
this.loginbutton.Click += new System.EventHandler(this.button2_Click);
//
// progressBar
//
this.progressBar.Location = new System.Drawing.Point(194, 220);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(189, 19);
this.progressBar.TabIndex = 16;
this.progressBar.Visible = false;
this.progressBar.Click += new System.EventHandler(this.progressBar_Click);
//
// password
//
this.password.Location = new System.Drawing.Point(194, 218);
this.password.Name = "password";
this.password.Size = new System.Drawing.Size(189, 20);
this.password.TabIndex = 2;
//
// userid
//
this.userid.Location = new System.Drawing.Point(194, 190);
this.userid.Name = "userid";
this.userid.Size = new System.Drawing.Size(189, 20);
this.userid.TabIndex = 1;
//
// login_label
//
this.login_label.AutoSize = true;
this.login_label.BackColor = System.Drawing.Color.Black;
this.login_label.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.login_label.ForeColor = System.Drawing.Color.White;
this.login_label.Location = new System.Drawing.Point(140, 194);
this.login_label.Name = "login_label";
this.login_label.Size = new System.Drawing.Size(41, 15);
this.login_label.TabIndex = 19;
this.login_label.Text = "Login:";
//
// password_label
//
this.password_label.AutoSize = true;
this.password_label.BackColor = System.Drawing.Color.Black;
this.password_label.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.password_label.ForeColor = System.Drawing.Color.White;
this.password_label.Location = new System.Drawing.Point(113, 221);
this.password_label.Name = "password_label";
this.password_label.Size = new System.Drawing.Size(68, 15);
this.password_label.TabIndex = 20;
this.password_label.Text = "Password:";
this.password_label.Click += new System.EventHandler(this.password_label_Click);
//
// league_combobox
//
this.league_combobox.FormattingEnabled = true;
this.league_combobox.Location = new System.Drawing.Point(194, 189);
this.league_combobox.Name = "league_combobox";
this.league_combobox.Size = new System.Drawing.Size(189, 21);
this.league_combobox.TabIndex = 1;
this.league_combobox.Visible = false;
this.league_combobox.SelectedIndexChanged += new System.EventHandler(this.league_combobox_SelectedIndexChanged);
//
// match_combobox
//
this.match_combobox.FormattingEnabled = true;
this.match_combobox.Location = new System.Drawing.Point(194, 218);
this.match_combobox.Name = "match_combobox";
this.match_combobox.Size = new System.Drawing.Size(189, 21);
this.match_combobox.TabIndex = 2;
this.match_combobox.Visible = false;
this.match_combobox.SelectedIndexChanged += new System.EventHandler(this.match_combobox_SelectedIndexChanged);
//
// startbutton
//
this.startbutton.Location = new System.Drawing.Point(280, 248);
this.startbutton.Name = "startbutton";
this.startbutton.Size = new System.Drawing.Size(103, 32);
this.startbutton.TabIndex = 3;
this.startbutton.Text = "Start Match";
this.startbutton.UseVisualStyleBackColor = true;
this.startbutton.Visible = false;
this.startbutton.Click += new System.EventHandler(this.startbutton_Click);
//
// leaguelabel
//
this.leaguelabel.AutoSize = true;
this.leaguelabel.BackColor = System.Drawing.Color.Black;
this.leaguelabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.leaguelabel.ForeColor = System.Drawing.Color.White;
this.leaguelabel.Location = new System.Drawing.Point(90, 193);
this.leaguelabel.Name = "leaguelabel";
this.leaguelabel.Size = new System.Drawing.Size(91, 15);
this.leaguelabel.TabIndex = 24;
this.leaguelabel.Text = "Select League:";
this.leaguelabel.Visible = false;
//
// matchlabel
//
this.matchlabel.AutoSize = true;
this.matchlabel.BackColor = System.Drawing.Color.Black;
this.matchlabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.matchlabel.ForeColor = System.Drawing.Color.White;
this.matchlabel.Location = new System.Drawing.Point(97, 220);
this.matchlabel.Name = "matchlabel";
this.matchlabel.Size = new System.Drawing.Size(84, 15);
this.matchlabel.TabIndex = 25;
this.matchlabel.Text = "Select Match:";
this.matchlabel.Visible = false;
//
// finalizelabel
//
this.finalizelabel.AutoSize = true;
this.finalizelabel.BackColor = System.Drawing.Color.Black;
this.finalizelabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.finalizelabel.ForeColor = System.Drawing.Color.White;
this.finalizelabel.Location = new System.Drawing.Point(191, 193);
this.finalizelabel.Name = "finalizelabel";
this.finalizelabel.Size = new System.Drawing.Size(51, 15);
this.finalizelabel.TabIndex = 26;
this.finalizelabel.Text = "Activity:";
this.finalizelabel.Visible = false;
this.finalizelabel.Click += new System.EventHandler(this.finalizelabel_Click);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Black;
this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(470, 20);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(10, 10);
this.pictureBox1.TabIndex = 27;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click_1);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(500, 300);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.finalizelabel);
this.Controls.Add(this.matchlabel);
this.Controls.Add(this.leaguelabel);
this.Controls.Add(this.startbutton);
this.Controls.Add(this.match_combobox);
this.Controls.Add(this.league_combobox);
this.Controls.Add(this.password_label);
this.Controls.Add(this.login_label);
this.Controls.Add(this.userid);
this.Controls.Add(this.password);
this.Controls.Add(this.progressBar);
this.Controls.Add(this.loginbutton);
this.Controls.Add(this.finalizebutton);
this.Controls.Add(this.picScreen);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(500, 300);
this.Menu = this.mainMenu1;
this.MinimumSize = new System.Drawing.Size(500, 300);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ECO ANTI-CHEAT";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.picScreen)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void mnuCaptureScreen_Click(object sender, System.EventArgs e)
{
picScreen.Image = CaptureScreen.GetDesktopImage();
}
private void mnuExit_Click(object sender, System.EventArgs e)
{
}
private void picScreen_Click(object sender, EventArgs e)
{
}
private void menuItem1_Click(object sender, EventArgs e)
{
}
private void menuItem2_Click(object sender, EventArgs e)
{
}
public void MainForm_Closing(object sender, CancelEventArgs cArgs)
{
if (sendinfo == true)
{
finalize();
}
if (steaminstallpath != null)
{
DirectoryInfo di = new DirectoryInfo(steaminstallpath);
//FileInfo[] rgFiles = di.GetFiles("*");
DirectoryInfo[] rgFolders = di.GetDirectories();
foreach (DirectoryInfo fi in rgFolders)
{
if (fi.Name != "common" && fi.Name != "SourceMods")
{
steamFolders = steamFolders + Environment.NewLine + fi.Name;
unwriteConfigs(steaminstallpath + fi.Name);
}
}
}
}
private void unwriteConfigs(string steamfolder)
{
steamfolder = steamfolder + "\\counter-strike source\\cstrike\\cfg\\";
if (File.Exists(steamfolder + "autoexec.cfg"))
{
StringBuilder newFile = new StringBuilder();
string temp = "";
string[] file = File.ReadAllLines(steamfolder + "autoexec.cfg");
foreach (string line in file)
{
if (line.Contains("exec eco-config.cfg"))
{
temp = line.Replace("exec eco-config.cfg", "");
newFile.Append(temp);
continue;
}
newFile.Append(line + "\r\n");
}
File.WriteAllText(steamfolder + "autoexec.cfg", newFile.ToString());
}
}
private void MainForm_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e) // Finalize Button
{
finalize();
}
private void finalize()
{
try
{
Clock.Stop();
finalizelabel.Text = "Finalizing...";
string MyConString = "SERVER=66.189.220.3;" +
"DATABASE= league_ac;" +
"UID=acs;" +
"PASSWORD=error;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
//format the steamaccount array
string steamaccts = "";
string[] acctsarray = steamaccounts.ToArray();
foreach (string accts in acctsarray)
{
steamaccts = steamaccts + accts.ToString() + ";";
}
DateTime stopTime = DateTime.Now;
TimeSpan duration = stopTime - startTime;
string matchlength = duration.Hours + ":" + duration.Minutes + ":" + duration.Seconds;
Console.WriteLine("Time Difference (seconds): " + duration.Seconds);
Console.WriteLine("Time Difference (minutes): " + duration.Minutes);
Console.WriteLine("Time Difference (hours): " + duration.Hours);
Console.WriteLine("Time Difference (days): " + duration.Days);
command.CommandText = "insert into league_ac.css (userid,processlist,processactivity,computername,hardwareid,os,steamaccounts,matchlength) values (" + computerName + ", " + processesList + "," + processActivity + "," + computerName + ", " + hardwareID + ", " + OS + ", " + steamaccts + ", " + matchlength + ")";
connection.Open();
Reader = command.ExecuteReader();
connection.Close();
System.Windows.Forms.Application.Exit();
}
catch { MessageBox.Show("Server is unavailable, please retry", "Error"); }
}
private void sendImage(string filelocation, string imagesize)
{
int x = 10;
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 30L);
byte[] blob;
//Stream test;
PointofEntry:
try
{
// Ping server and make sure it lives
WebClient myWebClient = new WebClient();
string uriString = "http://" + uploadservers[Convert.ToInt16(selectedmatch), x] + "/eco-ac/ping.php";
Stream myStream = myWebClient.OpenRead(uriString);
StreamReader sr = new StreamReader(myStream);
string webresponse = sr.ReadToEnd();
webresponse = webresponse.Trim();
if (webresponse == "Pong")
{
// Send the Image
System.Net.WebClient Client = new System.Net.WebClient();
Client.Headers.Add("Content-Type", "binary/octet-stream");
UploadFileInBackground2("http://" + uploadservers[Convert.ToInt16(selectedmatch), x] + "/eco-ac/eco_ac_uploader.php?userid=" + userid.Text + "&league=" + league[Convert.ToInt16(selectedmatch)] + "&division=" + division[Convert.ToInt16(selectedmatch)] + "&week=" + week[Convert.ToInt16(selectedmatch)] + "&teamid=" + teamid[Convert.ToInt16(selectedmatch)] + "&matchid=" + matchid[Convert.ToInt16(selectedmatch)] + "&size=" + imagesize + "&count=" + count, filelocation);
}
else
{
throw new System.ArgumentException("Did not return Ping Request", "webresponse");
}
}
catch {
Console.WriteLine("trying another server");
x++;
goto PointofEntry;
}
}
// Sample call: UploadFileInBackground2("http://www.contoso.com/fileUpload.aspx", "data.txt")
private void UploadFileInBackground2(string address, string fileName)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
client.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileCallback2);
// Specify a progress notification handler.
client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
client.UploadFileAsync(uri, "POST", fileName);
Console.WriteLine("File upload started.");
}
private void UploadFileCallback2(object sender, EventArgs eArgs)
{
Console.WriteLine("IM A WINNER!");
this.progressBar.Value = 0;
init_Timer();
}
private void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
{
// Displays the operation identifier, and the transfer progress.
Console.WriteLine("{0} uploaded {1} of {2} bytes. {3} % complete...",
(string)e.UserState,
e.BytesSent,
e.TotalBytesToSend,
e.ProgressPercentage);
//Thread.Sleep(300); // throttle the upload bandwidth
if (e.ProgressPercentage <= 50 && e.ProgressPercentage >= 0)
{
this.progressBar.Value = e.ProgressPercentage * 2;
}
}
private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{
// Displays the operation identifier, and the transfer progress.
Console.WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...",
(string)e.UserState,
e.BytesReceived,
e.TotalBytesToReceive,
e.ProgressPercentage);
}
private void button2_Click(object sender, EventArgs e)
{
//init_Timer();
// grab login data
authenticate();
}
private void password_label_Click(object sender, EventArgs e)
{
}
private void authenticate()
{
// User Login Check, recieve array of useful info to populate game selection lists
WebClient myWebClient = new WebClient();
string uriString = "http://66.189.220.3/eco/eco-ac/eco_ac_login.php?userid=" + userid.Text + "&password=" + password.Text;
Stream myStream = myWebClient.OpenRead(uriString);
StreamReader sr = new StreamReader(myStream);
string webresponse = sr.ReadToEnd();
webresponse = webresponse.Trim();
if (webresponse == "Login Failed")
{
MessageBox.Show("Login Failed, try again", "Error");
}
else
{
string[] leaguearray = new string[15];
string[] acsSettingsarray = new string[29];
char[] splitter = { , };
char[] splitter2 = { ; };
leaguearray = webresponse.Split(splitter2);
for (int y = 0; y < leaguearray.Length; y++)
{
try
{
acsSettingsarray = leaguearray[y].Split(splitter);
matchid[y] = acsSettingsarray[0];
league[y] = acsSettingsarray[1];
division[y] = acsSettingsarray[2];
season[y] = acsSettingsarray[3];
week[y] = acsSettingsarray[4];
map[y] = acsSettingsarray[5];
teamname[y] = acsSettingsarray[6];
opponent[y] = acsSettingsarray[7];
leaguename[y] = acsSettingsarray[8];
teamid[y] = acsSettingsarray[9];
for (int x = 10; x < acsSettingsarray.Length; x++) // get all available upload servers
{
uploadservers[y,x] = acsSettingsarray[x];
}
// determine if the leaguename is listed twice or more in the combobox
bool leaguedouble = false;
for (int i = 0; i < league_combobox.Items.Count; i++)
{
Console.WriteLine(leaguename + " " + leaguename[y]);
if (leaguename[y] == league_combobox.Items.ToString())
{
leaguedouble = true;
}
}
if (leaguedouble == false)
{
league_combobox.Items.Add(leaguename[y]); // sort out the doubles first
}
//
for (int x = 0; x < acsSettingsarray.Length; x++) // for testing, prints all info recieved from server
{
Console.WriteLine(acsSettingsarray[x] + " " + acsSettingsarray.Length);
}
loginbutton.Visible = false;
userid.Visible = false;
password.Visible = false;
login_label.Visible = false;
password_label.Visible = false;
league_combobox.Visible = true;
match_combobox.Visible = true;
leaguelabel.Visible = true;
matchlabel.Visible = true;
}
catch { MessageBox.Show("Server is unavailable, please retry", "Error"); }
}
}
Console.WriteLine("\nDisplaying Data :\n");
Console.WriteLine(webresponse);
myStream.Close();
}
private void league_combobox_SelectedIndexChanged(object sender, EventArgs e)
{
selectedleague = league_combobox.SelectedItem.ToString();
match_combobox.Items.Clear(); // clear all from match combobox so matches arent added twice
Console.WriteLine(selectedleague);
for (int x = 0; x < teamname.Length; x++) // get all available upload servers
{
if (leaguename[x] == selectedleague)
{
//match_combobox.Items.Add(teamname[x] + " (home) Vs " + opponent[x] + " (away)");
match_combobox.Items.Add(new itemobject(teamname[x] + " (home) Vs " + opponent[x] + " (away)", x));
}
}
}
private void match_combobox_SelectedIndexChanged(object sender, EventArgs e)
{
// track the selected match array id
itemobject obj = (itemobject)match_combobox.SelectedItem;
selectedmatch = obj.Value.ToString();
Console.WriteLine("Selected: " + selectedmatch);
startbutton.Visible = true;
}
private void startbutton_Click(object sender, EventArgs e)
{
init_Timer(); // begin with the screenshots
sendinfo = true;
startbutton.Visible = false;
match_combobox.Visible = false;
league_combobox.Visible = false;
leaguelabel.Visible = false;
matchlabel.Visible = false;
finalizebutton.Visible = true;
progressBar.Visible = true;
finalizelabel.Visible = true;
}
private void progressBar_Click(object sender, EventArgs e)
{
}
private void finalizelabel_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click_1(object sender, EventArgs e)
{
finalize();
}
}
}
If you know how to solve any of these errors please help me. Thanks in advance!
These are the errors:
Continue reading...
It really means a lot to me, Thanks in advance!
Source Code:
using System;
using System.Net;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Management;
using Microsoft.Win32;
using System.Diagnostics;
using MySql.Data.MySqlClient;
using System.Threading;
// TODO
// end program if active over 2.5 hours
namespace CaptureScreen
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.PictureBox picScreen;
private IContainer components;
private Button finalizebutton; // Finalize, Submit, and Close button
string steaminstallpath; // the steam install directory ie: c:/programfiles/steam/
List<string> steamaccounts = new List<string>(); // get all installed steamaccounts
List<string> startProc = new List<string>();
List<string> prochistory = new List<string>(); // logs open and closed programs
string[] originalArray; // the original running processes
// track how long the match takes place
DateTime startTime;
// timer when to take screenshots
System.Windows.Forms.Timer Clock;
// screenshot count used to make filename unique
int count = 0;
int errorcount = 0;
// info to be sent to dbase
string hardwareID;
string computerName;
string steamFolders;
string processesList;
string processActivity;
string OS;
//string[] league;
//string[] leaguename;
//string[] division;
//string[] season;
//string[] week;
//string[] map;
string matchlegth;
//string[] teamname;
//string[] opponent;
//string[] matchid;
//string[] uploadservers;
string selectedleague;
string selectedmatch;
private Button loginbutton;
private ProgressBar progressBar;
private TextBox password;
private TextBox userid;
private Label login_label;
private Label password_label;
private ComboBox league_combobox;
private ComboBox match_combobox;
string[] matchid = new string[20];
string[] teamid = new string[20];
string[] league = new string[20];
string[] division = new string[20];
string[] season = new string[20];
string[] week = new string[20];
string[] map = new string[20];
string[] teamname = new string[20];
string[] opponent = new string[20];
string[] leaguename = new string[20];
private Button startbutton;
private Label leaguelabel;
private Label matchlabel;
private Label finalizelabel;
string[,] uploadservers = new string[20, 20]; // 20 is the max number of alternative servers to check
bool sendinfo = false;
private PictureBox pictureBox1;
bool firstss = true;
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Closing += new CancelEventHandler(MainForm_Closing);
System.Diagnostics.Process.GetCurrentProcess().PriorityClass =
System.Diagnostics.ProcessPriorityClass.Normal;
// Get OS, Used for the Vista Config Workaround
OS = OS + System.Environment.OSVersion.ToString();
// Get Computer Name
computerName = computerName + System.Environment.MachineName;
// Get processors Hardward ID
string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == "")
{
//Get only the first CPUs ID
cpuInfo = mo.Properties["processorID"].Value.ToString();
break;
}
}
hardwareID = hardwareID + cpuInfo;
// Get Steam Install Path
try
{
Object steampath;
String RegID = "SOFTWARE\\Valve\\Steam\\";
RegistryKey key = Registry.CurrentUser;
key = key.OpenSubKey(RegID);
steampath = key.GetValue("SteamPath");
steampath = steampath + "\\steamapps\\";
steaminstallpath = steampath.ToString();
if (steampath != null)
{
DirectoryInfo di = new DirectoryInfo(steampath.ToString());
DirectoryInfo[] rgFolders = di.GetDirectories();
foreach (DirectoryInfo fi in rgFolders)
{
if (fi.Name != "common" && fi.Name != "SourceMods")
{
steamFolders = steamFolders + Environment.NewLine + fi.Name;
steamaccounts.Add(fi.Name);
writeConfigs(steampath.ToString() + fi.Name);
}
}
}
}
catch { }
// All process running at startup
startProc.Clear();
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
startProc.Add(theprocess.ProcessName + "_" + theprocess.Id);
processesList = processesList + theprocess.Id + ";" + theprocess.ProcessName + ";";
}
//
process_Timer();
}
private void process_Timer()
{
Clock = new System.Windows.Forms.Timer();
Clock.Interval = 1000;
Clock.Start();
Clock.Tick += new EventHandler(getProcesses);
}
private void getProcesses(object sender, EventArgs eArgs)
{
// Setup list that holds the latest processes running
List<string> curProc = new List<string>();
//curProc.Clear();
// get processes into list
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
curProc.Add(theprocess.ProcessName + "_" + theprocess.Id);
//String runningprocesses = String.Format("ID: {1} Process: {0}", theprocess.ProcessName, theprocess.Id);
//processes.Text = processes.Text + runningprocesses + Environment.NewLine
}
// Convert list into array to be compared
string[] latestArray = curProc.ToArray();
originalArray = startProc.ToArray();
//string[] originalArray = { "Red", "firefox", "Yellow", "rundll32", "Purple", "rundll32", "hack" };
// Find Closed Processes
int counter = 0;
foreach (string nextRole in originalArray)
{
if (Array.IndexOf(latestArray, nextRole) == -1)
{
processActivity = processActivity + "Closed " + nextRole + Environment.NewLine;
startProc.Remove(nextRole);
}
counter++;
}
// Find Opened Processes
counter = 0;
foreach (string nextRole in latestArray)
{
if (Array.IndexOf(originalArray, nextRole) == -1)
{
processActivity = processActivity + "Opened " + nextRole + Environment.NewLine;
startProc.Add(nextRole);
}
counter++;
}
}
private void init_Timer()
{
if (firstss == true)
{
Clock = new System.Windows.Forms.Timer();
Clock.Interval = 1000;
Clock.Start();
Clock.Tick += new EventHandler(Timer_Tick);
// Start the Match Length Clock
startTime = DateTime.Now;
}
else
{
Random RandomClass = new Random();
int RandomNumber = RandomClass.Next(5, 25);
int randomtime = RandomNumber * 1000;
Clock = new System.Windows.Forms.Timer();
Clock.Interval = randomtime;
Clock.Start();
Clock.Tick += new EventHandler(Timer_Tick);
}
}
public void Timer_Tick(object sender, EventArgs eArgs)
{
Clock.Stop();
if (sender == Clock)
{
string exePath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
exePath = exePath + @"\eco_ac32.dll";
System.Console.WriteLine(exePath);
System.Console.WriteLine(steaminstallpath);
//picScreen.Image.Save(exePath);
Bitmap bmp1 = CaptureScreen.GetDesktopImage();
//if (Clock.Interval <= (12 * 1000))
//{
//bmp1 = ResizeBitmap(bmp1, 416, 312);
//}
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
EncoderParameters myEncoderParameters = new EncoderParameters(1);
if (Clock.Interval >= (22 * 1000) || firstss == true)
{
int scale_x = (int)Math.Round((bmp1.Width / 1.5));
int scale_y = (int)Math.Round(bmp1.Height / 1.5);
if (scale_x >= 801 && scale_y >= 601)
{
bmp1 = ResizeBitmap(bmp1, scale_x, scale_y);
}
else
{
bmp1 = ResizeBitmap(bmp1, 800, 600);
}
Console.WriteLine("scale_x: " + scale_x + " scale_y: " + scale_y);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 80L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(exePath, jgpEncoder, myEncoderParameters);
sendImage(exePath, "large");
firstss = false;
}
else
{
bmp1 = ResizeBitmap(bmp1, 416, 312);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 30L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(exePath, jgpEncoder, myEncoderParameters);
sendImage(exePath, "thumb");
}
count++;
//Clock.Stop; // stop timer untill file uploads
}
}
public Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
{
Bitmap result = new Bitmap(nWidth, nHeight);
using (Graphics g = Graphics.FromImage((Image)result))
g.DrawImage(b, 0, 0, nWidth, nHeight);
return result;
}
private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
private void writeConfigs (string steamfolder)
{
steamfolder = steamfolder + "\\counter-strike source\\cstrike\\cfg\\";
if (File.Exists(steamfolder + "config.cfg"))
{
String line;
bool execExists = false;
try
{
//Pass the file path and file name to the StreamReader constructor
StreamReader sr = new StreamReader(steamfolder + "autoexec.cfg");
//Read the first line of text
line = sr.ReadLine();
//Continue to read until you reach end of file
while (line != null)
{
Console.WriteLine(line);
//write the lie to console window
//Console.WriteLine(line);
//Read the next line
if (line == "exec eco-config.cfg")
{
execExists = true;
}
line = sr.ReadLine();
}
//close the file
sr.Close();
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
// Write to the config folder
try
{
//Open the File
StreamWriter sw2 = new StreamWriter(steamfolder + "autoexec.cfg", true, Encoding.UTF8);
//Writeout the numbers 1 to 10 on the same line.
if (execExists == false)
{
sw2.WriteLine("exec eco-config.cfg");
}
//close the file
sw2.Close();
try
{
//Open the File
StreamWriter sw = new StreamWriter(steamfolder + "eco-config.cfg");
//Writeout the numbers 1 to 10 on the same line.
sw.WriteLine("mat_aaquality 0");
sw.WriteLine("mat_antialias 0");
sw.WriteLine("cl_updaterate 101");
sw.WriteLine("cl_cmdrate 101");
sw.WriteLine("rate 30000");
//close the file
sw.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.picScreen = new System.Windows.Forms.PictureBox();
this.finalizebutton = new System.Windows.Forms.Button();
this.loginbutton = new System.Windows.Forms.Button();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.password = new System.Windows.Forms.TextBox();
this.userid = new System.Windows.Forms.TextBox();
this.login_label = new System.Windows.Forms.Label();
this.password_label = new System.Windows.Forms.Label();
this.league_combobox = new System.Windows.Forms.ComboBox();
this.match_combobox = new System.Windows.Forms.ComboBox();
this.startbutton = new System.Windows.Forms.Button();
this.leaguelabel = new System.Windows.Forms.Label();
this.matchlabel = new System.Windows.Forms.Label();
this.finalizelabel = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.picScreen)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// picScreen
//
this.picScreen.Dock = System.Windows.Forms.DockStyle.Fill;
this.picScreen.Image = ((System.Drawing.Image)(resources.GetObject("picScreen.Image")));
this.picScreen.InitialImage = null;
this.picScreen.Location = new System.Drawing.Point(0, 0);
this.picScreen.Margin = new System.Windows.Forms.Padding(0);
this.picScreen.Name = "picScreen";
this.picScreen.Size = new System.Drawing.Size(500, 300);
this.picScreen.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.picScreen.TabIndex = 5;
this.picScreen.TabStop = false;
this.picScreen.Click += new System.EventHandler(this.picScreen_Click);
//
// finalizebutton
//
this.finalizebutton.Location = new System.Drawing.Point(280, 248);
this.finalizebutton.Name = "finalizebutton";
this.finalizebutton.Size = new System.Drawing.Size(103, 32);
this.finalizebutton.TabIndex = 14;
this.finalizebutton.Text = "Finalize";
this.finalizebutton.UseVisualStyleBackColor = true;
this.finalizebutton.Visible = false;
this.finalizebutton.Click += new System.EventHandler(this.button1_Click);
//
// loginbutton
//
this.loginbutton.Location = new System.Drawing.Point(280, 248);
this.loginbutton.Name = "loginbutton";
this.loginbutton.Size = new System.Drawing.Size(103, 32);
this.loginbutton.TabIndex = 15;
this.loginbutton.Text = "Login";
this.loginbutton.UseVisualStyleBackColor = true;
this.loginbutton.Click += new System.EventHandler(this.button2_Click);
//
// progressBar
//
this.progressBar.Location = new System.Drawing.Point(194, 220);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(189, 19);
this.progressBar.TabIndex = 16;
this.progressBar.Visible = false;
this.progressBar.Click += new System.EventHandler(this.progressBar_Click);
//
// password
//
this.password.Location = new System.Drawing.Point(194, 218);
this.password.Name = "password";
this.password.Size = new System.Drawing.Size(189, 20);
this.password.TabIndex = 2;
//
// userid
//
this.userid.Location = new System.Drawing.Point(194, 190);
this.userid.Name = "userid";
this.userid.Size = new System.Drawing.Size(189, 20);
this.userid.TabIndex = 1;
//
// login_label
//
this.login_label.AutoSize = true;
this.login_label.BackColor = System.Drawing.Color.Black;
this.login_label.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.login_label.ForeColor = System.Drawing.Color.White;
this.login_label.Location = new System.Drawing.Point(140, 194);
this.login_label.Name = "login_label";
this.login_label.Size = new System.Drawing.Size(41, 15);
this.login_label.TabIndex = 19;
this.login_label.Text = "Login:";
//
// password_label
//
this.password_label.AutoSize = true;
this.password_label.BackColor = System.Drawing.Color.Black;
this.password_label.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.password_label.ForeColor = System.Drawing.Color.White;
this.password_label.Location = new System.Drawing.Point(113, 221);
this.password_label.Name = "password_label";
this.password_label.Size = new System.Drawing.Size(68, 15);
this.password_label.TabIndex = 20;
this.password_label.Text = "Password:";
this.password_label.Click += new System.EventHandler(this.password_label_Click);
//
// league_combobox
//
this.league_combobox.FormattingEnabled = true;
this.league_combobox.Location = new System.Drawing.Point(194, 189);
this.league_combobox.Name = "league_combobox";
this.league_combobox.Size = new System.Drawing.Size(189, 21);
this.league_combobox.TabIndex = 1;
this.league_combobox.Visible = false;
this.league_combobox.SelectedIndexChanged += new System.EventHandler(this.league_combobox_SelectedIndexChanged);
//
// match_combobox
//
this.match_combobox.FormattingEnabled = true;
this.match_combobox.Location = new System.Drawing.Point(194, 218);
this.match_combobox.Name = "match_combobox";
this.match_combobox.Size = new System.Drawing.Size(189, 21);
this.match_combobox.TabIndex = 2;
this.match_combobox.Visible = false;
this.match_combobox.SelectedIndexChanged += new System.EventHandler(this.match_combobox_SelectedIndexChanged);
//
// startbutton
//
this.startbutton.Location = new System.Drawing.Point(280, 248);
this.startbutton.Name = "startbutton";
this.startbutton.Size = new System.Drawing.Size(103, 32);
this.startbutton.TabIndex = 3;
this.startbutton.Text = "Start Match";
this.startbutton.UseVisualStyleBackColor = true;
this.startbutton.Visible = false;
this.startbutton.Click += new System.EventHandler(this.startbutton_Click);
//
// leaguelabel
//
this.leaguelabel.AutoSize = true;
this.leaguelabel.BackColor = System.Drawing.Color.Black;
this.leaguelabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.leaguelabel.ForeColor = System.Drawing.Color.White;
this.leaguelabel.Location = new System.Drawing.Point(90, 193);
this.leaguelabel.Name = "leaguelabel";
this.leaguelabel.Size = new System.Drawing.Size(91, 15);
this.leaguelabel.TabIndex = 24;
this.leaguelabel.Text = "Select League:";
this.leaguelabel.Visible = false;
//
// matchlabel
//
this.matchlabel.AutoSize = true;
this.matchlabel.BackColor = System.Drawing.Color.Black;
this.matchlabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.matchlabel.ForeColor = System.Drawing.Color.White;
this.matchlabel.Location = new System.Drawing.Point(97, 220);
this.matchlabel.Name = "matchlabel";
this.matchlabel.Size = new System.Drawing.Size(84, 15);
this.matchlabel.TabIndex = 25;
this.matchlabel.Text = "Select Match:";
this.matchlabel.Visible = false;
//
// finalizelabel
//
this.finalizelabel.AutoSize = true;
this.finalizelabel.BackColor = System.Drawing.Color.Black;
this.finalizelabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.finalizelabel.ForeColor = System.Drawing.Color.White;
this.finalizelabel.Location = new System.Drawing.Point(191, 193);
this.finalizelabel.Name = "finalizelabel";
this.finalizelabel.Size = new System.Drawing.Size(51, 15);
this.finalizelabel.TabIndex = 26;
this.finalizelabel.Text = "Activity:";
this.finalizelabel.Visible = false;
this.finalizelabel.Click += new System.EventHandler(this.finalizelabel_Click);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Black;
this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(470, 20);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(10, 10);
this.pictureBox1.TabIndex = 27;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click_1);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(500, 300);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.finalizelabel);
this.Controls.Add(this.matchlabel);
this.Controls.Add(this.leaguelabel);
this.Controls.Add(this.startbutton);
this.Controls.Add(this.match_combobox);
this.Controls.Add(this.league_combobox);
this.Controls.Add(this.password_label);
this.Controls.Add(this.login_label);
this.Controls.Add(this.userid);
this.Controls.Add(this.password);
this.Controls.Add(this.progressBar);
this.Controls.Add(this.loginbutton);
this.Controls.Add(this.finalizebutton);
this.Controls.Add(this.picScreen);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(500, 300);
this.Menu = this.mainMenu1;
this.MinimumSize = new System.Drawing.Size(500, 300);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ECO ANTI-CHEAT";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.picScreen)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void mnuCaptureScreen_Click(object sender, System.EventArgs e)
{
picScreen.Image = CaptureScreen.GetDesktopImage();
}
private void mnuExit_Click(object sender, System.EventArgs e)
{
}
private void picScreen_Click(object sender, EventArgs e)
{
}
private void menuItem1_Click(object sender, EventArgs e)
{
}
private void menuItem2_Click(object sender, EventArgs e)
{
}
public void MainForm_Closing(object sender, CancelEventArgs cArgs)
{
if (sendinfo == true)
{
finalize();
}
if (steaminstallpath != null)
{
DirectoryInfo di = new DirectoryInfo(steaminstallpath);
//FileInfo[] rgFiles = di.GetFiles("*");
DirectoryInfo[] rgFolders = di.GetDirectories();
foreach (DirectoryInfo fi in rgFolders)
{
if (fi.Name != "common" && fi.Name != "SourceMods")
{
steamFolders = steamFolders + Environment.NewLine + fi.Name;
unwriteConfigs(steaminstallpath + fi.Name);
}
}
}
}
private void unwriteConfigs(string steamfolder)
{
steamfolder = steamfolder + "\\counter-strike source\\cstrike\\cfg\\";
if (File.Exists(steamfolder + "autoexec.cfg"))
{
StringBuilder newFile = new StringBuilder();
string temp = "";
string[] file = File.ReadAllLines(steamfolder + "autoexec.cfg");
foreach (string line in file)
{
if (line.Contains("exec eco-config.cfg"))
{
temp = line.Replace("exec eco-config.cfg", "");
newFile.Append(temp);
continue;
}
newFile.Append(line + "\r\n");
}
File.WriteAllText(steamfolder + "autoexec.cfg", newFile.ToString());
}
}
private void MainForm_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e) // Finalize Button
{
finalize();
}
private void finalize()
{
try
{
Clock.Stop();
finalizelabel.Text = "Finalizing...";
string MyConString = "SERVER=66.189.220.3;" +
"DATABASE= league_ac;" +
"UID=acs;" +
"PASSWORD=error;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
//format the steamaccount array
string steamaccts = "";
string[] acctsarray = steamaccounts.ToArray();
foreach (string accts in acctsarray)
{
steamaccts = steamaccts + accts.ToString() + ";";
}
DateTime stopTime = DateTime.Now;
TimeSpan duration = stopTime - startTime;
string matchlength = duration.Hours + ":" + duration.Minutes + ":" + duration.Seconds;
Console.WriteLine("Time Difference (seconds): " + duration.Seconds);
Console.WriteLine("Time Difference (minutes): " + duration.Minutes);
Console.WriteLine("Time Difference (hours): " + duration.Hours);
Console.WriteLine("Time Difference (days): " + duration.Days);
command.CommandText = "insert into league_ac.css (userid,processlist,processactivity,computername,hardwareid,os,steamaccounts,matchlength) values (" + computerName + ", " + processesList + "," + processActivity + "," + computerName + ", " + hardwareID + ", " + OS + ", " + steamaccts + ", " + matchlength + ")";
connection.Open();
Reader = command.ExecuteReader();
connection.Close();
System.Windows.Forms.Application.Exit();
}
catch { MessageBox.Show("Server is unavailable, please retry", "Error"); }
}
private void sendImage(string filelocation, string imagesize)
{
int x = 10;
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 30L);
byte[] blob;
//Stream test;
PointofEntry:
try
{
// Ping server and make sure it lives
WebClient myWebClient = new WebClient();
string uriString = "http://" + uploadservers[Convert.ToInt16(selectedmatch), x] + "/eco-ac/ping.php";
Stream myStream = myWebClient.OpenRead(uriString);
StreamReader sr = new StreamReader(myStream);
string webresponse = sr.ReadToEnd();
webresponse = webresponse.Trim();
if (webresponse == "Pong")
{
// Send the Image
System.Net.WebClient Client = new System.Net.WebClient();
Client.Headers.Add("Content-Type", "binary/octet-stream");
UploadFileInBackground2("http://" + uploadservers[Convert.ToInt16(selectedmatch), x] + "/eco-ac/eco_ac_uploader.php?userid=" + userid.Text + "&league=" + league[Convert.ToInt16(selectedmatch)] + "&division=" + division[Convert.ToInt16(selectedmatch)] + "&week=" + week[Convert.ToInt16(selectedmatch)] + "&teamid=" + teamid[Convert.ToInt16(selectedmatch)] + "&matchid=" + matchid[Convert.ToInt16(selectedmatch)] + "&size=" + imagesize + "&count=" + count, filelocation);
}
else
{
throw new System.ArgumentException("Did not return Ping Request", "webresponse");
}
}
catch {
Console.WriteLine("trying another server");
x++;
goto PointofEntry;
}
}
// Sample call: UploadFileInBackground2("http://www.contoso.com/fileUpload.aspx", "data.txt")
private void UploadFileInBackground2(string address, string fileName)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
client.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileCallback2);
// Specify a progress notification handler.
client.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);
client.UploadFileAsync(uri, "POST", fileName);
Console.WriteLine("File upload started.");
}
private void UploadFileCallback2(object sender, EventArgs eArgs)
{
Console.WriteLine("IM A WINNER!");
this.progressBar.Value = 0;
init_Timer();
}
private void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
{
// Displays the operation identifier, and the transfer progress.
Console.WriteLine("{0} uploaded {1} of {2} bytes. {3} % complete...",
(string)e.UserState,
e.BytesSent,
e.TotalBytesToSend,
e.ProgressPercentage);
//Thread.Sleep(300); // throttle the upload bandwidth
if (e.ProgressPercentage <= 50 && e.ProgressPercentage >= 0)
{
this.progressBar.Value = e.ProgressPercentage * 2;
}
}
private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{
// Displays the operation identifier, and the transfer progress.
Console.WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...",
(string)e.UserState,
e.BytesReceived,
e.TotalBytesToReceive,
e.ProgressPercentage);
}
private void button2_Click(object sender, EventArgs e)
{
//init_Timer();
// grab login data
authenticate();
}
private void password_label_Click(object sender, EventArgs e)
{
}
private void authenticate()
{
// User Login Check, recieve array of useful info to populate game selection lists
WebClient myWebClient = new WebClient();
string uriString = "http://66.189.220.3/eco/eco-ac/eco_ac_login.php?userid=" + userid.Text + "&password=" + password.Text;
Stream myStream = myWebClient.OpenRead(uriString);
StreamReader sr = new StreamReader(myStream);
string webresponse = sr.ReadToEnd();
webresponse = webresponse.Trim();
if (webresponse == "Login Failed")
{
MessageBox.Show("Login Failed, try again", "Error");
}
else
{
string[] leaguearray = new string[15];
string[] acsSettingsarray = new string[29];
char[] splitter = { , };
char[] splitter2 = { ; };
leaguearray = webresponse.Split(splitter2);
for (int y = 0; y < leaguearray.Length; y++)
{
try
{
acsSettingsarray = leaguearray[y].Split(splitter);
matchid[y] = acsSettingsarray[0];
league[y] = acsSettingsarray[1];
division[y] = acsSettingsarray[2];
season[y] = acsSettingsarray[3];
week[y] = acsSettingsarray[4];
map[y] = acsSettingsarray[5];
teamname[y] = acsSettingsarray[6];
opponent[y] = acsSettingsarray[7];
leaguename[y] = acsSettingsarray[8];
teamid[y] = acsSettingsarray[9];
for (int x = 10; x < acsSettingsarray.Length; x++) // get all available upload servers
{
uploadservers[y,x] = acsSettingsarray[x];
}
// determine if the leaguename is listed twice or more in the combobox
bool leaguedouble = false;
for (int i = 0; i < league_combobox.Items.Count; i++)
{
Console.WriteLine(leaguename + " " + leaguename[y]);
if (leaguename[y] == league_combobox.Items.ToString())
{
leaguedouble = true;
}
}
if (leaguedouble == false)
{
league_combobox.Items.Add(leaguename[y]); // sort out the doubles first
}
//
for (int x = 0; x < acsSettingsarray.Length; x++) // for testing, prints all info recieved from server
{
Console.WriteLine(acsSettingsarray[x] + " " + acsSettingsarray.Length);
}
loginbutton.Visible = false;
userid.Visible = false;
password.Visible = false;
login_label.Visible = false;
password_label.Visible = false;
league_combobox.Visible = true;
match_combobox.Visible = true;
leaguelabel.Visible = true;
matchlabel.Visible = true;
}
catch { MessageBox.Show("Server is unavailable, please retry", "Error"); }
}
}
Console.WriteLine("\nDisplaying Data :\n");
Console.WriteLine(webresponse);
myStream.Close();
}
private void league_combobox_SelectedIndexChanged(object sender, EventArgs e)
{
selectedleague = league_combobox.SelectedItem.ToString();
match_combobox.Items.Clear(); // clear all from match combobox so matches arent added twice
Console.WriteLine(selectedleague);
for (int x = 0; x < teamname.Length; x++) // get all available upload servers
{
if (leaguename[x] == selectedleague)
{
//match_combobox.Items.Add(teamname[x] + " (home) Vs " + opponent[x] + " (away)");
match_combobox.Items.Add(new itemobject(teamname[x] + " (home) Vs " + opponent[x] + " (away)", x));
}
}
}
private void match_combobox_SelectedIndexChanged(object sender, EventArgs e)
{
// track the selected match array id
itemobject obj = (itemobject)match_combobox.SelectedItem;
selectedmatch = obj.Value.ToString();
Console.WriteLine("Selected: " + selectedmatch);
startbutton.Visible = true;
}
private void startbutton_Click(object sender, EventArgs e)
{
init_Timer(); // begin with the screenshots
sendinfo = true;
startbutton.Visible = false;
match_combobox.Visible = false;
league_combobox.Visible = false;
leaguelabel.Visible = false;
matchlabel.Visible = false;
finalizebutton.Visible = true;
progressBar.Visible = true;
finalizelabel.Visible = true;
}
private void progressBar_Click(object sender, EventArgs e)
{
}
private void finalizelabel_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click_1(object sender, EventArgs e)
{
finalize();
}
}
}
If you know how to solve any of these errors please help me. Thanks in advance!
These are the errors:
Continue reading...