示例#1
0
        public void NewAccount(C.NewAccount P)
        {
            if (Stage != GameStage.Login)
            {
                return;
            }

            MirDB.CreateAccount(P, this);
        }
示例#2
0
        static void NewAccount(C.NewAccount P, string IPAddress)
        {
            DBCommand.Parameters.Clear();
            DBCommand.CommandText =
                "INSERT INTO [Account Info] (" +
                "[Account ID], [Password], [Birth Date], [User Name], [Secret Question], [Secret Answer], [EMail Address], [Creator IP], [Creation Date])" +
                "VALUES (@AccountID, @Password, @BirthDate, @UserName, @SecretQuestion, @SecretAnswer, @EMailAddress, @CreatorIP, @CreationDate)";

            DBCommand.Parameters.AddWithValue("@AccountID", P.AccountID);
            DBCommand.Parameters.AddWithValue("@Password", P.Password);
            DBCommand.Parameters.AddWithValue("@BirthDate", P.BirthDate.Ticks);
            DBCommand.Parameters.AddWithValue("@UserName", P.UserName);
            DBCommand.Parameters.AddWithValue("@SecretQuestion", P.SecretQuestion);
            DBCommand.Parameters.AddWithValue("@SecretAnswer", P.SecretAnswer);
            DBCommand.Parameters.AddWithValue("@EMailAddress", P.EMailAddress);

            DBCommand.Parameters.AddWithValue("@CreatorIP", IPAddress);
            DBCommand.Parameters.AddWithValue("@CreationDate", Main.Now.Ticks);

            DBCommand.ExecuteNonQuery();
        }
示例#3
0
        public static void CreateAccount(C.NewAccount P, MirConnection Con)
        {
            if (!Settings.AllowNewAccount)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 1
                });
                return;
            }

            if (!AccountIDReg.IsMatch(P.AccountID))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 2
                });
                return;
            }

            if (!PasswordReg.IsMatch(P.Password))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 3
                });
                return;
            }
            if (!string.IsNullOrWhiteSpace(P.EMailAddress) && !EMailReg.IsMatch(P.EMailAddress))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 4
                });
                return;
            }

            if (!string.IsNullOrWhiteSpace(P.UserName) && P.UserName.Length > 30)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 5
                });
                return;
            }

            if (!string.IsNullOrWhiteSpace(P.SecretQuestion) && P.SecretQuestion.Length > 20)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 6
                });
                return;
            }

            if (!string.IsNullOrWhiteSpace(P.SecretAnswer) && P.SecretAnswer.Length > 20)
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 7
                });
                return;
            }

            if (AccountExists(P.AccountID))
            {
                Con.QueuePacket(new S.NewAccount {
                    Result = 8
                });
                return;
            }

            NewAccount(P, Con.IPAddress);

            Con.QueuePacket(new S.NewAccount {
                Result = 9
            });
        }