Adds UserManager to sql

Changes the way Warps and Regions are stored
A few other minor tweaks
This commit is contained in:
Twitchy 2011-07-09 16:33:07 +12:00
parent 4a25cd612c
commit cb7033d89c
10 changed files with 154 additions and 430 deletions

View file

@ -533,90 +533,6 @@ namespace TShockAPI
return new Group("null");
}
/// <summary>
/// Returns a Group for a ip from users.txt
/// </summary>
/// <param name="ply">string ip</param>
public static Group GetGroupForIP(string ip)
{
ip = GetRealIP(ip);
StreamReader sr = new StreamReader(FileTools.UsersPath);
string data = sr.ReadToEnd();
data = data.Replace("\r", "");
string[] lines = data.Split('\n');
for (int i = 0; i < lines.Length; i++)
{
string[] args = lines[i].Split(' ');
if (args.Length < 2)
{
continue;
}
if (args[0].Contains(":"))
{
continue;
}
if (lines[i].StartsWith("#"))
{
continue;
}
try
{
var hi = GetIPv4Address(args[0]);
if (GetIPv4Address(args[0]).Equals(ip))
return GetGroup(args[1]);
}
catch (Exception ex)
{ Log.Error(ex.ToString()); }
}
sr.Close();
return GetGroup("default");
}
/// <summary>
/// Fetches the hashed password and group for a given username
/// </summary>
/// <param name="username">string username</param>
/// <returns>string[] {password, group}</returns>
public static string[] FetchHashedPasswordAndGroup(string username)
{
StreamReader sr = new StreamReader(FileTools.UsersPath);
string data = sr.ReadToEnd();
data = data.Replace("\r", "");
string[] lines = data.Split('\n');
string[] result = {"null", "null"};
for (int i = 0; i < lines.Length; i++)
{
string[] args = lines[i].Split(' ');
if (args.Length < 2)
{
continue;
}
if (lines[i].StartsWith("#"))
{
continue;
}
if (!lines[i].Contains(":"))
{
continue;
}
try
{
if (args[0].Split(':')[0].ToLower() == username.ToLower())
{
result = new string[] {args[0].Split(':')[1], args[1]};
return result;
}
}
catch (Exception ex)
{ Log.Error(ex.ToString()); }
}
sr.Close();
return result;
}
/// <summary>
/// Returns an IPv4 address from a DNS query
/// </summary>