Exemple #1
0
 internal void Load(Command.List commands,out string error)
 {
     groups.Clear();
     standard = null;
     int loaded = 0;
     int failed = 0;
     int cursor = Console.CursorLeft;
     error = null;
     if (!Directory.Exists("groups")) { return; }
     foreach (string file in Directory.GetFiles("groups","*."+host.Extension)) {
         string name = file.Substring(7,file.Length-host.Extension.Length-8);
         Group group = Group.Load(commands,name);
         if (group==null) { failed++; } else {
             if (group.standard) {
                 if (standard!=null) { error = "More than one standard group specified."; }
                 else { standard = group; }
             } loaded++;
             groups.Add(group.name.ToLower(),group);
         }
         Console.Write((loaded<0?-loaded:loaded)+" group"+(loaded==1?"":"s")+" loaded"+(failed==0?"":" ("+failed+" failed)")+".");
         Console.CursorLeft = cursor;
     }
     Console.Write((loaded<0?-loaded:loaded)+" group"+(loaded==1?"":"s")+" loaded"+(failed==0?"":" ("+failed+" failed)")+".");
     if (loaded==0) { error = "No groups loaded."; }
     else if (standard==null) { error = "No standard group specified."; }
 }
Exemple #2
0
 internal void Load(Group.List groups)
 {
     accounts.Clear();
     this.groups = groups;
     int loaded = 0;
     int failed = 0;
     int cursor = Console.CursorLeft;
     if (!Directory.Exists("accounts")) { return; }
     foreach (string file in Directory.GetFiles("accounts","*."+host.Extension)) {
         string name = file.Substring(9,file.Length-host.Extension.Length-10);
         Account account = Account.Load(groups,name);
         if (account==null) { failed++; }
         else { loaded++; accounts.Add(account.name.ToLower(),account); }
         Console.Write(loaded+" account"+(loaded==1?"":"s")+" loaded"+(failed==0?"":" ("+failed+" failed)")+".");
         Console.CursorLeft = cursor;
     }
     Console.Write(loaded+" account"+(loaded==1?"":"s")+" loaded"+(failed==0?"":" ("+failed+" failed)")+".");
 }
Exemple #3
0
 private static Group Load(Command.List commands,string name)
 {
     try {
         string filename = "groups/"+name+"."+host.Extension;
         string rootName;
         Node node = host.Load(filename,out rootName);
         if (rootName!="group") { return null; }
         string n = (string)node["name"].Value;
         if (n.ToLower()!=name.ToLower()) { return null; }
         Group group = new Group(n);
         group.standard = bool.Parse((string)node["standard"].Value);
         group.prefix = (string)node["prefix"].Value;
         group.postfix = (string)node["postfix"].Value;
         node["privileges"].ListForeach(group.LoadPrivilege);
         group.commands = commands.LoadPermissionList(node["commands"]);
         group.custom = node["custom"]??group.custom;
         return group;
     } catch { return null; }
 }
Exemple #4
0
 private static Account Load(Group.List groups,string name)
 {
     try {
         string filename = "accounts/"+name+"."+host.Extension;
         string rootName;
         Node node = host.Load(filename,out rootName);
         if (rootName!="account") { return null; }
         string n = (string)node["name"].Value;
         if (n.ToLower()!=name.ToLower()) { return null; }
         Group group = groups[(string)node["group"].Value];
         if (group==null) { return null; }
         Account account = new Account(n);
         Node statistics = node["statistics"];
         account.group = group;
         account.logins = (int)statistics["logins"].Value;
         account.total = TimeSpan.Parse((string)statistics["total"].Value);
         account.lastLogin = DateTime.Parse((string)statistics["lastLogin"].Value);
         account.lastLogout = DateTime.Parse((string)statistics["lastLogout"].Value);
         account.lastIP = (string)statistics["lastIP"].Value;
         account.fileModified = File.GetLastWriteTime(filename);
         account.custom = node["custom"]??account.custom;
         return account;
     } catch { return null; }
 }