示例#1
0
        /// <summary>
        /// Read login
        /// </summary>
        /// <param name="recvLogin">
        /// Username sent by client
        /// </param>
        public void GetLoginFlags(string recvLogin)
        {
            DBLoginData login = LoginDataDao.GetByUsername(recvLogin);

            if (login != null)
            {
                this.flagsL = login.Flags;
            }
        }
示例#2
0
        /// <summary>
        /// </summary>
        /// <param name="recvLogin">
        /// </param>
        public void GetLoginName(string recvLogin)
        {
            this.loginN = null;
            DBLoginData temp = LoginDataDao.GetByUsername(recvLogin);

            if (temp != null)
            {
                this.loginN = LoginDataDao.GetByUsername(recvLogin).Username;
            }
        }
示例#3
0
        /// <summary>
        /// </summary>
        /// <param name="RecvLogin">
        /// </param>
        /// <returns>
        /// </returns>
        private string GetLoginPassword(string RecvLogin)
        {
            DBLoginData loginPassword = LoginDataDao.GetByUsername(RecvLogin);

            if (loginPassword != null)
            {
                return(loginPassword.Password);
            }

            LogUtil.Debug(string.Format("No entry for account username '{0}' found", RecvLogin));
            return(string.Empty);
        }
示例#4
0
 /// <summary>
 /// </summary>
 /// <param name="obj">
 /// </param>
 private static void LogoffCharacters(string[] obj)
 {
     if (obj.Length != 2)
     {
         Colouring.Push(ConsoleColor.Red);
         Console.WriteLine("Syntax: logoffchars <username>");
         Colouring.Pop();
     }
     else
     {
         LoginDataDao.LogoffChars(obj[1]);
     }
 }
示例#5
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        private static bool CheckDatabase()
        {
            bool result = true;

            try
            {
                LoginDataDao.GetAll();
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
示例#6
0
        /// <summary>
        /// </summary>
        /// <param name="obj">
        /// </param>
        private static void AddUser(string[] obj)
        {
            Colouring.Push(ConsoleColor.Red);
            bool argsOk = CheckAddUserParameters(obj);

            Colouring.Pop();

            if (!argsOk)
            {
                return;
            }

            DBLoginData login = new DBLoginData
            {
                Username           = obj[1],
                AccountFlags       = 0,
                Allowed_Characters = int.Parse(obj[3]),
                CreationDate       = DateTime.Now,
                Email      = obj[6],
                Expansions = int.Parse(obj[4]),
                FirstName  = obj[7],
                LastName   = obj[8],
                GM         = int.Parse(obj[5]),
                Flags      = 0,
                Password   = new LoginEncryption().GeneratePasswordHash(obj[2])
            };

            try
            {
                LoginDataDao.WriteLoginData(login);
            }
            catch (Exception ex)
            {
                Colouring.Push(ConsoleColor.Red);
                Console.WriteLine(
                    "An error occured while trying to add a new user account:" + Environment.NewLine + "{0}",
                    ex.Message);
                Colouring.Pop();
                return;
            }

            Colouring.Push(ConsoleColor.Green);
            Console.WriteLine("User added successfully.");
            Colouring.Pop();
        }
示例#7
0
        /// <summary>
        /// </summary>
        /// <param name="obj">
        /// </param>
        private static void SetGMLevel(string[] obj)
        {
            int gmlevel = 0;

            if ((obj.Length != 3) || (!int.TryParse(obj[2], out gmlevel)))
            {
                Colouring.Push(ConsoleColor.Red);
                Console.WriteLine("Syntax: setgm <username> <gmlevel>");
                Console.WriteLine("gmlevel range: 0 - 511");
                Colouring.Pop();
            }
            else
            {
                LoginDataDao.SetGM(obj[1], gmlevel);
                Colouring.Push(ConsoleColor.Green);
                Console.WriteLine("Successfully set GM Level " + gmlevel + " to account " + obj[1]);
                Colouring.Pop();
            }
        }
示例#8
0
        // TODO: Figure out how to get ChatServe to gather some information about Users?

        // public TwitterUser TwitterUser
        // {
        // get;
        // private set;
        // }

        #region Public Methods and Operators

        /// <summary>
        /// </summary>
        /// <param name="username">
        /// </param>
        /// <param name="password">
        /// </param>
        /// <returns>
        /// </returns>
        public bool LogIn(string username, string password)
        {
            try
            {
                string dUser = LoginDataDao.GetByUsername(username).Username;

                if (dUser != username)
                {
                    return(false);
                }

                this.IsAuthenticated = true;

                return(true);
            }
            catch (SqlException)
            {
                throw;
            }
        }
示例#9
0
        /// <summary>
        /// </summary>
        /// <param name="obj">
        /// </param>
        private static void SetPassword(string[] obj)
        {
            string Syntax =
                "The syntax for this command is \"setpass <account username> <newpass>\" where newpass is alpha numeric no spaces";

            if (obj.Length != 3)
            {
                Colouring.Push(ConsoleColor.Red);
                Console.WriteLine(Syntax);
                Colouring.Pop();
            }
            else
            {
                string username = obj[1];
                string newpass  = obj[2];
                var    le       = new LoginEncryption();
                string hashed   = le.GeneratePasswordHash(newpass);
                int    affected =
                    LoginDataDao.WriteNewPassword(new DBLoginData()
                {
                    Username = username, Password = hashed
                });
                if (affected == 0)
                {
                    Colouring.Push(ConsoleColor.Red);
                    Console.WriteLine("Could not set new password. Maybe username is wrong?");
                    Colouring.Pop();
                }
                else
                {
                    Colouring.Push(ConsoleColor.Green);
                    Console.WriteLine("New password is set.");
                    Colouring.Pop();
                }
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="message">
        /// </param>
        public void Handle(object sender, Message message)
        {
            var client = (Client)sender;
            var userCredentialsMessage = (UserCredentialsMessage)message.Body;
            var checkLogin             = new CheckLogin();

            if (checkLogin.IsLoginAllowed(client, userCredentialsMessage.UserName) == false)
            {
                Colouring.Push(ConsoleColor.Green);
                Console.WriteLine(
                    "Client '" + client.AccountName
                    + "' banned, not a valid username, or sent a malformed Authentication Packet");
                Colouring.Pop();

                client.Send(0x00001F83, new LoginErrorMessage {
                    Error = LoginError.InvalidUserNamePassword
                });
                client.Server.DisconnectClient(client);
                return;
            }

            if (checkLogin.IsLoginCorrect(client, userCredentialsMessage.Credentials) == false)
            {
                Colouring.Push(ConsoleColor.Green);
                Console.WriteLine("Client '" + client.AccountName + "' failed Authentication.");

                client.Send(0x00001F83, new LoginErrorMessage {
                    Error = LoginError.InvalidUserNamePassword
                });
                client.Server.DisconnectClient(client);
                Colouring.Pop();

                return;
            }

            int expansions        = 0;
            int allowedCharacters = 0;

            /* This checks your expansions and
             * number of characters allowed (num. of chars doesn't work)*/
            string sqlQuery = "SELECT `Expansions`,`Allowed_Characters` FROM `login` WHERE Username = '******'";
            DBLoginData loginData = LoginDataDao.GetByUsername(client.AccountName);

            expansions        = loginData.Expansions;
            allowedCharacters = loginData.Allowed_Characters;

            IEnumerable <LoginCharacterInfo> characters = from c in CharacterList.LoadCharacters(client.AccountName)
                                                          select
                                                          new LoginCharacterInfo
            {
                Unknown1 = 4,
                Id       = c.Id,
                PlayfieldProxyVersion = 0x61,
                PlayfieldId           =
                    new Identity {
                    Type = IdentityType.Playfield, Instance = c.Playfield
                },
                PlayfieldAttribute   = 1,
                ExitDoor             = 0,
                ExitDoorId           = Identity.None,
                Unknown2             = 1,
                CharacterInfoVersion = 5,
                CharacterId          = c.Id,
                Name       = c.Name,
                Breed      = (Breed)c.Breed,
                Gender     = (Gender)c.Gender,
                Profession = (Profession)c.Profession,
                Level      = c.Level,
                AreaName   = "area unknown",
                Status     = CharacterStatus.Active
            };
            var characterListMessage = new CharacterListMessage
            {
                Characters        = characters.ToArray(),
                AllowedCharacters = allowedCharacters,
                Expansions        = expansions
            };

            client.Send(0x0000615B, characterListMessage);
        }
示例#11
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        private int CreateNewChar()
        {
            int charID = 0;

            switch (this.Breed)
            {
            case 0x1:     /* solitus */
                this.Abis = new[] { 6, 6, 6, 6, 6, 6 };
                break;

            case 0x2:     /* opifex */
                this.Abis = new[] { 3, 3, 10, 6, 6, 15 };
                break;

            case 0x3:     /* nanomage */
                this.Abis = new[] { 3, 10, 6, 15, 3, 3 };
                break;

            case 0x4:     /* atrox */
                this.Abis = new[] { 15, 3, 3, 3, 10, 6 };
                break;

            default:
                Console.WriteLine("unknown breed: ", this.Breed);
                break;
            }

            /*
             * Note, all default values are not specified here as defaults are handled
             * in the CharacterStats Class for us automatically. Also minimises SQL
             * usage for default stats that are never changed from their default value
             *           ~NV
             */
            // Delete orphaned stats for charID
            StatDao.DeleteStats(50000, charID);
            try
            {
                CharacterDao.AddCharacter(
                    new DBCharacter
                {
                    FirstName = string.Empty,
                    LastName  = string.Empty,
                    Name      = this.Name,
                    Username  = this.AccountName,
                });
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e);
                return(0);
            }

            try
            {
                /* select new char id */
                charID = CharacterDao.GetByCharName(this.Name).Id;
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e);
                return(0);
            }

            List <DBStats> stats = new List <DBStats>();

            // Transmit GM level into stats table
            stats.Add(
                new DBStats
            {
                type      = 50000,
                instance  = charID,
                statid    = 215,
                statvalue = LoginDataDao.GetByUsername(this.AccountName).GM
            });

            // Flags
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 0, statvalue = 20
            });

            // Level
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 54, statvalue = 1
            });

            // SEXXX
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 59, statvalue = this.Gender
            });

            // Headmesh
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 64, statvalue = this.HeadMesh
            });

            // MonsterScale
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 360, statvalue = this.MonsterScale
            });

            // Visual Sex (even better ^^)
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 369, statvalue = this.Gender
            });

            // Breed
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 4, statvalue = this.Breed
            });

            // Visual Breed
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 367, statvalue = this.Breed
            });

            // Profession / 60
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 60, statvalue = this.Profession
            });

            // VisualProfession / 368
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 368, statvalue = this.Profession
            });

            // Fatness / 47
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 47, statvalue = this.Fatness
            });

            // Strength / 16
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 16, statvalue = this.Abis[0]
            });

            // Psychic / 21
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 21, statvalue = this.Abis[1]
            });

            // Sense / 20
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 20, statvalue = this.Abis[2]
            });

            // Intelligence / 19
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 19, statvalue = this.Abis[3]
            });

            // Stamina / 18
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 18, statvalue = this.Abis[4]
            });

            // Agility / 17
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 17, statvalue = this.Abis[5]
            });

            // Set HP and NP auf 1
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 1, statvalue = 1
            });
            stats.Add(new DBStats {
                type = 50000, instance = charID, statid = 214, statvalue = 1
            });

            stats.Add(
                new DBStats
            {
                type      = 50000,
                instance  = charID,
                statid    = 389,
                statvalue = LoginDataDao.GetByUsername(this.AccountName).Expansions
            });

            StatDao.BulkReplace(stats);

            return(charID);
        }
示例#12
0
        /// <summary>
        /// </summary>
        /// <param name="args">
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        private static void Main(string[] args)
        {
            LogUtil.SetupConsoleLogging(LogLevel.Debug);
            LogUtil.SetupFileLogging("${basedir}/LoginEngineLog.txt", LogLevel.Trace);



            SettingsOverride.LoadCustomSettings("NBug.LoginEngine.Config");
            Settings.WriteLogToDisk = true;
            AppDomain.CurrentDomain.UnhandledException += Handler.UnhandledException;
            TaskScheduler.UnobservedTaskException      += Handler.UnobservedTaskException;



            Console.Title = "CellAO " + AssemblyInfoclass.Title + " Console. Version: " + AssemblyInfoclass.Description
                            + " " + AssemblyInfoclass.AssemblyVersion + " " + AssemblyInfoclass.Trademark;

            var ct = new ConsoleText();

            ct.TextRead("main.txt");
            Console.Write("Loading ");
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.Write(AssemblyInfoclass.Title + " ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(AssemblyInfoclass.Description);
            Console.ResetColor();
            Console.WriteLine("...");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("[OK]");
            Console.ResetColor();

            // Sying helped figure all this code out, about 5 yearts ago! :P
            bool processedargs = false;

            loginServer = Container.GetInstance <LoginServer>();
            bool TCPEnable = true;
            bool UDPEnable = false;
            int  Port      = Convert.ToInt32(Config.Instance.CurrentConfig.LoginPort);

            try
            {
                if (Config.Instance.CurrentConfig.ListenIP == "0.0.0.0")
                {
                    loginServer.TcpEndPoint = new IPEndPoint(IPAddress.Any, Port);
                }
                else
                {
                    loginServer.TcpIP = IPAddress.Parse(Config.Instance.CurrentConfig.ListenIP);
                }
            }
            catch
            {
                ct.TextRead("ip_config_parse_error.txt");
                Console.ReadKey();
                return;
            }

            // TODO: ADD More Handlers.
            loginServer.MaximumPendingConnections = 100;

            #region Console Commands

            // Andyzweb: Added checks for start and stop
            // also added a running command to return status of the server
            // and added Console.Write("\nServer Command >>"); to login server
            string consoleCommand;
            ct.TextRead("login_consolecommands.txt");
            while (true)
            {
                if (!processedargs)
                {
                    if (args.Length == 1)
                    {
                        if (args[0].ToLower() == "/autostart")
                        {
                            ct.TextRead("autostart.txt");
                            loginServer.Start(TCPEnable, UDPEnable);
                        }
                    }

                    processedargs = true;
                }

                Console.Write("\nServer Command >>");

                consoleCommand = Console.ReadLine();
                string temp = string.Empty;
                while (temp != consoleCommand)
                {
                    temp           = consoleCommand;
                    consoleCommand = consoleCommand.Replace("  ", " ");
                }

                consoleCommand = consoleCommand.Trim();
                switch (consoleCommand.ToLower())
                {
                case "start":
                    if (loginServer.IsRunning)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        ct.TextRead("loginisrunning.txt");
                        Console.ResetColor();
                        break;
                    }

                    loginServer.Start(TCPEnable, UDPEnable);
                    break;

                case "stop":
                    if (!loginServer.IsRunning)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        ct.TextRead("loginisnotrunning.txt");
                        Console.ResetColor();
                        break;
                    }

                    loginServer.Stop();
                    break;

                case "exit":
                    Process.GetCurrentProcess().Kill();
                    break;

                case "running":
                    if (loginServer.IsRunning)
                    {
                        // Console.WriteLine("Login Server is running");
                        ct.TextRead("loginisrunning.txt");
                        break;
                    }

                    // Console.WriteLine("Login Server not running");
                    ct.TextRead("loginisnotrunning.txt");
                    break;

                    #region Help Commands....

                case "help":
                    ct.TextRead("logincmdhelp.txt");
                    break;

                case "help start":
                    ct.TextRead("helpstart.txt");
                    break;

                case "help exit":
                    ct.TextRead("helpstop.txt");
                    break;

                case "help running":
                    ct.TextRead("loginhelpcmdrunning.txt");
                    break;

                case "help Adduser":
                    ct.TextRead("logincmdadduserhelp.txt");
                    break;

                case "help setpass":
                    ct.TextRead("logincmdhelpsetpass.txt");
                    break;

                    #endregion

                default:

                    #region Adduser

                    // This section handles the command for adding a user to the database
                    if (consoleCommand.ToLower().StartsWith("adduser"))
                    {
                        string[] parts = consoleCommand.Split(' ');
                        if (parts.Length < 9)
                        {
                            Console.WriteLine(
                                "Invalid command syntax.\nPlease use:\nAdduser <username> <password> <number of characters> <expansion> <gm level> <email> <FirstName> <LastName>");
                            break;
                        }

                        string username = parts[1];
                        string password = parts[2];
                        int    numChars = 0;
                        try
                        {
                            numChars = int.Parse(parts[3]);
                        }
                        catch
                        {
                            Console.WriteLine("Error: <number of characters> must be a number (duh!)");
                            break;
                        }

                        int expansions = 0;
                        try
                        {
                            expansions = int.Parse(parts[4]);
                        }
                        catch
                        {
                            Console.WriteLine("Error: <expansions> must be a number between 0 and 2047!");
                            break;
                        }

                        if (expansions < 0 || expansions > 2047)
                        {
                            Console.WriteLine("Error: <expansions> must be a number between 0 and 2047!");
                            break;
                        }

                        int gm = 0;
                        try
                        {
                            gm = int.Parse(parts[5]);
                        }
                        catch
                        {
                            Console.WriteLine("Error: <GM Level> must be number (duh!)");
                            break;
                        }

                        string email = parts[6];
                        if (email == null)
                        {
                            email = string.Empty;
                        }

                        if (!TestEmailRegex(email))
                        {
                            Console.WriteLine("Error: <Email> You must supply an email address for this account");
                            break;
                        }

                        string firstname = parts[7];
                        try
                        {
                            if (firstname == null)
                            {
                                throw new ArgumentNullException();
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Error: <FirstName> You must supply a first name for this accout");
                            break;
                        }

                        string lastname = parts[8];
                        try
                        {
                            if (lastname == null)
                            {
                                throw new ArgumentNullException();
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Error: <LastName> You must supply a last name for this account");
                            break;
                        }

                        DBLoginData login = new DBLoginData
                        {
                            Username           = username,
                            AccountFlags       = 0,
                            Allowed_Characters = numChars,
                            CreationDate       = DateTime.Now,
                            Email      = email,
                            Expansions = expansions,
                            FirstName  = firstname,
                            LastName   = lastname,
                            GM         = gm,
                            Flags      = 0,
                            Password   = new LoginEncryption().GeneratePasswordHash(password)
                        };
                        try
                        {
                            LoginDataDao.WriteLoginData(login);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(
                                "An error occured while trying to add a new user account:\n{0}", ex.Message);
                            break;
                        }

                        Console.WriteLine("User added successfully.");
                        break;
                    }

                    #endregion

                    #region Hashpass

                    // This function just hashes the string you enter using the loginencryption method
                    if (consoleCommand.ToLower().StartsWith("hash"))
                    {
                        string Syntax =
                            "The Syntax for this command is \"hash <String to hash>\" alphanumeric no spaces";
                        string[] parts = consoleCommand.Split(' ');
                        if (parts.Length != 2)
                        {
                            Console.WriteLine(Syntax);
                            break;
                        }

                        string pass   = parts[1];
                        var    le     = new LoginEncryption();
                        string hashed = le.GeneratePasswordHash(pass);
                        Console.WriteLine(hashed);
                        break;
                    }

                    #endregion

                    #region setpass

                    // sets the password for the given username
                    // Added by Andyzweb
                    // Still TODO add exception and error handling
                    if (consoleCommand.ToLower().StartsWith("setpass"))
                    {
                        string Syntax =
                            "The syntax for this command is \"setpass <account username> <newpass>\" where newpass is alpha numeric no spaces";
                        string[] parts = consoleCommand.Split(' ');
                        if (parts.Length != 3)
                        {
                            Console.WriteLine(Syntax);
                            break;
                        }

                        string username = parts[1];
                        string newpass  = parts[2];
                        var    le       = new LoginEncryption();
                        string hashed   = le.GeneratePasswordHash(newpass);

                        try
                        {
                            LoginDataDao.WriteNewPassword(
                                new DBLoginData {
                                Username = username, Password = hashed
                            });
                        }
                        // yeah this part here, some kind of exception handling for mysql errors
                        catch (Exception ex)
                        {
                            Console.WriteLine("Could not set new Password\r\n" + ex.Message);
                            LogUtil.ErrorException(ex);
                        }
                    }

                    #endregion

                    ct.TextRead("login_consolecmdsdefault.txt");
                    break;
                }
            }

            #endregion
        }
 /// <summary>
 /// Returns the Password hash
 /// </summary>
 /// <param name="recvLogin">
 /// Username received from the client
 /// </param>
 public void GetLoginPassword(string recvLogin)
 {
     this.passwdL = LoginDataDao.GetByUsername(recvLogin).Username;
 }
示例#14
0
        /// <summary>
        /// </summary>
        /// <param name="obj">
        /// </param>
        private static void AddUser(string[] obj)
        {
            if (obj.Length == 1)
            {
                List <string> temp = new List <string>();
                temp.Add("adduser");

                while (true)
                {
                    Console.Write("Username: "******"Please enter a username (at least 6 chars)...");
                        continue;
                    }
                    if (CheckUsername(test))
                    {
                        temp.Add(test);
                        break;
                    }
                }

                while (true)
                {
                    Console.Write("Password: "******"Please enter a password (at least 6 chars) for your safety...");
                        continue;
                    }
                    temp.Add(test);
                    break;
                }

                while (true)
                {
                    Console.WriteLine("Number of character slots: ");
                    string test = Console.ReadLine();
                    if (IsNumber(test))
                    {
                        temp.Add(test);
                        break;
                    }
                }

                Console.WriteLine("Expansions: Enter 2047 for all expansions (i know you want that)");
                while (true)
                {
                    Console.Write("Expansions: ");
                    string test = Console.ReadLine();
                    if (IsNumber(test))
                    {
                        temp.Add(test);
                        break;
                    }
                }

                Console.WriteLine(
                    "GM-Level: Anything above 0 is GM, but there are differences. Full Client GM = 1 (using keyboard shortcuts) but for some items you have to be GM Level 511");
                while (true)
                {
                    Console.Write("GM-Level: ");
                    string test = Console.ReadLine();
                    if (IsNumber(test))
                    {
                        temp.Add(test);
                        break;
                    }
                }

                while (true)
                {
                    Console.WriteLine("E-Mail: ");
                    string test = Console.ReadLine();
                    if (TestEmailRegex.TestEmail(test))
                    {
                        temp.Add(test);
                        break;
                    }
                }

                Console.Write("First name: ");
                temp.Add(Console.ReadLine());

                Console.Write("Last name: ");
                temp.Add(Console.ReadLine());

                obj = temp.ToArray();
            }

            Colouring.Push(ConsoleColor.Red);
            bool argsOk = CheckAddUserParameters(obj);

            Colouring.Pop();

            if (!argsOk)
            {
                return;
            }

            DBLoginData login = new DBLoginData
            {
                Username          = obj[1],
                AccountFlags      = 0,
                AllowedCharacters = int.Parse(obj[3]),
                CreationDate      = DateTime.Now,
                Email             = obj[6],
                Expansions        = int.Parse(obj[4]),
                FirstName         = obj[7],
                LastName          = obj[8],
                GM       = int.Parse(obj[5]),
                Flags    = 0,
                Password = new LoginEncryption().GeneratePasswordHash(obj[2])
            };

            try
            {
                LoginDataDao.WriteLoginData(login);
            }
            catch (Exception ex)
            {
                Colouring.Push(ConsoleColor.Red);
                Console.WriteLine(
                    "An error occured while trying to add a new user account:" + Environment.NewLine + "{0}",
                    ex.Message);
                Colouring.Pop();
                return;
            }

            Colouring.Push(ConsoleColor.Green);
            Console.WriteLine("User added successfully.");
            Colouring.Pop();
        }