Ejemplo n.º 1
0
        private static bool CheckAdmin(PlayerDBInfo playerinfo, Candidate c)
        {
            switch (playerinfo.group)
            {
                case 4:
                    c.player.access = Constants.ACCESS_ADMIN;
                    break;
                case 6:
                    c.player.access = Constants.ACCESS_DONOR;
                    break;
                case 7:
                    c.player.access = Constants.ACCESS_MAPPER_DEVELOPER;
                    break;
                case 8:
                    c.player.access = Constants.ACCESS_DONOR;
                    break;
                case 9:
                    c.player.access = Constants.ACCESS_DONOR;
                    break;
                case 10:
                    c.player.access = Constants.ACCESS_DONOR;
                    break;
                case 12:
                    c.player.access = Constants.ACCESS_GAMEMASTER;
                    break;
                default:
                    c.player.access = Constants.ACCESS_FREE;
                    break;
            }
            if (c.player.access < Constants.ACCESS_MAPPER_DEVELOPER)
            {
                if (_form.AdminOnly) return false;
            }
            else AppendLog(c.loginName + " is an admin.");

            return true;
        }
Ejemplo n.º 2
0
 private static void PreloadPlayer(Candidate c, PlayerDBInfo pInfo)
 {
     c.player = new Player(0);
     var file = new AccountsManager(_form);
     if (!file.LoadPlayer(c.loginName, ref c.player))
     {
         for (int i = 0; i < Constants.MAX_PLAYER_FRIENDS; i++)
         {
             c.player.friends[i].name = new string(' ', Constants.PLAYER_NAME_LENGTH); //<--- max display name length on the forum.
         }
     }
     c.player.PlayerName = pInfo.charName;
     c.playerBank = new Bank(0);
     file.LoadPlayerBank(c.loginName, ref c.playerBank);
 }
Ejemplo n.º 3
0
 private static bool CheckValidating(PlayerDBInfo pInfo)
 {
     if (pInfo.group != 1) return true; // 1 -> Group = 1 -> accounts awaiting validation
     return false;
 }
Ejemplo n.º 4
0
        private static bool CheckSubscription(PlayerDBInfo playerinfo, Candidate c)
        {
            if (playerinfo.group == (int)Donors.Silver || playerinfo.group == (int)Donors.Gold)
            {
                Donors don = (Donors)playerinfo.group;
                string donorType = "";
                switch (don)
                {
                    case Donors.Silver:
                        donorType = " (Silver)";
                        c.player.IsDonor = 2;
                        break;
                    case Donors.Gold:
                        donorType = " (Gold)";
                        c.player.IsDonor = 1;
                        break;
                }
                _form.appendLog(c.loginName + " is a donor" + donorType + ".");
            }
            else
            {
                c.player.IsDonor = 0;
                if (c.player.access == 0) _form.appendLog(c.loginName + " is a regular player.");
            }

            if (_form.DonorOnly && c.player.access < Constants.ACCESS_DONOR) return false;

            return true;
        }
Ejemplo n.º 5
0
        private static bool CheckPlayerStatus(Candidate c)
        {
            List<string>[] playerInfo;
            string ipAddress = ((IPEndPoint)c.socket.RemoteEndPoint).Address.ToString();
            if (!Database.Instance.SelectPlayerData(out playerInfo, c.loginName))
            {
                AppendLog("Couldn't connect with database for: " + ipAddress + ". Rejecting...");
                SendClient_AlertMsg(c.socket, "Unexpected loss of connection, try again in a minute!", true);
                KillClientSocket(c);
                return false;
            }
            if (playerInfo[0].Count == 0)
            {
                AppendLog("->" + c.loginName + "<-(" + ipAddress + ") doesn't exist in the database. Rejecting...");
                SendClient_AlertMsg(c.socket, "Sorry, but it seems that you've entered an incorrect login or password. Please try again!", true);
                KillClientSocket(c);
                return false;
            }
            PlayerDBInfo pInfo = new PlayerDBInfo(playerInfo[0][0], playerInfo[1][0], playerInfo[2][0], playerInfo[3][0]);
            if (!CheckPassword(pInfo, c.password))
            {
                AppendLog("Wrong password for: " + c.loginName + "/" + ipAddress + ". Rejecting...");
                SendClient_AlertMsg(c.socket, "Sorry, you've entered incorrect login or password. Please try again!", true);
                KillClientSocket(c);
                return false;
            }
            if (!CheckValidating(pInfo))
            {
                AppendLog("Account is not verified for: " + c.loginName + "/" + ipAddress + ". Rejecting...");
                SendClient_AlertMsg(c.socket, "Please validate your account, by confirming your email address!", true);
                KillClientSocket(c);
                return false;
            }
            //Load Player, to synchronize his status - gold silver admin.
            PreloadPlayer(c, pInfo);
            if (!CheckAdmin(pInfo, c))
            {
                SendClient_AlertMsg(c.socket, "Sorry, but the server is only available to staff members at the moment.", true);
                AppendLog(c.loginName + "/" + ipAddress + " isn't an Admin. Rejecting...");
                KillClientSocket(c);
                return false;
            }
            if (!CheckSubscription(pInfo, c))
            {
                SendClient_AlertMsg(c.socket, "Sorry, but the server is only available to Gold or Silver Shinobi at the moment.", true);
                AppendLog(c.loginName + "/" + ipAddress + " isn't a Donor" +
                          "" +
                          ". Rejecting...");
                KillClientSocket(c);
                return false;
            }

            //No more checks, it's seems player can join the server.
            AccountsManager file = new AccountsManager(_form);
            file.SavePlayer(c.loginName, ref c.player);
            file.SavePlayerBank(c.loginName, ref c.playerBank);

            if (!SendClient_ServerDetails(c))
            {
                SendClient_AlertMsg(c.socket, "Server is down, try again in a minute!", true);
                AppendLog(c.loginName + "/" + ipAddress + " rejected -> no available servers");
                KillClientSocket(c);
            }

            return true;
        }
Ejemplo n.º 6
0
 private static bool CheckPassword(PlayerDBInfo playerinfo, string pass)
 {
     string ultimateHash = playerinfo.hash;
     string salt = playerinfo.salt;
     using (MD5 md5Hash = MD5.Create())
     {
         string firstIteration = GetMd5Hash(md5Hash, salt) + GetMd5Hash(md5Hash, pass);
         string seconditeration = GetMd5Hash(md5Hash, firstIteration);
         if (seconditeration == ultimateHash)
         {
             return true;
         }
     }
     return false;
 }