using System; using System.Threading; using System.Collections; using System.Collections.Generic; using System.Data; using MySql.Data.MySqlClient; namespace gServer { public class MainClass { public int SecondsPassed = 0; public int SecondsPassedHalf = 0; private String MySQL_Host = "localhost"; private String MySQL_Username = "gs"; private String MySQL_Password = "gs"; private String MySQL_Database = "gs"; private String MySQL_Connector = ""; private IDbConnection MySQL_Connection; public MrAG.Serverlist.Server Listener; public MrAG.Serverlist.Server ListenerAlternative; public MrAG.Serverlist.Server ServerlistListener; public List Users = new List(); public List ServerlistServers = new List(); public List Servers = new List(); public void Start() { this.MySQL_Connector = "Server=" + this.MySQL_Host + ";" + "Database=" + this.MySQL_Database + ";" + "User ID=" + this.MySQL_Username + ";" + "Password=" + this.MySQL_Password + ";" + "Pooling=false"; this.MySQL_Connection = new MySqlConnection(this.MySQL_Connector); this.MySQL_Connection.Open(); this.Query("UPDATE `users` SET `API_Sessionkey`=''"); this.Listener = MrAG.Serverlist.Host("__site", 17000, "__site", false); this.ListenerAlternative = MrAG.Serverlist.Host("__site", 2222, "__site", false); this.Listener.OnIncomingConnection = new Action(IncomingConnection); this.Listener.OnFinishedConnection = new Action(FinishedConnection); this.ListenerAlternative.OnIncomingConnection = new Action(IncomingConnection); this.ListenerAlternative.OnFinishedConnection = new Action(FinishedConnection); this.Listener.Timeout = 2000; this.ListenerAlternative.Timeout = 2000; this.Log("GamerServices server started on port 17000 (and 2222)."); this.ServerlistListener = MrAG.Serverlist.Host("__site", 8443, "__site", false); this.ServerlistListener.OnIncomingConnection = new Action(Serverlist_IncomingConnection); this.ServerlistListener.OnFinishedConnection = new Action(Serverlist_FinishedConnection); this.ServerlistListener.Timeout = 2000; double LastKeepAliveForSQL = DateTime.Now.TimeOfDay.TotalMinutes; // keepalive :3 while(true) { if (Math.Abs(LastKeepAliveForSQL - DateTime.Now.TimeOfDay.TotalMinutes) >= 30){ // 30 min interval this.Query("SELECT 1"); // Completly useless query, just for keepalive :3 LastKeepAliveForSQL = DateTime.Now.TimeOfDay.TotalMinutes; } this.Listener.Update(); this.ListenerAlternative.Update(); this.ServerlistListener.Update(); for(int i=0; i ret = new List(); while(resource.Read()) { Hashtable newRow = new Hashtable(); for (int i=0; i \\ ret = ret.Replace("'", "\\'"); // ' -> \' return ret; } public string MD5(string input) { System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); System.Text.StringBuilder s = new System.Text.StringBuilder(); byte[] bs = System.Text.Encoding.UTF8.GetBytes(input); bs = x.ComputeHash(bs); foreach (byte b in bs) { s.Append(b.ToString("x2")); } return s.ToString().ToLower(); } public static void Main (string[] args) { new MainClass().Start(); } } }